ls

package
v0.0.0-...-6fb55b7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2025 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
var (
	ErrNoSourceFile      = errors.New("source file not found")
	ErrNoTokenAtPosition = errors.New("no token found at position")
)
View Source
var TriggerCharacters = []string{".", `"`, "'", "`", "/", "@", "<", "#", " "}

Functions

func IsInString

func IsInString(sourceFile *ast.SourceFile, position int, previousToken *ast.Node) bool

func ProvideWorkspaceSymbols

func ProvideWorkspaceSymbols(ctx context.Context, programs []*compiler.Program, converters *lsconv.Converters, query string) (lsproto.WorkspaceSymbolResponse, error)

func RangeContainsRange

func RangeContainsRange(r1 core.TextRange, r2 core.TextRange) bool

Types

type AddAsTypeOnly

type AddAsTypeOnly int
const (
	// These should not be combined as bitflags, but are given powers of 2 values to
	// easily detect conflicts between `NotAllowed` and `Required` by giving them a unique sum.
	// They're also ordered in terms of increasing priority for a fix-all scenario (see
	// `reduceAddAsTypeOnlyValues`).
	AddAsTypeOnlyAllowed    AddAsTypeOnly = 1 << 0
	AddAsTypeOnlyRequired   AddAsTypeOnly = 1 << 1
	AddAsTypeOnlyNotAllowed AddAsTypeOnly = 1 << 2
)

type AutoImportData

type AutoImportData struct {
	/**
	 * The name of the property or export in the module's symbol table. Differs from the completion name
	 * in the case of InternalSymbolName.ExportEquals and InternalSymbolName.Default.
	 */
	ExportName      string           `json:"exportName"`
	ExportMapKey    ExportInfoMapKey `json:"exportMapKey"`
	ModuleSpecifier string           `json:"moduleSpecifier"`

	/** The file name declaring the export's module symbol, if it was an external module */
	FileName string `json:"fileName"`
	/** The module name (with quotes stripped) of the export's module symbol, if it was an ambient module */
	AmbientModuleName *string `json:"ambientModuleName"`

	/** True if the export was found in the package.json AutoImportProvider */
	IsPackageJsonImport core.Tristate `json:"isPackageJsonImport"`
}

type CachedSymbolExportInfo

type CachedSymbolExportInfo struct {
	// contains filtered or unexported fields
}

type CandidateOrTypeInfo

type CandidateOrTypeInfo struct {
	// contains filtered or unexported fields
}

type CompletionItemData

type CompletionItemData struct {
	FileName   string          `json:"fileName"`
	Position   int             `json:"position"`
	Source     string          `json:"source,omitempty"`
	Name       string          `json:"name,omitempty"`
	AutoImport *AutoImportData `json:"autoImport,omitempty"`
}

func GetCompletionItemData

func GetCompletionItemData(item *lsproto.CompletionItem) (*CompletionItemData, error)

type CompletionKind

type CompletionKind int
const (
	CompletionKindNone CompletionKind = iota
	CompletionKindObjectPropertyDeclaration
	CompletionKindGlobal
	CompletionKindPropertyAccess
	CompletionKindMemberLike
	CompletionKindString
)

type CompletionsTriggerCharacter

type CompletionsTriggerCharacter = string

"." | '"' | "'" | "`" | "/" | "@" | "<" | "#" | " "

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 ExportInfoMap

type ExportInfoMap struct {
	// contains filtered or unexported fields
}

func NewExportInfoMap

func NewExportInfoMap(globalsTypingCacheLocation string) *ExportInfoMap

type ExportInfoMapKey

type ExportInfoMapKey struct {
	SymbolName        string
	SymbolId          ast.SymbolId
	AmbientModuleName string
	ModuleFile        tspath.Path
}

type ExportKind

type ExportKind int
const (
	ExportKindNamed        ExportKind = 0
	ExportKindDefault      ExportKind = 1
	ExportKindExportEquals ExportKind = 2
	ExportKindUMD          ExportKind = 3
	ExportKindModule       ExportKind = 4
)

func (ExportKind) String

func (i ExportKind) String() string

type FixAddToExistingImportInfo

type FixAddToExistingImportInfo struct {
	// contains filtered or unexported fields
}

* Information needed to augment an existing import declaration. !!! after full implementation, rename to AddToExistingImportInfo

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
}

type ImpExpKind

type ImpExpKind int32
const (
	ImpExpKindUnknown ImpExpKind = iota
	ImpExpKindImport
	ImpExpKindExport
)

type Import

type Import struct {
	// contains filtered or unexported fields
}

type ImportExportSymbol

type ImportExportSymbol struct {
	// contains filtered or unexported fields
}

type ImportFix

