Documentation
¶
Index ¶
- type LeadingTriviaOption
- type NodeOptions
- type Tracker
- func (t *Tracker) Delete(sourceFile *ast.SourceFile, node *ast.Node)
- func (t *Tracker) DeleteNode(sourceFile *ast.SourceFile, node *ast.Node, leadingTrivia LeadingTriviaOption, ...)
- func (t *Tracker) DeleteNodeRange(sourceFile *ast.SourceFile, startNode *ast.Node, endNode *ast.Node, ...)
- func (t *Tracker) DeleteRange(sourceFile *ast.SourceFile, textRange core.TextRange)
- func (t *Tracker) GetChanges() map[string][]*lsproto.TextEdit
- func (t *Tracker) InsertAtTopOfFile(sourceFile *ast.SourceFile, insert []*ast.Statement, blankLineBetween bool)
- func (t *Tracker) InsertImportSpecifierAtIndex(sourceFile *ast.SourceFile, newSpecifier *ast.Node, namedImports *ast.Node, ...)
- func (t *Tracker) InsertModifierBefore(sourceFile *ast.SourceFile, modifier ast.Kind, before *ast.Node)
- func (t *Tracker) InsertNodeAfter(sourceFile *ast.SourceFile, after *ast.Node, newNode *ast.Node)
- func (t *Tracker) InsertNodeAt(sourceFile *ast.SourceFile, pos core.TextPos, newNode *ast.Node, ...)
- func (t *Tracker) InsertNodeBefore(sourceFile *ast.SourceFile, before *ast.Node, newNode *ast.Node, ...)
- func (t *Tracker) InsertNodeInListAfter(sourceFile *ast.SourceFile, after *ast.Node, newNode *ast.Node, ...)
- func (t *Tracker) InsertNodesAfter(sourceFile *ast.SourceFile, after *ast.Node, newNodes []*ast.Node)
- func (t *Tracker) InsertNodesAt(sourceFile *ast.SourceFile, pos core.TextPos, newNodes []*ast.Node, ...)
- func (t *Tracker) InsertText(sourceFile *ast.SourceFile, pos lsproto.Position, text string)
- func (t *Tracker) ReplaceNode(sourceFile *ast.SourceFile, oldNode *ast.Node, newNode *ast.Node, ...)
- func (t *Tracker) ReplaceRange(sourceFile *ast.SourceFile, lsprotoRange lsproto.Range, newNode *ast.Node, ...)
- func (t *Tracker) ReplaceRangeWithNodes(sourceFile *ast.SourceFile, lsprotoRange lsproto.Range, newNodes []*ast.Node, ...)
- func (t *Tracker) ReplaceRangeWithText(sourceFile *ast.SourceFile, lsprotoRange lsproto.Range, text string)
- type TrailingTriviaOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LeadingTriviaOption ¶
type LeadingTriviaOption int
const ( LeadingTriviaOptionNone LeadingTriviaOption = 0 LeadingTriviaOptionExclude LeadingTriviaOption = 1 LeadingTriviaOptionIncludeAll LeadingTriviaOption = 2 LeadingTriviaOptionJSDoc LeadingTriviaOption = 3 LeadingTriviaOptionStartLine LeadingTriviaOption = 4 )
type NodeOptions ¶
type NodeOptions struct {
// Text to be inserted before the new node
Prefix string
// Text to be inserted after the new node
Suffix string
LeadingTriviaOption
TrailingTriviaOption
// contains filtered or unexported fields
}
type Tracker ¶
type Tracker struct {
*printer.EmitContext
*ast.NodeFactory
// contains filtered or unexported fields
}
func NewTracker ¶
func NewTracker(ctx context.Context, compilerOptions *core.CompilerOptions, formatOptions *format.FormatCodeSettings, converters *lsconv.Converters) *Tracker
func (*Tracker) Delete ¶
func (t *Tracker) Delete(sourceFile *ast.SourceFile, node *ast.Node)
Delete queues a node for deletion with smart handling of list items, imports, etc. The actual deletion happens in finishDeleteDeclarations during GetChanges.
func (*Tracker) DeleteNode ¶
func (t *Tracker) DeleteNode(sourceFile *ast.SourceFile, node *ast.Node, leadingTrivia LeadingTriviaOption, trailingTrivia TrailingTriviaOption)
DeleteNode deletes a node immediately with specified trivia options. Stop! Consider using Delete instead, which has logic for deleting nodes from delimited lists.
func (*Tracker) DeleteNodeRange ¶
func (t *Tracker) DeleteNodeRange(sourceFile *ast.SourceFile, startNode *ast.Node, endNode *ast.Node, leadingTrivia LeadingTriviaOption, trailingTrivia TrailingTriviaOption)
DeleteNodeRange deletes a range of nodes with specified trivia options.
func (*Tracker) DeleteRange ¶
func (t *Tracker) DeleteRange(sourceFile *ast.SourceFile, textRange core.TextRange)
DeleteRange deletes a text range from the source file.
func (*Tracker) GetChanges ¶
GetChanges returns the accumulated text edits. Note: after calling this, the Tracker object must be discarded!
func (*Tracker) InsertAtTopOfFile ¶
func (*Tracker) InsertImportSpecifierAtIndex ¶
func (t *Tracker) InsertImportSpecifierAtIndex(sourceFile *ast.SourceFile, newSpecifier *ast.Node, namedImports *ast.Node, index int)
InsertImportSpecifierAtIndex inserts a new import specifier at the specified index in a NamedImports list
func (*Tracker) InsertModifierBefore ¶
func (t *Tracker) InsertModifierBefore(sourceFile *ast.SourceFile, modifier ast.Kind, before *ast.Node)
InsertModifierBefore inserts a modifier token (like 'type') before a node with a trailing space.
func (*Tracker) InsertNodeAfter ¶
func (*Tracker) InsertNodeAt ¶
func (t *Tracker) InsertNodeAt(sourceFile *ast.SourceFile, pos core.TextPos, newNode *ast.Node, options NodeOptions)
func (*Tracker) InsertNodeBefore ¶
func (*Tracker) InsertNodeInListAfter ¶
func (t *Tracker) InsertNodeInListAfter(sourceFile *ast.SourceFile, after *ast.Node, newNode *ast.Node, containingList []*ast.Node)
* * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range, * i.e. arguments in arguments lists, parameters in parameter lists etc. * Note that separators are part of the node in statements and class elements.
func (*Tracker) InsertNodesAfter ¶
func (*Tracker) InsertNodesAt ¶
func (t *Tracker) InsertNodesAt(sourceFile *ast.SourceFile, pos core.TextPos, newNodes []*ast.Node, options NodeOptions)
func (*Tracker) InsertText ¶
func (*Tracker) ReplaceNode ¶
func (t *Tracker) ReplaceNode(sourceFile *ast.SourceFile, oldNode *ast.Node, newNode *ast.Node, options *NodeOptions)
func (*Tracker) ReplaceRange ¶
func (t *Tracker) ReplaceRange(sourceFile *ast.SourceFile, lsprotoRange lsproto.Range, newNode *ast.Node, options NodeOptions)
func (*Tracker) ReplaceRangeWithNodes ¶
func (t *Tracker) ReplaceRangeWithNodes(sourceFile *ast.SourceFile, lsprotoRange lsproto.Range, newNodes []*ast.Node, options NodeOptions)
func (*Tracker) ReplaceRangeWithText ¶
type TrailingTriviaOption ¶
type TrailingTriviaOption int
const ( TrailingTriviaOptionNone TrailingTriviaOption = 0 TrailingTriviaOptionExclude TrailingTriviaOption = 1 TrailingTriviaOptionExcludeWhitespace TrailingTriviaOption = 2 TrailingTriviaOptionInclude TrailingTriviaOption = 3 )