Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface LanguageService

Hierarchy

  • LanguageService

Index

Methods

applyCodeActionCommand

cleanupSemanticCache

  • cleanupSemanticCache(): void
  • This is used as a part of restarting the language service.

    Returns void

commentSelection

  • Parameters

    Returns TextChange[]

dispose

  • dispose(): void
  • Returns void

findReferences

  • Parameters

    • fileName: string
    • position: number

    Returns ReferencedSymbol[]

findRenameLocations

  • findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): readonly RenameLocation[]
  • Parameters

    • fileName: string
    • position: number
    • findInStrings: boolean
    • findInComments: boolean
    • Optional providePrefixAndSuffixTextForRename: boolean

    Returns readonly RenameLocation[]

getApplicableRefactors

getBraceMatchingAtPosition

  • getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[]
  • Parameters

    • fileName: string
    • position: number

    Returns TextSpan[]

getBreakpointStatementAtPosition

  • getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan
  • Parameters

    • fileName: string
    • position: number

    Returns TextSpan

getCodeFixesAtPosition

  • Parameters

    Returns readonly CodeFixAction[]

getCombinedCodeFix

getCompilerOptionsDiagnostics

  • Gets global diagnostics related to the program configuration and compiler options.

    Returns Diagnostic[]

getCompletionEntryDetails

  • Gets the extended details for a completion entry retrieved from getCompletionsAtPosition.

    Parameters

    • fileName: string

      The path to the file

    • position: number

      A zero based index of the character where you want the entries

    • entryName: string

      The name from an existing completion which came from getCompletionsAtPosition

    • formatOptions: FormatCodeSettings | FormatCodeOptions

      How should code samples in the completions be formatted, can be undefined for backwards compatibility

    • source: string

      source property from the completion entry

    • preferences: UserPreferences

      User settings, can be undefined for backwards compatibility

    • data: CompletionEntryData

      data property from the completion entry

    Returns CompletionEntryDetails

getCompletionEntrySymbol

  • getCompletionEntrySymbol(fileName: string, position: number, name: string, source: string): Symbol
  • Parameters

    • fileName: string
    • position: number
    • name: string
    • source: string

    Returns Symbol

getCompletionsAtPosition

  • Gets completion entries at a particular position in a file.

    Parameters

    • fileName: string

      The path to the file

    • position: number

      A zero-based index of the character where you want the entries

    • options: GetCompletionsAtPositionOptions

      An object describing how the request was triggered and what kinds of code actions can be returned with the completions.

    Returns WithMetadata<CompletionInfo>

getDefinitionAndBoundSpan

  • Parameters

    • fileName: string
    • position: number

    Returns DefinitionInfoAndBoundSpan

getDefinitionAtPosition

  • getDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[]
  • Parameters

    • fileName: string
    • position: number

    Returns readonly DefinitionInfo[]

getDocCommentTemplateAtPosition

getDocumentHighlights

  • getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[]
  • Parameters

    • fileName: string
    • position: number
    • filesToSearch: string[]

    Returns DocumentHighlights[]

getEditsForFileRename

getEditsForRefactor

getEmitOutput

  • getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean, forceDtsEmit?: boolean): EmitOutput
  • Parameters

    • fileName: string
    • Optional emitOnlyDtsFiles: boolean
    • Optional forceDtsEmit: boolean

    Returns EmitOutput

getEncodedSemanticClassifications

  • Gets semantic highlights information for a particular file. Has two formats, an older version used by VS and a format used by VS Code.

    Parameters

    Returns Classifications

    a number array encoded as triples of [start, length, ClassificationType, ...].

getEncodedSyntacticClassifications

  • Encoded as triples of [start, length, ClassificationType].

    Parameters

    Returns Classifications

getFileReferences

  • Parameters

    • fileName: string

    Returns ReferenceEntry[]

getFormattingEditsAfterKeystroke

getFormattingEditsForDocument

getFormattingEditsForRange

getImplementationAtPosition

  • Parameters

    • fileName: string
    • position: number

    Returns readonly ImplementationLocation[]

getIndentationAtPosition

  • Parameters

    Returns number

getJsxClosingTagAtPosition

  • This will return a defined result if the position is after the > of the opening tag, or somewhere in the text, of a JSXElement with no closing tag. Editors should call this after > is typed.

    Parameters

    • fileName: string
    • position: number

    Returns JsxClosingTagInfo

getNameOrDottedNameSpan

  • getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan
  • Parameters

    • fileName: string
    • startPos: number
    • endPos: number

    Returns TextSpan