type ImportFix struct {
	// contains filtered or unexported fields
}

type ImportFixKind

type ImportFixKind int
const (
	// Sorted with the preferred fix coming first.
	ImportFixKindUseNamespace    ImportFixKind = 0
	ImportFixKindJsdocTypeImport ImportFixKind = 1
	ImportFixKindAddToExisting   ImportFixKind = 2
	ImportFixKindAddNew          ImportFixKind = 3
	ImportFixKindPromoteTypeOnly ImportFixKind = 4
)

type ImportKind

type ImportKind int
const (
	ImportKindNamed     ImportKind = 0
	ImportKindDefault   ImportKind = 1
	ImportKindNamespace ImportKind = 2
	ImportKindCommonJS  ImportKind = 3
)

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 NewLanguageService(
	program *compiler.Program,
	host Host,
) *LanguageService

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,
	clientOptions *lsproto.SignatureHelpClientCapabilities,
) *lsproto.SignatureHelp

func (*LanguageService) GetSymbolAtLocation

func (l *LanguageService) GetSymbolAtLocation(ctx context.Context, node *ast.Node) *ast.Symbol

func (*LanguageService) GetSymbolAtPosition

func (l *LanguageService) GetSymbolAtPosition(ctx context.Context, fileName string, position int) (*ast.Symbol, error)

func (*LanguageService) GetTypeOfSymbol

func (l *LanguageService) GetTypeOfSymbol(ctx context.Context, symbol *ast.Symbol) *checker.Type

func (*LanguageService) ProvideCompletion

func (l *LanguageService) ProvideCompletion(
	ctx context.Context,
	documentURI lsproto.DocumentUri,
	LSPPosition lsproto.Position,
	context *lsproto.CompletionContext,
	clientOptions *lsproto.CompletionClientCapabilities,
) (lsproto.CompletionResponse, error)

func (*LanguageService) ProvideDefinition

func (l *LanguageService) ProvideDefinition(
	ctx context.Context,
	documentURI lsproto.DocumentUri,
	position lsproto.Position,
	clientSupportsLink bool,
) (lsproto.DefinitionResponse, error)

func (*LanguageService) ProvideDiagnostics

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) 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 (*LanguageService) ProvideReferences

func (l *LanguageService) ProvideReferences(ctx context.Context, params *lsproto.ReferenceParams) (lsproto.ReferencesResponse, error)

func (*LanguageService) ProvideRename

func (*LanguageService) ProvideSelectionRanges

func (*LanguageService) ProvideSignatureHelp

func (*LanguageService) ProvideTypeDefinition

func (l *LanguageService) ProvideTypeDefinition(
	ctx context.Context,
	documentURI lsproto.DocumentUri,
	position lsproto.Position,
	clientSupportsLink bool,
) (lsproto.DefinitionResponse, error)

func (*LanguageService) ReadFile

func (l *LanguageService) ReadFile(fileName string) (string, bool)

func (*LanguageService) ResolveCompletionItem

