Class Parser
Denotes an incremental parser system
public class Parser
- Inheritance
-
Parser
- Inherited Members
Constructors
Parser(Grammar)
Creates a new parser system
public Parser(Grammar grammar)
Parameters
grammarGrammarthe underlying grammar
Parser(ParseContext)
Creates a new parser system
public Parser(ParseContext context)
Parameters
contextParseContextthe parse context to use
Parser(Rule, StringComparison)
Creates a new parser system
public Parser(Rule root, StringComparison stringComparison = StringComparison.OrdinalIgnoreCase)
Parameters
rootRulethe root rule
stringComparisonStringComparisonthe string comparison mode
Properties
Context
Gets the parse context for this parser
public ParseContext Context { get; }
Property Value
Methods
Format(ParsePosition?, ParsePosition?, string, Dictionary<string, object>, bool, bool, bool)
Formats the current text using the parser's context and generates text edits based on the specified range of lines.
public TextEdit[] Format(ParsePosition? start = null, ParsePosition? end = null, string indentationString = " ", Dictionary<string, object> otherOptions = null, bool trimTrailingWhitespace = false, bool insertFinalNewline = false, bool trimFinalNewlines = false)
Parameters
startParsePosition?endParsePosition?indentationStringstringotherOptionsDictionary<string, object>trimTrailingWhitespaceboolinsertFinalNewlinebooltrimFinalNewlinesbool
Returns
- TextEdit[]
GetCodeActionInfo(ParsePosition, ParsePosition, Predicate<RuleApplication>)
Retrieves code action information within a specified range of parse positions.
public IEnumerable<ActionInfoApplication> GetCodeActionInfo(ParsePosition start, ParsePosition end, Predicate<RuleApplication> predicate = null)
Parameters
startParsePositionThe starting position of the range.
endParsePositionThe ending position of the range.
predicatePredicate<RuleApplication>An optional predicate to filter rule applications.
Returns
- IEnumerable<ActionInfoApplication>
A collection of ActionInfo objects representing available code actions.
GetDefinitions(ParsePosition)
Gets the rule application for the definition of a symbol
public IEnumerable<RuleApplication> GetDefinitions(ParsePosition position)
Parameters
positionParsePositionThe position of the symbol in the document
Returns
- IEnumerable<RuleApplication>
The rule applications of the symbols definitions
GetDocumentHighlights(ParsePosition)
Parses the locations and kinds of document highlights for a literal at a given position
public IEnumerable<DocumentHighlight> GetDocumentHighlights(ParsePosition position)
Parameters
positionParsePositionThe position of the literal in the document
Returns
- IEnumerable<DocumentHighlight>
An IEnumerable of DocumentHighlight objects, each containing a range between parse positions and the kind of the highlight.
GetDocumentSymbolsForNonValidDocuments()
Retrieves document symbols for non-valid documents.
public IEnumerable<DocumentSymbol> GetDocumentSymbolsForNonValidDocuments()
Returns
- IEnumerable<DocumentSymbol>
An IEnumerable of DocumentSymbol representing the symbols for non-valid documents.
GetDocumentSymbolsFromRoot()
Parses the document symbols starting from the root rule application
public IEnumerable<DocumentSymbol> GetDocumentSymbolsFromRoot()
Returns
- IEnumerable<DocumentSymbol>
An IEnumerable of DocumentSymbol objects, each containing details on a document symbol in the document.
GetFoldingRangesFromRoot()
Parses folding ranges starting from the root rule application
public IEnumerable<FoldingRange> GetFoldingRangesFromRoot()
Returns
- IEnumerable<FoldingRange>
An IEnumerable of FoldingRange objects, each containing details on a folding range in the document.
GetInlayEntriesInRange(ParseRange)
Parses the document symbols starting from the root rule application
public IEnumerable<InlayEntry> GetInlayEntriesInRange(ParseRange range)
Parameters
rangeParseRange
Returns
- IEnumerable<InlayEntry>
An IEnumerable of DocumentSymbol objects, each containing details on a document symbol in the document.
GetReferences(ParsePosition)
Gets the locations for references of a symbol
public IEnumerable<ParseRange> GetReferences(ParsePosition position)
Parameters
positionParsePositionThe position of the symbol in the document
Returns
- IEnumerable<ParseRange>
An IEnumerable of ParseRange objects, each denoting a range between parse positions.
GetRenameTextEdits(ParsePosition, string)
Gets the text edits for a rename operation of a symbol
public IEnumerable<TextEdit> GetRenameTextEdits(ParsePosition position, string newName)
Parameters
positionParsePositionThe position of the symbol in the document
newNamestringThe new name of the symbol
Returns
- IEnumerable<TextEdit>
An IEnumerable of TextEdit objects, each containing details on a text edit to be performed.
GetSelectionRanges(IEnumerable<ParsePosition>)
Parses the selection range for given positions
public IEnumerable<SelectionRange> GetSelectionRanges(IEnumerable<ParsePosition> positions)
Parameters
positionsIEnumerable<ParsePosition>The positions in the document
Returns
- IEnumerable<SelectionRange>
An IEnumerable of SelectionRange objects, each containing details on a selection range in the document.
GetSemanticElementsFromRoot(ParsePosition?, ParsePosition?)
Retrieves semantic elements from the root application with delta encoding for Language Server Protocol (LSP).
public IEnumerable<uint> GetSemanticElementsFromRoot(ParsePosition? start = null, ParsePosition? end = null)
Parameters
startParsePosition?An optional ParsePosition specifying the starting range of tokens to include. If null, all tokens from the beginning are considered.
endParsePosition?An optional ParsePosition specifying the ending range of tokens to include. If null, all tokens to the end are considered.
Returns
- IEnumerable<uint>
A list of semantic tokens represented as unsigned integers, including delta-encoded line and character positions, length, token type, and modifiers.
Initialize(object, bool)
Initializes the parser system with a semantic object
public void Initialize(object semanticObject, bool skipValidation = false)
Parameters
semanticObjectobjectthe semantic object
skipValidationboolif set to true, the parser does not perform validation rules (default: false)
Exceptions
- ArgumentException
thrown if no parse tree could be generated for the semantic object
Initialize(string[], bool)
Initializes the parser system
public object Initialize(string[] input, bool skipValidation = false)
Parameters
inputstring[]the initial input
skipValidationboolif set to true, the parser does not perform validation rules (default: false)
Returns
- object
the value parsed for the given input
Initialize(Uri)
Initializes the parser system
public object Initialize(Uri fileUri)
Parameters
fileUriUrithe Uri of the File
Returns
- object
the value parsed for the given input
SuggestCompletions(ParsePosition, out string)
Calculates completion suggestions for the given position
public IEnumerable<CompletionEntry> SuggestCompletions(ParsePosition position, out string fragment)
Parameters
positionParsePositionthe position where completions should be calculated
fragmentstringthe fragment of the token at the given position
Returns
- IEnumerable<CompletionEntry>
A collection of code completions
Update(TextEdit)
Updates the parse result with the given edit
public object Update(TextEdit edit)
Parameters
editTextEditAn edit operations
Returns
- object
the updated value parsed for the given input
Update(TextEdit, bool)
Updates the parse result with the given edit
public object Update(TextEdit edit, bool skipValidation)
Parameters
editTextEditAn edit operations
skipValidationboolif set to true, the parser does not perform validation rules
Returns
- object
the updated value parsed for the given input
Update(IEnumerable<TextEdit>)
Updates the parse result with the given edits
public object Update(IEnumerable<TextEdit> edits)
Parameters
editsIEnumerable<TextEdit>A collection of edit operations
Returns
- object
the updated value parsed for the given input
Update(IEnumerable<TextEdit>, bool)
Updates the parse result with the given edits
public object Update(IEnumerable<TextEdit> edits, bool skipValidation)
Parameters
editsIEnumerable<TextEdit>A collection of edit operations
skipValidationboolif set to true, the parser does not perform validation rules
Returns
- object
the updated value parsed for the given input
Update(object)
Performs necessary changes to update the text according to the given model element
public IReadOnlyList<TextEdit> Update(object updatedElement)
Parameters
updatedElementobjecta semantic model element that was updated outside the textual representation
Returns
- IReadOnlyList<TextEdit>
A list of changes necessary to reflect the updated element