public virtual State ParseClosingBracket <T> (char c, IParseContext context, State stateToReturn) where T : XNode { bool isEnding = false; var rootState = RootState as RazorFreeState; if (rootState.UseSimplifiedBracketTracker) { if (bracketsBuilder.Length > 0) { bracketsBuilder.Remove(0, 1); } if (bracketsBuilder.Length == 0) { isEnding = true; } } else if (!rootState.UseSimplifiedBracketTracker && CorrespondingBlock.IsEndingBracket(context.LocationMinus(1))) { isEnding = true; } if (isEnding) { StateEngineService.EndCodeFragment <T> (context); return(stateToReturn); } return(null); }
// ParseOpeningBracket and ParseClosingBracket can use simplified method of tracking brackets. // It's fast, and works correctly when parsing char by char, but sometimes may incorrectly determine // the end of a block in nested subblocks when we click inside the block from another one, // because the parent block isn't parsed from end to end then. // The simplified version is used mostly for testing. In real environment finding matching brackets // precisely is necessary for code completion. public virtual State ParseOpeningBracket(char c, IParseContext context) { var rootState = RootState as RazorFreeState; if (!rootState.UseSimplifiedBracketTracker && !CorrespondingBlock.FirstBracket.HasValue) { CorrespondingBlock.FindFirstBracket(context.Location); } else if (rootState.UseSimplifiedBracketTracker) { bracketsBuilder.Append(c); } return(null); }