func (l *LanguageService) ResolveCompletionItem(
	ctx context.Context,
	item *lsproto.CompletionItem,
	data *CompletionItemData,
	clientOptions *lsproto.CompletionClientCapabilities,
) (*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 Qualification

type Qualification struct {
	// contains filtered or unexported fields
}

type ReferenceEntry

type ReferenceEntry struct {
	// contains filtered or unexported fields
}

type ScriptElementKind

type ScriptElementKind string
const (
	ScriptElementKindUnknown ScriptElementKind = ""
	ScriptElementKindWarning ScriptElementKind = "warning"
	// predefined type (void) or keyword (class)
	ScriptElementKindKeyword ScriptElementKind = "keyword"
	// top level script node
	ScriptElementKindScriptElement ScriptElementKind = "script"
	// module foo {}
	ScriptElementKindModuleElement ScriptElementKind = "module"
	// class X {}
	ScriptElementKindClassElement ScriptElementKind = "class"
	// var x = class X {}
	ScriptElementKindLocalClassElement ScriptElementKind = "local class"
	// interface Y {}
	ScriptElementKindInterfaceElement ScriptElementKind = "interface"
	// type T = ...
	ScriptElementKindTypeElement ScriptElementKind = "type"
	// enum E {}
	ScriptElementKindEnumElement       ScriptElementKind = "enum"
	ScriptElementKindEnumMemberElement ScriptElementKind = "enum member"
	// Inside module and script only.
	// const v = ...
	ScriptElementKindVariableElement ScriptElementKind = "var"
	// Inside function.
	ScriptElementKindLocalVariableElement ScriptElementKind = "local var"
	// using foo = ...
	ScriptElementKindVariableUsingElement ScriptElementKind = "using"
	// await using foo = ...
	ScriptElementKindVariableAwaitUsingElement ScriptElementKind = "await using"
	// Inside module and script only.
	// function f() {}
	ScriptElementKindFunctionElement ScriptElementKind = "function"
	// Inside function.
	ScriptElementKindLocalFunctionElement ScriptElementKind = "local function"
	// class X { [public|private]* foo() {} }
	ScriptElementKindMemberFunctionElement ScriptElementKind = "method"
	// class X { [public|private]* [get|set] foo:number; }
	ScriptElementKindMemberGetAccessorElement ScriptElementKind = "getter"
	ScriptElementKindMemberSetAccessorElement ScriptElementKind = "setter"
	// class X { [public|private]* foo:number; }
	// interface Y { foo:number; }
	ScriptElementKindMemberVariableElement ScriptElementKind = "property"
	// class X { [public|private]* accessor foo: number; }
	ScriptElementKindMemberAccessorVariableElement ScriptElementKind = "accessor"
	// class X { constructor() { } }
	// class X { static { } }
	ScriptElementKindConstructorImplementationElement ScriptElementKind = "constructor"
	// interface Y { ():number; }
	ScriptElementKindCallSignatureElement ScriptElementKind = "call"
	// interface Y { []:number; }
	ScriptElementKindIndexSignatureElement ScriptElementKind = "index"
	// interface Y { new():Y; }
	ScriptElementKindConstructSignatureElement ScriptElementKind = "construct"
	// function foo(*Y*: string)
	ScriptElementKindParameterElement     ScriptElementKind = "parameter"
	ScriptElementKindTypeParameterElement ScriptElementKind = "type parameter"
	ScriptElementKindPrimitiveType        ScriptElementKind = "primitive type"
	ScriptElementKindLabel                ScriptElementKind = "label"
	ScriptElementKindAlias                ScriptElementKind = "alias"
	ScriptElementKindConstElement         ScriptElementKind = "const"
	ScriptElementKindLetElement           ScriptElementKind = "let"
	ScriptElementKindDirectory            ScriptElementKind = "directory"
	ScriptElementKindExternalModuleName   ScriptElementKind = "external module name"
	// String literal
	ScriptElementKindString ScriptElementKind = "string"
	// Jsdoc @link: in `{@link C link text}`, the before and after text "{@link " and "}"
	ScriptElementKindLink ScriptElementKind = "link"
	// Jsdoc @link: in `{@link C link text}`, the entity name "C"
	ScriptElementKindLinkName ScriptElementKind = "link name"
	// Jsdoc @link: in `{@link C link text}`, the link text "link text"
	ScriptElementKindLinkText ScriptElementKind = "link text"
)

type ScriptElementKindModifier

type ScriptElementKindModifier string
const (
	ScriptElementKindModifierNone       ScriptElementKindModifier = ""
	ScriptElementKindModifierPublic     ScriptElementKindModifier = "public"
	ScriptElementKindModifierPrivate    ScriptElementKindModifier = "private"
	ScriptElementKindModifierProtected  ScriptElementKindModifier = "protected"
	ScriptElementKindModifierExported   ScriptElementKindModifier = "export"
	ScriptElementKindModifierAmbient    ScriptElementKindModifier = "declare"
	ScriptElementKindModifierStatic     ScriptElementKindModifier = "static"
	ScriptElementKindModifierAbstract   ScriptElementKindModifier = "abstract"
	ScriptElementKindModifierOptional   ScriptElementKindModifier = "optional"
	ScriptElementKindModifierDeprecated ScriptElementKindModifier = "deprecated"
	ScriptElementKindModifierDts        ScriptElementKindModifier = ".d.ts"
	ScriptElementKindModifierTs         ScriptElementKindModifier = ".ts"
	ScriptElementKindModifierTsx        ScriptElementKindModifier = ".tsx"
	ScriptElementKindModifierJs         ScriptElementKindModifier = ".js"
	ScriptElementKindModifierJsx        ScriptElementKindModifier = ".jsx"
	ScriptElementKindModifierJson       ScriptElementKindModifier = ".json"
	ScriptElementKindModifierDmts       ScriptElementKindModifier = ".d.mts"
	ScriptElementKindModifierMts        ScriptElementKindModifier = ".mts"
	ScriptElementKindModifierMjs        ScriptElementKindModifier = ".mjs"
	ScriptElementKindModifierDcts       ScriptElementKindModifier = ".d.cts"
	ScriptElementKindModifierCts        ScriptElementKindModifier = ".cts"
	ScriptElementKindModifierCjs        ScriptElementKindModifier = ".cjs"
)

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

func DeprecateSortText(original SortText) SortText

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 SymbolExportInfo

type SymbolExportInfo struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL