private Expression ParseUnaryExpression() { UnaryOperator op = UnaryOperator.Default; SourceLocation?start = null; if (IsPrefixUnaryOperator()) { start = _current.Span.Start; op = ParsePrefixUnaryOperator(); } if (start == null) { start = _current.Span.Start; } var expression = ParsePrimaryExpression(); if (IsSuffixUnaryOperator()) { op = ParseSuffixUnaryOperator(); } if (op != UnaryOperator.Default) { return(new UnaryExpression(CreateSpan(start.Value), expression, op)); } return(expression); }
internal override void ForceComplete( SourceLocation?locationOpt, CancellationToken cancellationToken ) { _state.DefaultForceComplete(this, cancellationToken); }
protected override bool ParseInheritsStatement(CodeBlockInfo block) { _endInheritsLocation = CurrentLocation; bool result = base.ParseInheritsStatement(block); CheckForInheritsAndModelStatements(); return result; }
private void NamespaceImportTest( string content, string expectedNS, AcceptedCharacters acceptedCharacters = AcceptedCharacters.None, string errorMessage = null, SourceLocation?location = null ) { var errors = new RazorError[0]; if (!String.IsNullOrEmpty(errorMessage) && location.HasValue) { errors = new RazorError[] { new RazorError(errorMessage, location.Value) }; } ParseBlockTest( content, new DirectiveBlock( Factory .Code(content) .AsNamespaceImport(expectedNS, CSharpCodeParser.UsingKeywordLength) .Accepts(acceptedCharacters) ), errors ); }
protected override bool ParseInheritsStatement(CodeBlockInfo block) { this.endInheritsLocation = this.CurrentLocation; var result = this.ParseInheritsStatement(block); this.CheckForInheritsAndModelStatements(); return result; }
private Tokenizer MakeTokenizer(PythonLanguageVersion version, TokenizerOptions optionSet, StringReader reader, SourceLocation?initialSourceLocation = null) { var tokenizer = new Tokenizer(version, options: optionSet); tokenizer.Initialize(null, reader, initialSourceLocation ?? SourceLocation.MinValue); return(tokenizer); }
protected override bool ParseInheritsStatement(CodeBlockInfo block) { this.endInheritsLocation = this.CurrentLocation; var result = base.ParseInheritsStatement(block); this.CheckForInheritsAndModelStatements(); return(result); }
protected override bool ParseInheritsStatement(CodeBlockInfo block) { _endInheritsLocation = CurrentLocation; bool result = base.ParseInheritsStatement(block); CheckForInheritsAndResourceStatements(); return(result); }
private void Error(string msg, bool fatal = false, SourceLocation?on = null) { Errors.AddError(on ?? Current.Location, msg); if (fatal) { throw new LogicParserException(); } }
internal override void ForceComplete(SourceLocation?locationOpt, CancellationToken cancellationToken) { if ((object?)this.AssociatedField != null) { this.AssociatedField.ForceComplete(locationOpt, cancellationToken); } base.ForceComplete(locationOpt, cancellationToken); }
protected Node(ParserRuleContext?context) { if (context != null) { var start = new Position((uint)context.Start.Line, (uint)context.Start.Column); var end = new Position((uint)context.Stop.Line, (uint)context.Stop.Column); Loc = new SourceLocation(start, end); } }
protected override void InheritsDirective() { // Verify we're on the right keyword and accept AssertDirective(SyntaxConstants.CSharp.InheritsKeyword); AcceptAndMoveNext(); _endInheritsLocation = CurrentLocation; InheritsDirectiveCore(); CheckForInheritsAndModelStatements(); }
/// <summary> /// Parses the inherits statement. /// </summary> protected override void InheritsDirective() { // Verify we're on the right keyword and accept AssertDirective(SyntaxConstants.CSharp.InheritsKeyword); AcceptAndMoveNext(); _endInheritsLocation = CurrentLocation; InheritsDirectiveCore(); CheckForInheritsAndModelStatements(); }
protected override void InheritsDirective() { this.AssertDirective("inherits"); this.AcceptAndMoveNext(); this.endInheritsLocation = this.CurrentLocation; base.InheritsDirective(); this.CheckForInheritsAndModelStatements(); }
protected override void InheritsDirective() { this.AssertDirective("inherits"); this.AcceptAndMoveNext(); this.endInheritsLocation = this.CurrentLocation; base.InheritsDirective(); this.CheckForInheritsAndModelStatements(); }
protected override bool InheritsStatement() { this.AssertDirective("Inherits"); this.AcceptAndMoveNext(); this.endInheritsLocation = this.CurrentLocation; var result = base.InheritsStatement(); this.CheckForInheritsAndModelStatements(); return(result); }
private Expression ParseExp() { SourceLocation?start = null; if (start == null) { start = current.Span.Start; } var expression = ParsePrimaryExpression(); statm.Add(expression); // Console.WriteLine($"{expression.Kind} start {expression.Span}"); return(expression); }
protected override bool InheritsStatement() { this.AssertDirective("Inherits"); this.AcceptAndMoveNext(); this.endInheritsLocation = this.CurrentLocation; var result = base.InheritsStatement(); this.CheckForInheritsAndModelStatements(); return result; }
protected override bool InheritsStatement() { // Verify we're on the right keyword and accept Assert(VBKeyword.Inherits); VBSymbol inherits = CurrentSymbol; NextToken(); _endInheritsLocation = CurrentLocation; PutCurrentBack(); PutBack(inherits); EnsureCurrent(); bool result = base.InheritsStatement(); CheckForInheritsAndModelStatements(); return result; }
protected void RunEndLookaheadUpdatesSourceLocationTest() { SourceLocation?expectedLocation = null; SourceLocation?actualLocation = null; RunLookaheadTest("abc\r\ndef\r\nghi", null, Read(6), CaptureSourceLocation(s => expectedLocation = s), Lookahead(Read(6)), CaptureSourceLocation(s => actualLocation = s)); // Assert Assert.AreEqual(expectedLocation.Value.AbsoluteIndex, actualLocation.Value.AbsoluteIndex, "The reader did not correctly reset the RawIndex when Lookahead finished"); Assert.AreEqual(expectedLocation.Value.CharacterIndex, actualLocation.Value.CharacterIndex, "The reader did not correctly reset the CharacterIndex when Lookahead finished"); Assert.AreEqual(expectedLocation.Value.LineIndex, actualLocation.Value.LineIndex, "The reader did not correctly reset the LineIndex when Lookahead finished"); }
protected void RunEndLookaheadUpdatesSourceLocationTest() { SourceLocation?expectedLocation = null; SourceLocation?actualLocation = null; RunLookaheadTest("abc\r\ndef\r\nghi", null, Read(6), CaptureSourceLocation(s => expectedLocation = s), Lookahead(Read(6)), CaptureSourceLocation(s => actualLocation = s)); // Assert Assert.Equal(expectedLocation.Value.AbsoluteIndex, actualLocation.Value.AbsoluteIndex); Assert.Equal(expectedLocation.Value.CharacterIndex, actualLocation.Value.CharacterIndex); Assert.Equal(expectedLocation.Value.LineIndex, actualLocation.Value.LineIndex); }
/// <summary> /// Parses the inherits statement. /// </summary> protected override bool InheritsStatement() { // Verify we're on the right keyword and accept Assert(VBKeyword.Inherits); VBSymbol inherits = CurrentSymbol; NextToken(); _endInheritsLocation = CurrentLocation; PutCurrentBack(); PutBack(inherits); EnsureCurrent(); bool result = base.InheritsStatement(); CheckForInheritsAndModelStatements(); return(result); }
private void EnsureStart() { if (_start == null) { if (Previous == null) { _start = SourceLocation.Zero; } else { Debug.Assert(!ReferenceEquals(Previous, this), "Cycle detected in Span chain."); // Update the start position based on the offset. Absolute and Line are added, Character offset is simply set _start = new SourceLocation( Previous.Start.AbsoluteIndex + Previous.Offset.AbsoluteIndex, Previous.Start.LineIndex + Previous.Offset.LineIndex, Previous.Offset.LineIndex == 0 ? Previous.Start.CharacterIndex + Previous.Offset.CharacterIndex : Previous.Offset.CharacterIndex ); } } }
private YamlToken ReadNextWorker() { // Warn on: // # comment // no escape (= or |) // unallowed multiline escape // blank lines // different indent size // duplicate keys // empty properties (should have an indent) // no tabs. // don't allow --- documents // Start of line. // [Indent] [PropertyName] [Colon] // [Indent] [PropertyName] [Colon] [space] [equals] [VALUE] // [Indent] [PropertyName] [Colon] [space] [MultilineEscape] LineParser line; int indentLen; while (true) { line = PeekLine(); if (line == null) { // End of File. // Close any outstanding objects. if (_currentIndent.Count > 1) { _currentIndent.Pop(); return(YamlToken.EndObj); } return(YamlToken.EndOfFile); } // get starting indent. indentLen = line.EatIndent(); // Comment indent level doesn't matter - may not match object indent. if (line.Current == '#') { // https://github.com/microsoft/PowerApps-Language-Tooling/issues/115 // Allow comment lines. These will get stripped (won't roundtrip). if (!_commentStrippedWarning.HasValue) { _commentStrippedWarning = Loc(line); } MoveNextLine(); continue; } if (line.Current != 0) { break; } // Eat the newline and go to the next line. MoveNextLine(); } if (line.Current == '-') { return(Unsupported(line, "--- markers are not supported. Only a single document per file.")); } if (line.Current == '\t') { // Helpful warning. return(Error(line, "Use spaces, not tabs.")); } var startColumn = line._idx + 1; // 1-based start column number. // If last was 'start object', then this indent sets the new level, if (_lastPair.Kind == YamlTokenKind.StartObj) { var lastIndent = _currentIndent.Peek()._oldIndentLevel; if (indentLen == lastIndent) // Close immediate parent { _currentIndent.Pop(); return(YamlToken.EndObj); } else if (indentLen < lastIndent) { // Close current objects one at a time. _currentIndent.Pop(); var prevIndent = _currentIndent.Peek()._oldIndentLevel; // Indent must exactly match a previous one up the stack. if (indentLen > prevIndent) { return(Error(line, "Property indent must align exactly with a previous indent level.")); } return(YamlToken.EndObj); } if (indentLen <= lastIndent) { // Error. new object should be indented. return(Unsupported(line, "Can't have null properties. Line should be indented to start a new property.")); } _currentIndent.Peek()._newIndentLevel = indentLen; } else { // Subsequent properties should be at same indentation level. var expectedIndent = _currentIndent.Peek()._newIndentLevel; if (indentLen == expectedIndent) { // Good. Common case. // Continue processing below to actually parse this property. } else if (indentLen > expectedIndent) { return(Error(line, "Property should be at same indent level")); } else { // Closing an object. // Indent must exactly match a previous one up the stack. if (indentLen > _currentIndent.Peek()._oldIndentLevel) { return(Error(line, "Property indent must align exactly with a previous indent level.")); } // Close current objects one at a time. _currentIndent.Pop(); return(YamlToken.EndObj); } } // Get identifier // toggle isEscaped on every ' appearance bool isEscaped = false; bool requiresClosingDoubleQuote = line.MaybeEat('"'); while (line.Current != ':' || isEscaped || requiresClosingDoubleQuote) { if (line.Current == '\'') { isEscaped = !isEscaped; } if (requiresClosingDoubleQuote && line.Current == '"' && line.Previous != '\\') { line._idx++; break; } if (line.Current == 0) // EOL { if (isEscaped) { return(Unsupported(line, "Missing closing \'.")); } if (requiresClosingDoubleQuote) { return(Unsupported(line, "Missing closing \".")); } return(Unsupported(line, "Missing ':'. If this is a multiline property, use |")); } line._idx++; } line.MaybeEat(':'); // skip colon. // Prop name could have spaces, but no colons. var propName = line._line.Substring(indentLen, line._idx - indentLen - 1).Trim(); if (requiresClosingDoubleQuote) { propName = propName.Replace("\\\"", "\"").Trim('"'); } // If it's a property, must have at least 1 space. // If it's start object, then ignore all spaces. int iSpaces = 0; while (line.MaybeEat(' ')) { iSpaces++; // skip optional spaces } if (line.Current == 0) // EOL { var error = _currentIndent.Peek().CheckDuplicate(propName, _currentLine); if (error != null) { error.Span = Loc(line); return(error); } // New Object. // Next line must begin an indent. _currentIndent.Push(new Indent { _lineStart = _currentLine, _oldIndentLevel = indentLen // newIndentLevel will be set at next line }); MoveNextLine(); return(YamlToken.NewStartObj(Loc(startColumn, line), propName)); } if (line.Current == '#') { return(UnsupportedComment(line)); } if (iSpaces == 0) { return(Error(line, "Must have at least 1 space after colon.")); } // Escape must be string value = null; if (line.MaybeEat('=')) { // Single line. Property doesn't include \n at end. value = line.RestOfLine; if (value.IndexOf('#') >= 0) { return(UnsupportedComment(line)); } MoveNextLine(); } else if ((line.Current == '\"') || (line.Current == '\'')) { // These are common YAml sequences, but extremely problematic and could be user error. // Disallow them and force the user to explicit. // Is "hello" a string or identifer? // Foo: "Hello" // // Instead, have the user write: // Foo: ="Hello" // String // Foo: =Hello // identifier // Foo: | // ="Hello" // string return(Unsupported(line, "Quote is not a supported escape sequence. Use = or |")); } else if (line.MaybeEat('>')) { // Unsupported Multiline escape. return(Unsupported(line, "> is not a supported multiline escape. Use |")); } else if (line.MaybeEat('|')) { // Multiline int multilineMode; if (line.MaybeEat('-')) { multilineMode = 0; // 0 newlines at end } else if (line.MaybeEat('+')) { multilineMode = 2; // 1+ newlines. } else { multilineMode = 1; // exactly 1 newline at end. } iSpaces = 0; while (line.MaybeEat(' ')) { iSpaces++; // skip optional spaces } if (line.Current == '#') { return(UnsupportedComment(line)); } else if (line.Current != 0) // EOL, catch all error. { return(Error(line, "Content for | escape must start on next line.")); } MoveNextLine(); value = ReadMultiline(multilineMode); if (value.Length == 0) { return(Unsupported(line, "Can't have empty multiline expressions.")); } if (value[0] != '=') { return(Unsupported(line, "Property value must start with an '='")); } value = value.Substring(1); // move past '=' } else { // Warn on legal yaml escapes (>) that we don't support in our subset here. return(Error(line, "Expected either '=' for a single line expression or '|' to begin a multiline expression")); } { var error = _currentIndent.Peek().CheckDuplicate(propName, _currentLine); if (error != null) { error.Span = Loc(line); return(error); } } int endIndex = line._line.Length + 1; return(YamlToken.NewProperty(LocWorker(startColumn, endIndex), propName, value)); }
// Adds other's content to the start of this span // Adjusts this span's start point appropriately private void MergeLeft(Span other) { _content = other.Content + _content; _start = other.Start; }
public abstract SemanticTokens GetSemanticTokens(RazorCodeDocument codeDocument, SourceLocation?location = null);
protected Span(SpanKind kind, SourceLocation start, string content) : this(kind, content) { _start = start; }
public static InterpreterError WellKnown(SourceLocation?loc, string key, params object?[] args) => new(loc, MainProgram.LanguageLoader.CurrentLanguage?[key, args] ?? key);
public InterpreterError(SourceLocation?location, string message) { Location = location; Message = message; }
private void EnsureStart() { if (_start == null) { if (Previous == null) { _start = SourceLocation.Zero; } else { Debug.Assert(!ReferenceEquals(Previous, this), "Cycle detected in Span chain."); // Update the start position based on the offset. Absolute and Line are added, Character offset is simply set _start = new SourceLocation( Previous.Start.AbsoluteIndex + Previous.Offset.AbsoluteIndex, Previous.Start.LineIndex + Previous.Offset.LineIndex, Previous.Offset.LineIndex == 0 ? Previous.Start.CharacterIndex + Previous.Offset.CharacterIndex : Previous.Offset.CharacterIndex ); } } }
protected Span(SpanKind kind, SourceLocation start, string content, bool hidden) : this(kind, content, hidden) { _start = start; }
protected Span(SpanKind kind, SourceLocation start, string content, bool hidden, AcceptedCharacters acceptedCharacters) : this(kind, content, hidden, acceptedCharacters) { _start = start; }
public static bool Expect(this ParserContext context, char expected, bool outputError, string errorMessage, bool caseSensitive, SourceLocation?errorLocation) { return(Expect(context, expected.ToString(), outputError, errorMessage, caseSensitive, errorLocation)); }
public static string ExpectIdentifier(this ParserContext context, string unexpectedErrorMessageFormat, bool allowPrecedingWhiteSpace, SourceLocation?errorLocation) { using (context.StartTemporaryBuffer()) { if (allowPrecedingWhiteSpace) { context.AcceptWhiteSpace(includeNewLines: true); } if (!ParserHelpers.IsIdentifierStart(context.CurrentCharacter)) { if (context.EndOfFile) { context.OnError(errorLocation ?? context.CurrentLocation, unexpectedErrorMessageFormat, RazorResources.ErrorComponent_EndOfFile); } else if (Char.IsWhiteSpace(context.CurrentCharacter)) { context.OnError(errorLocation ?? context.CurrentLocation, unexpectedErrorMessageFormat, RazorResources.ErrorComponent_Whitespace); } else { context.OnError(errorLocation ?? context.CurrentLocation, unexpectedErrorMessageFormat, String.Format(CultureInfo.CurrentCulture, RazorResources.ErrorComponent_Character, context.CurrentCharacter)); } return(null); } else { context.AcceptTemporaryBuffer(); } } return(context.AcceptIdentifier()); }
/// <summary> /// Gets information about methods defined on base classes but not directly on the current class. /// </summary> private static IEnumerable <IPythonFunctionOverload> GetOverrideable(CompletionContext context, SourceLocation?location = null) { var result = new List <IPythonFunctionOverload>(); var scope = context.Analysis.FindScope(location ?? context.Location); if (!(scope?.Node is ClassDefinition cls)) { return(result); } var handled = new HashSet <string>(scope.Children.Select(child => child.Name)); var classVar = scope.OuterScope.Variables[cls.Name]; var classType = classVar?.GetValue <IMember>()?.GetPythonType <IPythonClassType>(); if (classType?.Mro == null) { return(result); } foreach (var baseClassType in classType.Mro.Skip(1).OfType <IPythonClassType>()) { var functions = baseClassType.GetMemberNames().Select(n => baseClassType.GetMember(n)).OfType <IPythonFunctionType>(); foreach (var f in functions.Where(f => f.Overloads.Count > 0)) { var overload = f.Overloads.Aggregate( (best, o) => o.Parameters.Count > best.Parameters.Count ? o : best ); if (handled.Contains(overload.Name)) { continue; } handled.Add(overload.Name); result.Add(overload); } } return(result); }
private static IList <KeyValuePair <string, SyntaxTreeNode> > GetTagAttributes( string tagName, bool validStructure, Block tagBlock, IEnumerable <TagHelperDescriptor> descriptors, ErrorSink errorSink) { // Ignore all but one descriptor per type since this method uses the TagHelperDescriptors only to get the // contained TagHelperAttributeDescriptor's. descriptors = descriptors.Distinct(TypeBasedTagHelperDescriptorComparer.Default); var attributes = new List <KeyValuePair <string, SyntaxTreeNode> >(); // We skip the first child "<tagname" and take everything up to the ending portion of the tag ">" or "/>". // The -2 accounts for both the start and end tags. If the tag does not have a valid structure then there's // no end tag to ignore. var symbolOffset = validStructure ? 2 : 1; var attributeChildren = tagBlock.Children.Skip(1).Take(tagBlock.Children.Count() - symbolOffset); foreach (var child in attributeChildren) { TryParseResult result; if (child.IsBlock) { result = TryParseBlock(tagName, (Block)child, descriptors, errorSink); } else { result = TryParseSpan((Span)child, descriptors, errorSink); } // Only want to track the attribute if we succeeded in parsing its corresponding Block/Span. if (result != null) { SourceLocation?errorLocation = null; // Check if it's a bound attribute that is minimized or if it's a bound non-string attribute that // is null or whitespace. if ((result.IsBoundAttribute && result.AttributeValueNode == null) || (result.IsBoundNonStringAttribute && IsNullOrWhitespaceAttributeValue(result.AttributeValueNode))) { errorLocation = GetAttributeNameStartLocation(child); errorSink.OnError( errorLocation.Value, RazorResources.FormatRewriterError_EmptyTagHelperBoundAttribute( result.AttributeName, tagName, GetPropertyType(result.AttributeName, descriptors)), result.AttributeName.Length); } // Check if the attribute was a prefix match for a tag helper dictionary property but the // dictionary key would be the empty string. if (result.IsMissingDictionaryKey) { if (!errorLocation.HasValue) { errorLocation = GetAttributeNameStartLocation(child); } errorSink.OnError( errorLocation.Value, RazorResources.FormatTagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey( result.AttributeName, tagName), result.AttributeName.Length); } attributes.Add( new KeyValuePair <string, SyntaxTreeNode>(result.AttributeName, result.AttributeValueNode)); } } return(attributes); }
private Tokenizer MakeTokenizer(PythonLanguageVersion version, TokenizerOptions optionSet, string text, SourceLocation?initialSourceLocation = null) { return(MakeTokenizer(version, optionSet, new StringReader(text), initialSourceLocation)); }
private static IList <TagHelperAttributeNode> GetTagAttributes( string tagName, bool validStructure, Block tagBlock, TagHelperBinding bindingResult, ErrorSink errorSink) { var attributes = new List <TagHelperAttributeNode>(); // We skip the first child "<tagname" and take everything up to the ending portion of the tag ">" or "/>". // The -2 accounts for both the start and end tags. If the tag does not have a valid structure then there's // no end tag to ignore. var symbolOffset = validStructure ? 2 : 1; var attributeChildren = tagBlock.Children.Skip(1).Take(tagBlock.Children.Count() - symbolOffset); var processedBoundAttributeNames = new HashSet <string>(StringComparer.OrdinalIgnoreCase); foreach (var child in attributeChildren) { TryParseResult result; if (child.IsBlock) { result = TryParseBlock(tagName, (Block)child, bindingResult.Descriptors, errorSink, processedBoundAttributeNames); } else { result = TryParseSpan((Span)child, bindingResult.Descriptors, errorSink, processedBoundAttributeNames); } // Only want to track the attribute if we succeeded in parsing its corresponding Block/Span. if (result != null) { SourceLocation?errorLocation = null; // Check if it's a bound attribute that is minimized or if it's a bound non-string attribute that // is null or whitespace. if ((result.IsBoundAttribute && result.AttributeValueNode == null) || (result.IsBoundNonStringAttribute && IsNullOrWhitespaceAttributeValue(result.AttributeValueNode))) { errorLocation = GetAttributeNameStartLocation(child); errorSink.OnError( errorLocation.Value, LegacyResources.FormatRewriterError_EmptyTagHelperBoundAttribute( result.AttributeName, tagName, GetPropertyType(result.AttributeName, bindingResult.Descriptors)), result.AttributeName.Length); } // Check if the attribute was a prefix match for a tag helper dictionary property but the // dictionary key would be the empty string. if (result.IsMissingDictionaryKey) { if (!errorLocation.HasValue) { errorLocation = GetAttributeNameStartLocation(child); } errorSink.OnError( errorLocation.Value, LegacyResources.FormatTagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey( result.AttributeName, tagName), result.AttributeName.Length); } var attributeNode = new TagHelperAttributeNode( result.AttributeName, result.AttributeValueNode, result.AttributeStructure); attributes.Add(attributeNode); } else { // Error occured while parsing the attribute. Don't try parsing the rest to avoid misleading errors. break; } } return(attributes); }
public static bool Accept(this ParserContext context, string expected, bool caseSensitive, out SourceLocation?errorLocation, out char?errorChar) { errorLocation = null; errorChar = null; using (context.StartTemporaryBuffer()) { for (int i = 0; i < expected.Length; i++) { if (CharsEqual(expected[i], context.CurrentCharacter, caseSensitive)) { context.AcceptCurrent(); } else { errorLocation = context.CurrentLocation; errorChar = context.CurrentCharacter; context.RejectTemporaryBuffer(); return(false); } } context.AcceptTemporaryBuffer(); } return(true); }
public static bool TryGetCompletionsForOverride(FunctionDefinition function, CompletionContext context, SourceLocation?location, out CompletionResult result) { result = CompletionResult.Empty; if (!string.IsNullOrEmpty(function.NameExpression?.Name) && context.Position > function.NameExpression.EndIndex) { return(false); } if (function.Parent is ClassDefinition cd && function.NameExpression != null && context.Position > function.NameExpression.StartIndex) { var loc = function.GetStart(); var overrideable = GetOverrideable(context, location).ToArray(); overrideable = !string.IsNullOrEmpty(function.Name) ? overrideable.Where(o => o.Name.StartsWithOrdinal(function.Name)).ToArray() : overrideable; var items = overrideable.Select(o => ToOverrideCompletionItem(o, cd, context, new string(' ', loc.Column - 1))); result = new CompletionResult(items); return(true); } return(false); }
public static bool Expect(this ParserContext context, string expected, bool outputError, string errorMessage, bool caseSensitive, SourceLocation?errorLocation) { SourceLocation?errLoc; char? errorChar; if (!Accept(context, expected, caseSensitive, out errLoc, out errorChar)) { if (outputError) { context.OnError(errorLocation ?? errLoc ?? context.CurrentLocation, errorMessage ?? RazorResources.ParseError_Expected_X, expected); } return(false); } return(true); }