getNavigateToItems

  • getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]
  • Parameters

    • searchValue: string
    • Optional maxResultCount: number
    • Optional fileName: string
    • Optional excludeDtsFiles: boolean

    Returns NavigateToItem[]

getNavigationBarItems

  • Parameters

    • fileName: string

    Returns NavigationBarItem[]

getNavigationTree

  • Parameters

    • fileName: string

    Returns NavigationTree

getOccurrencesAtPosition

  • getOccurrencesAtPosition(fileName: string, position: number): readonly ReferenceEntry[]
  • deprecated

    Parameters

    • fileName: string
    • position: number

    Returns readonly ReferenceEntry[]

getOutliningSpans

  • Parameters

    • fileName: string

    Returns OutliningSpan[]

getProgram

  • Returns Program

getQuickInfoAtPosition

  • getQuickInfoAtPosition(fileName: string, position: number): QuickInfo
  • Gets semantic information about the identifier at a particular position in a file. Quick info is what you typically see when you hover in an editor.

    Parameters

    • fileName: string

      The path to the file

    • position: number

      A zero-based index of the character where you want the quick info

    Returns QuickInfo

getReferencesAtPosition

  • getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]
  • Parameters

    • fileName: string
    • position: number

    Returns ReferenceEntry[]

getRenameInfo

  • Parameters

    Returns RenameInfo

getSemanticClassifications

getSemanticDiagnostics

  • getSemanticDiagnostics(fileName: string): Diagnostic[]
  • Gets warnings or errors indicating type system issues in a given file. Requesting semantic diagnostics may start up the type system and run deferred work, so the first call may take longer than subsequent calls.

    Unlike the other get*Diagnostics functions, these diagnostics can potentially not include a reference to a source file. Specifically, the first time this is called, it will return global diagnostics with no associated location.

    To contrast the differences between semantic and syntactic diagnostics, consider the sentence: "The sun is green." is syntactically correct; those are real English words with correct sentence structure. However, it is semantically invalid, because it is not true.

    Parameters

    • fileName: string

      A path to the file you want semantic diagnostics for

    Returns Diagnostic[]

getSignatureHelpItems

getSmartSelectionRange

  • getSmartSelectionRange(fileName: string, position: number): SelectionRange
  • Parameters

    • fileName: string
    • position: number

    Returns SelectionRange

getSpanOfEnclosingComment

  • getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan
  • Parameters

    • fileName: string
    • position: number
    • onlyMultiLine: boolean

    Returns TextSpan

getSuggestionDiagnostics

  • Gets suggestion diagnostics for a specific file. These diagnostics tend to proactively suggest refactors, as opposed to diagnostics that indicate potentially incorrect runtime behavior.

    Parameters

    • fileName: string

      A path to the file you want semantic diagnostics for

    Returns DiagnosticWithLocation[]

getSyntacticClassifications

getSyntacticDiagnostics

  • Gets errors indicating invalid syntax in a file.

    In English, "this cdeo have, erorrs" is syntactically invalid because it has typos, grammatical errors, and misplaced punctuation. Likewise, examples of syntax errors in TypeScript are missing parentheses in an if statement, mismatched curly braces, and using a reserved keyword as a variable name.

    These diagnostics are inexpensive to compute and don't require knowledge of other files. Note that a non-empty result increases the likelihood of false positives from getSemanticDiagnostics.

    While these represent the majority of syntax-related diagnostics, there are some that require the type system, which will be present in getSemanticDiagnostics.

    Parameters

    • fileName: string

      A path to the file you want syntactic diagnostics for

    Returns DiagnosticWithLocation[]

getTodoComments

getTypeDefinitionAtPosition

  • getTypeDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[]
  • Parameters

    • fileName: string
    • position: number

    Returns readonly DefinitionInfo[]

isValidBraceCompletionAtPosition

  • isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean
  • Parameters

    • fileName: string
    • position: number
    • openingBrace: number

    Returns boolean

organizeImports

prepareCallHierarchy

provideCallHierarchyIncomingCalls

  • Parameters

    • fileName: string
    • position: number

    Returns CallHierarchyIncomingCall[]

provideCallHierarchyOutgoingCalls

  • Parameters

    • fileName: string
    • position: number

    Returns CallHierarchyOutgoingCall[]

Optional toLineColumnOffset

  • Parameters

    • fileName: string
    • position: number

    Returns LineAndCharacter

toggleLineComment

  • Parameters

    Returns TextChange[]

toggleMultilineComment

  • Parameters

    Returns TextChange[]

uncommentSelection

  • Parameters

    Returns TextChange[]

Generated using TypeDoc