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
grammar
Grammarthe underlying grammar
Parser(ParseContext)
Creates a new parser system
public Parser(ParseContext context)
Parameters
context
ParseContextthe parse context to use
Parser(Rule, StringComparison)
Creates a new parser system
public Parser(Rule root, StringComparison stringComparison = StringComparison.OrdinalIgnoreCase)
Parameters
root
Rulethe root rule
stringComparison
StringComparisonthe 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
start
ParsePosition?end
ParsePosition?indentationString
stringotherOptions
Dictionary<string, object>trimTrailingWhitespace
boolinsertFinalNewline
booltrimFinalNewlines
bool
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
start
ParsePositionThe starting position of the range.
end
ParsePositionThe ending position of the range.
predicate
Predicate<RuleApplication>An optional predicate to filter rule applications.
Returns
- IEnumerable<ActionInfoApplication>
A collection of ActionInfo objects representing available code actions.
GetDefinition(ParsePosition)
Gets the rule application for the definition of a symbol
public RuleApplication GetDefinition(ParsePosition position)
Parameters
position
ParsePositionThe position of the symbol in the document
Returns
- RuleApplication
The rule application of the symbol definition
GetDocumentHighlights(ParsePosition)
Parses the locations and kinds of document highlights for a literal at a given position
public IEnumerable<DocumentHighlight> GetDocumentHighlights(ParsePosition position)
Parameters
position
ParsePositionThe 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
range
ParseRange
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
position
ParsePositionThe 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
position
ParsePositionThe position of the symbol in the document
newName
stringThe 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
positions
IEnumerable<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
start
ParsePosition?An optional ParsePosition specifying the starting range of tokens to include. If null, all tokens from the beginning are considered.
end
ParsePosition?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(string[])
Initializes the parser system
public object Initialize(string[] input)
Parameters
input
string[]the initial input
Returns
- object
the value parsed for the given input
Initialize(string[], bool)
Initializes the parser system
public object Initialize(string[] input, bool skipValidation)
Parameters
input
string[]the initial input
skipValidation
boolif set to true, the parser does not perform validation rules
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
position
ParsePositionthe position where completions should be calculated
fragment
stringthe 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
edit
TextEditAn 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
edit
TextEditAn edit operations
skipValidation
boolif 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
edits
IEnumerable<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
edits
IEnumerable<TextEdit>A collection of edit operations
skipValidation
boolif set to true, the parser does not perform validation rules
Returns
- object
the updated value parsed for the given input