diff --git a/Jakefile.js b/Jakefile.js
index 4c751945c8766..7646059d4c2f9 100644
--- a/Jakefile.js
+++ b/Jakefile.js
@@ -102,6 +102,7 @@ var servicesSources = [
"services.ts",
"shims.ts",
"signatureHelp.ts",
+ "types.ts",
"utilities.ts",
"formatting/formatting.ts",
"formatting/formattingContext.ts",
diff --git a/src/services/services.ts b/src/services/services.ts
index f38fa8eb3a3bc..a322a7fac923a 100644
--- a/src/services/services.ts
+++ b/src/services/services.ts
@@ -7,6 +7,7 @@
///
///
///
+///
///
///
///
@@ -16,123 +17,6 @@ namespace ts {
/** The version of the language service API */
export const servicesVersion = "0.5";
- export interface Node {
- getSourceFile(): SourceFile;
- getChildCount(sourceFile?: SourceFile): number;
- getChildAt(index: number, sourceFile?: SourceFile): Node;
- getChildren(sourceFile?: SourceFile): Node[];
- getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number;
- getFullStart(): number;
- getEnd(): number;
- getWidth(sourceFile?: SourceFile): number;
- getFullWidth(): number;
- getLeadingTriviaWidth(sourceFile?: SourceFile): number;
- getFullText(sourceFile?: SourceFile): string;
- getText(sourceFile?: SourceFile): string;
- getFirstToken(sourceFile?: SourceFile): Node;
- getLastToken(sourceFile?: SourceFile): Node;
- }
-
- export interface Symbol {
- getFlags(): SymbolFlags;
- getName(): string;
- getDeclarations(): Declaration[];
- getDocumentationComment(): SymbolDisplayPart[];
- }
-
- export interface Type {
- getFlags(): TypeFlags;
- getSymbol(): Symbol;
- getProperties(): Symbol[];
- getProperty(propertyName: string): Symbol;
- getApparentProperties(): Symbol[];
- getCallSignatures(): Signature[];
- getConstructSignatures(): Signature[];
- getStringIndexType(): Type;
- getNumberIndexType(): Type;
- getBaseTypes(): ObjectType[];
- getNonNullableType(): Type;
- }
-
- export interface Signature {
- getDeclaration(): SignatureDeclaration;
- getTypeParameters(): Type[];
- getParameters(): Symbol[];
- getReturnType(): Type;
- getDocumentationComment(): SymbolDisplayPart[];
- }
-
- export interface SourceFile {
- /* @internal */ version: string;
- /* @internal */ scriptSnapshot: IScriptSnapshot;
- /* @internal */ nameTable: Map;
-
- /* @internal */ getNamedDeclarations(): Map;
-
- getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
- getLineStarts(): number[];
- getPositionOfLineAndCharacter(line: number, character: number): number;
- update(newText: string, textChangeRange: TextChangeRange): SourceFile;
- }
-
- /**
- * Represents an immutable snapshot of a script at a specified time.Once acquired, the
- * snapshot is observably immutable. i.e. the same calls with the same parameters will return
- * the same values.
- */
- export interface IScriptSnapshot {
- /** Gets a portion of the script snapshot specified by [start, end). */
- getText(start: number, end: number): string;
-
- /** Gets the length of this script snapshot. */
- getLength(): number;
-
- /**
- * Gets the TextChangeRange that describe how the text changed between this text and
- * an older version. This information is used by the incremental parser to determine
- * what sections of the script need to be re-parsed. 'undefined' can be returned if the
- * change range cannot be determined. However, in that case, incremental parsing will
- * not happen and the entire document will be re - parsed.
- */
- getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange | undefined;
-
- /** Releases all resources held by this script snapshot */
- dispose?(): void;
- }
-
- export namespace ScriptSnapshot {
- class StringScriptSnapshot implements IScriptSnapshot {
-
- constructor(private text: string) {
- }
-
- public getText(start: number, end: number): string {
- return this.text.substring(start, end);
- }
-
- public getLength(): number {
- return this.text.length;
- }
-
- public getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange {
- // Text-based snapshots do not support incremental parsing. Return undefined
- // to signal that to the caller.
- return undefined;
- }
- }
-
- export function fromString(text: string): IScriptSnapshot {
- return new StringScriptSnapshot(text);
- }
- }
- export interface PreProcessedFileInfo {
- referencedFiles: FileReference[];
- typeReferenceDirectives: FileReference[];
- importedFiles: FileReference[];
- ambientExternalModules: string[];
- isLibFile: boolean;
- }
-
const scanner: Scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true);
const emptyArray: any[] = [];
@@ -1136,694 +1020,6 @@ namespace ts {
}
}
- export interface HostCancellationToken {
- isCancellationRequested(): boolean;
- }
-
- //
- // Public interface of the host of a language service instance.
- //
- export interface LanguageServiceHost {
- getCompilationSettings(): CompilerOptions;
- getNewLine?(): string;
- getProjectVersion?(): string;
- getScriptFileNames(): string[];
- getScriptKind?(fileName: string): ScriptKind;
- getScriptVersion(fileName: string): string;
- getScriptSnapshot(fileName: string): IScriptSnapshot | undefined;
- getLocalizedDiagnosticMessages?(): any;
- getCancellationToken?(): HostCancellationToken;
- getCurrentDirectory(): string;
- getDefaultLibFileName(options: CompilerOptions): string;
- log?(s: string): void;
- trace?(s: string): void;
- error?(s: string): void;
- useCaseSensitiveFileNames?(): boolean;
-
- /*
- * LS host can optionally implement this method if it wants to be completely in charge of module name resolution.
- * if implementation is omitted then language service will use built-in module resolution logic and get answers to
- * host specific questions using 'getScriptSnapshot'.
- */
- resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
- resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[];
- directoryExists?(directoryName: string): boolean;
- getDirectories?(directoryName: string): string[];
- }
-
- //
- // Public services of a language service instance associated
- // with a language service host instance
- //
- export interface LanguageService {
- cleanupSemanticCache(): void;
-
- getSyntacticDiagnostics(fileName: string): Diagnostic[];
- getSemanticDiagnostics(fileName: string): Diagnostic[];
-
- // TODO: Rename this to getProgramDiagnostics to better indicate that these are any
- // diagnostics present for the program level, and not just 'options' diagnostics.
- getCompilerOptionsDiagnostics(): Diagnostic[];
-
- /**
- * @deprecated Use getEncodedSyntacticClassifications instead.
- */
- getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
-
- /**
- * @deprecated Use getEncodedSemanticClassifications instead.
- */
- getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
-
- // Encoded as triples of [start, length, ClassificationType].
- getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications;
- getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications;
-
- getCompletionsAtPosition(fileName: string, position: number): CompletionInfo;
- getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails;
-
- getQuickInfoAtPosition(fileName: string, position: number): QuickInfo;
-
- getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan;
-
- getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan;
-
- getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems;
-
- getRenameInfo(fileName: string, position: number): RenameInfo;
- findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[];
-
- getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
- getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
-
- getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
- findReferences(fileName: string, position: number): ReferencedSymbol[];
- getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[];
-
- /** @deprecated */
- getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
-
- getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
- getNavigationBarItems(fileName: string): NavigationBarItem[];
-
- getOutliningSpans(fileName: string): OutliningSpan[];
- getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
- getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[];
- getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number;
-
- getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[];
- getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[];
- getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[];
-
- getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
-
- isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
-
- getEmitOutput(fileName: string): EmitOutput;
-
- getProgram(): Program;
-
- /* @internal */ getNonBoundSourceFile(fileName: string): SourceFile;
-
- dispose(): void;
- }
-
- export interface Classifications {
- spans: number[];
- endOfLineState: EndOfLineState;
- }
-
- export interface ClassifiedSpan {
- textSpan: TextSpan;
- classificationType: string; // ClassificationTypeNames
- }
-
- export interface NavigationBarItem {
- text: string;
- kind: string;
- kindModifiers: string;
- spans: TextSpan[];
- childItems: NavigationBarItem[];
- indent: number;
- bolded: boolean;
- grayed: boolean;
- }
-
- export interface TodoCommentDescriptor {
- text: string;
- priority: number;
- }
-
- export interface TodoComment {
- descriptor: TodoCommentDescriptor;
- message: string;
- position: number;
- }
-
- export class TextChange {
- span: TextSpan;
- newText: string;
- }
-
- export interface TextInsertion {
- newText: string;
- /** The position in newText the caret should point to after the insertion. */
- caretOffset: number;
- }
-
- export interface RenameLocation {
- textSpan: TextSpan;
- fileName: string;
- }
-
- export interface ReferenceEntry {
- textSpan: TextSpan;
- fileName: string;
- isWriteAccess: boolean;
- isDefinition: boolean;
- }
-
- export interface DocumentHighlights {
- fileName: string;
- highlightSpans: HighlightSpan[];
- }
-
- export namespace HighlightSpanKind {
- export const none = "none";
- export const definition = "definition";
- export const reference = "reference";
- export const writtenReference = "writtenReference";
- }
-
- export interface HighlightSpan {
- fileName?: string;
- textSpan: TextSpan;
- kind: string;
- }
-
- export interface NavigateToItem {
- name: string;
- kind: string;
- kindModifiers: string;
- matchKind: string;
- isCaseSensitive: boolean;
- fileName: string;
- textSpan: TextSpan;
- containerName: string;
- containerKind: string;
- }
-
- export interface EditorOptions {
- BaseIndentSize?: number;
- IndentSize: number;
- TabSize: number;
- NewLineCharacter: string;
- ConvertTabsToSpaces: boolean;
- IndentStyle: IndentStyle;
- }
-
- export enum IndentStyle {
- None = 0,
- Block = 1,
- Smart = 2,
- }
-
- export interface FormatCodeOptions extends EditorOptions {
- InsertSpaceAfterCommaDelimiter: boolean;
- InsertSpaceAfterSemicolonInForStatements: boolean;
- InsertSpaceBeforeAndAfterBinaryOperators: boolean;
- InsertSpaceAfterKeywordsInControlFlowStatements: boolean;
- InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean;
- InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
- InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean;
- InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean;
- InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
- PlaceOpenBraceOnNewLineForFunctions: boolean;
- PlaceOpenBraceOnNewLineForControlBlocks: boolean;
- [s: string]: boolean | number | string | undefined;
- }
-
- export interface DefinitionInfo {
- fileName: string;
- textSpan: TextSpan;
- kind: string;
- name: string;
- containerKind: string;
- containerName: string;
- }
-
- export interface ReferencedSymbolDefinitionInfo extends DefinitionInfo {
- displayParts: SymbolDisplayPart[];
- }
-
- export interface ReferencedSymbol {
- definition: ReferencedSymbolDefinitionInfo;
- references: ReferenceEntry[];
- }
-
- export enum SymbolDisplayPartKind {
- aliasName,
- className,
- enumName,
- fieldName,
- interfaceName,
- keyword,
- lineBreak,
- numericLiteral,
- stringLiteral,
- localName,
- methodName,
- moduleName,
- operator,
- parameterName,
- propertyName,
- punctuation,
- space,
- text,
- typeParameterName,
- enumMemberName,
- functionName,
- regularExpressionLiteral,
- }
-
- export interface SymbolDisplayPart {
- text: string;
- kind: string;
- }
-
- export interface QuickInfo {
- kind: string;
- kindModifiers: string;
- textSpan: TextSpan;
- displayParts: SymbolDisplayPart[];
- documentation: SymbolDisplayPart[];
- }
-
- export interface RenameInfo {
- canRename: boolean;
- localizedErrorMessage: string;
- displayName: string;
- fullDisplayName: string;
- kind: string;
- kindModifiers: string;
- triggerSpan: TextSpan;
- }
-
- export interface SignatureHelpParameter {
- name: string;
- documentation: SymbolDisplayPart[];
- displayParts: SymbolDisplayPart[];
- isOptional: boolean;
- }
-
- /**
- * Represents a single signature to show in signature help.
- * The id is used for subsequent calls into the language service to ask questions about the
- * signature help item in the context of any documents that have been updated. i.e. after
- * an edit has happened, while signature help is still active, the host can ask important
- * questions like 'what parameter is the user currently contained within?'.
- */
- export interface SignatureHelpItem {
- isVariadic: boolean;
- prefixDisplayParts: SymbolDisplayPart[];
- suffixDisplayParts: SymbolDisplayPart[];
- separatorDisplayParts: SymbolDisplayPart[];
- parameters: SignatureHelpParameter[];
- documentation: SymbolDisplayPart[];
- }
-
- /**
- * Represents a set of signature help items, and the preferred item that should be selected.
- */
- export interface SignatureHelpItems {
- items: SignatureHelpItem[];
- applicableSpan: TextSpan;
- selectedItemIndex: number;
- argumentIndex: number;
- argumentCount: number;
- }
-
- export interface CompletionInfo {
- isMemberCompletion: boolean;
- isNewIdentifierLocation: boolean; // true when the current location also allows for a new identifier
- entries: CompletionEntry[];
- }
-
- export interface CompletionEntry {
- name: string;
- kind: string; // see ScriptElementKind
- kindModifiers: string; // see ScriptElementKindModifier, comma separated
- sortText: string;
- }
-
- export interface CompletionEntryDetails {
- name: string;
- kind: string; // see ScriptElementKind
- kindModifiers: string; // see ScriptElementKindModifier, comma separated
- displayParts: SymbolDisplayPart[];
- documentation: SymbolDisplayPart[];
- }
-
- export interface OutliningSpan {
- /** The span of the document to actually collapse. */
- textSpan: TextSpan;
-
- /** The span of the document to display when the user hovers over the collapsed span. */
- hintSpan: TextSpan;
-
- /** The text to display in the editor for the collapsed region. */
- bannerText: string;
-
- /**
- * Whether or not this region should be automatically collapsed when
- * the 'Collapse to Definitions' command is invoked.
- */
- autoCollapse: boolean;
- }
-
- export interface EmitOutput {
- outputFiles: OutputFile[];
- emitSkipped: boolean;
- }
-
- export const enum OutputFileType {
- JavaScript,
- SourceMap,
- Declaration
- }
-
- export interface OutputFile {
- name: string;
- writeByteOrderMark: boolean;
- text: string;
- }
-
- export const enum EndOfLineState {
- None,
- InMultiLineCommentTrivia,
- InSingleQuoteStringLiteral,
- InDoubleQuoteStringLiteral,
- InTemplateHeadOrNoSubstitutionTemplate,
- InTemplateMiddleOrTail,
- InTemplateSubstitutionPosition,
- }
-
- export enum TokenClass {
- Punctuation,
- Keyword,
- Operator,
- Comment,
- Whitespace,
- Identifier,
- NumberLiteral,
- StringLiteral,
- RegExpLiteral,
- }
-
- export interface ClassificationResult {
- finalLexState: EndOfLineState;
- entries: ClassificationInfo[];
- }
-
- export interface ClassificationInfo {
- length: number;
- classification: TokenClass;
- }
-
- export interface Classifier {
- /**
- * Gives lexical classifications of tokens on a line without any syntactic context.
- * For instance, a token consisting of the text 'string' can be either an identifier
- * named 'string' or the keyword 'string', however, because this classifier is not aware,
- * it relies on certain heuristics to give acceptable results. For classifications where
- * speed trumps accuracy, this function is preferable; however, for true accuracy, the
- * syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
- * lexical, syntactic, and semantic classifiers may issue the best user experience.
- *
- * @param text The text of a line to classify.
- * @param lexState The state of the lexical classifier at the end of the previous line.
- * @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
- * If there is no syntactic classifier (syntacticClassifierAbsent=true),
- * certain heuristics may be used in its place; however, if there is a
- * syntactic classifier (syntacticClassifierAbsent=false), certain
- * classifications which may be incorrectly categorized will be given
- * back as Identifiers in order to allow the syntactic classifier to
- * subsume the classification.
- * @deprecated Use getLexicalClassifications instead.
- */
- getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
- getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications;
- }
-
- /**
- * The document registry represents a store of SourceFile objects that can be shared between
- * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST)
- * of files in the context.
- * SourceFile objects account for most of the memory usage by the language service. Sharing
- * the same DocumentRegistry instance between different instances of LanguageService allow
- * for more efficient memory utilization since all projects will share at least the library
- * file (lib.d.ts).
- *
- * A more advanced use of the document registry is to serialize sourceFile objects to disk
- * and re-hydrate them when needed.
- *
- * To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it
- * to all subsequent createLanguageService calls.
- */
- export interface DocumentRegistry {
- /**
- * Request a stored SourceFile with a given fileName and compilationSettings.
- * The first call to acquire will call createLanguageServiceSourceFile to generate
- * the SourceFile if was not found in the registry.
- *
- * @param fileName The name of the file requested
- * @param compilationSettings Some compilation settings like target affects the
- * shape of a the resulting SourceFile. This allows the DocumentRegistry to store
- * multiple copies of the same file for different compilation settings.
- * @parm scriptSnapshot Text of the file. Only used if the file was not found
- * in the registry and a new one was created.
- * @parm version Current version of the file. Only used if the file was not found
- * in the registry and a new one was created.
- */
- acquireDocument(
- fileName: string,
- compilationSettings: CompilerOptions,
- scriptSnapshot: IScriptSnapshot,
- version: string,
- scriptKind?: ScriptKind): SourceFile;
-
- acquireDocumentWithKey(
- fileName: string,
- path: Path,
- compilationSettings: CompilerOptions,
- key: DocumentRegistryBucketKey,
- scriptSnapshot: IScriptSnapshot,
- version: string,
- scriptKind?: ScriptKind): SourceFile;
-
- /**
- * Request an updated version of an already existing SourceFile with a given fileName
- * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile
- * to get an updated SourceFile.
- *
- * @param fileName The name of the file requested
- * @param compilationSettings Some compilation settings like target affects the
- * shape of a the resulting SourceFile. This allows the DocumentRegistry to store
- * multiple copies of the same file for different compilation settings.
- * @param scriptSnapshot Text of the file.
- * @param version Current version of the file.
- */
- updateDocument(
- fileName: string,
- compilationSettings: CompilerOptions,
- scriptSnapshot: IScriptSnapshot,
- version: string,
- scriptKind?: ScriptKind): SourceFile;
-
- updateDocumentWithKey(
- fileName: string,
- path: Path,
- compilationSettings: CompilerOptions,
- key: DocumentRegistryBucketKey,
- scriptSnapshot: IScriptSnapshot,
- version: string,
- scriptKind?: ScriptKind): SourceFile;
-
- getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey;
- /**
- * Informs the DocumentRegistry that a file is not needed any longer.
- *
- * Note: It is not allowed to call release on a SourceFile that was not acquired from
- * this registry originally.
- *
- * @param fileName The name of the file to be released
- * @param compilationSettings The compilation settings used to acquire the file
- */
- releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
-
- releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void;
-
- reportStats(): string;
- }
-
- export type DocumentRegistryBucketKey = string & { __bucketKey: any };
-
- // TODO: move these to enums
- export namespace ScriptElementKind {
- export const unknown = "";
- export const warning = "warning";
-
- /** predefined type (void) or keyword (class) */
- export const keyword = "keyword";
-
- /** top level script node */
- export const scriptElement = "script";
-
- /** module foo {} */
- export const moduleElement = "module";
-
- /** class X {} */
- export const classElement = "class";
-
- /** var x = class X {} */
- export const localClassElement = "local class";
-
- /** interface Y {} */
- export const interfaceElement = "interface";
-
- /** type T = ... */
- export const typeElement = "type";
-
- /** enum E */
- export const enumElement = "enum";
- // TODO: GH#9983
- export const enumMemberElement = "const";
-
- /**
- * Inside module and script only
- * const v = ..
- */
- export const variableElement = "var";
-
- /** Inside function */
- export const localVariableElement = "local var";
-
- /**
- * Inside module and script only
- * function f() { }
- */
- export const functionElement = "function";
-
- /** Inside function */
- export const localFunctionElement = "local function";
-
- /** class X { [public|private]* foo() {} } */
- export const memberFunctionElement = "method";
-
- /** class X { [public|private]* [get|set] foo:number; } */
- export const memberGetAccessorElement = "getter";
- export const memberSetAccessorElement = "setter";
-
- /**
- * class X { [public|private]* foo:number; }
- * interface Y { foo:number; }
- */
- export const memberVariableElement = "property";
-
- /** class X { constructor() { } } */
- export const constructorImplementationElement = "constructor";
-
- /** interface Y { ():number; } */
- export const callSignatureElement = "call";
-
- /** interface Y { []:number; } */
- export const indexSignatureElement = "index";
-
- /** interface Y { new():Y; } */
- export const constructSignatureElement = "construct";
-
- /** function foo(*Y*: string) */
- export const parameterElement = "parameter";
-
- export const typeParameterElement = "type parameter";
-
- export const primitiveType = "primitive type";
-
- export const label = "label";
-
- export const alias = "alias";
-
- export const constElement = "const";
-
- export const letElement = "let";
- }
-
- export namespace ScriptElementKindModifier {
- export const none = "";
- export const publicMemberModifier = "public";
- export const privateMemberModifier = "private";
- export const protectedMemberModifier = "protected";
- export const exportedModifier = "export";
- export const ambientModifier = "declare";
- export const staticModifier = "static";
- export const abstractModifier = "abstract";
- }
-
- export class ClassificationTypeNames {
- public static comment = "comment";
- public static identifier = "identifier";
- public static keyword = "keyword";
- public static numericLiteral = "number";
- public static operator = "operator";
- public static stringLiteral = "string";
- public static whiteSpace = "whitespace";
- public static text = "text";
-
- public static punctuation = "punctuation";
-
- public static className = "class name";
- public static enumName = "enum name";
- public static interfaceName = "interface name";
- public static moduleName = "module name";
- public static typeParameterName = "type parameter name";
- public static typeAliasName = "type alias name";
- public static parameterName = "parameter name";
- public static docCommentTagName = "doc comment tag name";
- public static jsxOpenTagName = "jsx open tag name";
- public static jsxCloseTagName = "jsx close tag name";
- public static jsxSelfClosingTagName = "jsx self closing tag name";
- public static jsxAttribute = "jsx attribute";
- public static jsxText = "jsx text";
- public static jsxAttributeStringLiteralValue = "jsx attribute string literal value";
- }
-
- export const enum ClassificationType {
- comment = 1,
- identifier = 2,
- keyword = 3,
- numericLiteral = 4,
- operator = 5,
- stringLiteral = 6,
- regularExpressionLiteral = 7,
- whiteSpace = 8,
- text = 9,
- punctuation = 10,
- className = 11,
- enumName = 12,
- interfaceName = 13,
- moduleName = 14,
- typeParameterName = 15,
- typeAliasName = 16,
- parameterName = 17,
- docCommentTagName = 18,
- jsxOpenTagName = 19,
- jsxCloseTagName = 20,
- jsxSelfClosingTagName = 21,
- jsxAttribute = 22,
- jsxText = 23,
- jsxAttributeStringLiteralValue = 24,
- }
-
/// Language Service
// Information about a specific host file.
diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json
index cfeb7c2fcd582..845ddd3e09c2a 100644
--- a/src/services/tsconfig.json
+++ b/src/services/tsconfig.json
@@ -35,6 +35,7 @@
"services.ts",
"shims.ts",
"signatureHelp.ts",
+ "types.ts",
"utilities.ts",
"jsTyping.ts",
"formatting/formatting.ts",
diff --git a/src/services/types.ts b/src/services/types.ts
new file mode 100644
index 0000000000000..9f911d1f10b84
--- /dev/null
+++ b/src/services/types.ts
@@ -0,0 +1,806 @@
+namespace ts {
+ export interface Node {
+ getSourceFile(): SourceFile;
+ getChildCount(sourceFile?: SourceFile): number;
+ getChildAt(index: number, sourceFile?: SourceFile): Node;
+ getChildren(sourceFile?: SourceFile): Node[];
+ getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number;
+ getFullStart(): number;
+ getEnd(): number;
+ getWidth(sourceFile?: SourceFile): number;
+ getFullWidth(): number;
+ getLeadingTriviaWidth(sourceFile?: SourceFile): number;
+ getFullText(sourceFile?: SourceFile): string;
+ getText(sourceFile?: SourceFile): string;
+ getFirstToken(sourceFile?: SourceFile): Node;
+ getLastToken(sourceFile?: SourceFile): Node;
+ }
+
+ export interface Symbol {
+ getFlags(): SymbolFlags;
+ getName(): string;
+ getDeclarations(): Declaration[];
+ getDocumentationComment(): SymbolDisplayPart[];
+ }
+
+ export interface Type {
+ getFlags(): TypeFlags;
+ getSymbol(): Symbol;
+ getProperties(): Symbol[];
+ getProperty(propertyName: string): Symbol;
+ getApparentProperties(): Symbol[];
+ getCallSignatures(): Signature[];
+ getConstructSignatures(): Signature[];
+ getStringIndexType(): Type;
+ getNumberIndexType(): Type;
+ getBaseTypes(): ObjectType[];
+ getNonNullableType(): Type;
+ }
+
+ export interface Signature {
+ getDeclaration(): SignatureDeclaration;
+ getTypeParameters(): Type[];
+ getParameters(): Symbol[];
+ getReturnType(): Type;
+ getDocumentationComment(): SymbolDisplayPart[];
+ }
+
+ export interface SourceFile {
+ /* @internal */ version: string;
+ /* @internal */ scriptSnapshot: IScriptSnapshot;
+ /* @internal */ nameTable: Map;
+
+ /* @internal */ getNamedDeclarations(): Map;
+
+ getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
+ getLineStarts(): number[];
+ getPositionOfLineAndCharacter(line: number, character: number): number;
+ update(newText: string, textChangeRange: TextChangeRange): SourceFile;
+ }
+
+ /**
+ * Represents an immutable snapshot of a script at a specified time.Once acquired, the
+ * snapshot is observably immutable. i.e. the same calls with the same parameters will return
+ * the same values.
+ */
+ export interface IScriptSnapshot {
+ /** Gets a portion of the script snapshot specified by [start, end). */
+ getText(start: number, end: number): string;
+
+ /** Gets the length of this script snapshot. */
+ getLength(): number;
+
+ /**
+ * Gets the TextChangeRange that describe how the text changed between this text and
+ * an older version. This information is used by the incremental parser to determine
+ * what sections of the script need to be re-parsed. 'undefined' can be returned if the
+ * change range cannot be determined. However, in that case, incremental parsing will
+ * not happen and the entire document will be re - parsed.
+ */
+ getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange | undefined;
+
+ /** Releases all resources held by this script snapshot */
+ dispose?(): void;
+ }
+
+ export namespace ScriptSnapshot {
+ class StringScriptSnapshot implements IScriptSnapshot {
+
+ constructor(private text: string) {
+ }
+
+ public getText(start: number, end: number): string {
+ return this.text.substring(start, end);
+ }
+
+ public getLength(): number {
+ return this.text.length;
+ }
+
+ public getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange {
+ // Text-based snapshots do not support incremental parsing. Return undefined
+ // to signal that to the caller.
+ return undefined;
+ }
+ }
+
+ export function fromString(text: string): IScriptSnapshot {
+ return new StringScriptSnapshot(text);
+ }
+ }
+ export interface PreProcessedFileInfo {
+ referencedFiles: FileReference[];
+ typeReferenceDirectives: FileReference[];
+ importedFiles: FileReference[];
+ ambientExternalModules: string[];
+ isLibFile: boolean;
+ }
+
+ export interface HostCancellationToken {
+ isCancellationRequested(): boolean;
+ }
+
+ //
+ // Public interface of the host of a language service instance.
+ //
+ export interface LanguageServiceHost {
+ getCompilationSettings(): CompilerOptions;
+ getNewLine?(): string;
+ getProjectVersion?(): string;
+ getScriptFileNames(): string[];
+ getScriptKind?(fileName: string): ScriptKind;
+ getScriptVersion(fileName: string): string;
+ getScriptSnapshot(fileName: string): IScriptSnapshot | undefined;
+ getLocalizedDiagnosticMessages?(): any;
+ getCancellationToken?(): HostCancellationToken;
+ getCurrentDirectory(): string;
+ getDefaultLibFileName(options: CompilerOptions): string;
+ log?(s: string): void;
+ trace?(s: string): void;
+ error?(s: string): void;
+ useCaseSensitiveFileNames?(): boolean;
+
+ /*
+ * LS host can optionally implement this method if it wants to be completely in charge of module name resolution.
+ * if implementation is omitted then language service will use built-in module resolution logic and get answers to
+ * host specific questions using 'getScriptSnapshot'.
+ */
+ resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
+ resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[];
+ directoryExists?(directoryName: string): boolean;
+ getDirectories?(directoryName: string): string[];
+ }
+
+ //
+ // Public services of a language service instance associated
+ // with a language service host instance
+ //
+ export interface LanguageService {
+ cleanupSemanticCache(): void;
+
+ getSyntacticDiagnostics(fileName: string): Diagnostic[];
+ getSemanticDiagnostics(fileName: string): Diagnostic[];
+
+ // TODO: Rename this to getProgramDiagnostics to better indicate that these are any
+ // diagnostics present for the program level, and not just 'options' diagnostics.
+ getCompilerOptionsDiagnostics(): Diagnostic[];
+
+ /**
+ * @deprecated Use getEncodedSyntacticClassifications instead.
+ */
+ getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
+
+ /**
+ * @deprecated Use getEncodedSemanticClassifications instead.
+ */
+ getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
+
+ // Encoded as triples of [start, length, ClassificationType].
+ getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications;
+ getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications;
+
+ getCompletionsAtPosition(fileName: string, position: number): CompletionInfo;
+ getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails;
+
+ getQuickInfoAtPosition(fileName: string, position: number): QuickInfo;
+
+ getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan;
+
+ getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan;
+
+ getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems;
+
+ getRenameInfo(fileName: string, position: number): RenameInfo;
+ findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[];
+
+ getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
+ getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
+
+ getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
+ findReferences(fileName: string, position: number): ReferencedSymbol[];
+ getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[];
+
+ /** @deprecated */
+ getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
+
+ getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
+ getNavigationBarItems(fileName: string): NavigationBarItem[];
+
+ getOutliningSpans(fileName: string): OutliningSpan[];
+ getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
+ getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[];
+ getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number;
+
+ getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[];
+ getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[];
+ getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[];
+
+ getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
+
+ isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
+
+ getEmitOutput(fileName: string): EmitOutput;
+
+ getProgram(): Program;
+
+ /* @internal */ getNonBoundSourceFile(fileName: string): SourceFile;
+
+ dispose(): void;
+ }
+
+ export interface Classifications {
+ spans: number[];
+ endOfLineState: EndOfLineState;
+ }
+
+ export interface ClassifiedSpan {
+ textSpan: TextSpan;
+ classificationType: string; // ClassificationTypeNames
+ }
+
+ export interface NavigationBarItem {
+ text: string;
+ kind: string;
+ kindModifiers: string;
+ spans: TextSpan[];
+ childItems: NavigationBarItem[];
+ indent: number;
+ bolded: boolean;
+ grayed: boolean;
+ }
+
+ export interface TodoCommentDescriptor {
+ text: string;
+ priority: number;
+ }
+
+ export interface TodoComment {
+ descriptor: TodoCommentDescriptor;
+ message: string;
+ position: number;
+ }
+
+ export class TextChange {
+ span: TextSpan;
+ newText: string;
+ }
+
+ export interface TextInsertion {
+ newText: string;
+ /** The position in newText the caret should point to after the insertion. */
+ caretOffset: number;
+ }
+
+ export interface RenameLocation {
+ textSpan: TextSpan;
+ fileName: string;
+ }
+
+ export interface ReferenceEntry {
+ textSpan: TextSpan;
+ fileName: string;
+ isWriteAccess: boolean;
+ isDefinition: boolean;
+ }
+
+ export interface DocumentHighlights {
+ fileName: string;
+ highlightSpans: HighlightSpan[];
+ }
+
+ export namespace HighlightSpanKind {
+ export const none = "none";
+ export const definition = "definition";
+ export const reference = "reference";
+ export const writtenReference = "writtenReference";
+ }
+
+ export interface HighlightSpan {
+ fileName?: string;
+ textSpan: TextSpan;
+ kind: string;
+ }
+
+ export interface NavigateToItem {
+ name: string;
+ kind: string;
+ kindModifiers: string;
+ matchKind: string;
+ isCaseSensitive: boolean;
+ fileName: string;
+ textSpan: TextSpan;
+ containerName: string;
+ containerKind: string;
+ }
+
+ export interface EditorOptions {
+ BaseIndentSize?: number;
+ IndentSize: number;
+ TabSize: number;
+ NewLineCharacter: string;
+ ConvertTabsToSpaces: boolean;
+ IndentStyle: IndentStyle;
+ }
+
+ export enum IndentStyle {
+ None = 0,
+ Block = 1,
+ Smart = 2,
+ }
+
+ export interface FormatCodeOptions extends EditorOptions {
+ InsertSpaceAfterCommaDelimiter: boolean;
+ InsertSpaceAfterSemicolonInForStatements: boolean;
+ InsertSpaceBeforeAndAfterBinaryOperators: boolean;
+ InsertSpaceAfterKeywordsInControlFlowStatements: boolean;
+ InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean;
+ InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
+ InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean;
+ InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean;
+ InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
+ PlaceOpenBraceOnNewLineForFunctions: boolean;
+ PlaceOpenBraceOnNewLineForControlBlocks: boolean;
+ [s: string]: boolean | number | string | undefined;
+ }
+
+ export interface DefinitionInfo {
+ fileName: string;
+ textSpan: TextSpan;
+ kind: string;
+ name: string;
+ containerKind: string;
+ containerName: string;
+ }
+
+ export interface ReferencedSymbolDefinitionInfo extends DefinitionInfo {
+ displayParts: SymbolDisplayPart[];
+ }
+
+ export interface ReferencedSymbol {
+ definition: ReferencedSymbolDefinitionInfo;
+ references: ReferenceEntry[];
+ }
+
+ export enum SymbolDisplayPartKind {
+ aliasName,
+ className,
+ enumName,
+ fieldName,
+ interfaceName,
+ keyword,
+ lineBreak,
+ numericLiteral,
+ stringLiteral,
+ localName,
+ methodName,
+ moduleName,
+ operator,
+ parameterName,
+ propertyName,
+ punctuation,
+ space,
+ text,
+ typeParameterName,
+ enumMemberName,
+ functionName,
+ regularExpressionLiteral,
+ }
+
+ export interface SymbolDisplayPart {
+ text: string;
+ kind: string;
+ }
+
+ export interface QuickInfo {
+ kind: string;
+ kindModifiers: string;
+ textSpan: TextSpan;
+ displayParts: SymbolDisplayPart[];
+ documentation: SymbolDisplayPart[];
+ }
+
+ export interface RenameInfo {
+ canRename: boolean;
+ localizedErrorMessage: string;
+ displayName: string;
+ fullDisplayName: string;
+ kind: string;
+ kindModifiers: string;
+ triggerSpan: TextSpan;
+ }
+
+ export interface SignatureHelpParameter {
+ name: string;
+ documentation: SymbolDisplayPart[];
+ displayParts: SymbolDisplayPart[];
+ isOptional: boolean;
+ }
+
+ /**
+ * Represents a single signature to show in signature help.
+ * The id is used for subsequent calls into the language service to ask questions about the
+ * signature help item in the context of any documents that have been updated. i.e. after
+ * an edit has happened, while signature help is still active, the host can ask important
+ * questions like 'what parameter is the user currently contained within?'.
+ */
+ export interface SignatureHelpItem {
+ isVariadic: boolean;
+ prefixDisplayParts: SymbolDisplayPart[];
+ suffixDisplayParts: SymbolDisplayPart[];
+ separatorDisplayParts: SymbolDisplayPart[];
+ parameters: SignatureHelpParameter[];
+ documentation: SymbolDisplayPart[];
+ }
+
+ /**
+ * Represents a set of signature help items, and the preferred item that should be selected.
+ */
+ export interface SignatureHelpItems {
+ items: SignatureHelpItem[];
+ applicableSpan: TextSpan;
+ selectedItemIndex: number;
+ argumentIndex: number;
+ argumentCount: number;
+ }
+
+ export interface CompletionInfo {
+ isMemberCompletion: boolean;
+ isNewIdentifierLocation: boolean; // true when the current location also allows for a new identifier
+ entries: CompletionEntry[];
+ }
+
+ export interface CompletionEntry {
+ name: string;
+ kind: string; // see ScriptElementKind
+ kindModifiers: string; // see ScriptElementKindModifier, comma separated
+ sortText: string;
+ }
+
+ export interface CompletionEntryDetails {
+ name: string;
+ kind: string; // see ScriptElementKind
+ kindModifiers: string; // see ScriptElementKindModifier, comma separated
+ displayParts: SymbolDisplayPart[];
+ documentation: SymbolDisplayPart[];
+ }
+
+ export interface OutliningSpan {
+ /** The span of the document to actually collapse. */
+ textSpan: TextSpan;
+
+ /** The span of the document to display when the user hovers over the collapsed span. */
+ hintSpan: TextSpan;
+
+ /** The text to display in the editor for the collapsed region. */
+ bannerText: string;
+
+ /**
+ * Whether or not this region should be automatically collapsed when
+ * the 'Collapse to Definitions' command is invoked.
+ */
+ autoCollapse: boolean;
+ }
+
+ export interface EmitOutput {
+ outputFiles: OutputFile[];
+ emitSkipped: boolean;
+ }
+
+ export const enum OutputFileType {
+ JavaScript,
+ SourceMap,
+ Declaration
+ }
+
+ export interface OutputFile {
+ name: string;
+ writeByteOrderMark: boolean;
+ text: string;
+ }
+
+ export const enum EndOfLineState {
+ None,
+ InMultiLineCommentTrivia,
+ InSingleQuoteStringLiteral,
+ InDoubleQuoteStringLiteral,
+ InTemplateHeadOrNoSubstitutionTemplate,
+ InTemplateMiddleOrTail,
+ InTemplateSubstitutionPosition,
+ }
+
+ export enum TokenClass {
+ Punctuation,
+ Keyword,
+ Operator,
+ Comment,
+ Whitespace,
+ Identifier,
+ NumberLiteral,
+ StringLiteral,
+ RegExpLiteral,
+ }
+
+ export interface ClassificationResult {
+ finalLexState: EndOfLineState;
+ entries: ClassificationInfo[];
+ }
+
+ export interface ClassificationInfo {
+ length: number;
+ classification: TokenClass;
+ }
+
+ export interface Classifier {
+ /**
+ * Gives lexical classifications of tokens on a line without any syntactic context.
+ * For instance, a token consisting of the text 'string' can be either an identifier
+ * named 'string' or the keyword 'string', however, because this classifier is not aware,
+ * it relies on certain heuristics to give acceptable results. For classifications where
+ * speed trumps accuracy, this function is preferable; however, for true accuracy, the
+ * syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
+ * lexical, syntactic, and semantic classifiers may issue the best user experience.
+ *
+ * @param text The text of a line to classify.
+ * @param lexState The state of the lexical classifier at the end of the previous line.
+ * @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
+ * If there is no syntactic classifier (syntacticClassifierAbsent=true),
+ * certain heuristics may be used in its place; however, if there is a
+ * syntactic classifier (syntacticClassifierAbsent=false), certain
+ * classifications which may be incorrectly categorized will be given
+ * back as Identifiers in order to allow the syntactic classifier to
+ * subsume the classification.
+ * @deprecated Use getLexicalClassifications instead.
+ */
+ getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
+ getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications;
+ }
+
+ /**
+ * The document registry represents a store of SourceFile objects that can be shared between
+ * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST)
+ * of files in the context.
+ * SourceFile objects account for most of the memory usage by the language service. Sharing
+ * the same DocumentRegistry instance between different instances of LanguageService allow
+ * for more efficient memory utilization since all projects will share at least the library
+ * file (lib.d.ts).
+ *
+ * A more advanced use of the document registry is to serialize sourceFile objects to disk
+ * and re-hydrate them when needed.
+ *
+ * To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it
+ * to all subsequent createLanguageService calls.
+ */
+ export interface DocumentRegistry {
+ /**
+ * Request a stored SourceFile with a given fileName and compilationSettings.
+ * The first call to acquire will call createLanguageServiceSourceFile to generate
+ * the SourceFile if was not found in the registry.
+ *
+ * @param fileName The name of the file requested
+ * @param compilationSettings Some compilation settings like target affects the
+ * shape of a the resulting SourceFile. This allows the DocumentRegistry to store
+ * multiple copies of the same file for different compilation settings.
+ * @parm scriptSnapshot Text of the file. Only used if the file was not found
+ * in the registry and a new one was created.
+ * @parm version Current version of the file. Only used if the file was not found
+ * in the registry and a new one was created.
+ */
+ acquireDocument(
+ fileName: string,
+ compilationSettings: CompilerOptions,
+ scriptSnapshot: IScriptSnapshot,
+ version: string,
+ scriptKind?: ScriptKind): SourceFile;
+
+ acquireDocumentWithKey(
+ fileName: string,
+ path: Path,
+ compilationSettings: CompilerOptions,
+ key: DocumentRegistryBucketKey,
+ scriptSnapshot: IScriptSnapshot,
+ version: string,
+ scriptKind?: ScriptKind): SourceFile;
+
+ /**
+ * Request an updated version of an already existing SourceFile with a given fileName
+ * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile
+ * to get an updated SourceFile.
+ *
+ * @param fileName The name of the file requested
+ * @param compilationSettings Some compilation settings like target affects the
+ * shape of a the resulting SourceFile. This allows the DocumentRegistry to store
+ * multiple copies of the same file for different compilation settings.
+ * @param scriptSnapshot Text of the file.
+ * @param version Current version of the file.
+ */
+ updateDocument(
+ fileName: string,
+ compilationSettings: CompilerOptions,
+ scriptSnapshot: IScriptSnapshot,
+ version: string,
+ scriptKind?: ScriptKind): SourceFile;
+
+ updateDocumentWithKey(
+ fileName: string,
+ path: Path,
+ compilationSettings: CompilerOptions,
+ key: DocumentRegistryBucketKey,
+ scriptSnapshot: IScriptSnapshot,
+ version: string,
+ scriptKind?: ScriptKind): SourceFile;
+
+ getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey;
+ /**
+ * Informs the DocumentRegistry that a file is not needed any longer.
+ *
+ * Note: It is not allowed to call release on a SourceFile that was not acquired from
+ * this registry originally.
+ *
+ * @param fileName The name of the file to be released
+ * @param compilationSettings The compilation settings used to acquire the file
+ */
+ releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
+
+ releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void;
+
+ reportStats(): string;
+ }
+
+ export type DocumentRegistryBucketKey = string & { __bucketKey: any };
+
+ // TODO: move these to enums
+ export namespace ScriptElementKind {
+ export const unknown = "";
+ export const warning = "warning";
+
+ /** predefined type (void) or keyword (class) */
+ export const keyword = "keyword";
+
+ /** top level script node */
+ export const scriptElement = "script";
+
+ /** module foo {} */
+ export const moduleElement = "module";
+
+ /** class X {} */
+ export const classElement = "class";
+
+ /** var x = class X {} */
+ export const localClassElement = "local class";
+
+ /** interface Y {} */
+ export const interfaceElement = "interface";
+
+ /** type T = ... */
+ export const typeElement = "type";
+
+ /** enum E */
+ export const enumElement = "enum";
+ // TODO: GH#9983
+ export const enumMemberElement = "const";
+
+ /**
+ * Inside module and script only
+ * const v = ..
+ */
+ export const variableElement = "var";
+
+ /** Inside function */
+ export const localVariableElement = "local var";
+
+ /**
+ * Inside module and script only
+ * function f() { }
+ */
+ export const functionElement = "function";
+
+ /** Inside function */
+ export const localFunctionElement = "local function";
+
+ /** class X { [public|private]* foo() {} } */
+ export const memberFunctionElement = "method";
+
+ /** class X { [public|private]* [get|set] foo:number; } */
+ export const memberGetAccessorElement = "getter";
+ export const memberSetAccessorElement = "setter";
+
+ /**
+ * class X { [public|private]* foo:number; }
+ * interface Y { foo:number; }
+ */
+ export const memberVariableElement = "property";
+
+ /** class X { constructor() { } } */
+ export const constructorImplementationElement = "constructor";
+
+ /** interface Y { ():number; } */
+ export const callSignatureElement = "call";
+
+ /** interface Y { []:number; } */
+ export const indexSignatureElement = "index";
+
+ /** interface Y { new():Y; } */
+ export const constructSignatureElement = "construct";
+
+ /** function foo(*Y*: string) */
+ export const parameterElement = "parameter";
+
+ export const typeParameterElement = "type parameter";
+
+ export const primitiveType = "primitive type";
+
+ export const label = "label";
+
+ export const alias = "alias";
+
+ export const constElement = "const";
+
+ export const letElement = "let";
+ }
+
+ export namespace ScriptElementKindModifier {
+ export const none = "";
+ export const publicMemberModifier = "public";
+ export const privateMemberModifier = "private";
+ export const protectedMemberModifier = "protected";
+ export const exportedModifier = "export";
+ export const ambientModifier = "declare";
+ export const staticModifier = "static";
+ export const abstractModifier = "abstract";
+ }
+
+ export class ClassificationTypeNames {
+ public static comment = "comment";
+ public static identifier = "identifier";
+ public static keyword = "keyword";
+ public static numericLiteral = "number";
+ public static operator = "operator";
+ public static stringLiteral = "string";
+ public static whiteSpace = "whitespace";
+ public static text = "text";
+
+ public static punctuation = "punctuation";
+
+ public static className = "class name";
+ public static enumName = "enum name";
+ public static interfaceName = "interface name";
+ public static moduleName = "module name";
+ public static typeParameterName = "type parameter name";
+ public static typeAliasName = "type alias name";
+ public static parameterName = "parameter name";
+ public static docCommentTagName = "doc comment tag name";
+ public static jsxOpenTagName = "jsx open tag name";
+ public static jsxCloseTagName = "jsx close tag name";
+ public static jsxSelfClosingTagName = "jsx self closing tag name";
+ public static jsxAttribute = "jsx attribute";
+ public static jsxText = "jsx text";
+ public static jsxAttributeStringLiteralValue = "jsx attribute string literal value";
+ }
+
+ export const enum ClassificationType {
+ comment = 1,
+ identifier = 2,
+ keyword = 3,
+ numericLiteral = 4,
+ operator = 5,
+ stringLiteral = 6,
+ regularExpressionLiteral = 7,
+ whiteSpace = 8,
+ text = 9,
+ punctuation = 10,
+ className = 11,
+ enumName = 12,
+ interfaceName = 13,
+ moduleName = 14,
+ typeParameterName = 15,
+ typeAliasName = 16,
+ parameterName = 17,
+ docCommentTagName = 18,
+ jsxOpenTagName = 19,
+ jsxCloseTagName = 20,
+ jsxSelfClosingTagName = 21,
+ jsxAttribute = 22,
+ jsxText = 23,
+ jsxAttributeStringLiteralValue = 24,
+ }
+}