public IChameleonNode ReSync(CachingLexer cachingLexer, TreeTextRange changedRange, int insertedTextLen) { TreeOffset currStartOffset = GetTreeStartOffset(); int currLength = GetTextLength(); Logger.Assert(changedRange.StartOffset >= currStartOffset && changedRange.EndOffset <= (currStartOffset + currLength), "changedRange.StartOffset >= currStartOffset && changedRange.EndOffset <= (currStartOffset+currLength)"); int newLength = currLength - changedRange.Length + insertedTextLen; LanguageService languageService = Language.LanguageService(); if (languageService != null) { var parser = (IPsiParser)languageService.CreateParser(new ProjectedLexer(cachingLexer, new TextRange(currStartOffset.Offset, currStartOffset.Offset + newLength)), GetPsiModule(), GetSourceFile()); TreeElement newElement = parser.ParseStatement(); if (newElement.GetTextLength() == 0) { return(null); } if ((newElement.GetTextLength() == newLength) && (";".Equals(newElement.GetText().Substring(newElement.GetTextLength() - 1)))) { var psiFile = GetContainingNode <PsiFile>(); if (psiFile != null) { psiFile.ClearTables(); } return(newElement as IRuleDeclaration); } } return(null); }