Documentation
¶
Index ¶
- Constants
- Variables
- func CompareCompletionEntries(a, b *lsproto.CompletionItem) int
- func IsInString(sourceFile *ast.SourceFile, position int, previousToken *ast.Node) bool
- func ProvideWorkspaceSymbols(ctx context.Context, programs []*compiler.Program, ...) (lsproto.WorkspaceSymbolResponse, error)
- func RangeContainsRange(r1 core.TextRange, r2 core.TextRange) bool
- type CallHierarchyDeclaration
- type CandidateOrTypeInfo
- type CodeAction
- type CodeFixContext
- type CodeFixProvider
- type CombinedCodeActions
- type CompletionKind
- type CompletionsTriggerCharacter
- type CrossProjectOrchestrator
- type DeclarationInfo
- type Definition
- type DefinitionKind
- type ExportInfo
- type ExportKind
- type Host
- type ImpExpKind
- type ImportExportSymbol
- type ImportTracker
- type ImportsResult
- type KeywordCompletionFilters
- type LanguageService
- func (l *LanguageService) FormatOptions() *format.FormatCodeSettings
- func (l *LanguageService) GetDocumentPositionMapper(fileName string) *sourcemap.DocumentPositionMapper
- func (l *LanguageService) GetECMALineInfo(fileName string) *sourcemap.ECMALineInfo
- func (l *LanguageService) GetProgram() *compiler.Program
- func (l *LanguageService) GetSignatureHelpItems(ctx context.Context, position int, program *compiler.Program, ...) *lsproto.SignatureHelp
- func (l *LanguageService) GetSymbolAtLocation(ctx context.Context, node *ast.Node) *ast.Symbol
- func (l *LanguageService) GetSymbolAtPosition(ctx context.Context, fileName string, position int) (*ast.Symbol, error)
- func (l *LanguageService) GetTypeOfSymbol(ctx context.Context, symbol *ast.Symbol) *checker.Type
- func (l *LanguageService) ProvideCallHierarchyIncomingCalls(ctx context.Context, item *lsproto.CallHierarchyItem, ...) (lsproto.CallHierarchyIncomingCallsResponse, error)
- func (l *LanguageService) ProvideCallHierarchyOutgoingCalls(ctx context.Context, item *lsproto.CallHierarchyItem) (lsproto.CallHierarchyOutgoingCallsResponse, error)
- func (l *LanguageService) ProvideClosingTagCompletion(ctx context.Context, params *lsproto.TextDocumentPositionParams) (lsproto.CustomClosingTagCompletionResponse, error)
- func (l *LanguageService) ProvideCodeActions(ctx context.Context, params *lsproto.CodeActionParams) (lsproto.CodeActionResponse, error)
- func (l *LanguageService) ProvideCodeLenses(ctx context.Context, documentURI lsproto.DocumentUri) (lsproto.CodeLensResponse, error)
- func (l *LanguageService) ProvideCompletion(ctx context.Context, documentURI lsproto.DocumentUri, ...) (lsproto.CompletionResponse, error)
- func (l *LanguageService) ProvideDefinition(ctx context.Context, documentURI lsproto.DocumentUri, ...) (lsproto.DefinitionResponse, error)
- func (l *LanguageService) ProvideDiagnostics(ctx context.Context, uri lsproto.DocumentUri) (lsproto.DocumentDiagnosticResponse, error)
- func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documentUri lsproto.DocumentUri, ...) (lsproto.DocumentHighlightResponse, error)
- func (l *LanguageService) ProvideDocumentSymbols(ctx context.Context, documentURI lsproto.DocumentUri) (lsproto.DocumentSymbolResponse, error)
- func (l *LanguageService) ProvideFoldingRange(ctx context.Context, documentURI lsproto.DocumentUri) (lsproto.FoldingRangeResponse, error)
- func (l *LanguageService) ProvideFormatDocument(ctx context.Context, documentURI lsproto.DocumentUri, ...) (lsproto.DocumentFormattingResponse, error)
- func (l *LanguageService) ProvideFormatDocumentOnType(ctx context.Context, documentURI lsproto.DocumentUri, ...) (lsproto.DocumentOnTypeFormattingResponse, error)
- func (l *LanguageService) ProvideFormatDocumentRange(ctx context.Context, documentURI lsproto.DocumentUri, ...) (lsproto.DocumentRangeFormattingResponse, error)
- func (l *LanguageService) ProvideHover(ctx context.Context, documentURI lsproto.DocumentUri, ...) (lsproto.HoverResponse, error)
- func (l *LanguageService) ProvideImplementations(ctx context.Context, params *lsproto.ImplementationParams, ...) (lsproto.ImplementationResponse, error)
- func (l *LanguageService) ProvideInlayHint(ctx context.Context, params *lsproto.InlayHintParams) (lsproto.InlayHintResponse, error)
- func (l *LanguageService) ProvidePrepareCallHierarchy(ctx context.Context, documentURI lsproto.DocumentUri, ...) (lsproto.CallHierarchyPrepareResponse, error)
- func (l *LanguageService) ProvideReferences(ctx context.Context, params *lsproto.ReferenceParams, ...) (lsproto.ReferencesResponse, error)
- func (l *LanguageService) ProvideRename(ctx context.Context, params *lsproto.RenameParams, ...) (lsproto.WorkspaceEditOrNull, error)
- func (l *LanguageService) ProvideSelectionRanges(ctx context.Context, params *lsproto.SelectionRangeParams) (lsproto.SelectionRangeResponse, error)
- func (l *LanguageService) ProvideSignatureHelp(ctx context.Context, documentURI lsproto.DocumentUri, ...) (lsproto.SignatureHelpResponse, error)
- func (l *LanguageService) ProvideTypeDefinition(ctx context.Context, documentURI lsproto.DocumentUri, ...) (lsproto.TypeDefinitionResponse, error)
- func (l *LanguageService) ReadFile(fileName string) (string, bool)
- func (l *LanguageService) ResolveCodeLens(ctx context.Context, codeLens *lsproto.CodeLens, ...) (*lsproto.CodeLens, error)
- func (l *LanguageService) ResolveCompletionItem(ctx context.Context, item *lsproto.CompletionItem, ...) (*lsproto.CompletionItem, error)
- func (l *LanguageService) UseCaseSensitiveFileNames() bool
- func (l *LanguageService) UserPreferences() *lsutil.UserPreferences
- type LocationAndSymbol
- type ModuleReference
- type ModuleReferenceKind
- type PossibleTypeArgumentInfo
- type Project
- type ReferenceEntry
- type SortText
- type SymbolAndEntries
- type SymbolAndEntriesData
Constants ¶
const ( // Completions that require `this.` insertion text SourceThisProperty = "ThisProperty/" // Auto-import that comes attached to a class member snippet SourceClassMemberSnippet = "ClassMemberSnippet/" // A type-only import that needs to be promoted in order to be used at the completion location SourceTypeOnlyAlias = "TypeOnlyAlias/" // Auto-import that comes attached to an object literal method snippet SourceObjectLiteralMethodSnippet = "ObjectLiteralMethodSnippet/" // Case completions for switch statements SourceSwitchCases = "SwitchCases/" // Completions for an object literal expression SourceObjectLiteralMemberWithComma = "ObjectLiteralMemberWithComma/" )
Special values for `CompletionInfo['source']` used to disambiguate completion items with the same `name`. (Each completion item must have a unique name/source combination, because those two fields comprise `CompletionEntryIdentifier` in `getCompletionEntryDetails`.
When the completion item is an auto-import suggestion, the source is the module specifier of the suggestion. To avoid collisions, the values here should not be a module specifier we would ever generate for an auto-import.
Variables ¶
var ( ErrNoSourceFile = errors.New("source file not found") ErrNoTokenAtPosition = errors.New("no token found at position") )
var ErrNeedsAutoImports = errors.New("completion list needs auto imports")
var ImportFixProvider = &CodeFixProvider{ ErrorCodes: importFixErrorCodes, GetCodeActions: getImportCodeActions, FixIds: []string{importFixID}, }
ImportFixProvider is the CodeFixProvider for import-related fixes
var TriggerCharacters = []string{".", `"`, "'", "`", "/", "@", "<", "#", " "}
Functions ¶
func CompareCompletionEntries ¶
func CompareCompletionEntries(a, b *lsproto.CompletionItem) int
Editors will use the `sortText` and then fall back to `name` for sorting, but leave ties in response order. So, it's important that we sort those ties in the order we want them displayed if it matters. We don't strictly need to sort by name or SortText here since clients are going to do it anyway, but we have to do the work of comparing them so we can sort those ties appropriately.
func IsInString ¶
func ProvideWorkspaceSymbols ¶
func ProvideWorkspaceSymbols( ctx context.Context, programs []*compiler.Program, converters *lsconv.Converters, preferences *lsutil.UserPreferences, query string, ) (lsproto.WorkspaceSymbolResponse, error)
Types ¶
type CandidateOrTypeInfo ¶
type CandidateOrTypeInfo struct {
// contains filtered or unexported fields
}
type CodeAction ¶
CodeAction represents a single code action fix
type CodeFixContext ¶
type CodeFixContext struct {
SourceFile *ast.SourceFile
Span core.TextRange
ErrorCode int32
Program *compiler.Program
LS *LanguageService
Diagnostic *lsproto.Diagnostic
Params *lsproto.CodeActionParams
}
CodeFixContext contains the context needed to generate code fixes
type CodeFixProvider ¶
type CodeFixProvider struct {
ErrorCodes []int32
GetCodeActions func(ctx context.Context, fixContext *CodeFixContext) ([]CodeAction, error)
FixIds []string
GetAllCodeActions func(ctx context.Context, fixContext *CodeFixContext) (*CombinedCodeActions, error)
}
CodeFixProvider represents a provider for a specific type of code fix
type CombinedCodeActions ¶
CombinedCodeActions represents combined code actions for fix-all scenarios
type CompletionKind ¶
type CompletionKind int
const ( CompletionKindNone CompletionKind = iota CompletionKindObjectPropertyDeclaration CompletionKindGlobal CompletionKindPropertyAccess CompletionKindMemberLike CompletionKindString )
type CompletionsTriggerCharacter ¶
type CompletionsTriggerCharacter = string
"." | '"' | "'" | "`" | "/" | "@" | "<" | "#" | " "
type CrossProjectOrchestrator ¶
type CrossProjectOrchestrator interface {
GetDefaultProject() Project
GetAllProjectsForInitialRequest() []Project
GetLanguageServiceForProjectWithFile(ctx context.Context, project Project, uri lsproto.DocumentUri) *LanguageService
GetProjectsForFile(ctx context.Context, uri lsproto.DocumentUri) ([]Project, error)
GetProjectsLoadingProjectTree(ctx context.Context, requestedProjectTrees *collections.Set[tspath.Path]) iter.Seq[Project]
}
type DeclarationInfo ¶
type DeclarationInfo struct {
// contains filtered or unexported fields
}
type Definition ¶
type Definition struct {
Kind DefinitionKind
// contains filtered or unexported fields
}
type DefinitionKind ¶
type DefinitionKind int
type ExportInfo ¶
type ExportInfo struct {
// contains filtered or unexported fields
}
type ExportKind ¶
type ExportKind int
const ( ExportKindNamed ExportKind = 0 ExportKindDefault ExportKind = 1 ExportKindExportEquals ExportKind = 2 ExportKindUMD ExportKind = 3 ExportKindModule ExportKind = 4 )
type Host ¶
type Host interface {
UseCaseSensitiveFileNames() bool
ReadFile(path string) (contents string, ok bool)
Converters() *lsconv.Converters
UserPreferences() *lsutil.UserPreferences
FormatOptions() *format.FormatCodeSettings
GetECMALineInfo(fileName string) *sourcemap.ECMALineInfo
AutoImportRegistry() *autoimport.Registry
}
type ImpExpKind ¶
type ImpExpKind int32
const ( ImpExpKindUnknown ImpExpKind = iota ImpExpKindImport ImpExpKindExport )
type ImportExportSymbol ¶
type ImportExportSymbol struct {
// contains filtered or unexported fields
}
type ImportTracker ¶
type ImportTracker func(exportSymbol *ast.Symbol, exportInfo *ExportInfo, isForRename bool) *ImportsResult
type ImportsResult ¶
type ImportsResult struct {
// contains filtered or unexported fields
}
type KeywordCompletionFilters ¶
type KeywordCompletionFilters int
const ( KeywordCompletionFiltersNone KeywordCompletionFilters = iota // No keywords KeywordCompletionFiltersAll // Every possible kewyord KeywordCompletionFiltersClassElementKeywords // Keywords inside class body KeywordCompletionFiltersInterfaceElementKeywords // Keywords inside interface body KeywordCompletionFiltersConstructorParameterKeywords // Keywords at constructor parameter KeywordCompletionFiltersFunctionLikeBodyKeywords // Keywords at function like body KeywordCompletionFiltersTypeAssertionKeywords KeywordCompletionFiltersTypeKeywords KeywordCompletionFiltersTypeKeyword // Literally just `type` KeywordCompletionFiltersLast = KeywordCompletionFiltersTypeKeyword )
type LanguageService ¶
type LanguageService struct {
// contains filtered or unexported fields
}
func NewLanguageService ¶
func (*LanguageService) FormatOptions ¶
func (l *LanguageService) FormatOptions() *format.FormatCodeSettings
func (*LanguageService) GetDocumentPositionMapper ¶
func (l *LanguageService) GetDocumentPositionMapper(fileName string) *sourcemap.DocumentPositionMapper
func (*LanguageService) GetECMALineInfo ¶
func (l *LanguageService) GetECMALineInfo(fileName string) *sourcemap.ECMALineInfo
func (*LanguageService) GetProgram ¶
func (l *LanguageService) GetProgram() *compiler.Program
func (*LanguageService) GetSignatureHelpItems ¶
func (l *LanguageService) GetSignatureHelpItems( ctx context.Context, position int, program *compiler.Program, sourceFile *ast.SourceFile, context *lsproto.SignatureHelpContext, ) *lsproto.SignatureHelp
func (*LanguageService) GetSymbolAtLocation ¶
func (*LanguageService) GetSymbolAtPosition ¶
func (*LanguageService) GetTypeOfSymbol ¶
func (*LanguageService) ProvideCallHierarchyIncomingCalls ¶
func (l *LanguageService) ProvideCallHierarchyIncomingCalls( ctx context.Context, item *lsproto.CallHierarchyItem, orchestrator CrossProjectOrchestrator, ) (lsproto.CallHierarchyIncomingCallsResponse, error)
func (*LanguageService) ProvideCallHierarchyOutgoingCalls ¶
func (l *LanguageService) ProvideCallHierarchyOutgoingCalls( ctx context.Context, item *lsproto.CallHierarchyItem, ) (lsproto.CallHierarchyOutgoingCallsResponse, error)
func (*LanguageService) ProvideClosingTagCompletion ¶
func (l *LanguageService) ProvideClosingTagCompletion(ctx context.Context, params *lsproto.TextDocumentPositionParams) (lsproto.CustomClosingTagCompletionResponse, error)
func (*LanguageService) ProvideCodeActions ¶
func (l *LanguageService) ProvideCodeActions(ctx context.Context, params *lsproto.CodeActionParams) (lsproto.CodeActionResponse, error)
ProvideCodeActions returns code actions for the given range and context
func (*LanguageService) ProvideCodeLenses ¶
func (l *LanguageService) ProvideCodeLenses(ctx context.Context, documentURI lsproto.DocumentUri) (lsproto.CodeLensResponse, error)
func (*LanguageService) ProvideCompletion ¶
func (l *LanguageService) ProvideCompletion( ctx context.Context, documentURI lsproto.DocumentUri, LSPPosition lsproto.Position, context *lsproto.CompletionContext, ) (lsproto.CompletionResponse, error)
func (*LanguageService) ProvideDefinition ¶
func (l *LanguageService) ProvideDefinition( ctx context.Context, documentURI lsproto.DocumentUri, position lsproto.Position, ) (lsproto.DefinitionResponse, error)
func (*LanguageService) ProvideDiagnostics ¶
func (l *LanguageService) ProvideDiagnostics(ctx context.Context, uri lsproto.DocumentUri) (lsproto.DocumentDiagnosticResponse, error)
func (*LanguageService) ProvideDocumentHighlights ¶
func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documentUri lsproto.DocumentUri, documentPosition lsproto.Position) (lsproto.DocumentHighlightResponse, error)
func (*LanguageService) ProvideDocumentSymbols ¶
func (l *LanguageService) ProvideDocumentSymbols(ctx context.Context, documentURI lsproto.DocumentUri) (lsproto.DocumentSymbolResponse, error)
func (*LanguageService) ProvideFoldingRange ¶
func (l *LanguageService) ProvideFoldingRange(ctx context.Context, documentURI lsproto.DocumentUri) (lsproto.FoldingRangeResponse, error)
func (*LanguageService) ProvideFormatDocument ¶
func (l *LanguageService) ProvideFormatDocument( ctx context.Context, documentURI lsproto.DocumentUri, options *lsproto.FormattingOptions, ) (lsproto.DocumentFormattingResponse, error)
func (*LanguageService) ProvideFormatDocumentOnType ¶
func (l *LanguageService) ProvideFormatDocumentOnType( ctx context.Context, documentURI lsproto.DocumentUri, options *lsproto.FormattingOptions, position lsproto.Position, character string, ) (lsproto.DocumentOnTypeFormattingResponse, error)
func (*LanguageService) ProvideFormatDocumentRange ¶
func (l *LanguageService) ProvideFormatDocumentRange( ctx context.Context, documentURI lsproto.DocumentUri, options *lsproto.FormattingOptions, r lsproto.Range, ) (lsproto.DocumentRangeFormattingResponse, error)
func (*LanguageService) ProvideHover ¶
func (l *LanguageService) ProvideHover(ctx context.Context, documentURI lsproto.DocumentUri, position lsproto.Position) (lsproto.HoverResponse, error)
func (*LanguageService) ProvideImplementations ¶
func (l *LanguageService) ProvideImplementations(ctx context.Context, params *lsproto.ImplementationParams, orchestrator CrossProjectOrchestrator) (lsproto.ImplementationResponse, error)
func (*LanguageService) ProvideInlayHint ¶
func (l *LanguageService) ProvideInlayHint( ctx context.Context, params *lsproto.InlayHintParams, ) (lsproto.InlayHintResponse, error)
func (*LanguageService) ProvidePrepareCallHierarchy ¶
func (l *LanguageService) ProvidePrepareCallHierarchy( ctx context.Context, documentURI lsproto.DocumentUri, position lsproto.Position, ) (lsproto.CallHierarchyPrepareResponse, error)
func (*LanguageService) ProvideReferences ¶
func (l *LanguageService) ProvideReferences(ctx context.Context, params *lsproto.ReferenceParams, orchestrator CrossProjectOrchestrator) (lsproto.ReferencesResponse, error)
func (*LanguageService) ProvideRename ¶
func (l *LanguageService) ProvideRename(ctx context.Context, params *lsproto.RenameParams, orchestrator CrossProjectOrchestrator) (lsproto.WorkspaceEditOrNull, error)
func (*LanguageService) ProvideSelectionRanges ¶
func (l *LanguageService) ProvideSelectionRanges(ctx context.Context, params *lsproto.SelectionRangeParams) (lsproto.SelectionRangeResponse, error)
func (*LanguageService) ProvideSignatureHelp ¶
func (l *LanguageService) ProvideSignatureHelp( ctx context.Context, documentURI lsproto.DocumentUri, position lsproto.Position, context *lsproto.SignatureHelpContext, ) (lsproto.SignatureHelpResponse, error)
func (*LanguageService) ProvideTypeDefinition ¶
func (l *LanguageService) ProvideTypeDefinition( ctx context.Context, documentURI lsproto.DocumentUri, position lsproto.Position, ) (lsproto.TypeDefinitionResponse, error)
func (*LanguageService) ReadFile ¶
func (l *LanguageService) ReadFile(fileName string) (string, bool)
func (*LanguageService) ResolveCodeLens ¶
func (l *LanguageService) ResolveCodeLens(ctx context.Context, codeLens *lsproto.CodeLens, showLocationsCommandName *string, orchestrator CrossProjectOrchestrator) (*lsproto.CodeLens, error)
func (*LanguageService) ResolveCompletionItem ¶
func (l *LanguageService) ResolveCompletionItem( ctx context.Context, item *lsproto.CompletionItem, data *lsproto.CompletionItemData, ) (*lsproto.CompletionItem, error)
func (*LanguageService) UseCaseSensitiveFileNames ¶
func (l *LanguageService) UseCaseSensitiveFileNames() bool
func (*LanguageService) UserPreferences ¶
func (l *LanguageService) UserPreferences() *lsutil.UserPreferences
type LocationAndSymbol ¶
type LocationAndSymbol struct {
// contains filtered or unexported fields
}
type ModuleReference ¶
type ModuleReference struct {
// contains filtered or unexported fields
}
ModuleReference represents a reference to a module, either via import, <reference>, or implicit reference
type ModuleReferenceKind ¶
type ModuleReferenceKind int32
const ( ModuleReferenceKindImport ModuleReferenceKind = iota ModuleReferenceKindReference ModuleReferenceKindImplicit )
type PossibleTypeArgumentInfo ¶
type PossibleTypeArgumentInfo struct {
// contains filtered or unexported fields
}
type ReferenceEntry ¶
type ReferenceEntry struct {
// contains filtered or unexported fields
}
type SortText ¶
type SortText string
const ( SortTextLocalDeclarationPriority SortText = "10" SortTextLocationPriority SortText = "11" SortTextOptionalMember SortText = "12" SortTextMemberDeclaredBySpreadAssignment SortText = "13" SortTextSuggestedClassMembers SortText = "14" SortTextGlobalsOrKeywords SortText = "15" SortTextAutoImportSuggestions SortText = "16" SortTextClassMemberSnippets SortText = "17" SortTextJavascriptIdentifiers SortText = "18" )
func DeprecateSortText ¶
type SymbolAndEntries ¶
type SymbolAndEntries struct {
// contains filtered or unexported fields
}
func NewSymbolAndEntries ¶
func NewSymbolAndEntries(kind DefinitionKind, node *ast.Node, symbol *ast.Symbol, references []*ReferenceEntry) *SymbolAndEntries
type SymbolAndEntriesData ¶
type SymbolAndEntriesData struct {
OriginalNode *ast.Node
SymbolsAndEntries []*SymbolAndEntries
Position int
}
Source Files
¶
- api.go
- callhierarchy.go
- codeactions.go
- codeactions_importfixes.go
- codelens.go
- completions.go
- constants.go
- crossproject.go
- definition.go
- diagnostics.go
- documenthighlights.go
- findallreferences.go
- folding.go
- format.go
- host.go
- hover.go
- importTracker.go
- inlay_hints.go
- jsxclosingtag.go
- languageservice.go
- selectionranges.go
- signaturehelp.go
- source_map.go
- string_completions.go
- symbols.go
- utilities.go