diff --git a/TypeScript b/TypeScript index 8038eb9..32b6746 160000 --- a/TypeScript +++ b/TypeScript @@ -1 +1 @@ -Subproject commit 8038eb943e6509a5da3377853ca04986bededbb1 +Subproject commit 32b6746afe193bfa0cd07798768134f1b8963fe1 diff --git a/bin/ntypescript.d.ts b/bin/ntypescript.d.ts index e9d9d88..7e622ca 100644 --- a/bin/ntypescript.d.ts +++ b/bin/ntypescript.d.ts @@ -2394,6 +2394,11 @@ declare namespace ts { function cloneMap(map: Map): Map; function clone(object: T): T; function extend(first: T1, second: T2): T1 & T2; + /** + * Adds the value to an array of values associated with the key, and returns the array. + * Creates the array if it does not already exist. + */ + function multiMapAdd(map: Map, key: string, value: V): V[]; /** * Tests whether a value is an array. */ @@ -7755,1154 +7760,1156 @@ declare namespace ts.SignatureHelp { function getContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile): ArgumentListInfo; } declare namespace ts { - interface ListItemInfo { - listItemIndex: number; - list: Node; + 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; } - function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number; - function rangeContainsRange(r1: TextRange, r2: TextRange): boolean; - function startEndContainsRange(start: number, end: number, range: TextRange): boolean; - function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean; - function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean; - function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean; - function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean; - function isCompletedNode(n: Node, sourceFile: SourceFile): boolean; - function findListItemInfo(node: Node): ListItemInfo; - function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean; - function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node; - function findContainingList(node: Node): Node; - function getTouchingWord(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; - function getTouchingPropertyName(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; - /** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */ - function getTouchingToken(sourceFile: SourceFile, position: number, includeItemAtEndPosition?: (n: Node) => boolean, includeJsDocComment?: boolean): Node; - /** Returns a token if position is in [start-of-leading-trivia, end) */ - function getTokenAtPosition(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; - /** - * The token on the left of the position is the token that strictly includes the position - * or sits to the left of the cursor if it is on a boundary. For example - * - * fo|o -> will return foo - * foo |bar -> will return foo - * - */ - function findTokenOnLeftOfPosition(file: SourceFile, position: number): Node; - function findNextToken(previousToken: Node, parent: Node): Node; - function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node): Node; - function isInString(sourceFile: SourceFile, position: number): boolean; - function isInComment(sourceFile: SourceFile, position: number): boolean; - /** - * returns true if the position is in between the open and close elements of an JSX expression. - */ - function isInsideJsxElementOrAttribute(sourceFile: SourceFile, position: number): boolean; - function isInTemplateString(sourceFile: SourceFile, position: number): boolean; - /** - * Returns true if the cursor at position in sourceFile is within a comment that additionally - * satisfies predicate, and false otherwise. - */ - function isInCommentHelper(sourceFile: SourceFile, position: number, predicate?: (c: CommentRange) => boolean): boolean; - function hasDocComment(sourceFile: SourceFile, position: number): boolean; - /** - * Get the corresponding JSDocTag node if the position is in a jsDoc comment - */ - function getJsDocTagAtPosition(sourceFile: SourceFile, position: number): JSDocTag; - function getNodeModifiers(node: Node): string; - function getTypeArgumentOrTypeParameterList(node: Node): NodeArray; - function isToken(n: Node): boolean; - function isWord(kind: SyntaxKind): boolean; - function isComment(kind: SyntaxKind): boolean; - function isStringOrRegularExpressionOrTemplateLiteral(kind: SyntaxKind): boolean; - function isPunctuation(kind: SyntaxKind): boolean; - function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean; - function isAccessibilityModifier(kind: SyntaxKind): boolean; - function compareDataObjects(dst: any, src: any): boolean; - function isArrayLiteralOrObjectLiteralDestructuringPattern(node: Node): boolean; -} -declare namespace ts { - function isFirstDeclarationOfSymbolParameter(symbol: Symbol): boolean; - function symbolPart(text: string, symbol: Symbol): SymbolDisplayPart; - function displayPart(text: string, kind: SymbolDisplayPartKind, symbol?: Symbol): SymbolDisplayPart; - function spacePart(): SymbolDisplayPart; - function keywordPart(kind: SyntaxKind): SymbolDisplayPart; - function punctuationPart(kind: SyntaxKind): SymbolDisplayPart; - function operatorPart(kind: SyntaxKind): SymbolDisplayPart; - function textOrKeywordPart(text: string): SymbolDisplayPart; - function textPart(text: string): SymbolDisplayPart; - /** - * The default is CRLF. - */ - function getNewLineOrDefaultFromHost(host: LanguageServiceHost | LanguageServiceShimHost): string; - function lineBreakPart(): SymbolDisplayPart; - function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[]; - function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; - function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): SymbolDisplayPart[]; - function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; - function getDeclaredName(typeChecker: TypeChecker, symbol: Symbol, location: Node): string; - function isImportOrExportSpecifierName(location: Node): boolean; - /** - * Strip off existed single quotes or double quotes from a given string - * - * @return non-quoted string - */ - function stripQuotes(name: string): string; - function scriptKindIs(fileName: string, host: LanguageServiceHost, ...scriptKinds: ScriptKind[]): boolean; - function getScriptKind(fileName: string, host?: LanguageServiceHost): ScriptKind; - function parseAndReEmitConfigJSONFile(content: string): { - configJsonObject: any; - diagnostics: Diagnostic[]; - }; -} -declare namespace ts.JsTyping { - interface TypingResolutionHost { - directoryExists: (path: string) => boolean; - fileExists: (fileName: string) => boolean; - readFile: (path: string, encoding?: string) => string; - readDirectory: (rootDir: string, extensions: string[], excludes: string[], includes: string[], depth?: number) => string[]; + interface Symbol { + getFlags(): SymbolFlags; + getName(): string; + getDeclarations(): Declaration[]; + getDocumentationComment(): SymbolDisplayPart[]; + } + 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; + } + interface Signature { + getDeclaration(): SignatureDeclaration; + getTypeParameters(): Type[]; + getParameters(): Symbol[]; + getReturnType(): Type; + getDocumentationComment(): SymbolDisplayPart[]; + } + interface SourceFile { + version: string; + scriptSnapshot: IScriptSnapshot; + nameTable: Map; + getNamedDeclarations(): Map; + getLineAndCharacterOfPosition(pos: number): LineAndCharacter; + getLineStarts(): number[]; + getPositionOfLineAndCharacter(line: number, character: number): number; + update(newText: string, textChangeRange: TextChangeRange): SourceFile; } /** - * @param host is the object providing I/O related operations. - * @param fileNames are the file names that belong to the same project - * @param projectRootPath is the path to the project root directory - * @param safeListPath is the path used to retrieve the safe list - * @param packageNameToTypingLocation is the map of package names to their cached typing locations - * @param typingOptions are used to customize the typing inference process - * @param compilerOptions are used as a source for typing inference + * 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. */ - function discoverTypings(host: TypingResolutionHost, fileNames: string[], projectRootPath: Path, safeListPath: Path, packageNameToTypingLocation: Map, typingOptions: TypingOptions, compilerOptions: CompilerOptions): { - cachedTypingPaths: string[]; - newTypingNames: string[]; - filesToWatch: string[]; - }; -} -declare namespace ts.formatting { - interface FormattingScanner { - advance(): void; - isOnToken(): boolean; - readTokenInfo(n: Node): TokenInfo; - getCurrentLeadingTrivia(): TextRangeWithKind[]; - lastTrailingTriviaWasNewLine(): boolean; - skipToEndOf(node: Node): void; - close(): void; - } - function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner; -} -declare namespace ts.formatting { - class FormattingContext { - sourceFile: SourceFile; - formattingRequestKind: FormattingRequestKind; - currentTokenSpan: TextRangeWithKind; - nextTokenSpan: TextRangeWithKind; - contextNode: Node; - currentTokenParent: Node; - nextTokenParent: Node; - private contextNodeAllOnSameLine; - private nextNodeAllOnSameLine; - private tokensAreOnSameLine; - private contextNodeBlockIsOnOneLine; - private nextNodeBlockIsOnOneLine; - constructor(sourceFile: SourceFile, formattingRequestKind: FormattingRequestKind); - updateContext(currentRange: TextRangeWithKind, currentTokenParent: Node, nextRange: TextRangeWithKind, nextTokenParent: Node, commonParent: Node): void; - ContextNodeAllOnSameLine(): boolean; - NextNodeAllOnSameLine(): boolean; - TokensAreOnSameLine(): boolean; - ContextNodeBlockIsOnOneLine(): boolean; - NextNodeBlockIsOnOneLine(): boolean; - private NodeIsOnOneLine(node); - private BlockIsOnOneLine(node); + 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; } -} -declare namespace ts.formatting { - enum FormattingRequestKind { - FormatDocument = 0, - FormatSelection = 1, - FormatOnEnter = 2, - FormatOnSemicolon = 3, - FormatOnClosingCurlyBrace = 4, + namespace ScriptSnapshot { + function fromString(text: string): IScriptSnapshot; } -} -declare namespace ts.formatting { - class Rule { - Descriptor: RuleDescriptor; - Operation: RuleOperation; - Flag: RuleFlags; - constructor(Descriptor: RuleDescriptor, Operation: RuleOperation, Flag?: RuleFlags); - toString(): string; + interface PreProcessedFileInfo { + referencedFiles: FileReference[]; + typeReferenceDirectives: FileReference[]; + importedFiles: FileReference[]; + ambientExternalModules: string[]; + isLibFile: boolean; } -} -declare namespace ts.formatting { - enum RuleAction { - Ignore = 1, - Space = 2, - NewLine = 4, - Delete = 8, + interface HostCancellationToken { + isCancellationRequested(): boolean; } -} -declare namespace ts.formatting { - class RuleDescriptor { - LeftTokenRange: Shared.TokenRange; - RightTokenRange: Shared.TokenRange; - constructor(LeftTokenRange: Shared.TokenRange, RightTokenRange: Shared.TokenRange); - toString(): string; - static create1(left: SyntaxKind, right: SyntaxKind): RuleDescriptor; - static create2(left: Shared.TokenRange, right: SyntaxKind): RuleDescriptor; - static create3(left: SyntaxKind, right: Shared.TokenRange): RuleDescriptor; - static create4(left: Shared.TokenRange, right: Shared.TokenRange): RuleDescriptor; + 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; + resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; + resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + directoryExists?(directoryName: string): boolean; + getDirectories?(directoryName: string): string[]; } -} -declare namespace ts.formatting { - enum RuleFlags { + interface LanguageService { + cleanupSemanticCache(): void; + getSyntacticDiagnostics(fileName: string): Diagnostic[]; + getSemanticDiagnostics(fileName: string): Diagnostic[]; + getCompilerOptionsDiagnostics(): Diagnostic[]; + /** + * @deprecated Use getEncodedSyntacticClassifications instead. + */ + getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + /** + * @deprecated Use getEncodedSemanticClassifications instead. + */ + getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + 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; + getNonBoundSourceFile(fileName: string): SourceFile; + dispose(): void; + } + interface Classifications { + spans: number[]; + endOfLineState: EndOfLineState; + } + interface ClassifiedSpan { + textSpan: TextSpan; + classificationType: string; + } + interface NavigationBarItem { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems: NavigationBarItem[]; + indent: number; + bolded: boolean; + grayed: boolean; + } + interface TodoCommentDescriptor { + text: string; + priority: number; + } + interface TodoComment { + descriptor: TodoCommentDescriptor; + message: string; + position: number; + } + class TextChange { + span: TextSpan; + newText: string; + } + interface TextInsertion { + newText: string; + /** The position in newText the caret should point to after the insertion. */ + caretOffset: number; + } + interface RenameLocation { + textSpan: TextSpan; + fileName: string; + } + interface ReferenceEntry { + textSpan: TextSpan; + fileName: string; + isWriteAccess: boolean; + isDefinition: boolean; + } + interface DocumentHighlights { + fileName: string; + highlightSpans: HighlightSpan[]; + } + namespace HighlightSpanKind { + const none: string; + const definition: string; + const reference: string; + const writtenReference: string; + } + interface HighlightSpan { + fileName?: string; + textSpan: TextSpan; + kind: string; + } + interface NavigateToItem { + name: string; + kind: string; + kindModifiers: string; + matchKind: string; + isCaseSensitive: boolean; + fileName: string; + textSpan: TextSpan; + containerName: string; + containerKind: string; + } + interface EditorOptions { + BaseIndentSize?: number; + IndentSize: number; + TabSize: number; + NewLineCharacter: string; + ConvertTabsToSpaces: boolean; + IndentStyle: IndentStyle; + } + enum IndentStyle { None = 0, - CanDeleteNewLines = 1, + Block = 1, + Smart = 2, } -} -declare namespace ts.formatting { - class RuleOperation { - Context: RuleOperationContext; - Action: RuleAction; - constructor(Context: RuleOperationContext, Action: RuleAction); - toString(): string; - static create1(action: RuleAction): RuleOperation; - static create2(context: RuleOperationContext, action: RuleAction): RuleOperation; + 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; } -} -declare namespace ts.formatting { - class RuleOperationContext { - private customContextChecks; - constructor(...funcs: { - (context: FormattingContext): boolean; - }[]); - static Any: RuleOperationContext; - IsAny(): boolean; - InContext(context: FormattingContext): boolean; + interface DefinitionInfo { + fileName: string; + textSpan: TextSpan; + kind: string; + name: string; + containerKind: string; + containerName: string; } -} -declare namespace ts.formatting { - class Rules { - getRuleName(rule: Rule): string; - [name: string]: any; - IgnoreBeforeComment: Rule; - IgnoreAfterLineComment: Rule; - NoSpaceBeforeSemicolon: Rule; - NoSpaceBeforeColon: Rule; - NoSpaceBeforeQuestionMark: Rule; - SpaceAfterColon: Rule; - SpaceAfterQuestionMarkInConditionalOperator: Rule; - NoSpaceAfterQuestionMark: Rule; - SpaceAfterSemicolon: Rule; - SpaceAfterCloseBrace: Rule; - SpaceBetweenCloseBraceAndElse: Rule; - SpaceBetweenCloseBraceAndWhile: Rule; - NoSpaceAfterCloseBrace: Rule; - NoSpaceBeforeDot: Rule; - NoSpaceAfterDot: Rule; - NoSpaceBeforeOpenBracket: Rule; - NoSpaceAfterCloseBracket: Rule; - SpaceAfterOpenBrace: Rule; - SpaceBeforeCloseBrace: Rule; - NoSpaceBetweenEmptyBraceBrackets: Rule; - NewLineAfterOpenBraceInBlockContext: Rule; - NewLineBeforeCloseBraceInBlockContext: Rule; - NoSpaceAfterUnaryPrefixOperator: Rule; - NoSpaceAfterUnaryPreincrementOperator: Rule; - NoSpaceAfterUnaryPredecrementOperator: Rule; - NoSpaceBeforeUnaryPostincrementOperator: Rule; - NoSpaceBeforeUnaryPostdecrementOperator: Rule; - SpaceAfterPostincrementWhenFollowedByAdd: Rule; - SpaceAfterAddWhenFollowedByUnaryPlus: Rule; - SpaceAfterAddWhenFollowedByPreincrement: Rule; - SpaceAfterPostdecrementWhenFollowedBySubtract: Rule; - SpaceAfterSubtractWhenFollowedByUnaryMinus: Rule; - SpaceAfterSubtractWhenFollowedByPredecrement: Rule; - NoSpaceBeforeComma: Rule; - SpaceAfterCertainKeywords: Rule; - SpaceAfterLetConstInVariableDeclaration: Rule; - NoSpaceBeforeOpenParenInFuncCall: Rule; - SpaceAfterFunctionInFuncDecl: Rule; - NoSpaceBeforeOpenParenInFuncDecl: Rule; - SpaceAfterVoidOperator: Rule; - NoSpaceBetweenReturnAndSemicolon: Rule; - SpaceBetweenStatements: Rule; - SpaceAfterTryFinally: Rule; - SpaceAfterGetSetInMember: Rule; - SpaceBeforeBinaryKeywordOperator: Rule; - SpaceAfterBinaryKeywordOperator: Rule; - NoSpaceAfterConstructor: Rule; - NoSpaceAfterModuleImport: Rule; - SpaceAfterCertainTypeScriptKeywords: Rule; - SpaceBeforeCertainTypeScriptKeywords: Rule; - SpaceAfterModuleName: Rule; - SpaceBeforeArrow: Rule; - SpaceAfterArrow: Rule; - NoSpaceAfterEllipsis: Rule; - NoSpaceAfterOptionalParameters: Rule; - NoSpaceBeforeOpenAngularBracket: Rule; - NoSpaceBetweenCloseParenAndAngularBracket: Rule; - NoSpaceAfterOpenAngularBracket: Rule; - NoSpaceBeforeCloseAngularBracket: Rule; - NoSpaceAfterCloseAngularBracket: Rule; - NoSpaceAfterTypeAssertion: Rule; - NoSpaceBetweenEmptyInterfaceBraceBrackets: Rule; - HighPriorityCommonRules: Rule[]; - LowPriorityCommonRules: Rule[]; - SpaceAfterComma: Rule; - NoSpaceAfterComma: Rule; - SpaceBeforeBinaryOperator: Rule; - SpaceAfterBinaryOperator: Rule; - NoSpaceBeforeBinaryOperator: Rule; - NoSpaceAfterBinaryOperator: Rule; - SpaceAfterKeywordInControl: Rule; - NoSpaceAfterKeywordInControl: Rule; - FunctionOpenBraceLeftTokenRange: Shared.TokenRange; - SpaceBeforeOpenBraceInFunction: Rule; - NewLineBeforeOpenBraceInFunction: Rule; - TypeScriptOpenBraceLeftTokenRange: Shared.TokenRange; - SpaceBeforeOpenBraceInTypeScriptDeclWithBlock: Rule; - NewLineBeforeOpenBraceInTypeScriptDeclWithBlock: Rule; - ControlOpenBraceLeftTokenRange: Shared.TokenRange; - SpaceBeforeOpenBraceInControl: Rule; - NewLineBeforeOpenBraceInControl: Rule; - SpaceAfterSemicolonInFor: Rule; - NoSpaceAfterSemicolonInFor: Rule; - SpaceAfterOpenParen: Rule; - SpaceBeforeCloseParen: Rule; - NoSpaceBetweenParens: Rule; - NoSpaceAfterOpenParen: Rule; - NoSpaceBeforeCloseParen: Rule; - SpaceAfterOpenBracket: Rule; - SpaceBeforeCloseBracket: Rule; - NoSpaceBetweenBrackets: Rule; - NoSpaceAfterOpenBracket: Rule; - NoSpaceBeforeCloseBracket: Rule; - SpaceAfterAnonymousFunctionKeyword: Rule; - NoSpaceAfterAnonymousFunctionKeyword: Rule; - SpaceBeforeAt: Rule; - NoSpaceAfterAt: Rule; - SpaceAfterDecorator: Rule; - NoSpaceBetweenFunctionKeywordAndStar: Rule; - SpaceAfterStarInGeneratorDeclaration: Rule; - NoSpaceBetweenYieldKeywordAndStar: Rule; - SpaceBetweenYieldOrYieldStarAndOperand: Rule; - SpaceBetweenAsyncAndOpenParen: Rule; - SpaceBetweenAsyncAndFunctionKeyword: Rule; - NoSpaceBetweenTagAndTemplateString: Rule; - NoSpaceAfterTemplateHeadAndMiddle: Rule; - SpaceAfterTemplateHeadAndMiddle: Rule; - NoSpaceBeforeTemplateMiddleAndTail: Rule; - SpaceBeforeTemplateMiddleAndTail: Rule; - NoSpaceAfterOpenBraceInJsxExpression: Rule; - SpaceAfterOpenBraceInJsxExpression: Rule; - NoSpaceBeforeCloseBraceInJsxExpression: Rule; - SpaceBeforeCloseBraceInJsxExpression: Rule; - SpaceBeforeJsxAttribute: Rule; - SpaceBeforeSlashInJsxOpeningElement: Rule; - NoSpaceBeforeGreaterThanTokenInJsxOpeningElement: Rule; - NoSpaceBeforeEqualInJsxAttribute: Rule; - NoSpaceAfterEqualInJsxAttribute: Rule; - constructor(); - static IsForContext(context: FormattingContext): boolean; - static IsNotForContext(context: FormattingContext): boolean; - static IsBinaryOpContext(context: FormattingContext): boolean; - static IsNotBinaryOpContext(context: FormattingContext): boolean; - static IsConditionalOperatorContext(context: FormattingContext): boolean; - static IsSameLineTokenOrBeforeMultilineBlockContext(context: FormattingContext): boolean; - static IsBeforeMultilineBlockContext(context: FormattingContext): boolean; - static IsMultilineBlockContext(context: FormattingContext): boolean; - static IsSingleLineBlockContext(context: FormattingContext): boolean; - static IsBlockContext(context: FormattingContext): boolean; - static IsBeforeBlockContext(context: FormattingContext): boolean; - static NodeIsBlockContext(node: Node): boolean; - static IsFunctionDeclContext(context: FormattingContext): boolean; - static IsFunctionDeclarationOrFunctionExpressionContext(context: FormattingContext): boolean; - static IsTypeScriptDeclWithBlockContext(context: FormattingContext): boolean; - static NodeIsTypeScriptDeclWithBlockContext(node: Node): boolean; - static IsAfterCodeBlockContext(context: FormattingContext): boolean; - static IsControlDeclContext(context: FormattingContext): boolean; - static IsObjectContext(context: FormattingContext): boolean; - static IsFunctionCallContext(context: FormattingContext): boolean; - static IsNewContext(context: FormattingContext): boolean; - static IsFunctionCallOrNewContext(context: FormattingContext): boolean; - static IsPreviousTokenNotComma(context: FormattingContext): boolean; - static IsNextTokenNotCloseBracket(context: FormattingContext): boolean; - static IsArrowFunctionContext(context: FormattingContext): boolean; - static IsNonJsxSameLineTokenContext(context: FormattingContext): boolean; - static IsNonJsxElementContext(context: FormattingContext): boolean; - static IsJsxExpressionContext(context: FormattingContext): boolean; - static IsNextTokenParentJsxAttribute(context: FormattingContext): boolean; - static IsJsxAttributeContext(context: FormattingContext): boolean; - static IsJsxSelfClosingElementContext(context: FormattingContext): boolean; - static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean; - static IsEndOfDecoratorContextOnSameLine(context: FormattingContext): boolean; - static NodeIsInDecoratorContext(node: Node): boolean; - static IsStartOfVariableDeclarationList(context: FormattingContext): boolean; - static IsNotFormatOnEnter(context: FormattingContext): boolean; - static IsModuleDeclContext(context: FormattingContext): boolean; - static IsObjectTypeContext(context: FormattingContext): boolean; - static IsTypeArgumentOrParameterOrAssertion(token: TextRangeWithKind, parent: Node): boolean; - static IsTypeArgumentOrParameterOrAssertionContext(context: FormattingContext): boolean; - static IsTypeAssertionContext(context: FormattingContext): boolean; - static IsVoidOpContext(context: FormattingContext): boolean; - static IsYieldOrYieldStarWithOperand(context: FormattingContext): boolean; + interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { + displayParts: SymbolDisplayPart[]; } -} -declare namespace ts.formatting { - class RulesMap { - map: RulesBucket[]; - mapRowLength: number; - constructor(); - static create(rules: Rule[]): RulesMap; - Initialize(rules: Rule[]): RulesBucket[]; - FillRules(rules: Rule[], rulesBucketConstructionStateList: RulesBucketConstructionState[]): void; - private GetRuleBucketIndex(row, column); - private FillRule(rule, rulesBucketConstructionStateList); - GetRule(context: FormattingContext): Rule; + interface ReferencedSymbol { + definition: ReferencedSymbolDefinitionInfo; + references: ReferenceEntry[]; } - enum RulesPosition { - IgnoreRulesSpecific = 0, - IgnoreRulesAny, - ContextRulesSpecific, - ContextRulesAny, - NoContextRulesSpecific, - NoContextRulesAny, + enum SymbolDisplayPartKind { + aliasName = 0, + className = 1, + enumName = 2, + fieldName = 3, + interfaceName = 4, + keyword = 5, + lineBreak = 6, + numericLiteral = 7, + stringLiteral = 8, + localName = 9, + methodName = 10, + moduleName = 11, + operator = 12, + parameterName = 13, + propertyName = 14, + punctuation = 15, + space = 16, + text = 17, + typeParameterName = 18, + enumMemberName = 19, + functionName = 20, + regularExpressionLiteral = 21, } - class RulesBucketConstructionState { - private rulesInsertionIndexBitmap; - constructor(); - GetInsertionIndex(maskPosition: RulesPosition): number; - IncreaseInsertionIndex(maskPosition: RulesPosition): void; + interface SymbolDisplayPart { + text: string; + kind: string; } - class RulesBucket { - private rules; - constructor(); - Rules(): Rule[]; - AddRule(rule: Rule, specificTokens: boolean, constructionState: RulesBucketConstructionState[], rulesBucketIndex: number): void; + interface QuickInfo { + kind: string; + kindModifiers: string; + textSpan: TextSpan; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; } -} -declare namespace ts.formatting { - namespace Shared { - interface ITokenAccess { - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - } - class TokenRangeAccess implements ITokenAccess { - private tokens; - constructor(from: SyntaxKind, to: SyntaxKind, except: SyntaxKind[]); - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - } - class TokenValuesAccess implements ITokenAccess { - private tokens; - constructor(tks: SyntaxKind[]); - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - } - class TokenSingleValueAccess implements ITokenAccess { - token: SyntaxKind; - constructor(token: SyntaxKind); - GetTokens(): SyntaxKind[]; - Contains(tokenValue: SyntaxKind): boolean; - } - class TokenAllAccess implements ITokenAccess { - GetTokens(): SyntaxKind[]; - Contains(tokenValue: SyntaxKind): boolean; - toString(): string; - } - class TokenRange { - tokenAccess: ITokenAccess; - constructor(tokenAccess: ITokenAccess); - static FromToken(token: SyntaxKind): TokenRange; - static FromTokens(tokens: SyntaxKind[]): TokenRange; - static FromRange(f: SyntaxKind, to: SyntaxKind, except?: SyntaxKind[]): TokenRange; - static AllTokens(): TokenRange; - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - toString(): string; - static Any: TokenRange; - static AnyIncludingMultilineComments: TokenRange; - static Keywords: TokenRange; - static BinaryOperators: TokenRange; - static BinaryKeywordOperators: TokenRange; - static UnaryPrefixOperators: TokenRange; - static UnaryPrefixExpressions: TokenRange; - static UnaryPreincrementExpressions: TokenRange; - static UnaryPostincrementExpressions: TokenRange; - static UnaryPredecrementExpressions: TokenRange; - static UnaryPostdecrementExpressions: TokenRange; - static Comments: TokenRange; - static TypeNames: TokenRange; - } + interface RenameInfo { + canRename: boolean; + localizedErrorMessage: string; + displayName: string; + fullDisplayName: string; + kind: string; + kindModifiers: string; + triggerSpan: TextSpan; } -} -declare namespace ts.formatting { - class RulesProvider { - private globalRules; - private options; - private activeRules; - private rulesMap; - constructor(); - getRuleName(rule: Rule): string; - getRuleByName(name: string): Rule; - getRulesMap(): RulesMap; - ensureUpToDate(options: ts.FormatCodeOptions): void; - private createActiveRules(options); + interface SignatureHelpParameter { + name: string; + documentation: SymbolDisplayPart[]; + displayParts: SymbolDisplayPart[]; + isOptional: boolean; } -} -declare namespace ts.formatting { - interface TextRangeWithKind extends TextRange { - kind: SyntaxKind; + /** + * 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?'. + */ + interface SignatureHelpItem { + isVariadic: boolean; + prefixDisplayParts: SymbolDisplayPart[]; + suffixDisplayParts: SymbolDisplayPart[]; + separatorDisplayParts: SymbolDisplayPart[]; + parameters: SignatureHelpParameter[]; + documentation: SymbolDisplayPart[]; } - interface TokenInfo { - leadingTrivia: TextRangeWithKind[]; - token: TextRangeWithKind; - trailingTrivia: TextRangeWithKind[]; + /** + * Represents a set of signature help items, and the preferred item that should be selected. + */ + interface SignatureHelpItems { + items: SignatureHelpItem[]; + applicableSpan: TextSpan; + selectedItemIndex: number; + argumentIndex: number; + argumentCount: number; } - function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; - function formatOnSemicolon(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; - function formatOnClosingCurly(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; - function formatDocument(sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; - function formatSelection(start: number, end: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; - function getIndentationString(indentation: number, options: FormatCodeOptions): string; -} -declare namespace ts.formatting { - namespace SmartIndenter { - function getIndentation(position: number, sourceFile: SourceFile, options: EditorOptions): number; - function getBaseIndentation(options: EditorOptions): number; - function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: FormatCodeOptions): number; - function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean; - function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorOptions): { - column: number; - character: number; - }; - function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorOptions): number; - function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind, indentByDefault: boolean): boolean; - function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind): boolean; + interface CompletionInfo { + isMemberCompletion: boolean; + isNewIdentifierLocation: boolean; + entries: CompletionEntry[]; } -} -declare namespace ts { - /** The version of the language service API */ - const servicesVersion: string; - 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; + interface CompletionEntry { + name: string; + kind: string; + kindModifiers: string; + sortText: string; } - interface Symbol { - getFlags(): SymbolFlags; - getName(): string; - getDeclarations(): Declaration[]; - getDocumentationComment(): SymbolDisplayPart[]; + interface CompletionEntryDetails { + name: string; + kind: string; + kindModifiers: string; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; } - 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; + 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; } - interface Signature { - getDeclaration(): SignatureDeclaration; - getTypeParameters(): Type[]; - getParameters(): Symbol[]; - getReturnType(): Type; - getDocumentationComment(): SymbolDisplayPart[]; + interface EmitOutput { + outputFiles: OutputFile[]; + emitSkipped: boolean; } - interface SourceFile { - version: string; - scriptSnapshot: IScriptSnapshot; - nameTable: Map; - getNamedDeclarations(): Map; - getLineAndCharacterOfPosition(pos: number): LineAndCharacter; - getLineStarts(): number[]; - getPositionOfLineAndCharacter(line: number, character: number): number; - update(newText: string, textChangeRange: TextChangeRange): SourceFile; + enum OutputFileType { + JavaScript = 0, + SourceMap = 1, + Declaration = 2, } - /** - * 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. - */ - 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; + interface OutputFile { + name: string; + writeByteOrderMark: boolean; + text: string; } - namespace ScriptSnapshot { - function fromString(text: string): IScriptSnapshot; + enum EndOfLineState { + None = 0, + InMultiLineCommentTrivia = 1, + InSingleQuoteStringLiteral = 2, + InDoubleQuoteStringLiteral = 3, + InTemplateHeadOrNoSubstitutionTemplate = 4, + InTemplateMiddleOrTail = 5, + InTemplateSubstitutionPosition = 6, } - interface PreProcessedFileInfo { - referencedFiles: FileReference[]; - typeReferenceDirectives: FileReference[]; - importedFiles: FileReference[]; - ambientExternalModules: string[]; - isLibFile: boolean; + enum TokenClass { + Punctuation = 0, + Keyword = 1, + Operator = 2, + Comment = 3, + Whitespace = 4, + Identifier = 5, + NumberLiteral = 6, + StringLiteral = 7, + RegExpLiteral = 8, } - interface HostCancellationToken { - isCancellationRequested(): boolean; + interface ClassificationResult { + finalLexState: EndOfLineState; + entries: ClassificationInfo[]; } - 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; - resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; - resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; - directoryExists?(directoryName: string): boolean; - getDirectories?(directoryName: string): string[]; + interface ClassificationInfo { + length: number; + classification: TokenClass; } - interface LanguageService { - cleanupSemanticCache(): void; - getSyntacticDiagnostics(fileName: string): Diagnostic[]; - getSemanticDiagnostics(fileName: string): Diagnostic[]; - getCompilerOptionsDiagnostics(): Diagnostic[]; - /** - * @deprecated Use getEncodedSyntacticClassifications instead. - */ - getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + interface Classifier { /** - * @deprecated Use getEncodedSemanticClassifications instead. + * 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. */ - getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; - 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; - getNonBoundSourceFile(fileName: string): SourceFile; - dispose(): void; - } - interface Classifications { - spans: number[]; - endOfLineState: EndOfLineState; - } - interface ClassifiedSpan { - textSpan: TextSpan; - classificationType: string; - } - interface NavigationBarItem { - text: string; - kind: string; - kindModifiers: string; - spans: TextSpan[]; - childItems: NavigationBarItem[]; - indent: number; - bolded: boolean; - grayed: boolean; - } - interface TodoCommentDescriptor { - text: string; - priority: number; + getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult; + getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications; } - interface TodoComment { - descriptor: TodoCommentDescriptor; - message: string; - position: number; + /** + * 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. + */ + 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; } - class TextChange { - span: TextSpan; - newText: string; + type DocumentRegistryBucketKey = string & { + __bucketKey: any; + }; + namespace ScriptElementKind { + const unknown: string; + const warning: string; + /** predefined type (void) or keyword (class) */ + const keyword: string; + /** top level script node */ + const scriptElement: string; + /** module foo {} */ + const moduleElement: string; + /** class X {} */ + const classElement: string; + /** var x = class X {} */ + const localClassElement: string; + /** interface Y {} */ + const interfaceElement: string; + /** type T = ... */ + const typeElement: string; + /** enum E */ + const enumElement: string; + const enumMemberElement: string; + /** + * Inside module and script only + * const v = .. + */ + const variableElement: string; + /** Inside function */ + const localVariableElement: string; + /** + * Inside module and script only + * function f() { } + */ + const functionElement: string; + /** Inside function */ + const localFunctionElement: string; + /** class X { [public|private]* foo() {} } */ + const memberFunctionElement: string; + /** class X { [public|private]* [get|set] foo:number; } */ + const memberGetAccessorElement: string; + const memberSetAccessorElement: string; + /** + * class X { [public|private]* foo:number; } + * interface Y { foo:number; } + */ + const memberVariableElement: string; + /** class X { constructor() { } } */ + const constructorImplementationElement: string; + /** interface Y { ():number; } */ + const callSignatureElement: string; + /** interface Y { []:number; } */ + const indexSignatureElement: string; + /** interface Y { new():Y; } */ + const constructSignatureElement: string; + /** function foo(*Y*: string) */ + const parameterElement: string; + const typeParameterElement: string; + const primitiveType: string; + const label: string; + const alias: string; + const constElement: string; + const letElement: string; } - interface TextInsertion { - newText: string; - /** The position in newText the caret should point to after the insertion. */ - caretOffset: number; + namespace ScriptElementKindModifier { + const none: string; + const publicMemberModifier: string; + const privateMemberModifier: string; + const protectedMemberModifier: string; + const exportedModifier: string; + const ambientModifier: string; + const staticModifier: string; + const abstractModifier: string; } - interface RenameLocation { - textSpan: TextSpan; - fileName: string; + class ClassificationTypeNames { + static comment: string; + static identifier: string; + static keyword: string; + static numericLiteral: string; + static operator: string; + static stringLiteral: string; + static whiteSpace: string; + static text: string; + static punctuation: string; + static className: string; + static enumName: string; + static interfaceName: string; + static moduleName: string; + static typeParameterName: string; + static typeAliasName: string; + static parameterName: string; + static docCommentTagName: string; + static jsxOpenTagName: string; + static jsxCloseTagName: string; + static jsxSelfClosingTagName: string; + static jsxAttribute: string; + static jsxText: string; + static jsxAttributeStringLiteralValue: string; } - interface ReferenceEntry { - textSpan: TextSpan; - fileName: string; - isWriteAccess: boolean; - isDefinition: boolean; + 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, } - interface DocumentHighlights { - fileName: string; - highlightSpans: HighlightSpan[]; +} +declare namespace ts { + interface ListItemInfo { + listItemIndex: number; + list: Node; } - namespace HighlightSpanKind { - const none: string; - const definition: string; - const reference: string; - const writtenReference: string; + function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number; + function rangeContainsRange(r1: TextRange, r2: TextRange): boolean; + function startEndContainsRange(start: number, end: number, range: TextRange): boolean; + function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean; + function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean; + function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean; + function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean; + function isCompletedNode(n: Node, sourceFile: SourceFile): boolean; + function findListItemInfo(node: Node): ListItemInfo; + function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean; + function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node; + function findContainingList(node: Node): Node; + function getTouchingWord(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; + function getTouchingPropertyName(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; + /** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */ + function getTouchingToken(sourceFile: SourceFile, position: number, includeItemAtEndPosition?: (n: Node) => boolean, includeJsDocComment?: boolean): Node; + /** Returns a token if position is in [start-of-leading-trivia, end) */ + function getTokenAtPosition(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; + /** + * The token on the left of the position is the token that strictly includes the position + * or sits to the left of the cursor if it is on a boundary. For example + * + * fo|o -> will return foo + * foo |bar -> will return foo + * + */ + function findTokenOnLeftOfPosition(file: SourceFile, position: number): Node; + function findNextToken(previousToken: Node, parent: Node): Node; + function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node): Node; + function isInString(sourceFile: SourceFile, position: number): boolean; + function isInComment(sourceFile: SourceFile, position: number): boolean; + /** + * returns true if the position is in between the open and close elements of an JSX expression. + */ + function isInsideJsxElementOrAttribute(sourceFile: SourceFile, position: number): boolean; + function isInTemplateString(sourceFile: SourceFile, position: number): boolean; + /** + * Returns true if the cursor at position in sourceFile is within a comment that additionally + * satisfies predicate, and false otherwise. + */ + function isInCommentHelper(sourceFile: SourceFile, position: number, predicate?: (c: CommentRange) => boolean): boolean; + function hasDocComment(sourceFile: SourceFile, position: number): boolean; + /** + * Get the corresponding JSDocTag node if the position is in a jsDoc comment + */ + function getJsDocTagAtPosition(sourceFile: SourceFile, position: number): JSDocTag; + function getNodeModifiers(node: Node): string; + function getTypeArgumentOrTypeParameterList(node: Node): NodeArray; + function isToken(n: Node): boolean; + function isWord(kind: SyntaxKind): boolean; + function isComment(kind: SyntaxKind): boolean; + function isStringOrRegularExpressionOrTemplateLiteral(kind: SyntaxKind): boolean; + function isPunctuation(kind: SyntaxKind): boolean; + function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean; + function isAccessibilityModifier(kind: SyntaxKind): boolean; + function compareDataObjects(dst: any, src: any): boolean; + function isArrayLiteralOrObjectLiteralDestructuringPattern(node: Node): boolean; +} +declare namespace ts { + function isFirstDeclarationOfSymbolParameter(symbol: Symbol): boolean; + function symbolPart(text: string, symbol: Symbol): SymbolDisplayPart; + function displayPart(text: string, kind: SymbolDisplayPartKind, symbol?: Symbol): SymbolDisplayPart; + function spacePart(): SymbolDisplayPart; + function keywordPart(kind: SyntaxKind): SymbolDisplayPart; + function punctuationPart(kind: SyntaxKind): SymbolDisplayPart; + function operatorPart(kind: SyntaxKind): SymbolDisplayPart; + function textOrKeywordPart(text: string): SymbolDisplayPart; + function textPart(text: string): SymbolDisplayPart; + /** + * The default is CRLF. + */ + function getNewLineOrDefaultFromHost(host: LanguageServiceHost | LanguageServiceShimHost): string; + function lineBreakPart(): SymbolDisplayPart; + function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[]; + function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; + function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): SymbolDisplayPart[]; + function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; + function getDeclaredName(typeChecker: TypeChecker, symbol: Symbol, location: Node): string; + function isImportOrExportSpecifierName(location: Node): boolean; + /** + * Strip off existed single quotes or double quotes from a given string + * + * @return non-quoted string + */ + function stripQuotes(name: string): string; + function scriptKindIs(fileName: string, host: LanguageServiceHost, ...scriptKinds: ScriptKind[]): boolean; + function getScriptKind(fileName: string, host?: LanguageServiceHost): ScriptKind; + function parseAndReEmitConfigJSONFile(content: string): { + configJsonObject: any; + diagnostics: Diagnostic[]; + }; +} +declare namespace ts.JsTyping { + interface TypingResolutionHost { + directoryExists: (path: string) => boolean; + fileExists: (fileName: string) => boolean; + readFile: (path: string, encoding?: string) => string; + readDirectory: (rootDir: string, extensions: string[], excludes: string[], includes: string[], depth?: number) => string[]; } - interface HighlightSpan { - fileName?: string; - textSpan: TextSpan; - kind: string; + /** + * @param host is the object providing I/O related operations. + * @param fileNames are the file names that belong to the same project + * @param projectRootPath is the path to the project root directory + * @param safeListPath is the path used to retrieve the safe list + * @param packageNameToTypingLocation is the map of package names to their cached typing locations + * @param typingOptions are used to customize the typing inference process + * @param compilerOptions are used as a source for typing inference + */ + function discoverTypings(host: TypingResolutionHost, fileNames: string[], projectRootPath: Path, safeListPath: Path, packageNameToTypingLocation: Map, typingOptions: TypingOptions, compilerOptions: CompilerOptions): { + cachedTypingPaths: string[]; + newTypingNames: string[]; + filesToWatch: string[]; + }; +} +declare namespace ts.formatting { + interface FormattingScanner { + advance(): void; + isOnToken(): boolean; + readTokenInfo(n: Node): TokenInfo; + getCurrentLeadingTrivia(): TextRangeWithKind[]; + lastTrailingTriviaWasNewLine(): boolean; + skipToEndOf(node: Node): void; + close(): void; } - interface NavigateToItem { - name: string; - kind: string; - kindModifiers: string; - matchKind: string; - isCaseSensitive: boolean; - fileName: string; - textSpan: TextSpan; - containerName: string; - containerKind: string; + function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner; +} +declare namespace ts.formatting { + class FormattingContext { + sourceFile: SourceFile; + formattingRequestKind: FormattingRequestKind; + currentTokenSpan: TextRangeWithKind; + nextTokenSpan: TextRangeWithKind; + contextNode: Node; + currentTokenParent: Node; + nextTokenParent: Node; + private contextNodeAllOnSameLine; + private nextNodeAllOnSameLine; + private tokensAreOnSameLine; + private contextNodeBlockIsOnOneLine; + private nextNodeBlockIsOnOneLine; + constructor(sourceFile: SourceFile, formattingRequestKind: FormattingRequestKind); + updateContext(currentRange: TextRangeWithKind, currentTokenParent: Node, nextRange: TextRangeWithKind, nextTokenParent: Node, commonParent: Node): void; + ContextNodeAllOnSameLine(): boolean; + NextNodeAllOnSameLine(): boolean; + TokensAreOnSameLine(): boolean; + ContextNodeBlockIsOnOneLine(): boolean; + NextNodeBlockIsOnOneLine(): boolean; + private NodeIsOnOneLine(node); + private BlockIsOnOneLine(node); } - interface EditorOptions { - BaseIndentSize?: number; - IndentSize: number; - TabSize: number; - NewLineCharacter: string; - ConvertTabsToSpaces: boolean; - IndentStyle: IndentStyle; +} +declare namespace ts.formatting { + enum FormattingRequestKind { + FormatDocument = 0, + FormatSelection = 1, + FormatOnEnter = 2, + FormatOnSemicolon = 3, + FormatOnClosingCurlyBrace = 4, } - enum IndentStyle { - None = 0, - Block = 1, - Smart = 2, +} +declare namespace ts.formatting { + class Rule { + Descriptor: RuleDescriptor; + Operation: RuleOperation; + Flag: RuleFlags; + constructor(Descriptor: RuleDescriptor, Operation: RuleOperation, Flag?: RuleFlags); + toString(): string; } - 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; +} +declare namespace ts.formatting { + enum RuleAction { + Ignore = 1, + Space = 2, + NewLine = 4, + Delete = 8, } - interface DefinitionInfo { - fileName: string; - textSpan: TextSpan; - kind: string; - name: string; - containerKind: string; - containerName: string; +} +declare namespace ts.formatting { + class RuleDescriptor { + LeftTokenRange: Shared.TokenRange; + RightTokenRange: Shared.TokenRange; + constructor(LeftTokenRange: Shared.TokenRange, RightTokenRange: Shared.TokenRange); + toString(): string; + static create1(left: SyntaxKind, right: SyntaxKind): RuleDescriptor; + static create2(left: Shared.TokenRange, right: SyntaxKind): RuleDescriptor; + static create3(left: SyntaxKind, right: Shared.TokenRange): RuleDescriptor; + static create4(left: Shared.TokenRange, right: Shared.TokenRange): RuleDescriptor; } - interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { - displayParts: SymbolDisplayPart[]; +} +declare namespace ts.formatting { + enum RuleFlags { + None = 0, + CanDeleteNewLines = 1, } - interface ReferencedSymbol { - definition: ReferencedSymbolDefinitionInfo; - references: ReferenceEntry[]; +} +declare namespace ts.formatting { + class RuleOperation { + Context: RuleOperationContext; + Action: RuleAction; + constructor(Context: RuleOperationContext, Action: RuleAction); + toString(): string; + static create1(action: RuleAction): RuleOperation; + static create2(context: RuleOperationContext, action: RuleAction): RuleOperation; } - enum SymbolDisplayPartKind { - aliasName = 0, - className = 1, - enumName = 2, - fieldName = 3, - interfaceName = 4, - keyword = 5, - lineBreak = 6, - numericLiteral = 7, - stringLiteral = 8, - localName = 9, - methodName = 10, - moduleName = 11, - operator = 12, - parameterName = 13, - propertyName = 14, - punctuation = 15, - space = 16, - text = 17, - typeParameterName = 18, - enumMemberName = 19, - functionName = 20, - regularExpressionLiteral = 21, - } - interface SymbolDisplayPart { - text: string; - kind: string; - } - interface QuickInfo { - kind: string; - kindModifiers: string; - textSpan: TextSpan; - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - } - interface RenameInfo { - canRename: boolean; - localizedErrorMessage: string; - displayName: string; - fullDisplayName: string; - kind: string; - kindModifiers: string; - triggerSpan: TextSpan; - } - 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?'. - */ - 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. - */ - interface SignatureHelpItems { - items: SignatureHelpItem[]; - applicableSpan: TextSpan; - selectedItemIndex: number; - argumentIndex: number; - argumentCount: number; - } - interface CompletionInfo { - isMemberCompletion: boolean; - isNewIdentifierLocation: boolean; - entries: CompletionEntry[]; - } - interface CompletionEntry { - name: string; - kind: string; - kindModifiers: string; - sortText: string; - } - interface CompletionEntryDetails { - name: string; - kind: string; - kindModifiers: string; - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - } - 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; - } - interface EmitOutput { - outputFiles: OutputFile[]; - emitSkipped: boolean; - } - enum OutputFileType { - JavaScript = 0, - SourceMap = 1, - Declaration = 2, - } - interface OutputFile { - name: string; - writeByteOrderMark: boolean; - text: string; - } - enum EndOfLineState { - None = 0, - InMultiLineCommentTrivia = 1, - InSingleQuoteStringLiteral = 2, - InDoubleQuoteStringLiteral = 3, - InTemplateHeadOrNoSubstitutionTemplate = 4, - InTemplateMiddleOrTail = 5, - InTemplateSubstitutionPosition = 6, - } - enum TokenClass { - Punctuation = 0, - Keyword = 1, - Operator = 2, - Comment = 3, - Whitespace = 4, - Identifier = 5, - NumberLiteral = 6, - StringLiteral = 7, - RegExpLiteral = 8, - } - interface ClassificationResult { - finalLexState: EndOfLineState; - entries: ClassificationInfo[]; - } - interface ClassificationInfo { - length: number; - classification: TokenClass; - } - 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; +} +declare namespace ts.formatting { + class RuleOperationContext { + private customContextChecks; + constructor(...funcs: { + (context: FormattingContext): boolean; + }[]); + static Any: RuleOperationContext; + IsAny(): boolean; + InContext(context: FormattingContext): boolean; } - /** - * 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. - */ - 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; +} +declare namespace ts.formatting { + class Rules { + getRuleName(rule: Rule): string; + [name: string]: any; + IgnoreBeforeComment: Rule; + IgnoreAfterLineComment: Rule; + NoSpaceBeforeSemicolon: Rule; + NoSpaceBeforeColon: Rule; + NoSpaceBeforeQuestionMark: Rule; + SpaceAfterColon: Rule; + SpaceAfterQuestionMarkInConditionalOperator: Rule; + NoSpaceAfterQuestionMark: Rule; + SpaceAfterSemicolon: Rule; + SpaceAfterCloseBrace: Rule; + SpaceBetweenCloseBraceAndElse: Rule; + SpaceBetweenCloseBraceAndWhile: Rule; + NoSpaceAfterCloseBrace: Rule; + NoSpaceBeforeDot: Rule; + NoSpaceAfterDot: Rule; + NoSpaceBeforeOpenBracket: Rule; + NoSpaceAfterCloseBracket: Rule; + SpaceAfterOpenBrace: Rule; + SpaceBeforeCloseBrace: Rule; + NoSpaceBetweenEmptyBraceBrackets: Rule; + NewLineAfterOpenBraceInBlockContext: Rule; + NewLineBeforeCloseBraceInBlockContext: Rule; + NoSpaceAfterUnaryPrefixOperator: Rule; + NoSpaceAfterUnaryPreincrementOperator: Rule; + NoSpaceAfterUnaryPredecrementOperator: Rule; + NoSpaceBeforeUnaryPostincrementOperator: Rule; + NoSpaceBeforeUnaryPostdecrementOperator: Rule; + SpaceAfterPostincrementWhenFollowedByAdd: Rule; + SpaceAfterAddWhenFollowedByUnaryPlus: Rule; + SpaceAfterAddWhenFollowedByPreincrement: Rule; + SpaceAfterPostdecrementWhenFollowedBySubtract: Rule; + SpaceAfterSubtractWhenFollowedByUnaryMinus: Rule; + SpaceAfterSubtractWhenFollowedByPredecrement: Rule; + NoSpaceBeforeComma: Rule; + SpaceAfterCertainKeywords: Rule; + SpaceAfterLetConstInVariableDeclaration: Rule; + NoSpaceBeforeOpenParenInFuncCall: Rule; + SpaceAfterFunctionInFuncDecl: Rule; + NoSpaceBeforeOpenParenInFuncDecl: Rule; + SpaceAfterVoidOperator: Rule; + NoSpaceBetweenReturnAndSemicolon: Rule; + SpaceBetweenStatements: Rule; + SpaceAfterTryFinally: Rule; + SpaceAfterGetSetInMember: Rule; + SpaceBeforeBinaryKeywordOperator: Rule; + SpaceAfterBinaryKeywordOperator: Rule; + NoSpaceAfterConstructor: Rule; + NoSpaceAfterModuleImport: Rule; + SpaceAfterCertainTypeScriptKeywords: Rule; + SpaceBeforeCertainTypeScriptKeywords: Rule; + SpaceAfterModuleName: Rule; + SpaceBeforeArrow: Rule; + SpaceAfterArrow: Rule; + NoSpaceAfterEllipsis: Rule; + NoSpaceAfterOptionalParameters: Rule; + NoSpaceBeforeOpenAngularBracket: Rule; + NoSpaceBetweenCloseParenAndAngularBracket: Rule; + NoSpaceAfterOpenAngularBracket: Rule; + NoSpaceBeforeCloseAngularBracket: Rule; + NoSpaceAfterCloseAngularBracket: Rule; + NoSpaceAfterTypeAssertion: Rule; + NoSpaceBetweenEmptyInterfaceBraceBrackets: Rule; + HighPriorityCommonRules: Rule[]; + LowPriorityCommonRules: Rule[]; + SpaceAfterComma: Rule; + NoSpaceAfterComma: Rule; + SpaceBeforeBinaryOperator: Rule; + SpaceAfterBinaryOperator: Rule; + NoSpaceBeforeBinaryOperator: Rule; + NoSpaceAfterBinaryOperator: Rule; + SpaceAfterKeywordInControl: Rule; + NoSpaceAfterKeywordInControl: Rule; + FunctionOpenBraceLeftTokenRange: Shared.TokenRange; + SpaceBeforeOpenBraceInFunction: Rule; + NewLineBeforeOpenBraceInFunction: Rule; + TypeScriptOpenBraceLeftTokenRange: Shared.TokenRange; + SpaceBeforeOpenBraceInTypeScriptDeclWithBlock: Rule; + NewLineBeforeOpenBraceInTypeScriptDeclWithBlock: Rule; + ControlOpenBraceLeftTokenRange: Shared.TokenRange; + SpaceBeforeOpenBraceInControl: Rule; + NewLineBeforeOpenBraceInControl: Rule; + SpaceAfterSemicolonInFor: Rule; + NoSpaceAfterSemicolonInFor: Rule; + SpaceAfterOpenParen: Rule; + SpaceBeforeCloseParen: Rule; + NoSpaceBetweenParens: Rule; + NoSpaceAfterOpenParen: Rule; + NoSpaceBeforeCloseParen: Rule; + SpaceAfterOpenBracket: Rule; + SpaceBeforeCloseBracket: Rule; + NoSpaceBetweenBrackets: Rule; + NoSpaceAfterOpenBracket: Rule; + NoSpaceBeforeCloseBracket: Rule; + SpaceAfterAnonymousFunctionKeyword: Rule; + NoSpaceAfterAnonymousFunctionKeyword: Rule; + SpaceBeforeAt: Rule; + NoSpaceAfterAt: Rule; + SpaceAfterDecorator: Rule; + NoSpaceBetweenFunctionKeywordAndStar: Rule; + SpaceAfterStarInGeneratorDeclaration: Rule; + NoSpaceBetweenYieldKeywordAndStar: Rule; + SpaceBetweenYieldOrYieldStarAndOperand: Rule; + SpaceBetweenAsyncAndOpenParen: Rule; + SpaceBetweenAsyncAndFunctionKeyword: Rule; + NoSpaceBetweenTagAndTemplateString: Rule; + NoSpaceAfterTemplateHeadAndMiddle: Rule; + SpaceAfterTemplateHeadAndMiddle: Rule; + NoSpaceBeforeTemplateMiddleAndTail: Rule; + SpaceBeforeTemplateMiddleAndTail: Rule; + NoSpaceAfterOpenBraceInJsxExpression: Rule; + SpaceAfterOpenBraceInJsxExpression: Rule; + NoSpaceBeforeCloseBraceInJsxExpression: Rule; + SpaceBeforeCloseBraceInJsxExpression: Rule; + SpaceBeforeJsxAttribute: Rule; + SpaceBeforeSlashInJsxOpeningElement: Rule; + NoSpaceBeforeGreaterThanTokenInJsxOpeningElement: Rule; + NoSpaceBeforeEqualInJsxAttribute: Rule; + NoSpaceAfterEqualInJsxAttribute: Rule; + constructor(); + static IsForContext(context: FormattingContext): boolean; + static IsNotForContext(context: FormattingContext): boolean; + static IsBinaryOpContext(context: FormattingContext): boolean; + static IsNotBinaryOpContext(context: FormattingContext): boolean; + static IsConditionalOperatorContext(context: FormattingContext): boolean; + static IsSameLineTokenOrBeforeMultilineBlockContext(context: FormattingContext): boolean; + static IsBeforeMultilineBlockContext(context: FormattingContext): boolean; + static IsMultilineBlockContext(context: FormattingContext): boolean; + static IsSingleLineBlockContext(context: FormattingContext): boolean; + static IsBlockContext(context: FormattingContext): boolean; + static IsBeforeBlockContext(context: FormattingContext): boolean; + static NodeIsBlockContext(node: Node): boolean; + static IsFunctionDeclContext(context: FormattingContext): boolean; + static IsFunctionDeclarationOrFunctionExpressionContext(context: FormattingContext): boolean; + static IsTypeScriptDeclWithBlockContext(context: FormattingContext): boolean; + static NodeIsTypeScriptDeclWithBlockContext(node: Node): boolean; + static IsAfterCodeBlockContext(context: FormattingContext): boolean; + static IsControlDeclContext(context: FormattingContext): boolean; + static IsObjectContext(context: FormattingContext): boolean; + static IsFunctionCallContext(context: FormattingContext): boolean; + static IsNewContext(context: FormattingContext): boolean; + static IsFunctionCallOrNewContext(context: FormattingContext): boolean; + static IsPreviousTokenNotComma(context: FormattingContext): boolean; + static IsNextTokenNotCloseBracket(context: FormattingContext): boolean; + static IsArrowFunctionContext(context: FormattingContext): boolean; + static IsNonJsxSameLineTokenContext(context: FormattingContext): boolean; + static IsNonJsxElementContext(context: FormattingContext): boolean; + static IsJsxExpressionContext(context: FormattingContext): boolean; + static IsNextTokenParentJsxAttribute(context: FormattingContext): boolean; + static IsJsxAttributeContext(context: FormattingContext): boolean; + static IsJsxSelfClosingElementContext(context: FormattingContext): boolean; + static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean; + static IsEndOfDecoratorContextOnSameLine(context: FormattingContext): boolean; + static NodeIsInDecoratorContext(node: Node): boolean; + static IsStartOfVariableDeclarationList(context: FormattingContext): boolean; + static IsNotFormatOnEnter(context: FormattingContext): boolean; + static IsModuleDeclContext(context: FormattingContext): boolean; + static IsObjectTypeContext(context: FormattingContext): boolean; + static IsTypeArgumentOrParameterOrAssertion(token: TextRangeWithKind, parent: Node): boolean; + static IsTypeArgumentOrParameterOrAssertionContext(context: FormattingContext): boolean; + static IsTypeAssertionContext(context: FormattingContext): boolean; + static IsVoidOpContext(context: FormattingContext): boolean; + static IsYieldOrYieldStarWithOperand(context: FormattingContext): boolean; } - type DocumentRegistryBucketKey = string & { - __bucketKey: any; - }; - namespace ScriptElementKind { - const unknown: string; - const warning: string; - /** predefined type (void) or keyword (class) */ - const keyword: string; - /** top level script node */ - const scriptElement: string; - /** module foo {} */ - const moduleElement: string; - /** class X {} */ - const classElement: string; - /** var x = class X {} */ - const localClassElement: string; - /** interface Y {} */ - const interfaceElement: string; - /** type T = ... */ - const typeElement: string; - /** enum E */ - const enumElement: string; - const enumMemberElement: string; - /** - * Inside module and script only - * const v = .. - */ - const variableElement: string; - /** Inside function */ - const localVariableElement: string; - /** - * Inside module and script only - * function f() { } - */ - const functionElement: string; - /** Inside function */ - const localFunctionElement: string; - /** class X { [public|private]* foo() {} } */ - const memberFunctionElement: string; - /** class X { [public|private]* [get|set] foo:number; } */ - const memberGetAccessorElement: string; - const memberSetAccessorElement: string; - /** - * class X { [public|private]* foo:number; } - * interface Y { foo:number; } - */ - const memberVariableElement: string; - /** class X { constructor() { } } */ - const constructorImplementationElement: string; - /** interface Y { ():number; } */ - const callSignatureElement: string; - /** interface Y { []:number; } */ - const indexSignatureElement: string; - /** interface Y { new():Y; } */ - const constructSignatureElement: string; - /** function foo(*Y*: string) */ - const parameterElement: string; - const typeParameterElement: string; - const primitiveType: string; - const label: string; - const alias: string; - const constElement: string; - const letElement: string; +} +declare namespace ts.formatting { + class RulesMap { + map: RulesBucket[]; + mapRowLength: number; + constructor(); + static create(rules: Rule[]): RulesMap; + Initialize(rules: Rule[]): RulesBucket[]; + FillRules(rules: Rule[], rulesBucketConstructionStateList: RulesBucketConstructionState[]): void; + private GetRuleBucketIndex(row, column); + private FillRule(rule, rulesBucketConstructionStateList); + GetRule(context: FormattingContext): Rule; } - namespace ScriptElementKindModifier { - const none: string; - const publicMemberModifier: string; - const privateMemberModifier: string; - const protectedMemberModifier: string; - const exportedModifier: string; - const ambientModifier: string; - const staticModifier: string; - const abstractModifier: string; + enum RulesPosition { + IgnoreRulesSpecific = 0, + IgnoreRulesAny, + ContextRulesSpecific, + ContextRulesAny, + NoContextRulesSpecific, + NoContextRulesAny, } - class ClassificationTypeNames { - static comment: string; - static identifier: string; - static keyword: string; - static numericLiteral: string; - static operator: string; - static stringLiteral: string; - static whiteSpace: string; - static text: string; - static punctuation: string; - static className: string; - static enumName: string; - static interfaceName: string; - static moduleName: string; - static typeParameterName: string; - static typeAliasName: string; - static parameterName: string; - static docCommentTagName: string; - static jsxOpenTagName: string; - static jsxCloseTagName: string; - static jsxSelfClosingTagName: string; - static jsxAttribute: string; - static jsxText: string; - static jsxAttributeStringLiteralValue: string; + class RulesBucketConstructionState { + private rulesInsertionIndexBitmap; + constructor(); + GetInsertionIndex(maskPosition: RulesPosition): number; + IncreaseInsertionIndex(maskPosition: RulesPosition): void; } - 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, + class RulesBucket { + private rules; + constructor(); + Rules(): Rule[]; + AddRule(rule: Rule, specificTokens: boolean, constructionState: RulesBucketConstructionState[], rulesBucketIndex: number): void; + } +} +declare namespace ts.formatting { + namespace Shared { + interface ITokenAccess { + GetTokens(): SyntaxKind[]; + Contains(token: SyntaxKind): boolean; + } + class TokenRangeAccess implements ITokenAccess { + private tokens; + constructor(from: SyntaxKind, to: SyntaxKind, except: SyntaxKind[]); + GetTokens(): SyntaxKind[]; + Contains(token: SyntaxKind): boolean; + } + class TokenValuesAccess implements ITokenAccess { + private tokens; + constructor(tks: SyntaxKind[]); + GetTokens(): SyntaxKind[]; + Contains(token: SyntaxKind): boolean; + } + class TokenSingleValueAccess implements ITokenAccess { + token: SyntaxKind; + constructor(token: SyntaxKind); + GetTokens(): SyntaxKind[]; + Contains(tokenValue: SyntaxKind): boolean; + } + class TokenAllAccess implements ITokenAccess { + GetTokens(): SyntaxKind[]; + Contains(tokenValue: SyntaxKind): boolean; + toString(): string; + } + class TokenRange { + tokenAccess: ITokenAccess; + constructor(tokenAccess: ITokenAccess); + static FromToken(token: SyntaxKind): TokenRange; + static FromTokens(tokens: SyntaxKind[]): TokenRange; + static FromRange(f: SyntaxKind, to: SyntaxKind, except?: SyntaxKind[]): TokenRange; + static AllTokens(): TokenRange; + GetTokens(): SyntaxKind[]; + Contains(token: SyntaxKind): boolean; + toString(): string; + static Any: TokenRange; + static AnyIncludingMultilineComments: TokenRange; + static Keywords: TokenRange; + static BinaryOperators: TokenRange; + static BinaryKeywordOperators: TokenRange; + static UnaryPrefixOperators: TokenRange; + static UnaryPrefixExpressions: TokenRange; + static UnaryPreincrementExpressions: TokenRange; + static UnaryPostincrementExpressions: TokenRange; + static UnaryPredecrementExpressions: TokenRange; + static UnaryPostdecrementExpressions: TokenRange; + static Comments: TokenRange; + static TypeNames: TokenRange; + } + } +} +declare namespace ts.formatting { + class RulesProvider { + private globalRules; + private options; + private activeRules; + private rulesMap; + constructor(); + getRuleName(rule: Rule): string; + getRuleByName(name: string): Rule; + getRulesMap(): RulesMap; + ensureUpToDate(options: ts.FormatCodeOptions): void; + private createActiveRules(options); + } +} +declare namespace ts.formatting { + interface TextRangeWithKind extends TextRange { + kind: SyntaxKind; + } + interface TokenInfo { + leadingTrivia: TextRangeWithKind[]; + token: TextRangeWithKind; + trailingTrivia: TextRangeWithKind[]; + } + function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; + function formatOnSemicolon(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; + function formatOnClosingCurly(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; + function formatDocument(sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; + function formatSelection(start: number, end: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; + function getIndentationString(indentation: number, options: FormatCodeOptions): string; +} +declare namespace ts.formatting { + namespace SmartIndenter { + function getIndentation(position: number, sourceFile: SourceFile, options: EditorOptions): number; + function getBaseIndentation(options: EditorOptions): number; + function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: FormatCodeOptions): number; + function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean; + function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorOptions): { + column: number; + character: number; + }; + function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorOptions): number; + function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind, indentByDefault: boolean): boolean; + function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind): boolean; } +} +declare namespace ts { + /** The version of the language service API */ + const servicesVersion: string; interface DisplayPartsSymbolWriter extends SymbolWriter { displayParts(): SymbolDisplayPart[]; } diff --git a/bin/ntypescript.js b/bin/ntypescript.js index 7bd4d6b..5e59004 100644 --- a/bin/ntypescript.js +++ b/bin/ntypescript.js @@ -1548,6 +1548,21 @@ var ts; return result; } ts.extend = extend; + /** + * Adds the value to an array of values associated with the key, and returns the array. + * Creates the array if it does not already exist. + */ + function multiMapAdd(map, key, value) { + var values = map[key]; + if (values) { + values.push(value); + return values; + } + else { + return map[key] = [value]; + } + } + ts.multiMapAdd = multiMapAdd; /** * Tests whether a value is an array. */ @@ -2601,7 +2616,7 @@ var ts; return; } function addFileWatcherCallback(filePath, callback) { - (fileWatcherCallbacks[filePath] || (fileWatcherCallbacks[filePath] = [])).push(callback); + ts.multiMapAdd(fileWatcherCallbacks, filePath, callback); } function addFile(fileName, callback) { addFileWatcherCallback(fileName, callback); @@ -43815,7 +43830,7 @@ var ts; for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; var name_32 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_32] || (exportSpecifiers[name_32] = [])).push(specifier); + ts.multiMapAdd(exportSpecifiers, name_32, specifier); } } break; @@ -45194,7 +45209,6 @@ var ts; /** The version of the TypeScript compiler release */ ts.version = "2.1.0"; var emptyArray = []; - var defaultTypeRoots = ["node_modules/@types"]; function findConfigFile(searchPath, fileExists) { while (true) { var fileName = ts.combinePaths(searchPath, "tsconfig.json"); @@ -45338,11 +45352,31 @@ var ts; else if (host.getCurrentDirectory) { currentDirectory = host.getCurrentDirectory(); } - if (!currentDirectory) { - return undefined; + return currentDirectory && getDefaultTypeRoots(currentDirectory, host); + } + /** + * Returns the path to every node_modules/@types directory from some ancestor directory. + * Returns undefined if there are none. + */ + function getDefaultTypeRoots(currentDirectory, host) { + if (!host.directoryExists) { + return [ts.combinePaths(currentDirectory, "node_modules")]; + } + var typeRoots; + while (true) { + var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); + if (host.directoryExists(atTypes)) { + (typeRoots || (typeRoots = [])).push(atTypes); + } + var parent_15 = ts.getDirectoryPath(currentDirectory); + if (parent_15 === currentDirectory) { + break; + } + currentDirectory = parent_15; } - return ts.map(defaultTypeRoots, function (d) { return ts.combinePaths(currentDirectory, d); }); + return typeRoots; } + var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups @@ -47966,28 +48000,28 @@ var ts; switch (n.kind) { case 199 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_15 = n.parent; + var parent_16 = n.parent; var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. - if (parent_15.kind === 204 /* DoStatement */ || - parent_15.kind === 207 /* ForInStatement */ || - parent_15.kind === 208 /* ForOfStatement */ || - parent_15.kind === 206 /* ForStatement */ || - parent_15.kind === 203 /* IfStatement */ || - parent_15.kind === 205 /* WhileStatement */ || - parent_15.kind === 212 /* WithStatement */ || - parent_15.kind === 252 /* CatchClause */) { - addOutliningSpan(parent_15, openBrace, closeBrace, autoCollapse(n)); + if (parent_16.kind === 204 /* DoStatement */ || + parent_16.kind === 207 /* ForInStatement */ || + parent_16.kind === 208 /* ForOfStatement */ || + parent_16.kind === 206 /* ForStatement */ || + parent_16.kind === 203 /* IfStatement */ || + parent_16.kind === 205 /* WhileStatement */ || + parent_16.kind === 212 /* WithStatement */ || + parent_16.kind === 252 /* CatchClause */) { + addOutliningSpan(parent_16, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_15.kind === 216 /* TryStatement */) { + if (parent_16.kind === 216 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_15; + var tryStatement = parent_16; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_15, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_16, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -49873,6 +49907,236 @@ var ts; } })(SignatureHelp = ts.SignatureHelp || (ts.SignatureHelp = {})); })(ts || (ts = {})); +var ts; +(function (ts) { + var ScriptSnapshot; + (function (ScriptSnapshot) { + var StringScriptSnapshot = (function () { + function StringScriptSnapshot(text) { + this.text = text; + } + StringScriptSnapshot.prototype.getText = function (start, end) { + return this.text.substring(start, end); + }; + StringScriptSnapshot.prototype.getLength = function () { + return this.text.length; + }; + StringScriptSnapshot.prototype.getChangeRange = function (oldSnapshot) { + // Text-based snapshots do not support incremental parsing. Return undefined + // to signal that to the caller. + return undefined; + }; + return StringScriptSnapshot; + }()); + function fromString(text) { + return new StringScriptSnapshot(text); + } + ScriptSnapshot.fromString = fromString; + })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); + var TextChange = (function () { + function TextChange() { + } + return TextChange; + }()); + ts.TextChange = TextChange; + var HighlightSpanKind; + (function (HighlightSpanKind) { + HighlightSpanKind.none = "none"; + HighlightSpanKind.definition = "definition"; + HighlightSpanKind.reference = "reference"; + HighlightSpanKind.writtenReference = "writtenReference"; + })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); + (function (IndentStyle) { + IndentStyle[IndentStyle["None"] = 0] = "None"; + IndentStyle[IndentStyle["Block"] = 1] = "Block"; + IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; + })(ts.IndentStyle || (ts.IndentStyle = {})); + var IndentStyle = ts.IndentStyle; + (function (SymbolDisplayPartKind) { + SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; + SymbolDisplayPartKind[SymbolDisplayPartKind["enumName"] = 2] = "enumName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["fieldName"] = 3] = "fieldName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["interfaceName"] = 4] = "interfaceName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["keyword"] = 5] = "keyword"; + SymbolDisplayPartKind[SymbolDisplayPartKind["lineBreak"] = 6] = "lineBreak"; + SymbolDisplayPartKind[SymbolDisplayPartKind["numericLiteral"] = 7] = "numericLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["stringLiteral"] = 8] = "stringLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["localName"] = 9] = "localName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["methodName"] = 10] = "methodName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["moduleName"] = 11] = "moduleName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["operator"] = 12] = "operator"; + SymbolDisplayPartKind[SymbolDisplayPartKind["parameterName"] = 13] = "parameterName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["propertyName"] = 14] = "propertyName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["punctuation"] = 15] = "punctuation"; + SymbolDisplayPartKind[SymbolDisplayPartKind["space"] = 16] = "space"; + SymbolDisplayPartKind[SymbolDisplayPartKind["text"] = 17] = "text"; + SymbolDisplayPartKind[SymbolDisplayPartKind["typeParameterName"] = 18] = "typeParameterName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; + })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; + (function (OutputFileType) { + OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; + OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; + OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; + })(ts.OutputFileType || (ts.OutputFileType = {})); + var OutputFileType = ts.OutputFileType; + (function (EndOfLineState) { + EndOfLineState[EndOfLineState["None"] = 0] = "None"; + EndOfLineState[EndOfLineState["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia"; + EndOfLineState[EndOfLineState["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral"; + EndOfLineState[EndOfLineState["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral"; + EndOfLineState[EndOfLineState["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate"; + EndOfLineState[EndOfLineState["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail"; + EndOfLineState[EndOfLineState["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition"; + })(ts.EndOfLineState || (ts.EndOfLineState = {})); + var EndOfLineState = ts.EndOfLineState; + (function (TokenClass) { + TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; + TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; + TokenClass[TokenClass["Operator"] = 2] = "Operator"; + TokenClass[TokenClass["Comment"] = 3] = "Comment"; + TokenClass[TokenClass["Whitespace"] = 4] = "Whitespace"; + TokenClass[TokenClass["Identifier"] = 5] = "Identifier"; + TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; + TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; + TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; + })(ts.TokenClass || (ts.TokenClass = {})); + var TokenClass = ts.TokenClass; + // TODO: move these to enums + var ScriptElementKind; + (function (ScriptElementKind) { + ScriptElementKind.unknown = ""; + ScriptElementKind.warning = "warning"; + /** predefined type (void) or keyword (class) */ + ScriptElementKind.keyword = "keyword"; + /** top level script node */ + ScriptElementKind.scriptElement = "script"; + /** module foo {} */ + ScriptElementKind.moduleElement = "module"; + /** class X {} */ + ScriptElementKind.classElement = "class"; + /** var x = class X {} */ + ScriptElementKind.localClassElement = "local class"; + /** interface Y {} */ + ScriptElementKind.interfaceElement = "interface"; + /** type T = ... */ + ScriptElementKind.typeElement = "type"; + /** enum E */ + ScriptElementKind.enumElement = "enum"; + // TODO: GH#9983 + ScriptElementKind.enumMemberElement = "const"; + /** + * Inside module and script only + * const v = .. + */ + ScriptElementKind.variableElement = "var"; + /** Inside function */ + ScriptElementKind.localVariableElement = "local var"; + /** + * Inside module and script only + * function f() { } + */ + ScriptElementKind.functionElement = "function"; + /** Inside function */ + ScriptElementKind.localFunctionElement = "local function"; + /** class X { [public|private]* foo() {} } */ + ScriptElementKind.memberFunctionElement = "method"; + /** class X { [public|private]* [get|set] foo:number; } */ + ScriptElementKind.memberGetAccessorElement = "getter"; + ScriptElementKind.memberSetAccessorElement = "setter"; + /** + * class X { [public|private]* foo:number; } + * interface Y { foo:number; } + */ + ScriptElementKind.memberVariableElement = "property"; + /** class X { constructor() { } } */ + ScriptElementKind.constructorImplementationElement = "constructor"; + /** interface Y { ():number; } */ + ScriptElementKind.callSignatureElement = "call"; + /** interface Y { []:number; } */ + ScriptElementKind.indexSignatureElement = "index"; + /** interface Y { new():Y; } */ + ScriptElementKind.constructSignatureElement = "construct"; + /** function foo(*Y*: string) */ + ScriptElementKind.parameterElement = "parameter"; + ScriptElementKind.typeParameterElement = "type parameter"; + ScriptElementKind.primitiveType = "primitive type"; + ScriptElementKind.label = "label"; + ScriptElementKind.alias = "alias"; + ScriptElementKind.constElement = "const"; + ScriptElementKind.letElement = "let"; + })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); + var ScriptElementKindModifier; + (function (ScriptElementKindModifier) { + ScriptElementKindModifier.none = ""; + ScriptElementKindModifier.publicMemberModifier = "public"; + ScriptElementKindModifier.privateMemberModifier = "private"; + ScriptElementKindModifier.protectedMemberModifier = "protected"; + ScriptElementKindModifier.exportedModifier = "export"; + ScriptElementKindModifier.ambientModifier = "declare"; + ScriptElementKindModifier.staticModifier = "static"; + ScriptElementKindModifier.abstractModifier = "abstract"; + })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); + var ClassificationTypeNames = (function () { + function ClassificationTypeNames() { + } + ClassificationTypeNames.comment = "comment"; + ClassificationTypeNames.identifier = "identifier"; + ClassificationTypeNames.keyword = "keyword"; + ClassificationTypeNames.numericLiteral = "number"; + ClassificationTypeNames.operator = "operator"; + ClassificationTypeNames.stringLiteral = "string"; + ClassificationTypeNames.whiteSpace = "whitespace"; + ClassificationTypeNames.text = "text"; + ClassificationTypeNames.punctuation = "punctuation"; + ClassificationTypeNames.className = "class name"; + ClassificationTypeNames.enumName = "enum name"; + ClassificationTypeNames.interfaceName = "interface name"; + ClassificationTypeNames.moduleName = "module name"; + ClassificationTypeNames.typeParameterName = "type parameter name"; + ClassificationTypeNames.typeAliasName = "type alias name"; + ClassificationTypeNames.parameterName = "parameter name"; + ClassificationTypeNames.docCommentTagName = "doc comment tag name"; + ClassificationTypeNames.jsxOpenTagName = "jsx open tag name"; + ClassificationTypeNames.jsxCloseTagName = "jsx close tag name"; + ClassificationTypeNames.jsxSelfClosingTagName = "jsx self closing tag name"; + ClassificationTypeNames.jsxAttribute = "jsx attribute"; + ClassificationTypeNames.jsxText = "jsx text"; + ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; + return ClassificationTypeNames; + }()); + ts.ClassificationTypeNames = ClassificationTypeNames; + (function (ClassificationType) { + ClassificationType[ClassificationType["comment"] = 1] = "comment"; + ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; + ClassificationType[ClassificationType["keyword"] = 3] = "keyword"; + ClassificationType[ClassificationType["numericLiteral"] = 4] = "numericLiteral"; + ClassificationType[ClassificationType["operator"] = 5] = "operator"; + ClassificationType[ClassificationType["stringLiteral"] = 6] = "stringLiteral"; + ClassificationType[ClassificationType["regularExpressionLiteral"] = 7] = "regularExpressionLiteral"; + ClassificationType[ClassificationType["whiteSpace"] = 8] = "whiteSpace"; + ClassificationType[ClassificationType["text"] = 9] = "text"; + ClassificationType[ClassificationType["punctuation"] = 10] = "punctuation"; + ClassificationType[ClassificationType["className"] = 11] = "className"; + ClassificationType[ClassificationType["enumName"] = 12] = "enumName"; + ClassificationType[ClassificationType["interfaceName"] = 13] = "interfaceName"; + ClassificationType[ClassificationType["moduleName"] = 14] = "moduleName"; + ClassificationType[ClassificationType["typeParameterName"] = 15] = "typeParameterName"; + ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName"; + ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName"; + ClassificationType[ClassificationType["docCommentTagName"] = 18] = "docCommentTagName"; + ClassificationType[ClassificationType["jsxOpenTagName"] = 19] = "jsxOpenTagName"; + ClassificationType[ClassificationType["jsxCloseTagName"] = 20] = "jsxCloseTagName"; + ClassificationType[ClassificationType["jsxSelfClosingTagName"] = 21] = "jsxSelfClosingTagName"; + ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; + ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; + ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; + })(ts.ClassificationType || (ts.ClassificationType = {})); + var ClassificationType = ts.ClassificationType; +})(ts || (ts = {})); // These utilities are common to multiple language service features. /* @internal */ var ts; @@ -53766,6 +54030,7 @@ var ts; /// /// /// +/// /// /// /// @@ -53774,30 +54039,6 @@ var ts; (function (ts) { /** The version of the language service API */ ts.servicesVersion = "0.5"; - var ScriptSnapshot; - (function (ScriptSnapshot) { - var StringScriptSnapshot = (function () { - function StringScriptSnapshot(text) { - this.text = text; - } - StringScriptSnapshot.prototype.getText = function (start, end) { - return this.text.substring(start, end); - }; - StringScriptSnapshot.prototype.getLength = function () { - return this.text.length; - }; - StringScriptSnapshot.prototype.getChangeRange = function (oldSnapshot) { - // Text-based snapshots do not support incremental parsing. Return undefined - // to signal that to the caller. - return undefined; - }; - return StringScriptSnapshot; - }()); - function fromString(text) { - return new StringScriptSnapshot(text); - } - ScriptSnapshot.fromString = fromString; - })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); var emptyArray = []; var jsDocTagNames = [ @@ -54463,8 +54704,7 @@ var ts; function addDeclaration(declaration) { var name = getDeclarationName(declaration); if (name) { - var declarations = getDeclarations(name); - declarations.push(declaration); + ts.multiMapAdd(result, name, declaration); } } function getDeclarations(name) { @@ -54595,209 +54835,6 @@ var ts; }; return SourceFileObject; }(NodeObject)); - var TextChange = (function () { - function TextChange() { - } - return TextChange; - }()); - ts.TextChange = TextChange; - var HighlightSpanKind; - (function (HighlightSpanKind) { - HighlightSpanKind.none = "none"; - HighlightSpanKind.definition = "definition"; - HighlightSpanKind.reference = "reference"; - HighlightSpanKind.writtenReference = "writtenReference"; - })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); - (function (IndentStyle) { - IndentStyle[IndentStyle["None"] = 0] = "None"; - IndentStyle[IndentStyle["Block"] = 1] = "Block"; - IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; - })(ts.IndentStyle || (ts.IndentStyle = {})); - var IndentStyle = ts.IndentStyle; - (function (SymbolDisplayPartKind) { - SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; - SymbolDisplayPartKind[SymbolDisplayPartKind["enumName"] = 2] = "enumName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["fieldName"] = 3] = "fieldName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["interfaceName"] = 4] = "interfaceName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["keyword"] = 5] = "keyword"; - SymbolDisplayPartKind[SymbolDisplayPartKind["lineBreak"] = 6] = "lineBreak"; - SymbolDisplayPartKind[SymbolDisplayPartKind["numericLiteral"] = 7] = "numericLiteral"; - SymbolDisplayPartKind[SymbolDisplayPartKind["stringLiteral"] = 8] = "stringLiteral"; - SymbolDisplayPartKind[SymbolDisplayPartKind["localName"] = 9] = "localName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["methodName"] = 10] = "methodName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["moduleName"] = 11] = "moduleName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["operator"] = 12] = "operator"; - SymbolDisplayPartKind[SymbolDisplayPartKind["parameterName"] = 13] = "parameterName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["propertyName"] = 14] = "propertyName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["punctuation"] = 15] = "punctuation"; - SymbolDisplayPartKind[SymbolDisplayPartKind["space"] = 16] = "space"; - SymbolDisplayPartKind[SymbolDisplayPartKind["text"] = 17] = "text"; - SymbolDisplayPartKind[SymbolDisplayPartKind["typeParameterName"] = 18] = "typeParameterName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; - })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); - var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; - (function (OutputFileType) { - OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; - OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; - OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; - })(ts.OutputFileType || (ts.OutputFileType = {})); - var OutputFileType = ts.OutputFileType; - (function (EndOfLineState) { - EndOfLineState[EndOfLineState["None"] = 0] = "None"; - EndOfLineState[EndOfLineState["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia"; - EndOfLineState[EndOfLineState["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral"; - EndOfLineState[EndOfLineState["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral"; - EndOfLineState[EndOfLineState["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate"; - EndOfLineState[EndOfLineState["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail"; - EndOfLineState[EndOfLineState["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition"; - })(ts.EndOfLineState || (ts.EndOfLineState = {})); - var EndOfLineState = ts.EndOfLineState; - (function (TokenClass) { - TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; - TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; - TokenClass[TokenClass["Operator"] = 2] = "Operator"; - TokenClass[TokenClass["Comment"] = 3] = "Comment"; - TokenClass[TokenClass["Whitespace"] = 4] = "Whitespace"; - TokenClass[TokenClass["Identifier"] = 5] = "Identifier"; - TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; - TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; - TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; - })(ts.TokenClass || (ts.TokenClass = {})); - var TokenClass = ts.TokenClass; - // TODO: move these to enums - var ScriptElementKind; - (function (ScriptElementKind) { - ScriptElementKind.unknown = ""; - ScriptElementKind.warning = "warning"; - /** predefined type (void) or keyword (class) */ - ScriptElementKind.keyword = "keyword"; - /** top level script node */ - ScriptElementKind.scriptElement = "script"; - /** module foo {} */ - ScriptElementKind.moduleElement = "module"; - /** class X {} */ - ScriptElementKind.classElement = "class"; - /** var x = class X {} */ - ScriptElementKind.localClassElement = "local class"; - /** interface Y {} */ - ScriptElementKind.interfaceElement = "interface"; - /** type T = ... */ - ScriptElementKind.typeElement = "type"; - /** enum E */ - ScriptElementKind.enumElement = "enum"; - // TODO: GH#9983 - ScriptElementKind.enumMemberElement = "const"; - /** - * Inside module and script only - * const v = .. - */ - ScriptElementKind.variableElement = "var"; - /** Inside function */ - ScriptElementKind.localVariableElement = "local var"; - /** - * Inside module and script only - * function f() { } - */ - ScriptElementKind.functionElement = "function"; - /** Inside function */ - ScriptElementKind.localFunctionElement = "local function"; - /** class X { [public|private]* foo() {} } */ - ScriptElementKind.memberFunctionElement = "method"; - /** class X { [public|private]* [get|set] foo:number; } */ - ScriptElementKind.memberGetAccessorElement = "getter"; - ScriptElementKind.memberSetAccessorElement = "setter"; - /** - * class X { [public|private]* foo:number; } - * interface Y { foo:number; } - */ - ScriptElementKind.memberVariableElement = "property"; - /** class X { constructor() { } } */ - ScriptElementKind.constructorImplementationElement = "constructor"; - /** interface Y { ():number; } */ - ScriptElementKind.callSignatureElement = "call"; - /** interface Y { []:number; } */ - ScriptElementKind.indexSignatureElement = "index"; - /** interface Y { new():Y; } */ - ScriptElementKind.constructSignatureElement = "construct"; - /** function foo(*Y*: string) */ - ScriptElementKind.parameterElement = "parameter"; - ScriptElementKind.typeParameterElement = "type parameter"; - ScriptElementKind.primitiveType = "primitive type"; - ScriptElementKind.label = "label"; - ScriptElementKind.alias = "alias"; - ScriptElementKind.constElement = "const"; - ScriptElementKind.letElement = "let"; - })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); - var ScriptElementKindModifier; - (function (ScriptElementKindModifier) { - ScriptElementKindModifier.none = ""; - ScriptElementKindModifier.publicMemberModifier = "public"; - ScriptElementKindModifier.privateMemberModifier = "private"; - ScriptElementKindModifier.protectedMemberModifier = "protected"; - ScriptElementKindModifier.exportedModifier = "export"; - ScriptElementKindModifier.ambientModifier = "declare"; - ScriptElementKindModifier.staticModifier = "static"; - ScriptElementKindModifier.abstractModifier = "abstract"; - })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); - var ClassificationTypeNames = (function () { - function ClassificationTypeNames() { - } - ClassificationTypeNames.comment = "comment"; - ClassificationTypeNames.identifier = "identifier"; - ClassificationTypeNames.keyword = "keyword"; - ClassificationTypeNames.numericLiteral = "number"; - ClassificationTypeNames.operator = "operator"; - ClassificationTypeNames.stringLiteral = "string"; - ClassificationTypeNames.whiteSpace = "whitespace"; - ClassificationTypeNames.text = "text"; - ClassificationTypeNames.punctuation = "punctuation"; - ClassificationTypeNames.className = "class name"; - ClassificationTypeNames.enumName = "enum name"; - ClassificationTypeNames.interfaceName = "interface name"; - ClassificationTypeNames.moduleName = "module name"; - ClassificationTypeNames.typeParameterName = "type parameter name"; - ClassificationTypeNames.typeAliasName = "type alias name"; - ClassificationTypeNames.parameterName = "parameter name"; - ClassificationTypeNames.docCommentTagName = "doc comment tag name"; - ClassificationTypeNames.jsxOpenTagName = "jsx open tag name"; - ClassificationTypeNames.jsxCloseTagName = "jsx close tag name"; - ClassificationTypeNames.jsxSelfClosingTagName = "jsx self closing tag name"; - ClassificationTypeNames.jsxAttribute = "jsx attribute"; - ClassificationTypeNames.jsxText = "jsx text"; - ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; - return ClassificationTypeNames; - }()); - ts.ClassificationTypeNames = ClassificationTypeNames; - (function (ClassificationType) { - ClassificationType[ClassificationType["comment"] = 1] = "comment"; - ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; - ClassificationType[ClassificationType["keyword"] = 3] = "keyword"; - ClassificationType[ClassificationType["numericLiteral"] = 4] = "numericLiteral"; - ClassificationType[ClassificationType["operator"] = 5] = "operator"; - ClassificationType[ClassificationType["stringLiteral"] = 6] = "stringLiteral"; - ClassificationType[ClassificationType["regularExpressionLiteral"] = 7] = "regularExpressionLiteral"; - ClassificationType[ClassificationType["whiteSpace"] = 8] = "whiteSpace"; - ClassificationType[ClassificationType["text"] = 9] = "text"; - ClassificationType[ClassificationType["punctuation"] = 10] = "punctuation"; - ClassificationType[ClassificationType["className"] = 11] = "className"; - ClassificationType[ClassificationType["enumName"] = 12] = "enumName"; - ClassificationType[ClassificationType["interfaceName"] = 13] = "interfaceName"; - ClassificationType[ClassificationType["moduleName"] = 14] = "moduleName"; - ClassificationType[ClassificationType["typeParameterName"] = 15] = "typeParameterName"; - ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName"; - ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName"; - ClassificationType[ClassificationType["docCommentTagName"] = 18] = "docCommentTagName"; - ClassificationType[ClassificationType["jsxOpenTagName"] = 19] = "jsxOpenTagName"; - ClassificationType[ClassificationType["jsxCloseTagName"] = 20] = "jsxCloseTagName"; - ClassificationType[ClassificationType["jsxSelfClosingTagName"] = 21] = "jsxSelfClosingTagName"; - ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; - ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; - ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; - })(ts.ClassificationType || (ts.ClassificationType = {})); - var ClassificationType = ts.ClassificationType; function displayPartsToString(displayParts) { if (displayParts) { return ts.map(displayParts, function (displayPart) { return displayPart.text; }).join(""); @@ -54818,9 +54855,9 @@ var ts; return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_16 = declaration.parent; !ts.isFunctionBlock(parent_16); parent_16 = parent_16.parent) { + for (var parent_17 = declaration.parent; !ts.isFunctionBlock(parent_17); parent_17 = parent_17.parent) { // Reached source file or module block - if (parent_16.kind === 256 /* SourceFile */ || parent_16.kind === 226 /* ModuleBlock */) { + if (parent_17.kind === 256 /* SourceFile */ || parent_17.kind === 226 /* ModuleBlock */) { return false; } } @@ -55745,8 +55782,8 @@ var ts; for (var i = 70 /* FirstKeyword */; i <= 138 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), - kind: ScriptElementKind.keyword, - kindModifiers: ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.keyword, + kindModifiers: ts.ScriptElementKindModifier.none, sortText: "0" }); } @@ -55776,15 +55813,15 @@ var ts; /* @internal */ function getNodeKind(node) { switch (node.kind) { case 256 /* SourceFile */: - return ts.isExternalModule(node) ? ScriptElementKind.moduleElement : ScriptElementKind.scriptElement; + return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; case 225 /* ModuleDeclaration */: - return ScriptElementKind.moduleElement; + return ts.ScriptElementKind.moduleElement; case 221 /* ClassDeclaration */: case 192 /* ClassExpression */: - return ScriptElementKind.classElement; - case 222 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 223 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 224 /* EnumDeclaration */: return ScriptElementKind.enumElement; + return ts.ScriptElementKind.classElement; + case 222 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 223 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 224 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; case 218 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); case 169 /* BindingElement */: @@ -55792,39 +55829,39 @@ var ts; case 180 /* ArrowFunction */: case 220 /* FunctionDeclaration */: case 179 /* FunctionExpression */: - return ScriptElementKind.functionElement; - case 149 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 150 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + return ts.ScriptElementKind.functionElement; + case 149 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; + case 150 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; case 147 /* MethodDeclaration */: case 146 /* MethodSignature */: - return ScriptElementKind.memberFunctionElement; + return ts.ScriptElementKind.memberFunctionElement; case 145 /* PropertyDeclaration */: case 144 /* PropertySignature */: - return ScriptElementKind.memberVariableElement; - case 153 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 152 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 151 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 148 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 141 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 255 /* EnumMember */: return ScriptElementKind.enumMemberElement; - case 142 /* Parameter */: return (node.flags & 92 /* ParameterPropertyModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + return ts.ScriptElementKind.memberVariableElement; + case 153 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; + case 152 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; + case 151 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; + case 148 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; + case 141 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; + case 255 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; + case 142 /* Parameter */: return (node.flags & 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; case 229 /* ImportEqualsDeclaration */: case 234 /* ImportSpecifier */: case 231 /* ImportClause */: case 238 /* ExportSpecifier */: case 232 /* NamespaceImport */: - return ScriptElementKind.alias; + return ts.ScriptElementKind.alias; case 279 /* JSDocTypedefTag */: - return ScriptElementKind.typeElement; + return ts.ScriptElementKind.typeElement; default: - return ScriptElementKind.unknown; + return ts.ScriptElementKind.unknown; } function getKindOfVariableDeclaration(v) { return ts.isConst(v) - ? ScriptElementKind.constElement + ? ts.ScriptElementKind.constElement : ts.isLet(v) - ? ScriptElementKind.letElement - : ScriptElementKind.variableElement; + ? ts.ScriptElementKind.letElement + : ts.ScriptElementKind.variableElement; } } ts.getNodeKind = getNodeKind; @@ -56204,13 +56241,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_17 = contextToken.parent, kind = contextToken.kind; + var parent_18 = contextToken.parent, kind = contextToken.kind; if (kind === 21 /* DotToken */) { - if (parent_17.kind === 172 /* PropertyAccessExpression */) { + if (parent_18.kind === 172 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_17.kind === 139 /* QualifiedName */) { + else if (parent_18.kind === 139 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -56588,9 +56625,9 @@ var ts; switch (contextToken.kind) { case 15 /* OpenBraceToken */: // const x = { | case 24 /* CommaToken */: - var parent_18 = contextToken.parent; - if (parent_18 && (parent_18.kind === 171 /* ObjectLiteralExpression */ || parent_18.kind === 167 /* ObjectBindingPattern */)) { - return parent_18; + var parent_19 = contextToken.parent; + if (parent_19 && (parent_19.kind === 171 /* ObjectLiteralExpression */ || parent_19.kind === 167 /* ObjectBindingPattern */)) { + return parent_19; } break; } @@ -56617,37 +56654,37 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_19 = contextToken.parent; + var parent_20 = contextToken.parent; switch (contextToken.kind) { case 26 /* LessThanSlashToken */: case 39 /* SlashToken */: case 69 /* Identifier */: case 246 /* JsxAttribute */: case 247 /* JsxSpreadAttribute */: - if (parent_19 && (parent_19.kind === 242 /* JsxSelfClosingElement */ || parent_19.kind === 243 /* JsxOpeningElement */)) { - return parent_19; + if (parent_20 && (parent_20.kind === 242 /* JsxSelfClosingElement */ || parent_20.kind === 243 /* JsxOpeningElement */)) { + return parent_20; } - else if (parent_19.kind === 246 /* JsxAttribute */) { - return parent_19.parent; + else if (parent_20.kind === 246 /* JsxAttribute */) { + return parent_20.parent; } break; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent_19 && ((parent_19.kind === 246 /* JsxAttribute */) || (parent_19.kind === 247 /* JsxSpreadAttribute */))) { - return parent_19.parent; + if (parent_20 && ((parent_20.kind === 246 /* JsxAttribute */) || (parent_20.kind === 247 /* JsxSpreadAttribute */))) { + return parent_20.parent; } break; case 16 /* CloseBraceToken */: - if (parent_19 && - parent_19.kind === 248 /* JsxExpression */ && - parent_19.parent && - (parent_19.parent.kind === 246 /* JsxAttribute */)) { - return parent_19.parent.parent; + if (parent_20 && + parent_20.kind === 248 /* JsxExpression */ && + parent_20.parent && + (parent_20.parent.kind === 246 /* JsxAttribute */)) { + return parent_20.parent.parent; } - if (parent_19 && parent_19.kind === 247 /* JsxSpreadAttribute */) { - return parent_19.parent; + if (parent_20 && parent_20.kind === 247 /* JsxSpreadAttribute */) { + return parent_20.parent; } break; } @@ -56916,7 +56953,7 @@ var ts; if (displayName) { var entry = { name: displayName, - kind: ScriptElementKind.warning, + kind: ts.ScriptElementKind.warning, kindModifiers: "", sortText: "1" }; @@ -56930,7 +56967,7 @@ var ts; return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: tagName, - kind: ScriptElementKind.keyword, + kind: ts.ScriptElementKind.keyword, kindModifiers: "", sortText: "0", }; @@ -57082,8 +57119,8 @@ var ts; if (type.flags & 32 /* StringLiteral */) { result.push({ name: type.text, - kindModifiers: ScriptElementKindModifier.none, - kind: ScriptElementKind.variableElement, + kindModifiers: ts.ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.variableElement, sortText: "0" }); } @@ -57118,9 +57155,9 @@ var ts; if (keywordCompletion) { return { name: entryName, - kind: ScriptElementKind.keyword, - kindModifiers: ScriptElementKindModifier.none, - displayParts: [ts.displayPart(entryName, SymbolDisplayPartKind.keyword)], + kind: ts.ScriptElementKind.keyword, + kindModifiers: ts.ScriptElementKindModifier.none, + displayParts: [ts.displayPart(entryName, ts.SymbolDisplayPartKind.keyword)], documentation: undefined }; } @@ -57131,68 +57168,68 @@ var ts; var flags = symbol.getFlags(); if (flags & 32 /* Class */) return ts.getDeclarationOfKind(symbol, 192 /* ClassExpression */) ? - ScriptElementKind.localClassElement : ScriptElementKind.classElement; + ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384 /* Enum */) - return ScriptElementKind.enumElement; + return ts.ScriptElementKind.enumElement; if (flags & 524288 /* TypeAlias */) - return ScriptElementKind.typeElement; + return ts.ScriptElementKind.typeElement; if (flags & 64 /* Interface */) - return ScriptElementKind.interfaceElement; + return ts.ScriptElementKind.interfaceElement; if (flags & 262144 /* TypeParameter */) - return ScriptElementKind.typeParameterElement; + return ts.ScriptElementKind.typeParameterElement; var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location); - if (result === ScriptElementKind.unknown) { + if (result === ts.ScriptElementKind.unknown) { if (flags & 262144 /* TypeParameter */) - return ScriptElementKind.typeParameterElement; + return ts.ScriptElementKind.typeParameterElement; if (flags & 8 /* EnumMember */) - return ScriptElementKind.variableElement; + return ts.ScriptElementKind.variableElement; if (flags & 8388608 /* Alias */) - return ScriptElementKind.alias; + return ts.ScriptElementKind.alias; if (flags & 1536 /* Module */) - return ScriptElementKind.moduleElement; + return ts.ScriptElementKind.moduleElement; } return result; } function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location) { var typeChecker = program.getTypeChecker(); if (typeChecker.isUndefinedSymbol(symbol)) { - return ScriptElementKind.variableElement; + return ts.ScriptElementKind.variableElement; } if (typeChecker.isArgumentsSymbol(symbol)) { - return ScriptElementKind.localVariableElement; + return ts.ScriptElementKind.localVariableElement; } if (location.kind === 97 /* ThisKeyword */ && ts.isExpression(location)) { - return ScriptElementKind.parameterElement; + return ts.ScriptElementKind.parameterElement; } if (flags & 3 /* Variable */) { if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { - return ScriptElementKind.parameterElement; + return ts.ScriptElementKind.parameterElement; } else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { - return ScriptElementKind.constElement; + return ts.ScriptElementKind.constElement; } else if (ts.forEach(symbol.declarations, ts.isLet)) { - return ScriptElementKind.letElement; + return ts.ScriptElementKind.letElement; } - return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localVariableElement : ScriptElementKind.variableElement; + return isLocalVariableOrFunction(symbol) ? ts.ScriptElementKind.localVariableElement : ts.ScriptElementKind.variableElement; } if (flags & 16 /* Function */) - return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localFunctionElement : ScriptElementKind.functionElement; + return isLocalVariableOrFunction(symbol) ? ts.ScriptElementKind.localFunctionElement : ts.ScriptElementKind.functionElement; if (flags & 32768 /* GetAccessor */) - return ScriptElementKind.memberGetAccessorElement; + return ts.ScriptElementKind.memberGetAccessorElement; if (flags & 65536 /* SetAccessor */) - return ScriptElementKind.memberSetAccessorElement; + return ts.ScriptElementKind.memberSetAccessorElement; if (flags & 8192 /* Method */) - return ScriptElementKind.memberFunctionElement; + return ts.ScriptElementKind.memberFunctionElement; if (flags & 16384 /* Constructor */) - return ScriptElementKind.constructorImplementationElement; + return ts.ScriptElementKind.constructorImplementationElement; if (flags & 4 /* Property */) { if (flags & 268435456 /* SyntheticProperty */) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { - return ScriptElementKind.memberVariableElement; + return ts.ScriptElementKind.memberVariableElement; } ts.Debug.assert(!!(rootSymbolFlags & 8192 /* Method */)); }); @@ -57201,20 +57238,20 @@ var ts; // make sure it has call signatures before we can label it as method var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { - return ScriptElementKind.memberFunctionElement; + return ts.ScriptElementKind.memberFunctionElement; } - return ScriptElementKind.memberVariableElement; + return ts.ScriptElementKind.memberVariableElement; } return unionPropertyKind; } - return ScriptElementKind.memberVariableElement; + return ts.ScriptElementKind.memberVariableElement; } - return ScriptElementKind.unknown; + return ts.ScriptElementKind.unknown; } function getSymbolModifiers(symbol) { return symbol && symbol.declarations && symbol.declarations.length > 0 ? ts.getNodeModifiers(symbol.declarations[0]) - : ScriptElementKindModifier.none; + : ts.ScriptElementKindModifier.none; } // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, enclosingDeclaration, location, semanticMeaning) { @@ -57228,10 +57265,10 @@ var ts; var isThisExpression = location.kind === 97 /* ThisKeyword */ && ts.isExpression(location); var type; // Class at constructor site need to be shown as constructor apart from property,method, vars - if (symbolKind !== ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Alias */) { + if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Alias */) { // If it is accessor they are allowed only if location is at name of the accessor - if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) { - symbolKind = ScriptElementKind.memberVariableElement; + if (symbolKind === ts.ScriptElementKind.memberGetAccessorElement || symbolKind === ts.ScriptElementKind.memberSetAccessorElement) { + symbolKind = ts.ScriptElementKind.memberVariableElement; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); @@ -57268,11 +57305,11 @@ var ts; if (signature) { if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { // Constructor - symbolKind = ScriptElementKind.constructorImplementationElement; + symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else if (symbolFlags & 8388608 /* Alias */) { - symbolKind = ScriptElementKind.alias; + symbolKind = ts.ScriptElementKind.alias; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { @@ -57285,12 +57322,12 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { - case ScriptElementKind.memberVariableElement: - case ScriptElementKind.variableElement: - case ScriptElementKind.constElement: - case ScriptElementKind.letElement: - case ScriptElementKind.parameterElement: - case ScriptElementKind.localVariableElement: + case ts.ScriptElementKind.memberVariableElement: + case ts.ScriptElementKind.variableElement: + case ts.ScriptElementKind.constElement: + case ts.ScriptElementKind.letElement: + case ts.ScriptElementKind.parameterElement: + case ts.ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name displayParts.push(ts.punctuationPart(54 /* ColonToken */)); displayParts.push(ts.spacePart()); @@ -57323,7 +57360,7 @@ var ts; } if (functionDeclaration.kind === 148 /* Constructor */) { // show (constructor) Type(...) signature - symbolKind = ScriptElementKind.constructorImplementationElement; + symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { @@ -57341,7 +57378,7 @@ var ts; // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class - pushTypePart(ScriptElementKind.localClassElement); + pushTypePart(ts.ScriptElementKind.localClassElement); } else { // Class declaration has name which is not local. @@ -57440,7 +57477,7 @@ var ts; displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); + displayParts.push(ts.displayPart(constantValue.toString(), ts.SymbolDisplayPartKind.numericLiteral)); } } } @@ -57465,7 +57502,7 @@ var ts; displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(129 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); - displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } else { @@ -57482,7 +57519,7 @@ var ts; }); } if (!hasAddedSymbolInfo) { - if (symbolKind !== ScriptElementKind.unknown) { + if (symbolKind !== ts.ScriptElementKind.unknown) { if (type) { if (isThisExpression) { addNewLineIfDisplayPartsExist(); @@ -57492,9 +57529,9 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } // For properties, variables and local vars: show the type - if (symbolKind === ScriptElementKind.memberVariableElement || + if (symbolKind === ts.ScriptElementKind.memberVariableElement || symbolFlags & 3 /* Variable */ || - symbolKind === ScriptElementKind.localVariableElement || + symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { displayParts.push(ts.punctuationPart(54 /* ColonToken */)); displayParts.push(ts.spacePart()); @@ -57514,7 +57551,7 @@ var ts; symbolFlags & 16384 /* Constructor */ || symbolFlags & 131072 /* Signature */ || symbolFlags & 98304 /* Accessor */ || - symbolKind === ScriptElementKind.memberFunctionElement) { + symbolKind === ts.ScriptElementKind.memberFunctionElement) { var allSignatures = type.getNonNullableType().getCallSignatures(); addSignatureDisplayParts(allSignatures[0], allSignatures); } @@ -57568,11 +57605,11 @@ var ts; } function pushTypePart(symbolKind) { switch (symbolKind) { - case ScriptElementKind.variableElement: - case ScriptElementKind.functionElement: - case ScriptElementKind.letElement: - case ScriptElementKind.constElement: - case ScriptElementKind.constructorImplementationElement: + case ts.ScriptElementKind.variableElement: + case ts.ScriptElementKind.functionElement: + case ts.ScriptElementKind.letElement: + case ts.ScriptElementKind.constElement: + case ts.ScriptElementKind.constructorImplementationElement: displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: @@ -57588,7 +57625,7 @@ var ts; displayParts.push(ts.spacePart()); displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.operatorPart(35 /* PlusToken */)); - displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); + displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); @@ -57627,8 +57664,8 @@ var ts; var type = typeChecker.getTypeAtLocation(node); if (type) { return { - kind: ScriptElementKind.unknown, - kindModifiers: ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.unknown, + kindModifiers: ts.ScriptElementKindModifier.none, textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: ts.typeToDisplayParts(typeChecker, type, getContainerNode(node)), documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined @@ -57740,7 +57777,7 @@ var ts; return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), - kind: ScriptElementKind.scriptElement, + kind: ts.ScriptElementKind.scriptElement, name: name, containerName: undefined, containerKind: undefined @@ -57776,7 +57813,7 @@ var ts; if (isJumpStatementTarget(node)) { var labelName = node.text; var label = getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; + return label ? [createDefinitionInfo(label, ts.ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; } var typeChecker = program.getTypeChecker(); var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); @@ -57880,7 +57917,7 @@ var ts; return { fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromBounds(start, end), - kind: HighlightSpanKind.none + kind: ts.HighlightSpanKind.none }; } function getSemanticDocumentHighlights(node) { @@ -57913,7 +57950,7 @@ var ts; } documentHighlights.highlightSpans.push({ textSpan: referenceEntry.textSpan, - kind: referenceEntry.isWriteAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference + kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference }); } } @@ -58054,19 +58091,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_20 = child.parent; - if (ts.isFunctionBlock(parent_20) || parent_20.kind === 256 /* SourceFile */) { - return parent_20; + var parent_21 = child.parent; + if (ts.isFunctionBlock(parent_21) || parent_21.kind === 256 /* SourceFile */) { + return parent_21; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_20.kind === 216 /* TryStatement */) { - var tryStatement = parent_20; + if (parent_21.kind === 216 /* TryStatement */) { + var tryStatement = parent_21; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_20; + child = parent_21; } return undefined; } @@ -58378,7 +58415,7 @@ var ts; result.push({ fileName: fileName, textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: HighlightSpanKind.reference + kind: ts.HighlightSpanKind.reference }); i++; // skip the next keyword continue; @@ -58407,7 +58444,7 @@ var ts; result.push({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, - isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference, + isWriteAccess: highlightSpan.kind === ts.HighlightSpanKind.writtenReference, isDefinition: false }); } @@ -58722,10 +58759,10 @@ var ts; containerKind: "", containerName: "", fileName: targetLabel.getSourceFile().fileName, - kind: ScriptElementKind.label, + kind: ts.ScriptElementKind.label, name: labelName, textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()), - displayParts: [ts.displayPart(labelName, SymbolDisplayPartKind.text)] + displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] }; return [{ definition: definition, references: references }]; } @@ -58999,7 +59036,7 @@ var ts; containerKind: "", containerName: "", fileName: node.getSourceFile().fileName, - kind: ScriptElementKind.variableElement, + kind: ts.ScriptElementKind.variableElement, name: "this", textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), displayParts: displayParts @@ -59062,10 +59099,10 @@ var ts; containerKind: "", containerName: "", fileName: node.getSourceFile().fileName, - kind: ScriptElementKind.variableElement, + kind: ts.ScriptElementKind.variableElement, name: type.text, textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: [ts.displayPart(ts.getTextOfNode(node), SymbolDisplayPartKind.stringLiteral)] + displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] }, references: references }]; @@ -59689,29 +59726,29 @@ var ts; } function getClassificationTypeName(type) { switch (type) { - case 1 /* comment */: return ClassificationTypeNames.comment; - case 2 /* identifier */: return ClassificationTypeNames.identifier; - case 3 /* keyword */: return ClassificationTypeNames.keyword; - case 4 /* numericLiteral */: return ClassificationTypeNames.numericLiteral; - case 5 /* operator */: return ClassificationTypeNames.operator; - case 6 /* stringLiteral */: return ClassificationTypeNames.stringLiteral; - case 8 /* whiteSpace */: return ClassificationTypeNames.whiteSpace; - case 9 /* text */: return ClassificationTypeNames.text; - case 10 /* punctuation */: return ClassificationTypeNames.punctuation; - case 11 /* className */: return ClassificationTypeNames.className; - case 12 /* enumName */: return ClassificationTypeNames.enumName; - case 13 /* interfaceName */: return ClassificationTypeNames.interfaceName; - case 14 /* moduleName */: return ClassificationTypeNames.moduleName; - case 15 /* typeParameterName */: return ClassificationTypeNames.typeParameterName; - case 16 /* typeAliasName */: return ClassificationTypeNames.typeAliasName; - case 17 /* parameterName */: return ClassificationTypeNames.parameterName; - case 18 /* docCommentTagName */: return ClassificationTypeNames.docCommentTagName; - case 19 /* jsxOpenTagName */: return ClassificationTypeNames.jsxOpenTagName; - case 20 /* jsxCloseTagName */: return ClassificationTypeNames.jsxCloseTagName; - case 21 /* jsxSelfClosingTagName */: return ClassificationTypeNames.jsxSelfClosingTagName; - case 22 /* jsxAttribute */: return ClassificationTypeNames.jsxAttribute; - case 23 /* jsxText */: return ClassificationTypeNames.jsxText; - case 24 /* jsxAttributeStringLiteralValue */: return ClassificationTypeNames.jsxAttributeStringLiteralValue; + case 1 /* comment */: return ts.ClassificationTypeNames.comment; + case 2 /* identifier */: return ts.ClassificationTypeNames.identifier; + case 3 /* keyword */: return ts.ClassificationTypeNames.keyword; + case 4 /* numericLiteral */: return ts.ClassificationTypeNames.numericLiteral; + case 5 /* operator */: return ts.ClassificationTypeNames.operator; + case 6 /* stringLiteral */: return ts.ClassificationTypeNames.stringLiteral; + case 8 /* whiteSpace */: return ts.ClassificationTypeNames.whiteSpace; + case 9 /* text */: return ts.ClassificationTypeNames.text; + case 10 /* punctuation */: return ts.ClassificationTypeNames.punctuation; + case 11 /* className */: return ts.ClassificationTypeNames.className; + case 12 /* enumName */: return ts.ClassificationTypeNames.enumName; + case 13 /* interfaceName */: return ts.ClassificationTypeNames.interfaceName; + case 14 /* moduleName */: return ts.ClassificationTypeNames.moduleName; + case 15 /* typeParameterName */: return ts.ClassificationTypeNames.typeParameterName; + case 16 /* typeAliasName */: return ts.ClassificationTypeNames.typeAliasName; + case 17 /* parameterName */: return ts.ClassificationTypeNames.parameterName; + case 18 /* docCommentTagName */: return ts.ClassificationTypeNames.docCommentTagName; + case 19 /* jsxOpenTagName */: return ts.ClassificationTypeNames.jsxOpenTagName; + case 20 /* jsxCloseTagName */: return ts.ClassificationTypeNames.jsxCloseTagName; + case 21 /* jsxSelfClosingTagName */: return ts.ClassificationTypeNames.jsxSelfClosingTagName; + case 22 /* jsxAttribute */: return ts.ClassificationTypeNames.jsxAttribute; + case 23 /* jsxText */: return ts.ClassificationTypeNames.jsxText; + case 24 /* jsxAttributeStringLiteralValue */: return ts.ClassificationTypeNames.jsxAttributeStringLiteralValue; } } function convertClassifications(classifications) { @@ -60453,11 +60490,11 @@ var ts; var displayName = ts.stripQuotes(type.text); return { canRename: true, - kind: ScriptElementKind.variableElement, + kind: ts.ScriptElementKind.variableElement, displayName: displayName, localizedErrorMessage: undefined, fullDisplayName: displayName, - kindModifiers: ScriptElementKindModifier.none, + kindModifiers: ts.ScriptElementKindModifier.none, triggerSpan: createTriggerSpanForNode(node, sourceFile) }; } @@ -60666,7 +60703,7 @@ var ts; if (lastEnd >= 0) { var whitespaceLength_1 = start - lastEnd; if (whitespaceLength_1 > 0) { - entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); + entries.push({ length: whitespaceLength_1, classification: ts.TokenClass.Whitespace }); } } entries.push({ length: length_5, classification: convertClassification(type) }); @@ -60674,19 +60711,19 @@ var ts; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { - entries.push({ length: whitespaceLength, classification: TokenClass.Whitespace }); + entries.push({ length: whitespaceLength, classification: ts.TokenClass.Whitespace }); } return { entries: entries, finalLexState: classifications.endOfLineState }; } function convertClassification(type) { switch (type) { - case 1 /* comment */: return TokenClass.Comment; - case 3 /* keyword */: return TokenClass.Keyword; - case 4 /* numericLiteral */: return TokenClass.NumberLiteral; - case 5 /* operator */: return TokenClass.Operator; - case 6 /* stringLiteral */: return TokenClass.StringLiteral; - case 8 /* whiteSpace */: return TokenClass.Whitespace; - case 10 /* punctuation */: return TokenClass.Punctuation; + case 1 /* comment */: return ts.TokenClass.Comment; + case 3 /* keyword */: return ts.TokenClass.Keyword; + case 4 /* numericLiteral */: return ts.TokenClass.NumberLiteral; + case 5 /* operator */: return ts.TokenClass.Operator; + case 6 /* stringLiteral */: return ts.TokenClass.StringLiteral; + case 8 /* whiteSpace */: return ts.TokenClass.Whitespace; + case 10 /* punctuation */: return ts.TokenClass.Punctuation; case 2 /* identifier */: case 11 /* className */: case 12 /* enumName */: @@ -60697,7 +60734,7 @@ var ts; case 9 /* text */: case 17 /* parameterName */: default: - return TokenClass.Identifier; + return ts.TokenClass.Identifier; } } function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { diff --git a/bin/typescript.d.ts b/bin/typescript.d.ts index e95da9f..8682c71 100644 --- a/bin/typescript.d.ts +++ b/bin/typescript.d.ts @@ -2394,6 +2394,11 @@ declare namespace ts { function cloneMap(map: Map): Map; function clone(object: T): T; function extend(first: T1, second: T2): T1 & T2; + /** + * Adds the value to an array of values associated with the key, and returns the array. + * Creates the array if it does not already exist. + */ + function multiMapAdd(map: Map, key: string, value: V): V[]; /** * Tests whether a value is an array. */ @@ -7755,1154 +7760,1156 @@ declare namespace ts.SignatureHelp { function getContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile): ArgumentListInfo; } declare namespace ts { - interface ListItemInfo { - listItemIndex: number; - list: Node; + 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; } - function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number; - function rangeContainsRange(r1: TextRange, r2: TextRange): boolean; - function startEndContainsRange(start: number, end: number, range: TextRange): boolean; - function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean; - function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean; - function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean; - function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean; - function isCompletedNode(n: Node, sourceFile: SourceFile): boolean; - function findListItemInfo(node: Node): ListItemInfo; - function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean; - function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node; - function findContainingList(node: Node): Node; - function getTouchingWord(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; - function getTouchingPropertyName(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; - /** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */ - function getTouchingToken(sourceFile: SourceFile, position: number, includeItemAtEndPosition?: (n: Node) => boolean, includeJsDocComment?: boolean): Node; - /** Returns a token if position is in [start-of-leading-trivia, end) */ - function getTokenAtPosition(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; - /** - * The token on the left of the position is the token that strictly includes the position - * or sits to the left of the cursor if it is on a boundary. For example - * - * fo|o -> will return foo - * foo |bar -> will return foo - * - */ - function findTokenOnLeftOfPosition(file: SourceFile, position: number): Node; - function findNextToken(previousToken: Node, parent: Node): Node; - function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node): Node; - function isInString(sourceFile: SourceFile, position: number): boolean; - function isInComment(sourceFile: SourceFile, position: number): boolean; - /** - * returns true if the position is in between the open and close elements of an JSX expression. - */ - function isInsideJsxElementOrAttribute(sourceFile: SourceFile, position: number): boolean; - function isInTemplateString(sourceFile: SourceFile, position: number): boolean; - /** - * Returns true if the cursor at position in sourceFile is within a comment that additionally - * satisfies predicate, and false otherwise. - */ - function isInCommentHelper(sourceFile: SourceFile, position: number, predicate?: (c: CommentRange) => boolean): boolean; - function hasDocComment(sourceFile: SourceFile, position: number): boolean; - /** - * Get the corresponding JSDocTag node if the position is in a jsDoc comment - */ - function getJsDocTagAtPosition(sourceFile: SourceFile, position: number): JSDocTag; - function getNodeModifiers(node: Node): string; - function getTypeArgumentOrTypeParameterList(node: Node): NodeArray; - function isToken(n: Node): boolean; - function isWord(kind: SyntaxKind): boolean; - function isComment(kind: SyntaxKind): boolean; - function isStringOrRegularExpressionOrTemplateLiteral(kind: SyntaxKind): boolean; - function isPunctuation(kind: SyntaxKind): boolean; - function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean; - function isAccessibilityModifier(kind: SyntaxKind): boolean; - function compareDataObjects(dst: any, src: any): boolean; - function isArrayLiteralOrObjectLiteralDestructuringPattern(node: Node): boolean; -} -declare namespace ts { - function isFirstDeclarationOfSymbolParameter(symbol: Symbol): boolean; - function symbolPart(text: string, symbol: Symbol): SymbolDisplayPart; - function displayPart(text: string, kind: SymbolDisplayPartKind, symbol?: Symbol): SymbolDisplayPart; - function spacePart(): SymbolDisplayPart; - function keywordPart(kind: SyntaxKind): SymbolDisplayPart; - function punctuationPart(kind: SyntaxKind): SymbolDisplayPart; - function operatorPart(kind: SyntaxKind): SymbolDisplayPart; - function textOrKeywordPart(text: string): SymbolDisplayPart; - function textPart(text: string): SymbolDisplayPart; - /** - * The default is CRLF. - */ - function getNewLineOrDefaultFromHost(host: LanguageServiceHost | LanguageServiceShimHost): string; - function lineBreakPart(): SymbolDisplayPart; - function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[]; - function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; - function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): SymbolDisplayPart[]; - function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; - function getDeclaredName(typeChecker: TypeChecker, symbol: Symbol, location: Node): string; - function isImportOrExportSpecifierName(location: Node): boolean; - /** - * Strip off existed single quotes or double quotes from a given string - * - * @return non-quoted string - */ - function stripQuotes(name: string): string; - function scriptKindIs(fileName: string, host: LanguageServiceHost, ...scriptKinds: ScriptKind[]): boolean; - function getScriptKind(fileName: string, host?: LanguageServiceHost): ScriptKind; - function parseAndReEmitConfigJSONFile(content: string): { - configJsonObject: any; - diagnostics: Diagnostic[]; - }; -} -declare namespace ts.JsTyping { - interface TypingResolutionHost { - directoryExists: (path: string) => boolean; - fileExists: (fileName: string) => boolean; - readFile: (path: string, encoding?: string) => string; - readDirectory: (rootDir: string, extensions: string[], excludes: string[], includes: string[], depth?: number) => string[]; + interface Symbol { + getFlags(): SymbolFlags; + getName(): string; + getDeclarations(): Declaration[]; + getDocumentationComment(): SymbolDisplayPart[]; + } + 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; + } + interface Signature { + getDeclaration(): SignatureDeclaration; + getTypeParameters(): Type[]; + getParameters(): Symbol[]; + getReturnType(): Type; + getDocumentationComment(): SymbolDisplayPart[]; + } + interface SourceFile { + version: string; + scriptSnapshot: IScriptSnapshot; + nameTable: Map; + getNamedDeclarations(): Map; + getLineAndCharacterOfPosition(pos: number): LineAndCharacter; + getLineStarts(): number[]; + getPositionOfLineAndCharacter(line: number, character: number): number; + update(newText: string, textChangeRange: TextChangeRange): SourceFile; } /** - * @param host is the object providing I/O related operations. - * @param fileNames are the file names that belong to the same project - * @param projectRootPath is the path to the project root directory - * @param safeListPath is the path used to retrieve the safe list - * @param packageNameToTypingLocation is the map of package names to their cached typing locations - * @param typingOptions are used to customize the typing inference process - * @param compilerOptions are used as a source for typing inference + * 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. */ - function discoverTypings(host: TypingResolutionHost, fileNames: string[], projectRootPath: Path, safeListPath: Path, packageNameToTypingLocation: Map, typingOptions: TypingOptions, compilerOptions: CompilerOptions): { - cachedTypingPaths: string[]; - newTypingNames: string[]; - filesToWatch: string[]; - }; -} -declare namespace ts.formatting { - interface FormattingScanner { - advance(): void; - isOnToken(): boolean; - readTokenInfo(n: Node): TokenInfo; - getCurrentLeadingTrivia(): TextRangeWithKind[]; - lastTrailingTriviaWasNewLine(): boolean; - skipToEndOf(node: Node): void; - close(): void; - } - function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner; -} -declare namespace ts.formatting { - class FormattingContext { - sourceFile: SourceFile; - formattingRequestKind: FormattingRequestKind; - currentTokenSpan: TextRangeWithKind; - nextTokenSpan: TextRangeWithKind; - contextNode: Node; - currentTokenParent: Node; - nextTokenParent: Node; - private contextNodeAllOnSameLine; - private nextNodeAllOnSameLine; - private tokensAreOnSameLine; - private contextNodeBlockIsOnOneLine; - private nextNodeBlockIsOnOneLine; - constructor(sourceFile: SourceFile, formattingRequestKind: FormattingRequestKind); - updateContext(currentRange: TextRangeWithKind, currentTokenParent: Node, nextRange: TextRangeWithKind, nextTokenParent: Node, commonParent: Node): void; - ContextNodeAllOnSameLine(): boolean; - NextNodeAllOnSameLine(): boolean; - TokensAreOnSameLine(): boolean; - ContextNodeBlockIsOnOneLine(): boolean; - NextNodeBlockIsOnOneLine(): boolean; - private NodeIsOnOneLine(node); - private BlockIsOnOneLine(node); + 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; } -} -declare namespace ts.formatting { - const enum FormattingRequestKind { - FormatDocument = 0, - FormatSelection = 1, - FormatOnEnter = 2, - FormatOnSemicolon = 3, - FormatOnClosingCurlyBrace = 4, + namespace ScriptSnapshot { + function fromString(text: string): IScriptSnapshot; } -} -declare namespace ts.formatting { - class Rule { - Descriptor: RuleDescriptor; - Operation: RuleOperation; - Flag: RuleFlags; - constructor(Descriptor: RuleDescriptor, Operation: RuleOperation, Flag?: RuleFlags); - toString(): string; + interface PreProcessedFileInfo { + referencedFiles: FileReference[]; + typeReferenceDirectives: FileReference[]; + importedFiles: FileReference[]; + ambientExternalModules: string[]; + isLibFile: boolean; } -} -declare namespace ts.formatting { - const enum RuleAction { - Ignore = 1, - Space = 2, - NewLine = 4, - Delete = 8, + interface HostCancellationToken { + isCancellationRequested(): boolean; } -} -declare namespace ts.formatting { - class RuleDescriptor { - LeftTokenRange: Shared.TokenRange; - RightTokenRange: Shared.TokenRange; - constructor(LeftTokenRange: Shared.TokenRange, RightTokenRange: Shared.TokenRange); - toString(): string; - static create1(left: SyntaxKind, right: SyntaxKind): RuleDescriptor; - static create2(left: Shared.TokenRange, right: SyntaxKind): RuleDescriptor; - static create3(left: SyntaxKind, right: Shared.TokenRange): RuleDescriptor; - static create4(left: Shared.TokenRange, right: Shared.TokenRange): RuleDescriptor; + 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; + resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; + resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + directoryExists?(directoryName: string): boolean; + getDirectories?(directoryName: string): string[]; } -} -declare namespace ts.formatting { - const enum RuleFlags { + interface LanguageService { + cleanupSemanticCache(): void; + getSyntacticDiagnostics(fileName: string): Diagnostic[]; + getSemanticDiagnostics(fileName: string): Diagnostic[]; + getCompilerOptionsDiagnostics(): Diagnostic[]; + /** + * @deprecated Use getEncodedSyntacticClassifications instead. + */ + getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + /** + * @deprecated Use getEncodedSemanticClassifications instead. + */ + getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + 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; + getNonBoundSourceFile(fileName: string): SourceFile; + dispose(): void; + } + interface Classifications { + spans: number[]; + endOfLineState: EndOfLineState; + } + interface ClassifiedSpan { + textSpan: TextSpan; + classificationType: string; + } + interface NavigationBarItem { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems: NavigationBarItem[]; + indent: number; + bolded: boolean; + grayed: boolean; + } + interface TodoCommentDescriptor { + text: string; + priority: number; + } + interface TodoComment { + descriptor: TodoCommentDescriptor; + message: string; + position: number; + } + class TextChange { + span: TextSpan; + newText: string; + } + interface TextInsertion { + newText: string; + /** The position in newText the caret should point to after the insertion. */ + caretOffset: number; + } + interface RenameLocation { + textSpan: TextSpan; + fileName: string; + } + interface ReferenceEntry { + textSpan: TextSpan; + fileName: string; + isWriteAccess: boolean; + isDefinition: boolean; + } + interface DocumentHighlights { + fileName: string; + highlightSpans: HighlightSpan[]; + } + namespace HighlightSpanKind { + const none: string; + const definition: string; + const reference: string; + const writtenReference: string; + } + interface HighlightSpan { + fileName?: string; + textSpan: TextSpan; + kind: string; + } + interface NavigateToItem { + name: string; + kind: string; + kindModifiers: string; + matchKind: string; + isCaseSensitive: boolean; + fileName: string; + textSpan: TextSpan; + containerName: string; + containerKind: string; + } + interface EditorOptions { + BaseIndentSize?: number; + IndentSize: number; + TabSize: number; + NewLineCharacter: string; + ConvertTabsToSpaces: boolean; + IndentStyle: IndentStyle; + } + enum IndentStyle { None = 0, - CanDeleteNewLines = 1, + Block = 1, + Smart = 2, } -} -declare namespace ts.formatting { - class RuleOperation { - Context: RuleOperationContext; - Action: RuleAction; - constructor(Context: RuleOperationContext, Action: RuleAction); - toString(): string; - static create1(action: RuleAction): RuleOperation; - static create2(context: RuleOperationContext, action: RuleAction): RuleOperation; + 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; } -} -declare namespace ts.formatting { - class RuleOperationContext { - private customContextChecks; - constructor(...funcs: { - (context: FormattingContext): boolean; - }[]); - static Any: RuleOperationContext; - IsAny(): boolean; - InContext(context: FormattingContext): boolean; + interface DefinitionInfo { + fileName: string; + textSpan: TextSpan; + kind: string; + name: string; + containerKind: string; + containerName: string; } -} -declare namespace ts.formatting { - class Rules { - getRuleName(rule: Rule): string; - [name: string]: any; - IgnoreBeforeComment: Rule; - IgnoreAfterLineComment: Rule; - NoSpaceBeforeSemicolon: Rule; - NoSpaceBeforeColon: Rule; - NoSpaceBeforeQuestionMark: Rule; - SpaceAfterColon: Rule; - SpaceAfterQuestionMarkInConditionalOperator: Rule; - NoSpaceAfterQuestionMark: Rule; - SpaceAfterSemicolon: Rule; - SpaceAfterCloseBrace: Rule; - SpaceBetweenCloseBraceAndElse: Rule; - SpaceBetweenCloseBraceAndWhile: Rule; - NoSpaceAfterCloseBrace: Rule; - NoSpaceBeforeDot: Rule; - NoSpaceAfterDot: Rule; - NoSpaceBeforeOpenBracket: Rule; - NoSpaceAfterCloseBracket: Rule; - SpaceAfterOpenBrace: Rule; - SpaceBeforeCloseBrace: Rule; - NoSpaceBetweenEmptyBraceBrackets: Rule; - NewLineAfterOpenBraceInBlockContext: Rule; - NewLineBeforeCloseBraceInBlockContext: Rule; - NoSpaceAfterUnaryPrefixOperator: Rule; - NoSpaceAfterUnaryPreincrementOperator: Rule; - NoSpaceAfterUnaryPredecrementOperator: Rule; - NoSpaceBeforeUnaryPostincrementOperator: Rule; - NoSpaceBeforeUnaryPostdecrementOperator: Rule; - SpaceAfterPostincrementWhenFollowedByAdd: Rule; - SpaceAfterAddWhenFollowedByUnaryPlus: Rule; - SpaceAfterAddWhenFollowedByPreincrement: Rule; - SpaceAfterPostdecrementWhenFollowedBySubtract: Rule; - SpaceAfterSubtractWhenFollowedByUnaryMinus: Rule; - SpaceAfterSubtractWhenFollowedByPredecrement: Rule; - NoSpaceBeforeComma: Rule; - SpaceAfterCertainKeywords: Rule; - SpaceAfterLetConstInVariableDeclaration: Rule; - NoSpaceBeforeOpenParenInFuncCall: Rule; - SpaceAfterFunctionInFuncDecl: Rule; - NoSpaceBeforeOpenParenInFuncDecl: Rule; - SpaceAfterVoidOperator: Rule; - NoSpaceBetweenReturnAndSemicolon: Rule; - SpaceBetweenStatements: Rule; - SpaceAfterTryFinally: Rule; - SpaceAfterGetSetInMember: Rule; - SpaceBeforeBinaryKeywordOperator: Rule; - SpaceAfterBinaryKeywordOperator: Rule; - NoSpaceAfterConstructor: Rule; - NoSpaceAfterModuleImport: Rule; - SpaceAfterCertainTypeScriptKeywords: Rule; - SpaceBeforeCertainTypeScriptKeywords: Rule; - SpaceAfterModuleName: Rule; - SpaceBeforeArrow: Rule; - SpaceAfterArrow: Rule; - NoSpaceAfterEllipsis: Rule; - NoSpaceAfterOptionalParameters: Rule; - NoSpaceBeforeOpenAngularBracket: Rule; - NoSpaceBetweenCloseParenAndAngularBracket: Rule; - NoSpaceAfterOpenAngularBracket: Rule; - NoSpaceBeforeCloseAngularBracket: Rule; - NoSpaceAfterCloseAngularBracket: Rule; - NoSpaceAfterTypeAssertion: Rule; - NoSpaceBetweenEmptyInterfaceBraceBrackets: Rule; - HighPriorityCommonRules: Rule[]; - LowPriorityCommonRules: Rule[]; - SpaceAfterComma: Rule; - NoSpaceAfterComma: Rule; - SpaceBeforeBinaryOperator: Rule; - SpaceAfterBinaryOperator: Rule; - NoSpaceBeforeBinaryOperator: Rule; - NoSpaceAfterBinaryOperator: Rule; - SpaceAfterKeywordInControl: Rule; - NoSpaceAfterKeywordInControl: Rule; - FunctionOpenBraceLeftTokenRange: Shared.TokenRange; - SpaceBeforeOpenBraceInFunction: Rule; - NewLineBeforeOpenBraceInFunction: Rule; - TypeScriptOpenBraceLeftTokenRange: Shared.TokenRange; - SpaceBeforeOpenBraceInTypeScriptDeclWithBlock: Rule; - NewLineBeforeOpenBraceInTypeScriptDeclWithBlock: Rule; - ControlOpenBraceLeftTokenRange: Shared.TokenRange; - SpaceBeforeOpenBraceInControl: Rule; - NewLineBeforeOpenBraceInControl: Rule; - SpaceAfterSemicolonInFor: Rule; - NoSpaceAfterSemicolonInFor: Rule; - SpaceAfterOpenParen: Rule; - SpaceBeforeCloseParen: Rule; - NoSpaceBetweenParens: Rule; - NoSpaceAfterOpenParen: Rule; - NoSpaceBeforeCloseParen: Rule; - SpaceAfterOpenBracket: Rule; - SpaceBeforeCloseBracket: Rule; - NoSpaceBetweenBrackets: Rule; - NoSpaceAfterOpenBracket: Rule; - NoSpaceBeforeCloseBracket: Rule; - SpaceAfterAnonymousFunctionKeyword: Rule; - NoSpaceAfterAnonymousFunctionKeyword: Rule; - SpaceBeforeAt: Rule; - NoSpaceAfterAt: Rule; - SpaceAfterDecorator: Rule; - NoSpaceBetweenFunctionKeywordAndStar: Rule; - SpaceAfterStarInGeneratorDeclaration: Rule; - NoSpaceBetweenYieldKeywordAndStar: Rule; - SpaceBetweenYieldOrYieldStarAndOperand: Rule; - SpaceBetweenAsyncAndOpenParen: Rule; - SpaceBetweenAsyncAndFunctionKeyword: Rule; - NoSpaceBetweenTagAndTemplateString: Rule; - NoSpaceAfterTemplateHeadAndMiddle: Rule; - SpaceAfterTemplateHeadAndMiddle: Rule; - NoSpaceBeforeTemplateMiddleAndTail: Rule; - SpaceBeforeTemplateMiddleAndTail: Rule; - NoSpaceAfterOpenBraceInJsxExpression: Rule; - SpaceAfterOpenBraceInJsxExpression: Rule; - NoSpaceBeforeCloseBraceInJsxExpression: Rule; - SpaceBeforeCloseBraceInJsxExpression: Rule; - SpaceBeforeJsxAttribute: Rule; - SpaceBeforeSlashInJsxOpeningElement: Rule; - NoSpaceBeforeGreaterThanTokenInJsxOpeningElement: Rule; - NoSpaceBeforeEqualInJsxAttribute: Rule; - NoSpaceAfterEqualInJsxAttribute: Rule; - constructor(); - static IsForContext(context: FormattingContext): boolean; - static IsNotForContext(context: FormattingContext): boolean; - static IsBinaryOpContext(context: FormattingContext): boolean; - static IsNotBinaryOpContext(context: FormattingContext): boolean; - static IsConditionalOperatorContext(context: FormattingContext): boolean; - static IsSameLineTokenOrBeforeMultilineBlockContext(context: FormattingContext): boolean; - static IsBeforeMultilineBlockContext(context: FormattingContext): boolean; - static IsMultilineBlockContext(context: FormattingContext): boolean; - static IsSingleLineBlockContext(context: FormattingContext): boolean; - static IsBlockContext(context: FormattingContext): boolean; - static IsBeforeBlockContext(context: FormattingContext): boolean; - static NodeIsBlockContext(node: Node): boolean; - static IsFunctionDeclContext(context: FormattingContext): boolean; - static IsFunctionDeclarationOrFunctionExpressionContext(context: FormattingContext): boolean; - static IsTypeScriptDeclWithBlockContext(context: FormattingContext): boolean; - static NodeIsTypeScriptDeclWithBlockContext(node: Node): boolean; - static IsAfterCodeBlockContext(context: FormattingContext): boolean; - static IsControlDeclContext(context: FormattingContext): boolean; - static IsObjectContext(context: FormattingContext): boolean; - static IsFunctionCallContext(context: FormattingContext): boolean; - static IsNewContext(context: FormattingContext): boolean; - static IsFunctionCallOrNewContext(context: FormattingContext): boolean; - static IsPreviousTokenNotComma(context: FormattingContext): boolean; - static IsNextTokenNotCloseBracket(context: FormattingContext): boolean; - static IsArrowFunctionContext(context: FormattingContext): boolean; - static IsNonJsxSameLineTokenContext(context: FormattingContext): boolean; - static IsNonJsxElementContext(context: FormattingContext): boolean; - static IsJsxExpressionContext(context: FormattingContext): boolean; - static IsNextTokenParentJsxAttribute(context: FormattingContext): boolean; - static IsJsxAttributeContext(context: FormattingContext): boolean; - static IsJsxSelfClosingElementContext(context: FormattingContext): boolean; - static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean; - static IsEndOfDecoratorContextOnSameLine(context: FormattingContext): boolean; - static NodeIsInDecoratorContext(node: Node): boolean; - static IsStartOfVariableDeclarationList(context: FormattingContext): boolean; - static IsNotFormatOnEnter(context: FormattingContext): boolean; - static IsModuleDeclContext(context: FormattingContext): boolean; - static IsObjectTypeContext(context: FormattingContext): boolean; - static IsTypeArgumentOrParameterOrAssertion(token: TextRangeWithKind, parent: Node): boolean; - static IsTypeArgumentOrParameterOrAssertionContext(context: FormattingContext): boolean; - static IsTypeAssertionContext(context: FormattingContext): boolean; - static IsVoidOpContext(context: FormattingContext): boolean; - static IsYieldOrYieldStarWithOperand(context: FormattingContext): boolean; + interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { + displayParts: SymbolDisplayPart[]; } -} -declare namespace ts.formatting { - class RulesMap { - map: RulesBucket[]; - mapRowLength: number; - constructor(); - static create(rules: Rule[]): RulesMap; - Initialize(rules: Rule[]): RulesBucket[]; - FillRules(rules: Rule[], rulesBucketConstructionStateList: RulesBucketConstructionState[]): void; - private GetRuleBucketIndex(row, column); - private FillRule(rule, rulesBucketConstructionStateList); - GetRule(context: FormattingContext): Rule; + interface ReferencedSymbol { + definition: ReferencedSymbolDefinitionInfo; + references: ReferenceEntry[]; } - enum RulesPosition { - IgnoreRulesSpecific = 0, - IgnoreRulesAny, - ContextRulesSpecific, - ContextRulesAny, - NoContextRulesSpecific, - NoContextRulesAny, + enum SymbolDisplayPartKind { + aliasName = 0, + className = 1, + enumName = 2, + fieldName = 3, + interfaceName = 4, + keyword = 5, + lineBreak = 6, + numericLiteral = 7, + stringLiteral = 8, + localName = 9, + methodName = 10, + moduleName = 11, + operator = 12, + parameterName = 13, + propertyName = 14, + punctuation = 15, + space = 16, + text = 17, + typeParameterName = 18, + enumMemberName = 19, + functionName = 20, + regularExpressionLiteral = 21, } - class RulesBucketConstructionState { - private rulesInsertionIndexBitmap; - constructor(); - GetInsertionIndex(maskPosition: RulesPosition): number; - IncreaseInsertionIndex(maskPosition: RulesPosition): void; + interface SymbolDisplayPart { + text: string; + kind: string; } - class RulesBucket { - private rules; - constructor(); - Rules(): Rule[]; - AddRule(rule: Rule, specificTokens: boolean, constructionState: RulesBucketConstructionState[], rulesBucketIndex: number): void; + interface QuickInfo { + kind: string; + kindModifiers: string; + textSpan: TextSpan; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; } -} -declare namespace ts.formatting { - namespace Shared { - interface ITokenAccess { - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - } - class TokenRangeAccess implements ITokenAccess { - private tokens; - constructor(from: SyntaxKind, to: SyntaxKind, except: SyntaxKind[]); - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - } - class TokenValuesAccess implements ITokenAccess { - private tokens; - constructor(tks: SyntaxKind[]); - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - } - class TokenSingleValueAccess implements ITokenAccess { - token: SyntaxKind; - constructor(token: SyntaxKind); - GetTokens(): SyntaxKind[]; - Contains(tokenValue: SyntaxKind): boolean; - } - class TokenAllAccess implements ITokenAccess { - GetTokens(): SyntaxKind[]; - Contains(tokenValue: SyntaxKind): boolean; - toString(): string; - } - class TokenRange { - tokenAccess: ITokenAccess; - constructor(tokenAccess: ITokenAccess); - static FromToken(token: SyntaxKind): TokenRange; - static FromTokens(tokens: SyntaxKind[]): TokenRange; - static FromRange(f: SyntaxKind, to: SyntaxKind, except?: SyntaxKind[]): TokenRange; - static AllTokens(): TokenRange; - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - toString(): string; - static Any: TokenRange; - static AnyIncludingMultilineComments: TokenRange; - static Keywords: TokenRange; - static BinaryOperators: TokenRange; - static BinaryKeywordOperators: TokenRange; - static UnaryPrefixOperators: TokenRange; - static UnaryPrefixExpressions: TokenRange; - static UnaryPreincrementExpressions: TokenRange; - static UnaryPostincrementExpressions: TokenRange; - static UnaryPredecrementExpressions: TokenRange; - static UnaryPostdecrementExpressions: TokenRange; - static Comments: TokenRange; - static TypeNames: TokenRange; - } + interface RenameInfo { + canRename: boolean; + localizedErrorMessage: string; + displayName: string; + fullDisplayName: string; + kind: string; + kindModifiers: string; + triggerSpan: TextSpan; } -} -declare namespace ts.formatting { - class RulesProvider { - private globalRules; - private options; - private activeRules; - private rulesMap; - constructor(); - getRuleName(rule: Rule): string; - getRuleByName(name: string): Rule; - getRulesMap(): RulesMap; - ensureUpToDate(options: ts.FormatCodeOptions): void; - private createActiveRules(options); + interface SignatureHelpParameter { + name: string; + documentation: SymbolDisplayPart[]; + displayParts: SymbolDisplayPart[]; + isOptional: boolean; } -} -declare namespace ts.formatting { - interface TextRangeWithKind extends TextRange { - kind: SyntaxKind; + /** + * 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?'. + */ + interface SignatureHelpItem { + isVariadic: boolean; + prefixDisplayParts: SymbolDisplayPart[]; + suffixDisplayParts: SymbolDisplayPart[]; + separatorDisplayParts: SymbolDisplayPart[]; + parameters: SignatureHelpParameter[]; + documentation: SymbolDisplayPart[]; } - interface TokenInfo { - leadingTrivia: TextRangeWithKind[]; - token: TextRangeWithKind; - trailingTrivia: TextRangeWithKind[]; + /** + * Represents a set of signature help items, and the preferred item that should be selected. + */ + interface SignatureHelpItems { + items: SignatureHelpItem[]; + applicableSpan: TextSpan; + selectedItemIndex: number; + argumentIndex: number; + argumentCount: number; } - function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; - function formatOnSemicolon(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; - function formatOnClosingCurly(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; - function formatDocument(sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; - function formatSelection(start: number, end: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; - function getIndentationString(indentation: number, options: FormatCodeOptions): string; -} -declare namespace ts.formatting { - namespace SmartIndenter { - function getIndentation(position: number, sourceFile: SourceFile, options: EditorOptions): number; - function getBaseIndentation(options: EditorOptions): number; - function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: FormatCodeOptions): number; - function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean; - function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorOptions): { - column: number; - character: number; - }; - function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorOptions): number; - function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind, indentByDefault: boolean): boolean; - function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind): boolean; + interface CompletionInfo { + isMemberCompletion: boolean; + isNewIdentifierLocation: boolean; + entries: CompletionEntry[]; } -} -declare namespace ts { - /** The version of the language service API */ - const servicesVersion: string; - 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; + interface CompletionEntry { + name: string; + kind: string; + kindModifiers: string; + sortText: string; } - interface Symbol { - getFlags(): SymbolFlags; - getName(): string; - getDeclarations(): Declaration[]; - getDocumentationComment(): SymbolDisplayPart[]; + interface CompletionEntryDetails { + name: string; + kind: string; + kindModifiers: string; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; } - 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; + 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; } - interface Signature { - getDeclaration(): SignatureDeclaration; - getTypeParameters(): Type[]; - getParameters(): Symbol[]; - getReturnType(): Type; - getDocumentationComment(): SymbolDisplayPart[]; + interface EmitOutput { + outputFiles: OutputFile[]; + emitSkipped: boolean; } - interface SourceFile { - version: string; - scriptSnapshot: IScriptSnapshot; - nameTable: Map; - getNamedDeclarations(): Map; - getLineAndCharacterOfPosition(pos: number): LineAndCharacter; - getLineStarts(): number[]; - getPositionOfLineAndCharacter(line: number, character: number): number; - update(newText: string, textChangeRange: TextChangeRange): SourceFile; + const enum OutputFileType { + JavaScript = 0, + SourceMap = 1, + Declaration = 2, } - /** - * 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. - */ - 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; + interface OutputFile { + name: string; + writeByteOrderMark: boolean; + text: string; } - namespace ScriptSnapshot { - function fromString(text: string): IScriptSnapshot; + const enum EndOfLineState { + None = 0, + InMultiLineCommentTrivia = 1, + InSingleQuoteStringLiteral = 2, + InDoubleQuoteStringLiteral = 3, + InTemplateHeadOrNoSubstitutionTemplate = 4, + InTemplateMiddleOrTail = 5, + InTemplateSubstitutionPosition = 6, } - interface PreProcessedFileInfo { - referencedFiles: FileReference[]; - typeReferenceDirectives: FileReference[]; - importedFiles: FileReference[]; - ambientExternalModules: string[]; - isLibFile: boolean; + enum TokenClass { + Punctuation = 0, + Keyword = 1, + Operator = 2, + Comment = 3, + Whitespace = 4, + Identifier = 5, + NumberLiteral = 6, + StringLiteral = 7, + RegExpLiteral = 8, } - interface HostCancellationToken { - isCancellationRequested(): boolean; + interface ClassificationResult { + finalLexState: EndOfLineState; + entries: ClassificationInfo[]; } - 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; - resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; - resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; - directoryExists?(directoryName: string): boolean; - getDirectories?(directoryName: string): string[]; + interface ClassificationInfo { + length: number; + classification: TokenClass; } - interface LanguageService { - cleanupSemanticCache(): void; - getSyntacticDiagnostics(fileName: string): Diagnostic[]; - getSemanticDiagnostics(fileName: string): Diagnostic[]; - getCompilerOptionsDiagnostics(): Diagnostic[]; - /** - * @deprecated Use getEncodedSyntacticClassifications instead. - */ - getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + interface Classifier { /** - * @deprecated Use getEncodedSemanticClassifications instead. + * 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. */ - getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; - 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; - getNonBoundSourceFile(fileName: string): SourceFile; - dispose(): void; - } - interface Classifications { - spans: number[]; - endOfLineState: EndOfLineState; - } - interface ClassifiedSpan { - textSpan: TextSpan; - classificationType: string; - } - interface NavigationBarItem { - text: string; - kind: string; - kindModifiers: string; - spans: TextSpan[]; - childItems: NavigationBarItem[]; - indent: number; - bolded: boolean; - grayed: boolean; - } - interface TodoCommentDescriptor { - text: string; - priority: number; + getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult; + getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications; } - interface TodoComment { - descriptor: TodoCommentDescriptor; - message: string; - position: number; + /** + * 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. + */ + 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; } - class TextChange { - span: TextSpan; - newText: string; + type DocumentRegistryBucketKey = string & { + __bucketKey: any; + }; + namespace ScriptElementKind { + const unknown: string; + const warning: string; + /** predefined type (void) or keyword (class) */ + const keyword: string; + /** top level script node */ + const scriptElement: string; + /** module foo {} */ + const moduleElement: string; + /** class X {} */ + const classElement: string; + /** var x = class X {} */ + const localClassElement: string; + /** interface Y {} */ + const interfaceElement: string; + /** type T = ... */ + const typeElement: string; + /** enum E */ + const enumElement: string; + const enumMemberElement: string; + /** + * Inside module and script only + * const v = .. + */ + const variableElement: string; + /** Inside function */ + const localVariableElement: string; + /** + * Inside module and script only + * function f() { } + */ + const functionElement: string; + /** Inside function */ + const localFunctionElement: string; + /** class X { [public|private]* foo() {} } */ + const memberFunctionElement: string; + /** class X { [public|private]* [get|set] foo:number; } */ + const memberGetAccessorElement: string; + const memberSetAccessorElement: string; + /** + * class X { [public|private]* foo:number; } + * interface Y { foo:number; } + */ + const memberVariableElement: string; + /** class X { constructor() { } } */ + const constructorImplementationElement: string; + /** interface Y { ():number; } */ + const callSignatureElement: string; + /** interface Y { []:number; } */ + const indexSignatureElement: string; + /** interface Y { new():Y; } */ + const constructSignatureElement: string; + /** function foo(*Y*: string) */ + const parameterElement: string; + const typeParameterElement: string; + const primitiveType: string; + const label: string; + const alias: string; + const constElement: string; + const letElement: string; } - interface TextInsertion { - newText: string; - /** The position in newText the caret should point to after the insertion. */ - caretOffset: number; + namespace ScriptElementKindModifier { + const none: string; + const publicMemberModifier: string; + const privateMemberModifier: string; + const protectedMemberModifier: string; + const exportedModifier: string; + const ambientModifier: string; + const staticModifier: string; + const abstractModifier: string; } - interface RenameLocation { - textSpan: TextSpan; - fileName: string; + class ClassificationTypeNames { + static comment: string; + static identifier: string; + static keyword: string; + static numericLiteral: string; + static operator: string; + static stringLiteral: string; + static whiteSpace: string; + static text: string; + static punctuation: string; + static className: string; + static enumName: string; + static interfaceName: string; + static moduleName: string; + static typeParameterName: string; + static typeAliasName: string; + static parameterName: string; + static docCommentTagName: string; + static jsxOpenTagName: string; + static jsxCloseTagName: string; + static jsxSelfClosingTagName: string; + static jsxAttribute: string; + static jsxText: string; + static jsxAttributeStringLiteralValue: string; } - interface ReferenceEntry { - textSpan: TextSpan; - fileName: string; - isWriteAccess: boolean; - isDefinition: boolean; + 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, } - interface DocumentHighlights { - fileName: string; - highlightSpans: HighlightSpan[]; +} +declare namespace ts { + interface ListItemInfo { + listItemIndex: number; + list: Node; } - namespace HighlightSpanKind { - const none: string; - const definition: string; - const reference: string; - const writtenReference: string; + function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number; + function rangeContainsRange(r1: TextRange, r2: TextRange): boolean; + function startEndContainsRange(start: number, end: number, range: TextRange): boolean; + function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean; + function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean; + function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean; + function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean; + function isCompletedNode(n: Node, sourceFile: SourceFile): boolean; + function findListItemInfo(node: Node): ListItemInfo; + function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean; + function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node; + function findContainingList(node: Node): Node; + function getTouchingWord(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; + function getTouchingPropertyName(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; + /** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */ + function getTouchingToken(sourceFile: SourceFile, position: number, includeItemAtEndPosition?: (n: Node) => boolean, includeJsDocComment?: boolean): Node; + /** Returns a token if position is in [start-of-leading-trivia, end) */ + function getTokenAtPosition(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; + /** + * The token on the left of the position is the token that strictly includes the position + * or sits to the left of the cursor if it is on a boundary. For example + * + * fo|o -> will return foo + * foo |bar -> will return foo + * + */ + function findTokenOnLeftOfPosition(file: SourceFile, position: number): Node; + function findNextToken(previousToken: Node, parent: Node): Node; + function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node): Node; + function isInString(sourceFile: SourceFile, position: number): boolean; + function isInComment(sourceFile: SourceFile, position: number): boolean; + /** + * returns true if the position is in between the open and close elements of an JSX expression. + */ + function isInsideJsxElementOrAttribute(sourceFile: SourceFile, position: number): boolean; + function isInTemplateString(sourceFile: SourceFile, position: number): boolean; + /** + * Returns true if the cursor at position in sourceFile is within a comment that additionally + * satisfies predicate, and false otherwise. + */ + function isInCommentHelper(sourceFile: SourceFile, position: number, predicate?: (c: CommentRange) => boolean): boolean; + function hasDocComment(sourceFile: SourceFile, position: number): boolean; + /** + * Get the corresponding JSDocTag node if the position is in a jsDoc comment + */ + function getJsDocTagAtPosition(sourceFile: SourceFile, position: number): JSDocTag; + function getNodeModifiers(node: Node): string; + function getTypeArgumentOrTypeParameterList(node: Node): NodeArray; + function isToken(n: Node): boolean; + function isWord(kind: SyntaxKind): boolean; + function isComment(kind: SyntaxKind): boolean; + function isStringOrRegularExpressionOrTemplateLiteral(kind: SyntaxKind): boolean; + function isPunctuation(kind: SyntaxKind): boolean; + function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean; + function isAccessibilityModifier(kind: SyntaxKind): boolean; + function compareDataObjects(dst: any, src: any): boolean; + function isArrayLiteralOrObjectLiteralDestructuringPattern(node: Node): boolean; +} +declare namespace ts { + function isFirstDeclarationOfSymbolParameter(symbol: Symbol): boolean; + function symbolPart(text: string, symbol: Symbol): SymbolDisplayPart; + function displayPart(text: string, kind: SymbolDisplayPartKind, symbol?: Symbol): SymbolDisplayPart; + function spacePart(): SymbolDisplayPart; + function keywordPart(kind: SyntaxKind): SymbolDisplayPart; + function punctuationPart(kind: SyntaxKind): SymbolDisplayPart; + function operatorPart(kind: SyntaxKind): SymbolDisplayPart; + function textOrKeywordPart(text: string): SymbolDisplayPart; + function textPart(text: string): SymbolDisplayPart; + /** + * The default is CRLF. + */ + function getNewLineOrDefaultFromHost(host: LanguageServiceHost | LanguageServiceShimHost): string; + function lineBreakPart(): SymbolDisplayPart; + function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[]; + function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; + function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): SymbolDisplayPart[]; + function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; + function getDeclaredName(typeChecker: TypeChecker, symbol: Symbol, location: Node): string; + function isImportOrExportSpecifierName(location: Node): boolean; + /** + * Strip off existed single quotes or double quotes from a given string + * + * @return non-quoted string + */ + function stripQuotes(name: string): string; + function scriptKindIs(fileName: string, host: LanguageServiceHost, ...scriptKinds: ScriptKind[]): boolean; + function getScriptKind(fileName: string, host?: LanguageServiceHost): ScriptKind; + function parseAndReEmitConfigJSONFile(content: string): { + configJsonObject: any; + diagnostics: Diagnostic[]; + }; +} +declare namespace ts.JsTyping { + interface TypingResolutionHost { + directoryExists: (path: string) => boolean; + fileExists: (fileName: string) => boolean; + readFile: (path: string, encoding?: string) => string; + readDirectory: (rootDir: string, extensions: string[], excludes: string[], includes: string[], depth?: number) => string[]; } - interface HighlightSpan { - fileName?: string; - textSpan: TextSpan; - kind: string; + /** + * @param host is the object providing I/O related operations. + * @param fileNames are the file names that belong to the same project + * @param projectRootPath is the path to the project root directory + * @param safeListPath is the path used to retrieve the safe list + * @param packageNameToTypingLocation is the map of package names to their cached typing locations + * @param typingOptions are used to customize the typing inference process + * @param compilerOptions are used as a source for typing inference + */ + function discoverTypings(host: TypingResolutionHost, fileNames: string[], projectRootPath: Path, safeListPath: Path, packageNameToTypingLocation: Map, typingOptions: TypingOptions, compilerOptions: CompilerOptions): { + cachedTypingPaths: string[]; + newTypingNames: string[]; + filesToWatch: string[]; + }; +} +declare namespace ts.formatting { + interface FormattingScanner { + advance(): void; + isOnToken(): boolean; + readTokenInfo(n: Node): TokenInfo; + getCurrentLeadingTrivia(): TextRangeWithKind[]; + lastTrailingTriviaWasNewLine(): boolean; + skipToEndOf(node: Node): void; + close(): void; } - interface NavigateToItem { - name: string; - kind: string; - kindModifiers: string; - matchKind: string; - isCaseSensitive: boolean; - fileName: string; - textSpan: TextSpan; - containerName: string; - containerKind: string; + function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner; +} +declare namespace ts.formatting { + class FormattingContext { + sourceFile: SourceFile; + formattingRequestKind: FormattingRequestKind; + currentTokenSpan: TextRangeWithKind; + nextTokenSpan: TextRangeWithKind; + contextNode: Node; + currentTokenParent: Node; + nextTokenParent: Node; + private contextNodeAllOnSameLine; + private nextNodeAllOnSameLine; + private tokensAreOnSameLine; + private contextNodeBlockIsOnOneLine; + private nextNodeBlockIsOnOneLine; + constructor(sourceFile: SourceFile, formattingRequestKind: FormattingRequestKind); + updateContext(currentRange: TextRangeWithKind, currentTokenParent: Node, nextRange: TextRangeWithKind, nextTokenParent: Node, commonParent: Node): void; + ContextNodeAllOnSameLine(): boolean; + NextNodeAllOnSameLine(): boolean; + TokensAreOnSameLine(): boolean; + ContextNodeBlockIsOnOneLine(): boolean; + NextNodeBlockIsOnOneLine(): boolean; + private NodeIsOnOneLine(node); + private BlockIsOnOneLine(node); } - interface EditorOptions { - BaseIndentSize?: number; - IndentSize: number; - TabSize: number; - NewLineCharacter: string; - ConvertTabsToSpaces: boolean; - IndentStyle: IndentStyle; +} +declare namespace ts.formatting { + const enum FormattingRequestKind { + FormatDocument = 0, + FormatSelection = 1, + FormatOnEnter = 2, + FormatOnSemicolon = 3, + FormatOnClosingCurlyBrace = 4, } - enum IndentStyle { - None = 0, - Block = 1, - Smart = 2, +} +declare namespace ts.formatting { + class Rule { + Descriptor: RuleDescriptor; + Operation: RuleOperation; + Flag: RuleFlags; + constructor(Descriptor: RuleDescriptor, Operation: RuleOperation, Flag?: RuleFlags); + toString(): string; } - 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; +} +declare namespace ts.formatting { + const enum RuleAction { + Ignore = 1, + Space = 2, + NewLine = 4, + Delete = 8, } - interface DefinitionInfo { - fileName: string; - textSpan: TextSpan; - kind: string; - name: string; - containerKind: string; - containerName: string; +} +declare namespace ts.formatting { + class RuleDescriptor { + LeftTokenRange: Shared.TokenRange; + RightTokenRange: Shared.TokenRange; + constructor(LeftTokenRange: Shared.TokenRange, RightTokenRange: Shared.TokenRange); + toString(): string; + static create1(left: SyntaxKind, right: SyntaxKind): RuleDescriptor; + static create2(left: Shared.TokenRange, right: SyntaxKind): RuleDescriptor; + static create3(left: SyntaxKind, right: Shared.TokenRange): RuleDescriptor; + static create4(left: Shared.TokenRange, right: Shared.TokenRange): RuleDescriptor; } - interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { - displayParts: SymbolDisplayPart[]; +} +declare namespace ts.formatting { + const enum RuleFlags { + None = 0, + CanDeleteNewLines = 1, } - interface ReferencedSymbol { - definition: ReferencedSymbolDefinitionInfo; - references: ReferenceEntry[]; +} +declare namespace ts.formatting { + class RuleOperation { + Context: RuleOperationContext; + Action: RuleAction; + constructor(Context: RuleOperationContext, Action: RuleAction); + toString(): string; + static create1(action: RuleAction): RuleOperation; + static create2(context: RuleOperationContext, action: RuleAction): RuleOperation; } - enum SymbolDisplayPartKind { - aliasName = 0, - className = 1, - enumName = 2, - fieldName = 3, - interfaceName = 4, - keyword = 5, - lineBreak = 6, - numericLiteral = 7, - stringLiteral = 8, - localName = 9, - methodName = 10, - moduleName = 11, - operator = 12, - parameterName = 13, - propertyName = 14, - punctuation = 15, - space = 16, - text = 17, - typeParameterName = 18, - enumMemberName = 19, - functionName = 20, - regularExpressionLiteral = 21, - } - interface SymbolDisplayPart { - text: string; - kind: string; - } - interface QuickInfo { - kind: string; - kindModifiers: string; - textSpan: TextSpan; - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - } - interface RenameInfo { - canRename: boolean; - localizedErrorMessage: string; - displayName: string; - fullDisplayName: string; - kind: string; - kindModifiers: string; - triggerSpan: TextSpan; - } - 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?'. - */ - 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. - */ - interface SignatureHelpItems { - items: SignatureHelpItem[]; - applicableSpan: TextSpan; - selectedItemIndex: number; - argumentIndex: number; - argumentCount: number; - } - interface CompletionInfo { - isMemberCompletion: boolean; - isNewIdentifierLocation: boolean; - entries: CompletionEntry[]; - } - interface CompletionEntry { - name: string; - kind: string; - kindModifiers: string; - sortText: string; - } - interface CompletionEntryDetails { - name: string; - kind: string; - kindModifiers: string; - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - } - 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; - } - interface EmitOutput { - outputFiles: OutputFile[]; - emitSkipped: boolean; - } - const enum OutputFileType { - JavaScript = 0, - SourceMap = 1, - Declaration = 2, - } - interface OutputFile { - name: string; - writeByteOrderMark: boolean; - text: string; - } - const enum EndOfLineState { - None = 0, - InMultiLineCommentTrivia = 1, - InSingleQuoteStringLiteral = 2, - InDoubleQuoteStringLiteral = 3, - InTemplateHeadOrNoSubstitutionTemplate = 4, - InTemplateMiddleOrTail = 5, - InTemplateSubstitutionPosition = 6, - } - enum TokenClass { - Punctuation = 0, - Keyword = 1, - Operator = 2, - Comment = 3, - Whitespace = 4, - Identifier = 5, - NumberLiteral = 6, - StringLiteral = 7, - RegExpLiteral = 8, - } - interface ClassificationResult { - finalLexState: EndOfLineState; - entries: ClassificationInfo[]; - } - interface ClassificationInfo { - length: number; - classification: TokenClass; - } - 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; +} +declare namespace ts.formatting { + class RuleOperationContext { + private customContextChecks; + constructor(...funcs: { + (context: FormattingContext): boolean; + }[]); + static Any: RuleOperationContext; + IsAny(): boolean; + InContext(context: FormattingContext): boolean; } - /** - * 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. - */ - 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; +} +declare namespace ts.formatting { + class Rules { + getRuleName(rule: Rule): string; + [name: string]: any; + IgnoreBeforeComment: Rule; + IgnoreAfterLineComment: Rule; + NoSpaceBeforeSemicolon: Rule; + NoSpaceBeforeColon: Rule; + NoSpaceBeforeQuestionMark: Rule; + SpaceAfterColon: Rule; + SpaceAfterQuestionMarkInConditionalOperator: Rule; + NoSpaceAfterQuestionMark: Rule; + SpaceAfterSemicolon: Rule; + SpaceAfterCloseBrace: Rule; + SpaceBetweenCloseBraceAndElse: Rule; + SpaceBetweenCloseBraceAndWhile: Rule; + NoSpaceAfterCloseBrace: Rule; + NoSpaceBeforeDot: Rule; + NoSpaceAfterDot: Rule; + NoSpaceBeforeOpenBracket: Rule; + NoSpaceAfterCloseBracket: Rule; + SpaceAfterOpenBrace: Rule; + SpaceBeforeCloseBrace: Rule; + NoSpaceBetweenEmptyBraceBrackets: Rule; + NewLineAfterOpenBraceInBlockContext: Rule; + NewLineBeforeCloseBraceInBlockContext: Rule; + NoSpaceAfterUnaryPrefixOperator: Rule; + NoSpaceAfterUnaryPreincrementOperator: Rule; + NoSpaceAfterUnaryPredecrementOperator: Rule; + NoSpaceBeforeUnaryPostincrementOperator: Rule; + NoSpaceBeforeUnaryPostdecrementOperator: Rule; + SpaceAfterPostincrementWhenFollowedByAdd: Rule; + SpaceAfterAddWhenFollowedByUnaryPlus: Rule; + SpaceAfterAddWhenFollowedByPreincrement: Rule; + SpaceAfterPostdecrementWhenFollowedBySubtract: Rule; + SpaceAfterSubtractWhenFollowedByUnaryMinus: Rule; + SpaceAfterSubtractWhenFollowedByPredecrement: Rule; + NoSpaceBeforeComma: Rule; + SpaceAfterCertainKeywords: Rule; + SpaceAfterLetConstInVariableDeclaration: Rule; + NoSpaceBeforeOpenParenInFuncCall: Rule; + SpaceAfterFunctionInFuncDecl: Rule; + NoSpaceBeforeOpenParenInFuncDecl: Rule; + SpaceAfterVoidOperator: Rule; + NoSpaceBetweenReturnAndSemicolon: Rule; + SpaceBetweenStatements: Rule; + SpaceAfterTryFinally: Rule; + SpaceAfterGetSetInMember: Rule; + SpaceBeforeBinaryKeywordOperator: Rule; + SpaceAfterBinaryKeywordOperator: Rule; + NoSpaceAfterConstructor: Rule; + NoSpaceAfterModuleImport: Rule; + SpaceAfterCertainTypeScriptKeywords: Rule; + SpaceBeforeCertainTypeScriptKeywords: Rule; + SpaceAfterModuleName: Rule; + SpaceBeforeArrow: Rule; + SpaceAfterArrow: Rule; + NoSpaceAfterEllipsis: Rule; + NoSpaceAfterOptionalParameters: Rule; + NoSpaceBeforeOpenAngularBracket: Rule; + NoSpaceBetweenCloseParenAndAngularBracket: Rule; + NoSpaceAfterOpenAngularBracket: Rule; + NoSpaceBeforeCloseAngularBracket: Rule; + NoSpaceAfterCloseAngularBracket: Rule; + NoSpaceAfterTypeAssertion: Rule; + NoSpaceBetweenEmptyInterfaceBraceBrackets: Rule; + HighPriorityCommonRules: Rule[]; + LowPriorityCommonRules: Rule[]; + SpaceAfterComma: Rule; + NoSpaceAfterComma: Rule; + SpaceBeforeBinaryOperator: Rule; + SpaceAfterBinaryOperator: Rule; + NoSpaceBeforeBinaryOperator: Rule; + NoSpaceAfterBinaryOperator: Rule; + SpaceAfterKeywordInControl: Rule; + NoSpaceAfterKeywordInControl: Rule; + FunctionOpenBraceLeftTokenRange: Shared.TokenRange; + SpaceBeforeOpenBraceInFunction: Rule; + NewLineBeforeOpenBraceInFunction: Rule; + TypeScriptOpenBraceLeftTokenRange: Shared.TokenRange; + SpaceBeforeOpenBraceInTypeScriptDeclWithBlock: Rule; + NewLineBeforeOpenBraceInTypeScriptDeclWithBlock: Rule; + ControlOpenBraceLeftTokenRange: Shared.TokenRange; + SpaceBeforeOpenBraceInControl: Rule; + NewLineBeforeOpenBraceInControl: Rule; + SpaceAfterSemicolonInFor: Rule; + NoSpaceAfterSemicolonInFor: Rule; + SpaceAfterOpenParen: Rule; + SpaceBeforeCloseParen: Rule; + NoSpaceBetweenParens: Rule; + NoSpaceAfterOpenParen: Rule; + NoSpaceBeforeCloseParen: Rule; + SpaceAfterOpenBracket: Rule; + SpaceBeforeCloseBracket: Rule; + NoSpaceBetweenBrackets: Rule; + NoSpaceAfterOpenBracket: Rule; + NoSpaceBeforeCloseBracket: Rule; + SpaceAfterAnonymousFunctionKeyword: Rule; + NoSpaceAfterAnonymousFunctionKeyword: Rule; + SpaceBeforeAt: Rule; + NoSpaceAfterAt: Rule; + SpaceAfterDecorator: Rule; + NoSpaceBetweenFunctionKeywordAndStar: Rule; + SpaceAfterStarInGeneratorDeclaration: Rule; + NoSpaceBetweenYieldKeywordAndStar: Rule; + SpaceBetweenYieldOrYieldStarAndOperand: Rule; + SpaceBetweenAsyncAndOpenParen: Rule; + SpaceBetweenAsyncAndFunctionKeyword: Rule; + NoSpaceBetweenTagAndTemplateString: Rule; + NoSpaceAfterTemplateHeadAndMiddle: Rule; + SpaceAfterTemplateHeadAndMiddle: Rule; + NoSpaceBeforeTemplateMiddleAndTail: Rule; + SpaceBeforeTemplateMiddleAndTail: Rule; + NoSpaceAfterOpenBraceInJsxExpression: Rule; + SpaceAfterOpenBraceInJsxExpression: Rule; + NoSpaceBeforeCloseBraceInJsxExpression: Rule; + SpaceBeforeCloseBraceInJsxExpression: Rule; + SpaceBeforeJsxAttribute: Rule; + SpaceBeforeSlashInJsxOpeningElement: Rule; + NoSpaceBeforeGreaterThanTokenInJsxOpeningElement: Rule; + NoSpaceBeforeEqualInJsxAttribute: Rule; + NoSpaceAfterEqualInJsxAttribute: Rule; + constructor(); + static IsForContext(context: FormattingContext): boolean; + static IsNotForContext(context: FormattingContext): boolean; + static IsBinaryOpContext(context: FormattingContext): boolean; + static IsNotBinaryOpContext(context: FormattingContext): boolean; + static IsConditionalOperatorContext(context: FormattingContext): boolean; + static IsSameLineTokenOrBeforeMultilineBlockContext(context: FormattingContext): boolean; + static IsBeforeMultilineBlockContext(context: FormattingContext): boolean; + static IsMultilineBlockContext(context: FormattingContext): boolean; + static IsSingleLineBlockContext(context: FormattingContext): boolean; + static IsBlockContext(context: FormattingContext): boolean; + static IsBeforeBlockContext(context: FormattingContext): boolean; + static NodeIsBlockContext(node: Node): boolean; + static IsFunctionDeclContext(context: FormattingContext): boolean; + static IsFunctionDeclarationOrFunctionExpressionContext(context: FormattingContext): boolean; + static IsTypeScriptDeclWithBlockContext(context: FormattingContext): boolean; + static NodeIsTypeScriptDeclWithBlockContext(node: Node): boolean; + static IsAfterCodeBlockContext(context: FormattingContext): boolean; + static IsControlDeclContext(context: FormattingContext): boolean; + static IsObjectContext(context: FormattingContext): boolean; + static IsFunctionCallContext(context: FormattingContext): boolean; + static IsNewContext(context: FormattingContext): boolean; + static IsFunctionCallOrNewContext(context: FormattingContext): boolean; + static IsPreviousTokenNotComma(context: FormattingContext): boolean; + static IsNextTokenNotCloseBracket(context: FormattingContext): boolean; + static IsArrowFunctionContext(context: FormattingContext): boolean; + static IsNonJsxSameLineTokenContext(context: FormattingContext): boolean; + static IsNonJsxElementContext(context: FormattingContext): boolean; + static IsJsxExpressionContext(context: FormattingContext): boolean; + static IsNextTokenParentJsxAttribute(context: FormattingContext): boolean; + static IsJsxAttributeContext(context: FormattingContext): boolean; + static IsJsxSelfClosingElementContext(context: FormattingContext): boolean; + static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean; + static IsEndOfDecoratorContextOnSameLine(context: FormattingContext): boolean; + static NodeIsInDecoratorContext(node: Node): boolean; + static IsStartOfVariableDeclarationList(context: FormattingContext): boolean; + static IsNotFormatOnEnter(context: FormattingContext): boolean; + static IsModuleDeclContext(context: FormattingContext): boolean; + static IsObjectTypeContext(context: FormattingContext): boolean; + static IsTypeArgumentOrParameterOrAssertion(token: TextRangeWithKind, parent: Node): boolean; + static IsTypeArgumentOrParameterOrAssertionContext(context: FormattingContext): boolean; + static IsTypeAssertionContext(context: FormattingContext): boolean; + static IsVoidOpContext(context: FormattingContext): boolean; + static IsYieldOrYieldStarWithOperand(context: FormattingContext): boolean; } - type DocumentRegistryBucketKey = string & { - __bucketKey: any; - }; - namespace ScriptElementKind { - const unknown: string; - const warning: string; - /** predefined type (void) or keyword (class) */ - const keyword: string; - /** top level script node */ - const scriptElement: string; - /** module foo {} */ - const moduleElement: string; - /** class X {} */ - const classElement: string; - /** var x = class X {} */ - const localClassElement: string; - /** interface Y {} */ - const interfaceElement: string; - /** type T = ... */ - const typeElement: string; - /** enum E */ - const enumElement: string; - const enumMemberElement: string; - /** - * Inside module and script only - * const v = .. - */ - const variableElement: string; - /** Inside function */ - const localVariableElement: string; - /** - * Inside module and script only - * function f() { } - */ - const functionElement: string; - /** Inside function */ - const localFunctionElement: string; - /** class X { [public|private]* foo() {} } */ - const memberFunctionElement: string; - /** class X { [public|private]* [get|set] foo:number; } */ - const memberGetAccessorElement: string; - const memberSetAccessorElement: string; - /** - * class X { [public|private]* foo:number; } - * interface Y { foo:number; } - */ - const memberVariableElement: string; - /** class X { constructor() { } } */ - const constructorImplementationElement: string; - /** interface Y { ():number; } */ - const callSignatureElement: string; - /** interface Y { []:number; } */ - const indexSignatureElement: string; - /** interface Y { new():Y; } */ - const constructSignatureElement: string; - /** function foo(*Y*: string) */ - const parameterElement: string; - const typeParameterElement: string; - const primitiveType: string; - const label: string; - const alias: string; - const constElement: string; - const letElement: string; +} +declare namespace ts.formatting { + class RulesMap { + map: RulesBucket[]; + mapRowLength: number; + constructor(); + static create(rules: Rule[]): RulesMap; + Initialize(rules: Rule[]): RulesBucket[]; + FillRules(rules: Rule[], rulesBucketConstructionStateList: RulesBucketConstructionState[]): void; + private GetRuleBucketIndex(row, column); + private FillRule(rule, rulesBucketConstructionStateList); + GetRule(context: FormattingContext): Rule; } - namespace ScriptElementKindModifier { - const none: string; - const publicMemberModifier: string; - const privateMemberModifier: string; - const protectedMemberModifier: string; - const exportedModifier: string; - const ambientModifier: string; - const staticModifier: string; - const abstractModifier: string; + enum RulesPosition { + IgnoreRulesSpecific = 0, + IgnoreRulesAny, + ContextRulesSpecific, + ContextRulesAny, + NoContextRulesSpecific, + NoContextRulesAny, } - class ClassificationTypeNames { - static comment: string; - static identifier: string; - static keyword: string; - static numericLiteral: string; - static operator: string; - static stringLiteral: string; - static whiteSpace: string; - static text: string; - static punctuation: string; - static className: string; - static enumName: string; - static interfaceName: string; - static moduleName: string; - static typeParameterName: string; - static typeAliasName: string; - static parameterName: string; - static docCommentTagName: string; - static jsxOpenTagName: string; - static jsxCloseTagName: string; - static jsxSelfClosingTagName: string; - static jsxAttribute: string; - static jsxText: string; - static jsxAttributeStringLiteralValue: string; + class RulesBucketConstructionState { + private rulesInsertionIndexBitmap; + constructor(); + GetInsertionIndex(maskPosition: RulesPosition): number; + IncreaseInsertionIndex(maskPosition: RulesPosition): void; } - 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, + class RulesBucket { + private rules; + constructor(); + Rules(): Rule[]; + AddRule(rule: Rule, specificTokens: boolean, constructionState: RulesBucketConstructionState[], rulesBucketIndex: number): void; + } +} +declare namespace ts.formatting { + namespace Shared { + interface ITokenAccess { + GetTokens(): SyntaxKind[]; + Contains(token: SyntaxKind): boolean; + } + class TokenRangeAccess implements ITokenAccess { + private tokens; + constructor(from: SyntaxKind, to: SyntaxKind, except: SyntaxKind[]); + GetTokens(): SyntaxKind[]; + Contains(token: SyntaxKind): boolean; + } + class TokenValuesAccess implements ITokenAccess { + private tokens; + constructor(tks: SyntaxKind[]); + GetTokens(): SyntaxKind[]; + Contains(token: SyntaxKind): boolean; + } + class TokenSingleValueAccess implements ITokenAccess { + token: SyntaxKind; + constructor(token: SyntaxKind); + GetTokens(): SyntaxKind[]; + Contains(tokenValue: SyntaxKind): boolean; + } + class TokenAllAccess implements ITokenAccess { + GetTokens(): SyntaxKind[]; + Contains(tokenValue: SyntaxKind): boolean; + toString(): string; + } + class TokenRange { + tokenAccess: ITokenAccess; + constructor(tokenAccess: ITokenAccess); + static FromToken(token: SyntaxKind): TokenRange; + static FromTokens(tokens: SyntaxKind[]): TokenRange; + static FromRange(f: SyntaxKind, to: SyntaxKind, except?: SyntaxKind[]): TokenRange; + static AllTokens(): TokenRange; + GetTokens(): SyntaxKind[]; + Contains(token: SyntaxKind): boolean; + toString(): string; + static Any: TokenRange; + static AnyIncludingMultilineComments: TokenRange; + static Keywords: TokenRange; + static BinaryOperators: TokenRange; + static BinaryKeywordOperators: TokenRange; + static UnaryPrefixOperators: TokenRange; + static UnaryPrefixExpressions: TokenRange; + static UnaryPreincrementExpressions: TokenRange; + static UnaryPostincrementExpressions: TokenRange; + static UnaryPredecrementExpressions: TokenRange; + static UnaryPostdecrementExpressions: TokenRange; + static Comments: TokenRange; + static TypeNames: TokenRange; + } + } +} +declare namespace ts.formatting { + class RulesProvider { + private globalRules; + private options; + private activeRules; + private rulesMap; + constructor(); + getRuleName(rule: Rule): string; + getRuleByName(name: string): Rule; + getRulesMap(): RulesMap; + ensureUpToDate(options: ts.FormatCodeOptions): void; + private createActiveRules(options); + } +} +declare namespace ts.formatting { + interface TextRangeWithKind extends TextRange { + kind: SyntaxKind; + } + interface TokenInfo { + leadingTrivia: TextRangeWithKind[]; + token: TextRangeWithKind; + trailingTrivia: TextRangeWithKind[]; + } + function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; + function formatOnSemicolon(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; + function formatOnClosingCurly(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; + function formatDocument(sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; + function formatSelection(start: number, end: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; + function getIndentationString(indentation: number, options: FormatCodeOptions): string; +} +declare namespace ts.formatting { + namespace SmartIndenter { + function getIndentation(position: number, sourceFile: SourceFile, options: EditorOptions): number; + function getBaseIndentation(options: EditorOptions): number; + function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: FormatCodeOptions): number; + function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean; + function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorOptions): { + column: number; + character: number; + }; + function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorOptions): number; + function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind, indentByDefault: boolean): boolean; + function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind): boolean; } +} +declare namespace ts { + /** The version of the language service API */ + const servicesVersion: string; interface DisplayPartsSymbolWriter extends SymbolWriter { displayParts(): SymbolDisplayPart[]; } diff --git a/bin/typescript.js b/bin/typescript.js index 0b4b752..bbd9f34 100644 --- a/bin/typescript.js +++ b/bin/typescript.js @@ -1548,6 +1548,21 @@ var ts; return result; } ts.extend = extend; + /** + * Adds the value to an array of values associated with the key, and returns the array. + * Creates the array if it does not already exist. + */ + function multiMapAdd(map, key, value) { + var values = map[key]; + if (values) { + values.push(value); + return values; + } + else { + return map[key] = [value]; + } + } + ts.multiMapAdd = multiMapAdd; /** * Tests whether a value is an array. */ @@ -2601,7 +2616,7 @@ var ts; return; } function addFileWatcherCallback(filePath, callback) { - (fileWatcherCallbacks[filePath] || (fileWatcherCallbacks[filePath] = [])).push(callback); + ts.multiMapAdd(fileWatcherCallbacks, filePath, callback); } function addFile(fileName, callback) { addFileWatcherCallback(fileName, callback); @@ -43815,7 +43830,7 @@ var ts; for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; var name_32 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_32] || (exportSpecifiers[name_32] = [])).push(specifier); + ts.multiMapAdd(exportSpecifiers, name_32, specifier); } } break; @@ -45194,7 +45209,6 @@ var ts; /** The version of the TypeScript compiler release */ ts.version = "2.1.0"; var emptyArray = []; - var defaultTypeRoots = ["node_modules/@types"]; function findConfigFile(searchPath, fileExists) { while (true) { var fileName = ts.combinePaths(searchPath, "tsconfig.json"); @@ -45338,11 +45352,31 @@ var ts; else if (host.getCurrentDirectory) { currentDirectory = host.getCurrentDirectory(); } - if (!currentDirectory) { - return undefined; + return currentDirectory && getDefaultTypeRoots(currentDirectory, host); + } + /** + * Returns the path to every node_modules/@types directory from some ancestor directory. + * Returns undefined if there are none. + */ + function getDefaultTypeRoots(currentDirectory, host) { + if (!host.directoryExists) { + return [ts.combinePaths(currentDirectory, "node_modules")]; + } + var typeRoots; + while (true) { + var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); + if (host.directoryExists(atTypes)) { + (typeRoots || (typeRoots = [])).push(atTypes); + } + var parent_15 = ts.getDirectoryPath(currentDirectory); + if (parent_15 === currentDirectory) { + break; + } + currentDirectory = parent_15; } - return ts.map(defaultTypeRoots, function (d) { return ts.combinePaths(currentDirectory, d); }); + return typeRoots; } + var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups @@ -47966,28 +48000,28 @@ var ts; switch (n.kind) { case 199 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_15 = n.parent; + var parent_16 = n.parent; var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. - if (parent_15.kind === 204 /* DoStatement */ || - parent_15.kind === 207 /* ForInStatement */ || - parent_15.kind === 208 /* ForOfStatement */ || - parent_15.kind === 206 /* ForStatement */ || - parent_15.kind === 203 /* IfStatement */ || - parent_15.kind === 205 /* WhileStatement */ || - parent_15.kind === 212 /* WithStatement */ || - parent_15.kind === 252 /* CatchClause */) { - addOutliningSpan(parent_15, openBrace, closeBrace, autoCollapse(n)); + if (parent_16.kind === 204 /* DoStatement */ || + parent_16.kind === 207 /* ForInStatement */ || + parent_16.kind === 208 /* ForOfStatement */ || + parent_16.kind === 206 /* ForStatement */ || + parent_16.kind === 203 /* IfStatement */ || + parent_16.kind === 205 /* WhileStatement */ || + parent_16.kind === 212 /* WithStatement */ || + parent_16.kind === 252 /* CatchClause */) { + addOutliningSpan(parent_16, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_15.kind === 216 /* TryStatement */) { + if (parent_16.kind === 216 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_15; + var tryStatement = parent_16; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_15, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_16, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -49873,6 +49907,236 @@ var ts; } })(SignatureHelp = ts.SignatureHelp || (ts.SignatureHelp = {})); })(ts || (ts = {})); +var ts; +(function (ts) { + var ScriptSnapshot; + (function (ScriptSnapshot) { + var StringScriptSnapshot = (function () { + function StringScriptSnapshot(text) { + this.text = text; + } + StringScriptSnapshot.prototype.getText = function (start, end) { + return this.text.substring(start, end); + }; + StringScriptSnapshot.prototype.getLength = function () { + return this.text.length; + }; + StringScriptSnapshot.prototype.getChangeRange = function (oldSnapshot) { + // Text-based snapshots do not support incremental parsing. Return undefined + // to signal that to the caller. + return undefined; + }; + return StringScriptSnapshot; + }()); + function fromString(text) { + return new StringScriptSnapshot(text); + } + ScriptSnapshot.fromString = fromString; + })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); + var TextChange = (function () { + function TextChange() { + } + return TextChange; + }()); + ts.TextChange = TextChange; + var HighlightSpanKind; + (function (HighlightSpanKind) { + HighlightSpanKind.none = "none"; + HighlightSpanKind.definition = "definition"; + HighlightSpanKind.reference = "reference"; + HighlightSpanKind.writtenReference = "writtenReference"; + })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); + (function (IndentStyle) { + IndentStyle[IndentStyle["None"] = 0] = "None"; + IndentStyle[IndentStyle["Block"] = 1] = "Block"; + IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; + })(ts.IndentStyle || (ts.IndentStyle = {})); + var IndentStyle = ts.IndentStyle; + (function (SymbolDisplayPartKind) { + SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; + SymbolDisplayPartKind[SymbolDisplayPartKind["enumName"] = 2] = "enumName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["fieldName"] = 3] = "fieldName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["interfaceName"] = 4] = "interfaceName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["keyword"] = 5] = "keyword"; + SymbolDisplayPartKind[SymbolDisplayPartKind["lineBreak"] = 6] = "lineBreak"; + SymbolDisplayPartKind[SymbolDisplayPartKind["numericLiteral"] = 7] = "numericLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["stringLiteral"] = 8] = "stringLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["localName"] = 9] = "localName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["methodName"] = 10] = "methodName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["moduleName"] = 11] = "moduleName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["operator"] = 12] = "operator"; + SymbolDisplayPartKind[SymbolDisplayPartKind["parameterName"] = 13] = "parameterName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["propertyName"] = 14] = "propertyName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["punctuation"] = 15] = "punctuation"; + SymbolDisplayPartKind[SymbolDisplayPartKind["space"] = 16] = "space"; + SymbolDisplayPartKind[SymbolDisplayPartKind["text"] = 17] = "text"; + SymbolDisplayPartKind[SymbolDisplayPartKind["typeParameterName"] = 18] = "typeParameterName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; + })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; + (function (OutputFileType) { + OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; + OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; + OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; + })(ts.OutputFileType || (ts.OutputFileType = {})); + var OutputFileType = ts.OutputFileType; + (function (EndOfLineState) { + EndOfLineState[EndOfLineState["None"] = 0] = "None"; + EndOfLineState[EndOfLineState["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia"; + EndOfLineState[EndOfLineState["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral"; + EndOfLineState[EndOfLineState["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral"; + EndOfLineState[EndOfLineState["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate"; + EndOfLineState[EndOfLineState["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail"; + EndOfLineState[EndOfLineState["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition"; + })(ts.EndOfLineState || (ts.EndOfLineState = {})); + var EndOfLineState = ts.EndOfLineState; + (function (TokenClass) { + TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; + TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; + TokenClass[TokenClass["Operator"] = 2] = "Operator"; + TokenClass[TokenClass["Comment"] = 3] = "Comment"; + TokenClass[TokenClass["Whitespace"] = 4] = "Whitespace"; + TokenClass[TokenClass["Identifier"] = 5] = "Identifier"; + TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; + TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; + TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; + })(ts.TokenClass || (ts.TokenClass = {})); + var TokenClass = ts.TokenClass; + // TODO: move these to enums + var ScriptElementKind; + (function (ScriptElementKind) { + ScriptElementKind.unknown = ""; + ScriptElementKind.warning = "warning"; + /** predefined type (void) or keyword (class) */ + ScriptElementKind.keyword = "keyword"; + /** top level script node */ + ScriptElementKind.scriptElement = "script"; + /** module foo {} */ + ScriptElementKind.moduleElement = "module"; + /** class X {} */ + ScriptElementKind.classElement = "class"; + /** var x = class X {} */ + ScriptElementKind.localClassElement = "local class"; + /** interface Y {} */ + ScriptElementKind.interfaceElement = "interface"; + /** type T = ... */ + ScriptElementKind.typeElement = "type"; + /** enum E */ + ScriptElementKind.enumElement = "enum"; + // TODO: GH#9983 + ScriptElementKind.enumMemberElement = "const"; + /** + * Inside module and script only + * const v = .. + */ + ScriptElementKind.variableElement = "var"; + /** Inside function */ + ScriptElementKind.localVariableElement = "local var"; + /** + * Inside module and script only + * function f() { } + */ + ScriptElementKind.functionElement = "function"; + /** Inside function */ + ScriptElementKind.localFunctionElement = "local function"; + /** class X { [public|private]* foo() {} } */ + ScriptElementKind.memberFunctionElement = "method"; + /** class X { [public|private]* [get|set] foo:number; } */ + ScriptElementKind.memberGetAccessorElement = "getter"; + ScriptElementKind.memberSetAccessorElement = "setter"; + /** + * class X { [public|private]* foo:number; } + * interface Y { foo:number; } + */ + ScriptElementKind.memberVariableElement = "property"; + /** class X { constructor() { } } */ + ScriptElementKind.constructorImplementationElement = "constructor"; + /** interface Y { ():number; } */ + ScriptElementKind.callSignatureElement = "call"; + /** interface Y { []:number; } */ + ScriptElementKind.indexSignatureElement = "index"; + /** interface Y { new():Y; } */ + ScriptElementKind.constructSignatureElement = "construct"; + /** function foo(*Y*: string) */ + ScriptElementKind.parameterElement = "parameter"; + ScriptElementKind.typeParameterElement = "type parameter"; + ScriptElementKind.primitiveType = "primitive type"; + ScriptElementKind.label = "label"; + ScriptElementKind.alias = "alias"; + ScriptElementKind.constElement = "const"; + ScriptElementKind.letElement = "let"; + })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); + var ScriptElementKindModifier; + (function (ScriptElementKindModifier) { + ScriptElementKindModifier.none = ""; + ScriptElementKindModifier.publicMemberModifier = "public"; + ScriptElementKindModifier.privateMemberModifier = "private"; + ScriptElementKindModifier.protectedMemberModifier = "protected"; + ScriptElementKindModifier.exportedModifier = "export"; + ScriptElementKindModifier.ambientModifier = "declare"; + ScriptElementKindModifier.staticModifier = "static"; + ScriptElementKindModifier.abstractModifier = "abstract"; + })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); + var ClassificationTypeNames = (function () { + function ClassificationTypeNames() { + } + ClassificationTypeNames.comment = "comment"; + ClassificationTypeNames.identifier = "identifier"; + ClassificationTypeNames.keyword = "keyword"; + ClassificationTypeNames.numericLiteral = "number"; + ClassificationTypeNames.operator = "operator"; + ClassificationTypeNames.stringLiteral = "string"; + ClassificationTypeNames.whiteSpace = "whitespace"; + ClassificationTypeNames.text = "text"; + ClassificationTypeNames.punctuation = "punctuation"; + ClassificationTypeNames.className = "class name"; + ClassificationTypeNames.enumName = "enum name"; + ClassificationTypeNames.interfaceName = "interface name"; + ClassificationTypeNames.moduleName = "module name"; + ClassificationTypeNames.typeParameterName = "type parameter name"; + ClassificationTypeNames.typeAliasName = "type alias name"; + ClassificationTypeNames.parameterName = "parameter name"; + ClassificationTypeNames.docCommentTagName = "doc comment tag name"; + ClassificationTypeNames.jsxOpenTagName = "jsx open tag name"; + ClassificationTypeNames.jsxCloseTagName = "jsx close tag name"; + ClassificationTypeNames.jsxSelfClosingTagName = "jsx self closing tag name"; + ClassificationTypeNames.jsxAttribute = "jsx attribute"; + ClassificationTypeNames.jsxText = "jsx text"; + ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; + return ClassificationTypeNames; + }()); + ts.ClassificationTypeNames = ClassificationTypeNames; + (function (ClassificationType) { + ClassificationType[ClassificationType["comment"] = 1] = "comment"; + ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; + ClassificationType[ClassificationType["keyword"] = 3] = "keyword"; + ClassificationType[ClassificationType["numericLiteral"] = 4] = "numericLiteral"; + ClassificationType[ClassificationType["operator"] = 5] = "operator"; + ClassificationType[ClassificationType["stringLiteral"] = 6] = "stringLiteral"; + ClassificationType[ClassificationType["regularExpressionLiteral"] = 7] = "regularExpressionLiteral"; + ClassificationType[ClassificationType["whiteSpace"] = 8] = "whiteSpace"; + ClassificationType[ClassificationType["text"] = 9] = "text"; + ClassificationType[ClassificationType["punctuation"] = 10] = "punctuation"; + ClassificationType[ClassificationType["className"] = 11] = "className"; + ClassificationType[ClassificationType["enumName"] = 12] = "enumName"; + ClassificationType[ClassificationType["interfaceName"] = 13] = "interfaceName"; + ClassificationType[ClassificationType["moduleName"] = 14] = "moduleName"; + ClassificationType[ClassificationType["typeParameterName"] = 15] = "typeParameterName"; + ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName"; + ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName"; + ClassificationType[ClassificationType["docCommentTagName"] = 18] = "docCommentTagName"; + ClassificationType[ClassificationType["jsxOpenTagName"] = 19] = "jsxOpenTagName"; + ClassificationType[ClassificationType["jsxCloseTagName"] = 20] = "jsxCloseTagName"; + ClassificationType[ClassificationType["jsxSelfClosingTagName"] = 21] = "jsxSelfClosingTagName"; + ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; + ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; + ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; + })(ts.ClassificationType || (ts.ClassificationType = {})); + var ClassificationType = ts.ClassificationType; +})(ts || (ts = {})); // These utilities are common to multiple language service features. /* @internal */ var ts; @@ -53766,6 +54030,7 @@ var ts; /// /// /// +/// /// /// /// @@ -53774,30 +54039,6 @@ var ts; (function (ts) { /** The version of the language service API */ ts.servicesVersion = "0.5"; - var ScriptSnapshot; - (function (ScriptSnapshot) { - var StringScriptSnapshot = (function () { - function StringScriptSnapshot(text) { - this.text = text; - } - StringScriptSnapshot.prototype.getText = function (start, end) { - return this.text.substring(start, end); - }; - StringScriptSnapshot.prototype.getLength = function () { - return this.text.length; - }; - StringScriptSnapshot.prototype.getChangeRange = function (oldSnapshot) { - // Text-based snapshots do not support incremental parsing. Return undefined - // to signal that to the caller. - return undefined; - }; - return StringScriptSnapshot; - }()); - function fromString(text) { - return new StringScriptSnapshot(text); - } - ScriptSnapshot.fromString = fromString; - })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); var emptyArray = []; var jsDocTagNames = [ @@ -54463,8 +54704,7 @@ var ts; function addDeclaration(declaration) { var name = getDeclarationName(declaration); if (name) { - var declarations = getDeclarations(name); - declarations.push(declaration); + ts.multiMapAdd(result, name, declaration); } } function getDeclarations(name) { @@ -54595,209 +54835,6 @@ var ts; }; return SourceFileObject; }(NodeObject)); - var TextChange = (function () { - function TextChange() { - } - return TextChange; - }()); - ts.TextChange = TextChange; - var HighlightSpanKind; - (function (HighlightSpanKind) { - HighlightSpanKind.none = "none"; - HighlightSpanKind.definition = "definition"; - HighlightSpanKind.reference = "reference"; - HighlightSpanKind.writtenReference = "writtenReference"; - })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); - (function (IndentStyle) { - IndentStyle[IndentStyle["None"] = 0] = "None"; - IndentStyle[IndentStyle["Block"] = 1] = "Block"; - IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; - })(ts.IndentStyle || (ts.IndentStyle = {})); - var IndentStyle = ts.IndentStyle; - (function (SymbolDisplayPartKind) { - SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; - SymbolDisplayPartKind[SymbolDisplayPartKind["enumName"] = 2] = "enumName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["fieldName"] = 3] = "fieldName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["interfaceName"] = 4] = "interfaceName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["keyword"] = 5] = "keyword"; - SymbolDisplayPartKind[SymbolDisplayPartKind["lineBreak"] = 6] = "lineBreak"; - SymbolDisplayPartKind[SymbolDisplayPartKind["numericLiteral"] = 7] = "numericLiteral"; - SymbolDisplayPartKind[SymbolDisplayPartKind["stringLiteral"] = 8] = "stringLiteral"; - SymbolDisplayPartKind[SymbolDisplayPartKind["localName"] = 9] = "localName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["methodName"] = 10] = "methodName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["moduleName"] = 11] = "moduleName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["operator"] = 12] = "operator"; - SymbolDisplayPartKind[SymbolDisplayPartKind["parameterName"] = 13] = "parameterName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["propertyName"] = 14] = "propertyName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["punctuation"] = 15] = "punctuation"; - SymbolDisplayPartKind[SymbolDisplayPartKind["space"] = 16] = "space"; - SymbolDisplayPartKind[SymbolDisplayPartKind["text"] = 17] = "text"; - SymbolDisplayPartKind[SymbolDisplayPartKind["typeParameterName"] = 18] = "typeParameterName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; - })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); - var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; - (function (OutputFileType) { - OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; - OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; - OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; - })(ts.OutputFileType || (ts.OutputFileType = {})); - var OutputFileType = ts.OutputFileType; - (function (EndOfLineState) { - EndOfLineState[EndOfLineState["None"] = 0] = "None"; - EndOfLineState[EndOfLineState["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia"; - EndOfLineState[EndOfLineState["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral"; - EndOfLineState[EndOfLineState["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral"; - EndOfLineState[EndOfLineState["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate"; - EndOfLineState[EndOfLineState["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail"; - EndOfLineState[EndOfLineState["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition"; - })(ts.EndOfLineState || (ts.EndOfLineState = {})); - var EndOfLineState = ts.EndOfLineState; - (function (TokenClass) { - TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; - TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; - TokenClass[TokenClass["Operator"] = 2] = "Operator"; - TokenClass[TokenClass["Comment"] = 3] = "Comment"; - TokenClass[TokenClass["Whitespace"] = 4] = "Whitespace"; - TokenClass[TokenClass["Identifier"] = 5] = "Identifier"; - TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; - TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; - TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; - })(ts.TokenClass || (ts.TokenClass = {})); - var TokenClass = ts.TokenClass; - // TODO: move these to enums - var ScriptElementKind; - (function (ScriptElementKind) { - ScriptElementKind.unknown = ""; - ScriptElementKind.warning = "warning"; - /** predefined type (void) or keyword (class) */ - ScriptElementKind.keyword = "keyword"; - /** top level script node */ - ScriptElementKind.scriptElement = "script"; - /** module foo {} */ - ScriptElementKind.moduleElement = "module"; - /** class X {} */ - ScriptElementKind.classElement = "class"; - /** var x = class X {} */ - ScriptElementKind.localClassElement = "local class"; - /** interface Y {} */ - ScriptElementKind.interfaceElement = "interface"; - /** type T = ... */ - ScriptElementKind.typeElement = "type"; - /** enum E */ - ScriptElementKind.enumElement = "enum"; - // TODO: GH#9983 - ScriptElementKind.enumMemberElement = "const"; - /** - * Inside module and script only - * const v = .. - */ - ScriptElementKind.variableElement = "var"; - /** Inside function */ - ScriptElementKind.localVariableElement = "local var"; - /** - * Inside module and script only - * function f() { } - */ - ScriptElementKind.functionElement = "function"; - /** Inside function */ - ScriptElementKind.localFunctionElement = "local function"; - /** class X { [public|private]* foo() {} } */ - ScriptElementKind.memberFunctionElement = "method"; - /** class X { [public|private]* [get|set] foo:number; } */ - ScriptElementKind.memberGetAccessorElement = "getter"; - ScriptElementKind.memberSetAccessorElement = "setter"; - /** - * class X { [public|private]* foo:number; } - * interface Y { foo:number; } - */ - ScriptElementKind.memberVariableElement = "property"; - /** class X { constructor() { } } */ - ScriptElementKind.constructorImplementationElement = "constructor"; - /** interface Y { ():number; } */ - ScriptElementKind.callSignatureElement = "call"; - /** interface Y { []:number; } */ - ScriptElementKind.indexSignatureElement = "index"; - /** interface Y { new():Y; } */ - ScriptElementKind.constructSignatureElement = "construct"; - /** function foo(*Y*: string) */ - ScriptElementKind.parameterElement = "parameter"; - ScriptElementKind.typeParameterElement = "type parameter"; - ScriptElementKind.primitiveType = "primitive type"; - ScriptElementKind.label = "label"; - ScriptElementKind.alias = "alias"; - ScriptElementKind.constElement = "const"; - ScriptElementKind.letElement = "let"; - })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); - var ScriptElementKindModifier; - (function (ScriptElementKindModifier) { - ScriptElementKindModifier.none = ""; - ScriptElementKindModifier.publicMemberModifier = "public"; - ScriptElementKindModifier.privateMemberModifier = "private"; - ScriptElementKindModifier.protectedMemberModifier = "protected"; - ScriptElementKindModifier.exportedModifier = "export"; - ScriptElementKindModifier.ambientModifier = "declare"; - ScriptElementKindModifier.staticModifier = "static"; - ScriptElementKindModifier.abstractModifier = "abstract"; - })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); - var ClassificationTypeNames = (function () { - function ClassificationTypeNames() { - } - ClassificationTypeNames.comment = "comment"; - ClassificationTypeNames.identifier = "identifier"; - ClassificationTypeNames.keyword = "keyword"; - ClassificationTypeNames.numericLiteral = "number"; - ClassificationTypeNames.operator = "operator"; - ClassificationTypeNames.stringLiteral = "string"; - ClassificationTypeNames.whiteSpace = "whitespace"; - ClassificationTypeNames.text = "text"; - ClassificationTypeNames.punctuation = "punctuation"; - ClassificationTypeNames.className = "class name"; - ClassificationTypeNames.enumName = "enum name"; - ClassificationTypeNames.interfaceName = "interface name"; - ClassificationTypeNames.moduleName = "module name"; - ClassificationTypeNames.typeParameterName = "type parameter name"; - ClassificationTypeNames.typeAliasName = "type alias name"; - ClassificationTypeNames.parameterName = "parameter name"; - ClassificationTypeNames.docCommentTagName = "doc comment tag name"; - ClassificationTypeNames.jsxOpenTagName = "jsx open tag name"; - ClassificationTypeNames.jsxCloseTagName = "jsx close tag name"; - ClassificationTypeNames.jsxSelfClosingTagName = "jsx self closing tag name"; - ClassificationTypeNames.jsxAttribute = "jsx attribute"; - ClassificationTypeNames.jsxText = "jsx text"; - ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; - return ClassificationTypeNames; - }()); - ts.ClassificationTypeNames = ClassificationTypeNames; - (function (ClassificationType) { - ClassificationType[ClassificationType["comment"] = 1] = "comment"; - ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; - ClassificationType[ClassificationType["keyword"] = 3] = "keyword"; - ClassificationType[ClassificationType["numericLiteral"] = 4] = "numericLiteral"; - ClassificationType[ClassificationType["operator"] = 5] = "operator"; - ClassificationType[ClassificationType["stringLiteral"] = 6] = "stringLiteral"; - ClassificationType[ClassificationType["regularExpressionLiteral"] = 7] = "regularExpressionLiteral"; - ClassificationType[ClassificationType["whiteSpace"] = 8] = "whiteSpace"; - ClassificationType[ClassificationType["text"] = 9] = "text"; - ClassificationType[ClassificationType["punctuation"] = 10] = "punctuation"; - ClassificationType[ClassificationType["className"] = 11] = "className"; - ClassificationType[ClassificationType["enumName"] = 12] = "enumName"; - ClassificationType[ClassificationType["interfaceName"] = 13] = "interfaceName"; - ClassificationType[ClassificationType["moduleName"] = 14] = "moduleName"; - ClassificationType[ClassificationType["typeParameterName"] = 15] = "typeParameterName"; - ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName"; - ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName"; - ClassificationType[ClassificationType["docCommentTagName"] = 18] = "docCommentTagName"; - ClassificationType[ClassificationType["jsxOpenTagName"] = 19] = "jsxOpenTagName"; - ClassificationType[ClassificationType["jsxCloseTagName"] = 20] = "jsxCloseTagName"; - ClassificationType[ClassificationType["jsxSelfClosingTagName"] = 21] = "jsxSelfClosingTagName"; - ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; - ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; - ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; - })(ts.ClassificationType || (ts.ClassificationType = {})); - var ClassificationType = ts.ClassificationType; function displayPartsToString(displayParts) { if (displayParts) { return ts.map(displayParts, function (displayPart) { return displayPart.text; }).join(""); @@ -54818,9 +54855,9 @@ var ts; return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_16 = declaration.parent; !ts.isFunctionBlock(parent_16); parent_16 = parent_16.parent) { + for (var parent_17 = declaration.parent; !ts.isFunctionBlock(parent_17); parent_17 = parent_17.parent) { // Reached source file or module block - if (parent_16.kind === 256 /* SourceFile */ || parent_16.kind === 226 /* ModuleBlock */) { + if (parent_17.kind === 256 /* SourceFile */ || parent_17.kind === 226 /* ModuleBlock */) { return false; } } @@ -55745,8 +55782,8 @@ var ts; for (var i = 70 /* FirstKeyword */; i <= 138 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), - kind: ScriptElementKind.keyword, - kindModifiers: ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.keyword, + kindModifiers: ts.ScriptElementKindModifier.none, sortText: "0" }); } @@ -55776,15 +55813,15 @@ var ts; /* @internal */ function getNodeKind(node) { switch (node.kind) { case 256 /* SourceFile */: - return ts.isExternalModule(node) ? ScriptElementKind.moduleElement : ScriptElementKind.scriptElement; + return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; case 225 /* ModuleDeclaration */: - return ScriptElementKind.moduleElement; + return ts.ScriptElementKind.moduleElement; case 221 /* ClassDeclaration */: case 192 /* ClassExpression */: - return ScriptElementKind.classElement; - case 222 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 223 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 224 /* EnumDeclaration */: return ScriptElementKind.enumElement; + return ts.ScriptElementKind.classElement; + case 222 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 223 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 224 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; case 218 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); case 169 /* BindingElement */: @@ -55792,39 +55829,39 @@ var ts; case 180 /* ArrowFunction */: case 220 /* FunctionDeclaration */: case 179 /* FunctionExpression */: - return ScriptElementKind.functionElement; - case 149 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 150 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + return ts.ScriptElementKind.functionElement; + case 149 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; + case 150 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; case 147 /* MethodDeclaration */: case 146 /* MethodSignature */: - return ScriptElementKind.memberFunctionElement; + return ts.ScriptElementKind.memberFunctionElement; case 145 /* PropertyDeclaration */: case 144 /* PropertySignature */: - return ScriptElementKind.memberVariableElement; - case 153 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 152 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 151 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 148 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 141 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 255 /* EnumMember */: return ScriptElementKind.enumMemberElement; - case 142 /* Parameter */: return (node.flags & 92 /* ParameterPropertyModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + return ts.ScriptElementKind.memberVariableElement; + case 153 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; + case 152 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; + case 151 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; + case 148 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; + case 141 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; + case 255 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; + case 142 /* Parameter */: return (node.flags & 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; case 229 /* ImportEqualsDeclaration */: case 234 /* ImportSpecifier */: case 231 /* ImportClause */: case 238 /* ExportSpecifier */: case 232 /* NamespaceImport */: - return ScriptElementKind.alias; + return ts.ScriptElementKind.alias; case 279 /* JSDocTypedefTag */: - return ScriptElementKind.typeElement; + return ts.ScriptElementKind.typeElement; default: - return ScriptElementKind.unknown; + return ts.ScriptElementKind.unknown; } function getKindOfVariableDeclaration(v) { return ts.isConst(v) - ? ScriptElementKind.constElement + ? ts.ScriptElementKind.constElement : ts.isLet(v) - ? ScriptElementKind.letElement - : ScriptElementKind.variableElement; + ? ts.ScriptElementKind.letElement + : ts.ScriptElementKind.variableElement; } } ts.getNodeKind = getNodeKind; @@ -56204,13 +56241,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_17 = contextToken.parent, kind = contextToken.kind; + var parent_18 = contextToken.parent, kind = contextToken.kind; if (kind === 21 /* DotToken */) { - if (parent_17.kind === 172 /* PropertyAccessExpression */) { + if (parent_18.kind === 172 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_17.kind === 139 /* QualifiedName */) { + else if (parent_18.kind === 139 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -56588,9 +56625,9 @@ var ts; switch (contextToken.kind) { case 15 /* OpenBraceToken */: // const x = { | case 24 /* CommaToken */: - var parent_18 = contextToken.parent; - if (parent_18 && (parent_18.kind === 171 /* ObjectLiteralExpression */ || parent_18.kind === 167 /* ObjectBindingPattern */)) { - return parent_18; + var parent_19 = contextToken.parent; + if (parent_19 && (parent_19.kind === 171 /* ObjectLiteralExpression */ || parent_19.kind === 167 /* ObjectBindingPattern */)) { + return parent_19; } break; } @@ -56617,37 +56654,37 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_19 = contextToken.parent; + var parent_20 = contextToken.parent; switch (contextToken.kind) { case 26 /* LessThanSlashToken */: case 39 /* SlashToken */: case 69 /* Identifier */: case 246 /* JsxAttribute */: case 247 /* JsxSpreadAttribute */: - if (parent_19 && (parent_19.kind === 242 /* JsxSelfClosingElement */ || parent_19.kind === 243 /* JsxOpeningElement */)) { - return parent_19; + if (parent_20 && (parent_20.kind === 242 /* JsxSelfClosingElement */ || parent_20.kind === 243 /* JsxOpeningElement */)) { + return parent_20; } - else if (parent_19.kind === 246 /* JsxAttribute */) { - return parent_19.parent; + else if (parent_20.kind === 246 /* JsxAttribute */) { + return parent_20.parent; } break; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent_19 && ((parent_19.kind === 246 /* JsxAttribute */) || (parent_19.kind === 247 /* JsxSpreadAttribute */))) { - return parent_19.parent; + if (parent_20 && ((parent_20.kind === 246 /* JsxAttribute */) || (parent_20.kind === 247 /* JsxSpreadAttribute */))) { + return parent_20.parent; } break; case 16 /* CloseBraceToken */: - if (parent_19 && - parent_19.kind === 248 /* JsxExpression */ && - parent_19.parent && - (parent_19.parent.kind === 246 /* JsxAttribute */)) { - return parent_19.parent.parent; + if (parent_20 && + parent_20.kind === 248 /* JsxExpression */ && + parent_20.parent && + (parent_20.parent.kind === 246 /* JsxAttribute */)) { + return parent_20.parent.parent; } - if (parent_19 && parent_19.kind === 247 /* JsxSpreadAttribute */) { - return parent_19.parent; + if (parent_20 && parent_20.kind === 247 /* JsxSpreadAttribute */) { + return parent_20.parent; } break; } @@ -56916,7 +56953,7 @@ var ts; if (displayName) { var entry = { name: displayName, - kind: ScriptElementKind.warning, + kind: ts.ScriptElementKind.warning, kindModifiers: "", sortText: "1" }; @@ -56930,7 +56967,7 @@ var ts; return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: tagName, - kind: ScriptElementKind.keyword, + kind: ts.ScriptElementKind.keyword, kindModifiers: "", sortText: "0", }; @@ -57082,8 +57119,8 @@ var ts; if (type.flags & 32 /* StringLiteral */) { result.push({ name: type.text, - kindModifiers: ScriptElementKindModifier.none, - kind: ScriptElementKind.variableElement, + kindModifiers: ts.ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.variableElement, sortText: "0" }); } @@ -57118,9 +57155,9 @@ var ts; if (keywordCompletion) { return { name: entryName, - kind: ScriptElementKind.keyword, - kindModifiers: ScriptElementKindModifier.none, - displayParts: [ts.displayPart(entryName, SymbolDisplayPartKind.keyword)], + kind: ts.ScriptElementKind.keyword, + kindModifiers: ts.ScriptElementKindModifier.none, + displayParts: [ts.displayPart(entryName, ts.SymbolDisplayPartKind.keyword)], documentation: undefined }; } @@ -57131,68 +57168,68 @@ var ts; var flags = symbol.getFlags(); if (flags & 32 /* Class */) return ts.getDeclarationOfKind(symbol, 192 /* ClassExpression */) ? - ScriptElementKind.localClassElement : ScriptElementKind.classElement; + ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384 /* Enum */) - return ScriptElementKind.enumElement; + return ts.ScriptElementKind.enumElement; if (flags & 524288 /* TypeAlias */) - return ScriptElementKind.typeElement; + return ts.ScriptElementKind.typeElement; if (flags & 64 /* Interface */) - return ScriptElementKind.interfaceElement; + return ts.ScriptElementKind.interfaceElement; if (flags & 262144 /* TypeParameter */) - return ScriptElementKind.typeParameterElement; + return ts.ScriptElementKind.typeParameterElement; var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location); - if (result === ScriptElementKind.unknown) { + if (result === ts.ScriptElementKind.unknown) { if (flags & 262144 /* TypeParameter */) - return ScriptElementKind.typeParameterElement; + return ts.ScriptElementKind.typeParameterElement; if (flags & 8 /* EnumMember */) - return ScriptElementKind.variableElement; + return ts.ScriptElementKind.variableElement; if (flags & 8388608 /* Alias */) - return ScriptElementKind.alias; + return ts.ScriptElementKind.alias; if (flags & 1536 /* Module */) - return ScriptElementKind.moduleElement; + return ts.ScriptElementKind.moduleElement; } return result; } function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location) { var typeChecker = program.getTypeChecker(); if (typeChecker.isUndefinedSymbol(symbol)) { - return ScriptElementKind.variableElement; + return ts.ScriptElementKind.variableElement; } if (typeChecker.isArgumentsSymbol(symbol)) { - return ScriptElementKind.localVariableElement; + return ts.ScriptElementKind.localVariableElement; } if (location.kind === 97 /* ThisKeyword */ && ts.isExpression(location)) { - return ScriptElementKind.parameterElement; + return ts.ScriptElementKind.parameterElement; } if (flags & 3 /* Variable */) { if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { - return ScriptElementKind.parameterElement; + return ts.ScriptElementKind.parameterElement; } else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { - return ScriptElementKind.constElement; + return ts.ScriptElementKind.constElement; } else if (ts.forEach(symbol.declarations, ts.isLet)) { - return ScriptElementKind.letElement; + return ts.ScriptElementKind.letElement; } - return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localVariableElement : ScriptElementKind.variableElement; + return isLocalVariableOrFunction(symbol) ? ts.ScriptElementKind.localVariableElement : ts.ScriptElementKind.variableElement; } if (flags & 16 /* Function */) - return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localFunctionElement : ScriptElementKind.functionElement; + return isLocalVariableOrFunction(symbol) ? ts.ScriptElementKind.localFunctionElement : ts.ScriptElementKind.functionElement; if (flags & 32768 /* GetAccessor */) - return ScriptElementKind.memberGetAccessorElement; + return ts.ScriptElementKind.memberGetAccessorElement; if (flags & 65536 /* SetAccessor */) - return ScriptElementKind.memberSetAccessorElement; + return ts.ScriptElementKind.memberSetAccessorElement; if (flags & 8192 /* Method */) - return ScriptElementKind.memberFunctionElement; + return ts.ScriptElementKind.memberFunctionElement; if (flags & 16384 /* Constructor */) - return ScriptElementKind.constructorImplementationElement; + return ts.ScriptElementKind.constructorImplementationElement; if (flags & 4 /* Property */) { if (flags & 268435456 /* SyntheticProperty */) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { - return ScriptElementKind.memberVariableElement; + return ts.ScriptElementKind.memberVariableElement; } ts.Debug.assert(!!(rootSymbolFlags & 8192 /* Method */)); }); @@ -57201,20 +57238,20 @@ var ts; // make sure it has call signatures before we can label it as method var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { - return ScriptElementKind.memberFunctionElement; + return ts.ScriptElementKind.memberFunctionElement; } - return ScriptElementKind.memberVariableElement; + return ts.ScriptElementKind.memberVariableElement; } return unionPropertyKind; } - return ScriptElementKind.memberVariableElement; + return ts.ScriptElementKind.memberVariableElement; } - return ScriptElementKind.unknown; + return ts.ScriptElementKind.unknown; } function getSymbolModifiers(symbol) { return symbol && symbol.declarations && symbol.declarations.length > 0 ? ts.getNodeModifiers(symbol.declarations[0]) - : ScriptElementKindModifier.none; + : ts.ScriptElementKindModifier.none; } // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, enclosingDeclaration, location, semanticMeaning) { @@ -57228,10 +57265,10 @@ var ts; var isThisExpression = location.kind === 97 /* ThisKeyword */ && ts.isExpression(location); var type; // Class at constructor site need to be shown as constructor apart from property,method, vars - if (symbolKind !== ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Alias */) { + if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Alias */) { // If it is accessor they are allowed only if location is at name of the accessor - if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) { - symbolKind = ScriptElementKind.memberVariableElement; + if (symbolKind === ts.ScriptElementKind.memberGetAccessorElement || symbolKind === ts.ScriptElementKind.memberSetAccessorElement) { + symbolKind = ts.ScriptElementKind.memberVariableElement; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); @@ -57268,11 +57305,11 @@ var ts; if (signature) { if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { // Constructor - symbolKind = ScriptElementKind.constructorImplementationElement; + symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else if (symbolFlags & 8388608 /* Alias */) { - symbolKind = ScriptElementKind.alias; + symbolKind = ts.ScriptElementKind.alias; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { @@ -57285,12 +57322,12 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { - case ScriptElementKind.memberVariableElement: - case ScriptElementKind.variableElement: - case ScriptElementKind.constElement: - case ScriptElementKind.letElement: - case ScriptElementKind.parameterElement: - case ScriptElementKind.localVariableElement: + case ts.ScriptElementKind.memberVariableElement: + case ts.ScriptElementKind.variableElement: + case ts.ScriptElementKind.constElement: + case ts.ScriptElementKind.letElement: + case ts.ScriptElementKind.parameterElement: + case ts.ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name displayParts.push(ts.punctuationPart(54 /* ColonToken */)); displayParts.push(ts.spacePart()); @@ -57323,7 +57360,7 @@ var ts; } if (functionDeclaration.kind === 148 /* Constructor */) { // show (constructor) Type(...) signature - symbolKind = ScriptElementKind.constructorImplementationElement; + symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { @@ -57341,7 +57378,7 @@ var ts; // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class - pushTypePart(ScriptElementKind.localClassElement); + pushTypePart(ts.ScriptElementKind.localClassElement); } else { // Class declaration has name which is not local. @@ -57440,7 +57477,7 @@ var ts; displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); + displayParts.push(ts.displayPart(constantValue.toString(), ts.SymbolDisplayPartKind.numericLiteral)); } } } @@ -57465,7 +57502,7 @@ var ts; displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(129 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); - displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } else { @@ -57482,7 +57519,7 @@ var ts; }); } if (!hasAddedSymbolInfo) { - if (symbolKind !== ScriptElementKind.unknown) { + if (symbolKind !== ts.ScriptElementKind.unknown) { if (type) { if (isThisExpression) { addNewLineIfDisplayPartsExist(); @@ -57492,9 +57529,9 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } // For properties, variables and local vars: show the type - if (symbolKind === ScriptElementKind.memberVariableElement || + if (symbolKind === ts.ScriptElementKind.memberVariableElement || symbolFlags & 3 /* Variable */ || - symbolKind === ScriptElementKind.localVariableElement || + symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { displayParts.push(ts.punctuationPart(54 /* ColonToken */)); displayParts.push(ts.spacePart()); @@ -57514,7 +57551,7 @@ var ts; symbolFlags & 16384 /* Constructor */ || symbolFlags & 131072 /* Signature */ || symbolFlags & 98304 /* Accessor */ || - symbolKind === ScriptElementKind.memberFunctionElement) { + symbolKind === ts.ScriptElementKind.memberFunctionElement) { var allSignatures = type.getNonNullableType().getCallSignatures(); addSignatureDisplayParts(allSignatures[0], allSignatures); } @@ -57568,11 +57605,11 @@ var ts; } function pushTypePart(symbolKind) { switch (symbolKind) { - case ScriptElementKind.variableElement: - case ScriptElementKind.functionElement: - case ScriptElementKind.letElement: - case ScriptElementKind.constElement: - case ScriptElementKind.constructorImplementationElement: + case ts.ScriptElementKind.variableElement: + case ts.ScriptElementKind.functionElement: + case ts.ScriptElementKind.letElement: + case ts.ScriptElementKind.constElement: + case ts.ScriptElementKind.constructorImplementationElement: displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: @@ -57588,7 +57625,7 @@ var ts; displayParts.push(ts.spacePart()); displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.operatorPart(35 /* PlusToken */)); - displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); + displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); @@ -57627,8 +57664,8 @@ var ts; var type = typeChecker.getTypeAtLocation(node); if (type) { return { - kind: ScriptElementKind.unknown, - kindModifiers: ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.unknown, + kindModifiers: ts.ScriptElementKindModifier.none, textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: ts.typeToDisplayParts(typeChecker, type, getContainerNode(node)), documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined @@ -57740,7 +57777,7 @@ var ts; return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), - kind: ScriptElementKind.scriptElement, + kind: ts.ScriptElementKind.scriptElement, name: name, containerName: undefined, containerKind: undefined @@ -57776,7 +57813,7 @@ var ts; if (isJumpStatementTarget(node)) { var labelName = node.text; var label = getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; + return label ? [createDefinitionInfo(label, ts.ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; } var typeChecker = program.getTypeChecker(); var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); @@ -57880,7 +57917,7 @@ var ts; return { fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromBounds(start, end), - kind: HighlightSpanKind.none + kind: ts.HighlightSpanKind.none }; } function getSemanticDocumentHighlights(node) { @@ -57913,7 +57950,7 @@ var ts; } documentHighlights.highlightSpans.push({ textSpan: referenceEntry.textSpan, - kind: referenceEntry.isWriteAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference + kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference }); } } @@ -58054,19 +58091,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_20 = child.parent; - if (ts.isFunctionBlock(parent_20) || parent_20.kind === 256 /* SourceFile */) { - return parent_20; + var parent_21 = child.parent; + if (ts.isFunctionBlock(parent_21) || parent_21.kind === 256 /* SourceFile */) { + return parent_21; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_20.kind === 216 /* TryStatement */) { - var tryStatement = parent_20; + if (parent_21.kind === 216 /* TryStatement */) { + var tryStatement = parent_21; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_20; + child = parent_21; } return undefined; } @@ -58378,7 +58415,7 @@ var ts; result.push({ fileName: fileName, textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: HighlightSpanKind.reference + kind: ts.HighlightSpanKind.reference }); i++; // skip the next keyword continue; @@ -58407,7 +58444,7 @@ var ts; result.push({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, - isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference, + isWriteAccess: highlightSpan.kind === ts.HighlightSpanKind.writtenReference, isDefinition: false }); } @@ -58722,10 +58759,10 @@ var ts; containerKind: "", containerName: "", fileName: targetLabel.getSourceFile().fileName, - kind: ScriptElementKind.label, + kind: ts.ScriptElementKind.label, name: labelName, textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()), - displayParts: [ts.displayPart(labelName, SymbolDisplayPartKind.text)] + displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] }; return [{ definition: definition, references: references }]; } @@ -58999,7 +59036,7 @@ var ts; containerKind: "", containerName: "", fileName: node.getSourceFile().fileName, - kind: ScriptElementKind.variableElement, + kind: ts.ScriptElementKind.variableElement, name: "this", textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), displayParts: displayParts @@ -59062,10 +59099,10 @@ var ts; containerKind: "", containerName: "", fileName: node.getSourceFile().fileName, - kind: ScriptElementKind.variableElement, + kind: ts.ScriptElementKind.variableElement, name: type.text, textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: [ts.displayPart(ts.getTextOfNode(node), SymbolDisplayPartKind.stringLiteral)] + displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] }, references: references }]; @@ -59689,29 +59726,29 @@ var ts; } function getClassificationTypeName(type) { switch (type) { - case 1 /* comment */: return ClassificationTypeNames.comment; - case 2 /* identifier */: return ClassificationTypeNames.identifier; - case 3 /* keyword */: return ClassificationTypeNames.keyword; - case 4 /* numericLiteral */: return ClassificationTypeNames.numericLiteral; - case 5 /* operator */: return ClassificationTypeNames.operator; - case 6 /* stringLiteral */: return ClassificationTypeNames.stringLiteral; - case 8 /* whiteSpace */: return ClassificationTypeNames.whiteSpace; - case 9 /* text */: return ClassificationTypeNames.text; - case 10 /* punctuation */: return ClassificationTypeNames.punctuation; - case 11 /* className */: return ClassificationTypeNames.className; - case 12 /* enumName */: return ClassificationTypeNames.enumName; - case 13 /* interfaceName */: return ClassificationTypeNames.interfaceName; - case 14 /* moduleName */: return ClassificationTypeNames.moduleName; - case 15 /* typeParameterName */: return ClassificationTypeNames.typeParameterName; - case 16 /* typeAliasName */: return ClassificationTypeNames.typeAliasName; - case 17 /* parameterName */: return ClassificationTypeNames.parameterName; - case 18 /* docCommentTagName */: return ClassificationTypeNames.docCommentTagName; - case 19 /* jsxOpenTagName */: return ClassificationTypeNames.jsxOpenTagName; - case 20 /* jsxCloseTagName */: return ClassificationTypeNames.jsxCloseTagName; - case 21 /* jsxSelfClosingTagName */: return ClassificationTypeNames.jsxSelfClosingTagName; - case 22 /* jsxAttribute */: return ClassificationTypeNames.jsxAttribute; - case 23 /* jsxText */: return ClassificationTypeNames.jsxText; - case 24 /* jsxAttributeStringLiteralValue */: return ClassificationTypeNames.jsxAttributeStringLiteralValue; + case 1 /* comment */: return ts.ClassificationTypeNames.comment; + case 2 /* identifier */: return ts.ClassificationTypeNames.identifier; + case 3 /* keyword */: return ts.ClassificationTypeNames.keyword; + case 4 /* numericLiteral */: return ts.ClassificationTypeNames.numericLiteral; + case 5 /* operator */: return ts.ClassificationTypeNames.operator; + case 6 /* stringLiteral */: return ts.ClassificationTypeNames.stringLiteral; + case 8 /* whiteSpace */: return ts.ClassificationTypeNames.whiteSpace; + case 9 /* text */: return ts.ClassificationTypeNames.text; + case 10 /* punctuation */: return ts.ClassificationTypeNames.punctuation; + case 11 /* className */: return ts.ClassificationTypeNames.className; + case 12 /* enumName */: return ts.ClassificationTypeNames.enumName; + case 13 /* interfaceName */: return ts.ClassificationTypeNames.interfaceName; + case 14 /* moduleName */: return ts.ClassificationTypeNames.moduleName; + case 15 /* typeParameterName */: return ts.ClassificationTypeNames.typeParameterName; + case 16 /* typeAliasName */: return ts.ClassificationTypeNames.typeAliasName; + case 17 /* parameterName */: return ts.ClassificationTypeNames.parameterName; + case 18 /* docCommentTagName */: return ts.ClassificationTypeNames.docCommentTagName; + case 19 /* jsxOpenTagName */: return ts.ClassificationTypeNames.jsxOpenTagName; + case 20 /* jsxCloseTagName */: return ts.ClassificationTypeNames.jsxCloseTagName; + case 21 /* jsxSelfClosingTagName */: return ts.ClassificationTypeNames.jsxSelfClosingTagName; + case 22 /* jsxAttribute */: return ts.ClassificationTypeNames.jsxAttribute; + case 23 /* jsxText */: return ts.ClassificationTypeNames.jsxText; + case 24 /* jsxAttributeStringLiteralValue */: return ts.ClassificationTypeNames.jsxAttributeStringLiteralValue; } } function convertClassifications(classifications) { @@ -60453,11 +60490,11 @@ var ts; var displayName = ts.stripQuotes(type.text); return { canRename: true, - kind: ScriptElementKind.variableElement, + kind: ts.ScriptElementKind.variableElement, displayName: displayName, localizedErrorMessage: undefined, fullDisplayName: displayName, - kindModifiers: ScriptElementKindModifier.none, + kindModifiers: ts.ScriptElementKindModifier.none, triggerSpan: createTriggerSpanForNode(node, sourceFile) }; } @@ -60666,7 +60703,7 @@ var ts; if (lastEnd >= 0) { var whitespaceLength_1 = start - lastEnd; if (whitespaceLength_1 > 0) { - entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); + entries.push({ length: whitespaceLength_1, classification: ts.TokenClass.Whitespace }); } } entries.push({ length: length_5, classification: convertClassification(type) }); @@ -60674,19 +60711,19 @@ var ts; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { - entries.push({ length: whitespaceLength, classification: TokenClass.Whitespace }); + entries.push({ length: whitespaceLength, classification: ts.TokenClass.Whitespace }); } return { entries: entries, finalLexState: classifications.endOfLineState }; } function convertClassification(type) { switch (type) { - case 1 /* comment */: return TokenClass.Comment; - case 3 /* keyword */: return TokenClass.Keyword; - case 4 /* numericLiteral */: return TokenClass.NumberLiteral; - case 5 /* operator */: return TokenClass.Operator; - case 6 /* stringLiteral */: return TokenClass.StringLiteral; - case 8 /* whiteSpace */: return TokenClass.Whitespace; - case 10 /* punctuation */: return TokenClass.Punctuation; + case 1 /* comment */: return ts.TokenClass.Comment; + case 3 /* keyword */: return ts.TokenClass.Keyword; + case 4 /* numericLiteral */: return ts.TokenClass.NumberLiteral; + case 5 /* operator */: return ts.TokenClass.Operator; + case 6 /* stringLiteral */: return ts.TokenClass.StringLiteral; + case 8 /* whiteSpace */: return ts.TokenClass.Whitespace; + case 10 /* punctuation */: return ts.TokenClass.Punctuation; case 2 /* identifier */: case 11 /* className */: case 12 /* enumName */: @@ -60697,7 +60734,7 @@ var ts; case 9 /* text */: case 17 /* parameterName */: default: - return TokenClass.Identifier; + return ts.TokenClass.Identifier; } } function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { diff --git a/kicktravis b/kicktravis index 85d43c4..1f5206b 100644 --- a/kicktravis +++ b/kicktravis @@ -1 +1 @@ -2016-09-02 [ci skip] Version: 1.201609020105.1+8038eb943e6509a5da3377853ca04986bededbb1 +2016-09-03 [ci skip] Version: 1.201609030106.1+32b6746afe193bfa0cd07798768134f1b8963fe1 diff --git a/package.json b/package.json index 98a571b..6e1ebff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ntypescript", - "version": "1.201609020105.1+8038eb943e6509a5da3377853ca04986bededbb1", + "version": "1.201609030106.1+32b6746afe193bfa0cd07798768134f1b8963fe1", "description": "A nicer version of microsoft/typescript packaged and released for API developers", "main": "./bin/ntypescript.js", "bin": { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index eb17740..092fa59 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -566,6 +566,21 @@ namespace ts { return result; } + /** + * Adds the value to an array of values associated with the key, and returns the array. + * Creates the array if it does not already exist. + */ + export function multiMapAdd(map: Map, key: string, value: V): V[] { + const values = map[key]; + if (values) { + values.push(value); + return values; + } + else { + return map[key] = [value]; + } + } + /** * Tests whether a value is an array. */ diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index f02cf26..90cc06f 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -6851,7 +6851,7 @@ const _super = (function (geti, seti) { // export { x, y } for (const specifier of (node).exportClause.elements) { const name = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name] || (exportSpecifiers[name] = [])).push(specifier); + multiMapAdd(exportSpecifiers, name, specifier); } } break; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 49f6198..6226d0d 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -8,8 +8,6 @@ namespace ts { const emptyArray: any[] = []; - const defaultTypeRoots = ["node_modules/@types"]; - export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string { while (true) { const fileName = combinePaths(searchPath, "tsconfig.json"); @@ -168,7 +166,7 @@ namespace ts { const typeReferenceExtensions = [".d.ts"]; - function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost) { + function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost): string[] | undefined { if (options.typeRoots) { return options.typeRoots; } @@ -181,11 +179,37 @@ namespace ts { currentDirectory = host.getCurrentDirectory(); } - if (!currentDirectory) { - return undefined; + return currentDirectory && getDefaultTypeRoots(currentDirectory, host); + } + + /** + * Returns the path to every node_modules/@types directory from some ancestor directory. + * Returns undefined if there are none. + */ + function getDefaultTypeRoots(currentDirectory: string, host: ModuleResolutionHost): string[] | undefined { + if (!host.directoryExists) { + return [combinePaths(currentDirectory, "node_modules")]; + // And if it doesn't exist, tough. } - return map(defaultTypeRoots, d => combinePaths(currentDirectory, d)); + + let typeRoots: string[]; + + while (true) { + const atTypes = combinePaths(currentDirectory, nodeModulesAtTypes); + if (host.directoryExists(atTypes)) { + (typeRoots || (typeRoots = [])).push(atTypes); + } + + const parent = getDirectoryPath(currentDirectory); + if (parent === currentDirectory) { + break; + } + currentDirectory = parent; + } + + return typeRoots; } + const nodeModulesAtTypes = combinePaths("node_modules", "@types"); /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 118186b..f380401 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -267,7 +267,7 @@ namespace ts { } function addFileWatcherCallback(filePath: string, callback: FileWatcherCallback): void { - (fileWatcherCallbacks[filePath] || (fileWatcherCallbacks[filePath] = [])).push(callback); + multiMapAdd(fileWatcherCallbacks, filePath, callback); } function addFile(fileName: string, callback: FileWatcherCallback): WatchedFile { diff --git a/src/services/services.ts b/src/services/services.ts index c97455c..a322a7f 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[] = []; @@ -987,8 +871,7 @@ namespace ts { function addDeclaration(declaration: Declaration) { const name = getDeclarationName(declaration); if (name) { - const declarations = getDeclarations(name); - declarations.push(declaration); + multiMapAdd(result, name, declaration); } } @@ -1137,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/types.ts b/src/services/types.ts new file mode 100644 index 0000000..9f911d1 --- /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, + } +}