diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 7ba4e94902db8..32303b93e9312 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -583,19 +583,23 @@ namespace FourSlash { } public verifyGoToDefinition(arg0: any, endMarkerNames?: string | string[]) { - this.verifyGoToX(arg0, endMarkerNames, () => this.getGoToDefinition()); + this.verifyGoToX(arg0, endMarkerNames, () => this.getGoToDefinitionAndBoundSpan()); } private getGoToDefinition(): ts.DefinitionInfo[] { return this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); } + private getGoToDefinitionAndBoundSpan(): ts.DefinitionInfoAndBoundSpan { + return this.languageService.getDefinitionAndBoundSpan(this.activeFile.fileName, this.currentCaretPosition); + } + public verifyGoToType(arg0: any, endMarkerNames?: string | string[]) { this.verifyGoToX(arg0, endMarkerNames, () => this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition)); } - private verifyGoToX(arg0: any, endMarkerNames: string | string[] | undefined, getDefs: () => ts.DefinitionInfo[] | undefined) { + private verifyGoToX(arg0: any, endMarkerNames: string | string[] | undefined, getDefs: () => ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) { if (endMarkerNames) { this.verifyGoToXPlain(arg0, endMarkerNames, getDefs); } @@ -615,7 +619,7 @@ namespace FourSlash { } } - private verifyGoToXPlain(startMarkerNames: string | string[], endMarkerNames: string | string[], getDefs: () => ts.DefinitionInfo[] | undefined) { + private verifyGoToXPlain(startMarkerNames: string | string[], endMarkerNames: string | string[], getDefs: () => ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) { for (const start of toArray(startMarkerNames)) { this.verifyGoToXSingle(start, endMarkerNames, getDefs); } @@ -627,26 +631,57 @@ namespace FourSlash { } } - private verifyGoToXSingle(startMarkerName: string, endMarkerNames: string | string[], getDefs: () => ts.DefinitionInfo[] | undefined) { + private verifyGoToXSingle(startMarkerName: string, endMarkerNames: string | string[], getDefs: () => ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) { this.goToMarker(startMarkerName); - this.verifyGoToXWorker(toArray(endMarkerNames), getDefs); + this.verifyGoToXWorker(toArray(endMarkerNames), getDefs, startMarkerName); } - private verifyGoToXWorker(endMarkers: string[], getDefs: () => ts.DefinitionInfo[] | undefined) { - const definitions = getDefs() || []; + private verifyGoToXWorker(endMarkers: string[], getDefs: () => ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined, startMarkerName?: string) { + const defs = getDefs(); + let definitions: ts.DefinitionInfo[] | ReadonlyArray; + let testName: string; + + if (!defs || Array.isArray(defs)) { + definitions = defs as ts.DefinitionInfo[] || []; + testName = "goToDefinitions"; + } + else { + this.verifyDefinitionTextSpan(defs, startMarkerName); + + definitions = defs.definitions; + testName = "goToDefinitionsAndBoundSpan"; + } if (endMarkers.length !== definitions.length) { - this.raiseError(`goToDefinitions failed - expected to find ${endMarkers.length} definitions but got ${definitions.length}`); + this.raiseError(`${testName} failed - expected to find ${endMarkers.length} definitions but got ${definitions.length}`); } ts.zipWith(endMarkers, definitions, (endMarker, definition, i) => { const marker = this.getMarkerByName(endMarker); if (marker.fileName !== definition.fileName || marker.position !== definition.textSpan.start) { - this.raiseError(`goToDefinition failed for definition ${endMarker} (${i}): expected ${marker.fileName} at ${marker.position}, got ${definition.fileName} at ${definition.textSpan.start}`); + this.raiseError(`${testName} failed for definition ${endMarker} (${i}): expected ${marker.fileName} at ${marker.position}, got ${definition.fileName} at ${definition.textSpan.start}`); } }); } + private verifyDefinitionTextSpan(defs: ts.DefinitionInfoAndBoundSpan, startMarkerName: string) { + const range = this.testData.ranges.find(range => this.markerName(range.marker) === startMarkerName); + + if (!range && !defs.textSpan) { + return; + } + + if (!range) { + this.raiseError(`goToDefinitionsAndBoundSpan failed - found a TextSpan ${JSON.stringify(defs.textSpan)} when it wasn't expected.`); + } + else if (defs.textSpan.start !== range.start || defs.textSpan.length !== range.end - range.start) { + const expected: ts.TextSpan = { + start: range.start, length: range.end - range.start + }; + this.raiseError(`goToDefinitionsAndBoundSpan failed - expected to find TextSpan ${JSON.stringify(expected)} but got ${JSON.stringify(defs.textSpan)}`); + } + } + public verifyGetEmitOutputForCurrentFile(expected: string): void { const emit = this.languageService.getEmitOutput(this.activeFile.fileName); if (emit.outputFiles.length !== 1) { @@ -3900,6 +3935,7 @@ namespace FourSlashInterface { } public goToDefinition(startMarkerName: string | string[], endMarkerName: string | string[]): void; + public goToDefinition(startMarkerName: string | string[], endMarkerName: string | string[], range: FourSlash.Range): void; public goToDefinition(startsAndEnds: [string | string[], string | string[]][]): void; public goToDefinition(startsAndEnds: { [startMarkerName: string]: string | string[] }): void; public goToDefinition(arg0: any, endMarkerName?: string | string[]) { diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 87827d0c14ae4..55d4375873412 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -443,6 +443,9 @@ namespace Harness.LanguageService { getDefinitionAtPosition(fileName: string, position: number): ts.DefinitionInfo[] { return unwrapJSONCallResult(this.shim.getDefinitionAtPosition(fileName, position)); } + getDefinitionAndBoundSpan(fileName: string, position: number): ts.DefinitionInfoAndBoundSpan { + return unwrapJSONCallResult(this.shim.getDefinitionAndBoundSpan(fileName, position)); + } getTypeDefinitionAtPosition(fileName: string, position: number): ts.DefinitionInfo[] { return unwrapJSONCallResult(this.shim.getTypeDefinitionAtPosition(fileName, position)); } diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index 3d9f782b2e09e..e40e7d11b1a6a 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -128,7 +128,7 @@ namespace ts.server { body: undefined }); }); - it ("should handle literal types in request", () => { + it("should handle literal types in request", () => { const configureRequest: protocol.ConfigureRequest = { command: CommandNames.Configure, seq: 0, @@ -186,6 +186,8 @@ namespace ts.server { CommandNames.Configure, CommandNames.Definition, CommandNames.DefinitionFull, + CommandNames.DefinitionAndBoundSpan, + CommandNames.DefinitionAndBoundSpanFull, CommandNames.Implementation, CommandNames.ImplementationFull, CommandNames.Exit, @@ -352,7 +354,7 @@ namespace ts.server { session.addProtocolHandler(command, () => resp); expect(() => session.addProtocolHandler(command, () => resp)) - .to.throw(`Protocol handler already exists for command "${command}"`); + .to.throw(`Protocol handler already exists for command "${command}"`); }); }); diff --git a/src/server/client.ts b/src/server/client.ts index 2781d7cf20ae5..bf46301ff86cb 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -270,6 +270,25 @@ namespace ts.server { })); } + getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan { + const args: protocol.FileLocationRequestArgs = this.createFileLocationRequestArgs(fileName, position); + + const request = this.processRequest(CommandNames.DefinitionAndBoundSpan, args); + const response = this.processResponse(request); + + return { + definitions: response.body.definitions.map(entry => ({ + containerKind: ScriptElementKind.unknown, + containerName: "", + fileName: entry.file, + textSpan: this.decodeSpan(entry), + kind: ScriptElementKind.unknown, + name: "" + })), + textSpan: this.decodeSpan(response.body.textSpan, request.arguments.file) + }; + } + getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] { const args: protocol.FileLocationRequestArgs = this.createFileLocationRequestArgs(fileName, position); @@ -324,7 +343,7 @@ namespace ts.server { } getSyntacticDiagnostics(file: string): Diagnostic[] { - const args: protocol.SyntacticDiagnosticsSyncRequestArgs = { file, includeLinePosition: true }; + const args: protocol.SyntacticDiagnosticsSyncRequestArgs = { file, includeLinePosition: true }; const request = this.processRequest(CommandNames.SyntacticDiagnosticsSync, args); const response = this.processResponse(request); diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 6092f235942ed..9a94c265f5d3b 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -21,6 +21,9 @@ namespace ts.server.protocol { Definition = "definition", /* @internal */ DefinitionFull = "definition-full", + DefinitionAndBoundSpan = "definitionAndBoundSpan", + /* @internal */ + DefinitionAndBoundSpanFull = "definitionAndBoundSpan-full", Implementation = "implementation", /* @internal */ ImplementationFull = "implementation-full", @@ -708,6 +711,11 @@ namespace ts.server.protocol { file: string; } + export interface DefinitionInfoAndBoundSpan { + definitions: ReadonlyArray; + textSpan: TextSpan; + } + /** * Definition response message. Gives text range for definition. */ @@ -715,6 +723,10 @@ namespace ts.server.protocol { body?: FileSpan[]; } + export interface DefinitionInfoAndBoundSpanReponse extends Response { + body?: DefinitionInfoAndBoundSpan; + } + /** * Definition response message. Gives text range for definition. */ diff --git a/src/server/session.ts b/src/server/session.ts index 7ada8d2ff9c82..f02e1c620b994 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -167,7 +167,7 @@ namespace ts.server { private timerHandle: any; private immediateId: number | undefined; - constructor(private readonly operationHost: MultistepOperationHost) {} + constructor(private readonly operationHost: MultistepOperationHost) { } public startNew(action: (next: NextStep) => void) { this.complete(); @@ -587,7 +587,7 @@ namespace ts.server { private getDiagnosticsWorker( args: protocol.FileRequestArgs, isSemantic: boolean, selector: (project: Project, file: string) => ReadonlyArray, includeLinePosition: boolean - ): ReadonlyArray | ReadonlyArray { + ): ReadonlyArray | ReadonlyArray { const { project, file } = this.getFileAndProject(args); if (isSemantic && isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) { return emptyArray; @@ -609,20 +609,51 @@ namespace ts.server { } if (simplifiedResult) { - return definitions.map(def => { - const defScriptInfo = project.getScriptInfo(def.fileName); - return { - file: def.fileName, - start: defScriptInfo.positionToLineOffset(def.textSpan.start), - end: defScriptInfo.positionToLineOffset(textSpanEnd(def.textSpan)) - }; - }); + return this.mapDefinitionInfo(definitions, project); } else { return definitions; } } + private getDefinitionAndBoundSpan(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.DefinitionInfoAndBoundSpan | DefinitionInfoAndBoundSpan { + const { file, project } = this.getFileAndProject(args); + const position = this.getPositionInFile(args, file); + const scriptInfo = project.getScriptInfo(file); + + const definitionAndBoundSpan = project.getLanguageService().getDefinitionAndBoundSpan(file, position); + + if (!definitionAndBoundSpan || !definitionAndBoundSpan.definitions) { + return { + definitions: emptyArray, + textSpan: undefined + }; + } + + if (simplifiedResult) { + return { + definitions: this.mapDefinitionInfo(definitionAndBoundSpan.definitions, project), + textSpan: this.toLocationTextSpan(definitionAndBoundSpan.textSpan, scriptInfo) + }; + } + + return definitionAndBoundSpan; + } + + private mapDefinitionInfo(definitions: ReadonlyArray, project: Project): ReadonlyArray { + return definitions.map(def => this.toFileSpan(def.fileName, def.textSpan, project)); + } + + private toFileSpan(fileName: string, textSpan: TextSpan, project: Project): protocol.FileSpan { + const scriptInfo = project.getScriptInfo(fileName); + + return { + file: fileName, + start: scriptInfo.positionToLineOffset(textSpan.start), + end: scriptInfo.positionToLineOffset(textSpanEnd(textSpan)) + }; + } + private getTypeDefinition(args: protocol.FileLocationRequestArgs): ReadonlyArray { const { file, project } = this.getFileAndProject(args); const position = this.getPositionInFile(args, file); @@ -632,14 +663,7 @@ namespace ts.server { return emptyArray; } - return definitions.map(def => { - const defScriptInfo = project.getScriptInfo(def.fileName); - return { - file: def.fileName, - start: defScriptInfo.positionToLineOffset(def.textSpan.start), - end: defScriptInfo.positionToLineOffset(textSpanEnd(def.textSpan)) - }; - }); + return this.mapDefinitionInfo(definitions, project); } private getImplementation(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): ReadonlyArray | ReadonlyArray { @@ -650,14 +674,7 @@ namespace ts.server { return emptyArray; } if (simplifiedResult) { - return implementations.map(({ fileName, textSpan }) => { - const scriptInfo = project.getScriptInfo(fileName); - return { - file: fileName, - start: scriptInfo.positionToLineOffset(textSpan.start), - end: scriptInfo.positionToLineOffset(textSpanEnd(textSpan)) - }; - }); + return implementations.map(({ fileName, textSpan }) => this.toFileSpan(fileName, textSpan, project)); } else { return implementations; @@ -666,6 +683,7 @@ namespace ts.server { private getOccurrences(args: protocol.FileLocationRequestArgs): ReadonlyArray { const { file, project } = this.getFileAndProject(args); + const position = this.getPositionInFile(args, file); const occurrences = project.getLanguageService().getOccurrencesAtPosition(file, position); @@ -677,11 +695,9 @@ namespace ts.server { return occurrences.map(occurrence => { const { fileName, isWriteAccess, textSpan, isInString } = occurrence; const scriptInfo = project.getScriptInfo(fileName); - const start = scriptInfo.positionToLineOffset(textSpan.start); - const end = scriptInfo.positionToLineOffset(textSpanEnd(textSpan)); const result: protocol.OccurrencesResponseItem = { - start, - end, + start: scriptInfo.positionToLineOffset(textSpan.start), + end: scriptInfo.positionToLineOffset(textSpanEnd(textSpan)), file: fileName, isWriteAccess, }; @@ -1189,7 +1205,7 @@ namespace ts.server { return mapDefined(completions && completions.entries, entry => { if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { const { name, kind, kindModifiers, sortText, replacementSpan, hasAction, source } = entry; - const convertedSpan = replacementSpan ? this.decorateSpan(replacementSpan, scriptInfo) : undefined; + const convertedSpan = replacementSpan ? this.toLocationTextSpan(replacementSpan, scriptInfo) : undefined; // Use `hasAction || undefined` to avoid serializing `false`. return { name, kind, kindModifiers, sortText, replacementSpan: convertedSpan, hasAction: hasAction || undefined, source }; } @@ -1337,13 +1353,13 @@ namespace ts.server { this.projectService.closeClientFile(file); } - private decorateNavigationBarItems(items: NavigationBarItem[], scriptInfo: ScriptInfo): protocol.NavigationBarItem[] { + private mapLocationNavigationBarItems(items: NavigationBarItem[], scriptInfo: ScriptInfo): protocol.NavigationBarItem[] { return map(items, item => ({ text: item.text, kind: item.kind, kindModifiers: item.kindModifiers, - spans: item.spans.map(span => this.decorateSpan(span, scriptInfo)), - childItems: this.decorateNavigationBarItems(item.childItems, scriptInfo), + spans: item.spans.map(span => this.toLocationTextSpan(span, scriptInfo)), + childItems: this.mapLocationNavigationBarItems(item.childItems, scriptInfo), indent: item.indent })); } @@ -1354,21 +1370,21 @@ namespace ts.server { return !items ? undefined : simplifiedResult - ? this.decorateNavigationBarItems(items, this.projectService.getScriptInfoForNormalizedPath(file)) + ? this.mapLocationNavigationBarItems(items, this.projectService.getScriptInfoForNormalizedPath(file)) : items; } - private decorateNavigationTree(tree: NavigationTree, scriptInfo: ScriptInfo): protocol.NavigationTree { + private toLocationNavigationTree(tree: NavigationTree, scriptInfo: ScriptInfo): protocol.NavigationTree { return { text: tree.text, kind: tree.kind, kindModifiers: tree.kindModifiers, - spans: tree.spans.map(span => this.decorateSpan(span, scriptInfo)), - childItems: map(tree.childItems, item => this.decorateNavigationTree(item, scriptInfo)) + spans: tree.spans.map(span => this.toLocationTextSpan(span, scriptInfo)), + childItems: map(tree.childItems, item => this.toLocationNavigationTree(item, scriptInfo)) }; } - private decorateSpan(span: TextSpan, scriptInfo: ScriptInfo): protocol.TextSpan { + private toLocationTextSpan(span: TextSpan, scriptInfo: ScriptInfo): protocol.TextSpan { return { start: scriptInfo.positionToLineOffset(span.start), end: scriptInfo.positionToLineOffset(textSpanEnd(span)) @@ -1381,7 +1397,7 @@ namespace ts.server { return !tree ? undefined : simplifiedResult - ? this.decorateNavigationTree(tree, this.projectService.getScriptInfoForNormalizedPath(file)) + ? this.toLocationNavigationTree(tree, this.projectService.getScriptInfoForNormalizedPath(file)) : tree; } @@ -1400,14 +1416,12 @@ namespace ts.server { return navItems.map((navItem) => { const scriptInfo = project.getScriptInfo(navItem.fileName); - const start = scriptInfo.positionToLineOffset(navItem.textSpan.start); - const end = scriptInfo.positionToLineOffset(textSpanEnd(navItem.textSpan)); const bakedItem: protocol.NavtoItem = { name: navItem.name, kind: navItem.kind, file: navItem.fileName, - start, - end, + start: scriptInfo.positionToLineOffset(navItem.textSpan.start), + end: scriptInfo.positionToLineOffset(textSpanEnd(navItem.textSpan)) }; if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { bakedItem.kindModifiers = navItem.kindModifiers; @@ -1594,7 +1608,7 @@ namespace ts.server { fileName: change.fileName, textChanges: change.textChanges.map(textChange => this.convertTextChangeToCodeEdit(textChange, scriptInfo)) })); - return { description, changes, commands }; + return { description, changes, commands }; } private mapTextChangesToCodeEdits(project: Project, textChanges: FileTextChanges): protocol.FileCodeEdits { @@ -1622,7 +1636,7 @@ namespace ts.server { return !spans ? undefined : simplifiedResult - ? spans.map(span => this.decorateSpan(span, scriptInfo)) + ? spans.map(span => this.toLocationTextSpan(span, scriptInfo)) : spans; } @@ -1738,6 +1752,12 @@ namespace ts.server { [CommandNames.DefinitionFull]: (request: protocol.DefinitionRequest) => { return this.requiredResponse(this.getDefinition(request.arguments, /*simplifiedResult*/ false)); }, + [CommandNames.DefinitionAndBoundSpan]: (request: protocol.DefinitionRequest) => { + return this.requiredResponse(this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ true)); + }, + [CommandNames.DefinitionAndBoundSpanFull]: (request: protocol.DefinitionRequest) => { + return this.requiredResponse(this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false)); + }, [CommandNames.TypeDefinition]: (request: protocol.FileLocationRequest) => { return this.requiredResponse(this.getTypeDefinition(request.arguments)); }, diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index cb2be7d484caf..35f4d079e292c 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -88,7 +88,7 @@ namespace ts.GoToDefinition { // } // bar(({pr/*goto*/op1})=>{}); if (isPropertyName(node) && isBindingElement(node.parent) && isObjectBindingPattern(node.parent.parent) && - (node === (node.parent.propertyName || node.parent.name))) { + (node === (node.parent.propertyName || node.parent.name))) { const type = typeChecker.getTypeAtLocation(node.parent.parent); if (type) { const propSymbols = getPropertySymbolsFromType(type, node); @@ -149,6 +149,28 @@ namespace ts.GoToDefinition { return getDefinitionFromSymbol(typeChecker, type.symbol, node); } + export function getDefinitionAndBoundSpan(program: Program, sourceFile: SourceFile, position: number): DefinitionInfoAndBoundSpan { + const definitions = getDefinitionAtPosition(program, sourceFile, position); + + if (!definitions || definitions.length === 0) { + return undefined; + } + + // Check if position is on triple slash reference. + const comment = findReferenceInPosition(sourceFile.referencedFiles, position) || findReferenceInPosition(sourceFile.typeReferenceDirectives, position); + if (comment) { + return { + definitions, + textSpan: createTextSpanFromBounds(comment.pos, comment.end) + }; + } + + const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); + const textSpan = createTextSpan(node.getStart(), node.getWidth()); + + return { definitions, textSpan }; + } + // Go to the original declaration for cases: // // (1) when the aliased symbol was declared in the location(parent). diff --git a/src/services/services.ts b/src/services/services.ts index 100e90529e892..06edd621e964b 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -724,9 +724,9 @@ namespace ts { case SyntaxKind.BinaryExpression: if (getSpecialPropertyAssignmentKind(node as BinaryExpression) !== SpecialPropertyAssignmentKind.None) { - addDeclaration(node as BinaryExpression); + addDeclaration(node as BinaryExpression); } - // falls through + // falls through default: forEachChild(node, visit); @@ -1428,6 +1428,11 @@ namespace ts { return GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position); } + function getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan { + synchronizeHostData(); + return GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position); + } + function getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] { synchronizeHostData(); return GoToDefinition.getTypeDefinitionAtPosition(program.getTypeChecker(), getValidSourceFile(fileName), position); @@ -2040,6 +2045,7 @@ namespace ts { getSignatureHelpItems, getQuickInfoAtPosition, getDefinitionAtPosition, + getDefinitionAndBoundSpan, getImplementationAtPosition, getTypeDefinitionAtPosition, getReferencesAtPosition, diff --git a/src/services/shims.ts b/src/services/shims.ts index 3e0a1e75f4183..9048d68c82878 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -170,6 +170,8 @@ namespace ts { */ getDefinitionAtPosition(fileName: string, position: number): string; + getDefinitionAndBoundSpan(fileName: string, position: number): string; + /** * Returns a JSON-encoded value of the type: * { fileName: string; textSpan: { start: number; length: number}; kind: string; name: string; containerKind: string; containerName: string } @@ -772,6 +774,17 @@ namespace ts { ); } + /** + * Computes the definition location and file for the symbol + * at the requested position. + */ + public getDefinitionAndBoundSpan(fileName: string, position: number): string { + return this.forwardJSONCall( + `getDefinitionAndBoundSpan('${fileName}', ${position})`, + () => this.languageService.getDefinitionAndBoundSpan(fileName, position) + ); + } + /// GOTO Type /** diff --git a/src/services/types.ts b/src/services/types.ts index 3bb65b808fd65..2d629041d1f8f 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -259,6 +259,7 @@ namespace ts { findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan; getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[]; @@ -581,6 +582,11 @@ namespace ts { containerName: string; } + export interface DefinitionInfoAndBoundSpan { + definitions: ReadonlyArray; + textSpan: TextSpan; + } + export interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { displayParts: SymbolDisplayPart[]; } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 9f95a3af7c1ce..89747c653c038 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -3925,6 +3925,7 @@ declare namespace ts { getRenameInfo(fileName: string, position: number): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan; getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[]; getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; @@ -4188,6 +4189,10 @@ declare namespace ts { containerKind: ScriptElementKind; containerName: string; } + interface DefinitionInfoAndBoundSpan { + definitions: ReadonlyArray; + textSpan: TextSpan; + } interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { displayParts: SymbolDisplayPart[]; } @@ -4823,6 +4828,7 @@ declare namespace ts.server.protocol { CompileOnSaveEmitFile = "compileOnSaveEmitFile", Configure = "configure", Definition = "definition", + DefinitionAndBoundSpan = "definitionAndBoundSpan", Implementation = "implementation", Exit = "exit", Format = "format", @@ -5342,12 +5348,19 @@ declare namespace ts.server.protocol { */ file: string; } + interface DefinitionInfoAndBoundSpan { + definitions: ReadonlyArray; + textSpan: TextSpan; + } /** * Definition response message. Gives text range for definition. */ interface DefinitionResponse extends Response { body?: FileSpan[]; } + interface DefinitionInfoAndBoundSpanReponse extends Response { + body?: DefinitionInfoAndBoundSpan; + } /** * Definition response message. Gives text range for definition. */ @@ -6923,6 +6936,9 @@ declare namespace ts.server { private convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo); private getDiagnosticsWorker(args, isSemantic, selector, includeLinePosition); private getDefinition(args, simplifiedResult); + private getDefinitionAndBoundSpan(args, simplifiedResult); + private mapDefinitionInfo(definitions, project); + private toFileSpan(fileName, textSpan, project); private getTypeDefinition(args); private getImplementation(args, simplifiedResult); private getOccurrences(args); @@ -6972,10 +6988,10 @@ declare namespace ts.server { private reload(args, reqSeq); private saveToTmp(fileName, tempFileName); private closeClientFile(fileName); - private decorateNavigationBarItems(items, scriptInfo); + private mapLocationNavigationBarItems(items, scriptInfo); private getNavigationBarItems(args, simplifiedResult); - private decorateNavigationTree(tree, scriptInfo); - private decorateSpan(span, scriptInfo); + private toLocationNavigationTree(tree, scriptInfo); + private toLocationTextSpan(span, scriptInfo); private getNavigationTree(args, simplifiedResult); private getNavigateToItems(args, simplifiedResult); private getSupportedCodeFixes(); diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 67965ca33e340..32c3c3b425566 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3925,6 +3925,7 @@ declare namespace ts { getRenameInfo(fileName: string, position: number): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan; getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[]; getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; @@ -4188,6 +4189,10 @@ declare namespace ts { containerKind: ScriptElementKind; containerName: string; } + interface DefinitionInfoAndBoundSpan { + definitions: ReadonlyArray; + textSpan: TextSpan; + } interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { displayParts: SymbolDisplayPart[]; } diff --git a/tests/cases/fourslash/ambientShorthandGotoDefinition.ts b/tests/cases/fourslash/ambientShorthandGotoDefinition.ts index 74e348beb7437..f0e717999cf6e 100644 --- a/tests/cases/fourslash/ambientShorthandGotoDefinition.ts +++ b/tests/cases/fourslash/ambientShorthandGotoDefinition.ts @@ -5,10 +5,10 @@ // @Filename: user.ts /////// -////import /*importFoo*/foo, {bar} from "jquery"; -////import * as /*importBaz*/baz from "jquery"; -////import /*importBang*/bang = require("jquery"); -////foo/*useFoo*/(bar/*useBar*/, baz/*useBaz*/, bang/*useBang*/); +////import [|/*importFoo*/foo|], {bar} from "jquery"; +////import * as [|/*importBaz*/baz|] from "jquery"; +////import [|/*importBang*/bang|] = require("jquery"); +////[|foo/*useFoo*/|]([|bar/*useBar*/|], [|baz/*useBaz*/|], [|bang/*useBang*/|]); verify.quickInfoAt("useFoo", "import foo"); verify.goToDefinition({ diff --git a/tests/cases/fourslash/definition.ts b/tests/cases/fourslash/definition.ts index 705cdd655832b..f91d8a9e34610 100644 --- a/tests/cases/fourslash/definition.ts +++ b/tests/cases/fourslash/definition.ts @@ -1,7 +1,7 @@ /// // @Filename: b.ts -////import n = require('./a/*1*/'); +////import n = require([|'./a/*1*/'|]); ////var x = new n.Foo(); // @Filename: a.ts diff --git a/tests/cases/fourslash/definitionNameOnEnumMember.ts b/tests/cases/fourslash/definitionNameOnEnumMember.ts index b82b0dc0465a7..5529dc2bb5515 100644 --- a/tests/cases/fourslash/definitionNameOnEnumMember.ts +++ b/tests/cases/fourslash/definitionNameOnEnumMember.ts @@ -5,7 +5,7 @@ //// secondMember, //// thirdMember ////} -////var enumMember = e./*1*/thirdMember; +////var enumMember = e.[|/*1*/thirdMember|]; goTo.marker("1"); verify.goToDefinitionName("thirdMember", "e"); diff --git a/tests/cases/fourslash/duplicatePackageServices.ts b/tests/cases/fourslash/duplicatePackageServices.ts index 360611ad1403b..c84c43cdd9e8c 100644 --- a/tests/cases/fourslash/duplicatePackageServices.ts +++ b/tests/cases/fourslash/duplicatePackageServices.ts @@ -2,7 +2,7 @@ // @noImplicitReferences: true // @Filename: /node_modules/a/index.d.ts -////import /*useAX*/[|{| "isWriteAccess": true, "isDefinition": true |}X|] from "x"; +////import [|{| "name": "useAX", "isWriteAccess": true, "isDefinition": true |}X|] from "x"; ////export function a(x: [|X|]): void; // @Filename: /node_modules/a/node_modules/x/index.d.ts @@ -14,7 +14,7 @@ ////{ "name": "x", "version": "1.2.3" } // @Filename: /node_modules/b/index.d.ts -////import /*useBX*/[|{| "isWriteAccess": true, "isDefinition": true |}X|] from "x"; +////import [|{| "name": "useBX", "isWriteAccess": true, "isDefinition": true |}X|] from "x"; ////export const b: [|X|]; // @Filename: /node_modules/b/node_modules/x/index.d.ts diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport.ts b/tests/cases/fourslash/findAllRefsForDefaultExport.ts index 7cd6fe8d57c62..414b2503391a1 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport.ts @@ -5,7 +5,7 @@ // @Filename: b.ts ////import [|{| "isWriteAccess": true, "isDefinition": true |}g|] from "./a"; -/////*ref*/[|g|](); +////[|/*ref*/g|](); // @Filename: c.ts ////import { f } from "./a"; diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 5136508f64a0c..9eca1d6456556 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -221,6 +221,7 @@ declare namespace FourSlashInterface { * `verify.goToDefinition("a", ["b", "bb"]);` verifies that "a" has multiple definitions available. */ goToDefinition(startMarkerNames: string | string[], endMarkerNames: string | string[]): void; + goToDefinition(startMarkerNames: string | string[], endMarkerNames: string | string[], range: Range): void; /** Performs `goToDefinition` for each pair. */ goToDefinition(startsAndEnds: [string | string[], string | string[]][]): void; /** Performs `goToDefinition` on each key and value. */ diff --git a/tests/cases/fourslash/goToDefinitionAcrossMultipleProjects.ts b/tests/cases/fourslash/goToDefinitionAcrossMultipleProjects.ts index 7c0565c626a8f..5447609c02785 100644 --- a/tests/cases/fourslash/goToDefinitionAcrossMultipleProjects.ts +++ b/tests/cases/fourslash/goToDefinitionAcrossMultipleProjects.ts @@ -9,6 +9,6 @@ //@Filename: c.ts /////// /////// -/////*use*/x++; +////[|/*use*/x|]++; verify.goToDefinition("use", ["def1", "def2"]); diff --git a/tests/cases/fourslash/goToDefinitionAlias.ts b/tests/cases/fourslash/goToDefinitionAlias.ts index 22aa049fde3a8..66afe07b6334f 100644 --- a/tests/cases/fourslash/goToDefinitionAlias.ts +++ b/tests/cases/fourslash/goToDefinitionAlias.ts @@ -7,12 +7,12 @@ ////} //// ////// Type position -////var t1: /*alias1Type*/alias1.IFoo; -////var t2: Module./*alias2Type*/alias2.IFoo; +////var t1: [|/*alias1Type*/alias1|].IFoo; +////var t2: Module.[|/*alias2Type*/alias2|].IFoo; //// ////// Value posistion -////var v1 = new /*alias1Value*/alias1.Foo(); -////var v2 = new Module./*alias2Value*/alias2.Foo(); +////var v1 = new [|/*alias1Value*/alias1|].Foo(); +////var v2 = new Module.[|/*alias2Value*/alias2|].Foo(); // @Filename: a.ts diff --git a/tests/cases/fourslash/goToDefinitionApparentTypeProperties.ts b/tests/cases/fourslash/goToDefinitionApparentTypeProperties.ts index dd0d91810c498..5d4ec89638064 100644 --- a/tests/cases/fourslash/goToDefinitionApparentTypeProperties.ts +++ b/tests/cases/fourslash/goToDefinitionApparentTypeProperties.ts @@ -5,7 +5,7 @@ ////} //// ////var o = 0; -////o./*reference1*/myObjectMethod(); -////o["/*reference2*/myObjectMethod"](); +////o.[|/*reference1*/myObjectMethod|](); +////o[[|"/*reference2*/myObjectMethod"|]](); verify.goToDefinition(["reference1", "reference2"], "definition"); diff --git a/tests/cases/fourslash/goToDefinitionConstructorOfClassExpression01.ts b/tests/cases/fourslash/goToDefinitionConstructorOfClassExpression01.ts index 4b774b8b0ee2d..b9f17611b18a5 100644 --- a/tests/cases/fourslash/goToDefinitionConstructorOfClassExpression01.ts +++ b/tests/cases/fourslash/goToDefinitionConstructorOfClassExpression01.ts @@ -2,7 +2,7 @@ ////var x = class C { //// /*definition*/constructor() { -//// var other = new /*usage*/C; +//// var other = new [|/*usage*/C|]; //// } ////} diff --git a/tests/cases/fourslash/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01.ts b/tests/cases/fourslash/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01.ts index bf698c0752da0..8f1bc2496dc0b 100644 --- a/tests/cases/fourslash/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01.ts +++ b/tests/cases/fourslash/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01.ts @@ -9,6 +9,6 @@ //// } ////} //// -////var x = new /*usage*/Foo(); +////var x = new [|/*usage*/Foo|](); verify.goToDefinition("usage", "definition"); diff --git a/tests/cases/fourslash/goToDefinitionConstructorOverloads.ts b/tests/cases/fourslash/goToDefinitionConstructorOverloads.ts index a3a5e3286b28f..edc9e85d44426 100644 --- a/tests/cases/fourslash/goToDefinitionConstructorOverloads.ts +++ b/tests/cases/fourslash/goToDefinitionConstructorOverloads.ts @@ -1,13 +1,13 @@ /// ////class ConstructorOverload { -//// /*constructorOverload1*/constructor(); +//// [|/*constructorOverload1*/constructor|](); //// /*constructorOverload2*/constructor(foo: string); //// /*constructorDefinition*/constructor(foo: any) { } ////} //// -////var constructorOverload = new /*constructorOverloadReference1*/ConstructorOverload(); -////var constructorOverload = new /*constructorOverloadReference2*/ConstructorOverload("foo"); +////var constructorOverload = new [|/*constructorOverloadReference1*/ConstructorOverload|](); +////var constructorOverload = new [|/*constructorOverloadReference2*/ConstructorOverload|]("foo"); verify.goToDefinition({ constructorOverloadReference1: "constructorOverload1", diff --git a/tests/cases/fourslash/goToDefinitionDecorator.ts b/tests/cases/fourslash/goToDefinitionDecorator.ts index bef9c8fa5f11a..535726aef0889 100644 --- a/tests/cases/fourslash/goToDefinitionDecorator.ts +++ b/tests/cases/fourslash/goToDefinitionDecorator.ts @@ -1,9 +1,9 @@ /// // @Filename: b.ts -////@/*decoratorUse*/decorator +////@[|/*decoratorUse*/decorator|] ////class C { -//// @decora/*decoratorFactoryUse*/torFactory(a, "22", true) +//// @[|decora/*decoratorFactoryUse*/torFactory|](a, "22", true) //// method() {} ////} diff --git a/tests/cases/fourslash/goToDefinitionDecoratorOverloads.ts b/tests/cases/fourslash/goToDefinitionDecoratorOverloads.ts index 965c8bbbc6d48..4943c23e392e6 100644 --- a/tests/cases/fourslash/goToDefinitionDecoratorOverloads.ts +++ b/tests/cases/fourslash/goToDefinitionDecoratorOverloads.ts @@ -9,8 +9,8 @@ //// ////declare const s: symbol; ////class C { -//// @/*useDecString*/dec f() {} -//// @/*useDecSymbol*/dec [s]() {} +//// @[|/*useDecString*/dec|] f() {} +//// @[|/*useDecSymbol*/dec|] [s]() {} ////} verify.goToDefinition({ diff --git a/tests/cases/fourslash/goToDefinitionDynamicImport1.ts b/tests/cases/fourslash/goToDefinitionDynamicImport1.ts index 2e93534496a87..d85ba12d72529 100644 --- a/tests/cases/fourslash/goToDefinitionDynamicImport1.ts +++ b/tests/cases/fourslash/goToDefinitionDynamicImport1.ts @@ -3,8 +3,8 @@ // @Filename: foo.ts //// /*Destination*/export function foo() { return "foo"; } -//// import("./f/*1*/oo") -//// var x = import("./fo/*2*/o") +//// import([|"./f/*1*/oo"|]) +//// var x = import([|"./fo/*2*/o"|]) verify.goToDefinition("1", "Destination"); verify.goToDefinition("2", "Destination"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToDefinitionDynamicImport2.ts b/tests/cases/fourslash/goToDefinitionDynamicImport2.ts index c3c213a6cdb25..678628d641fdd 100644 --- a/tests/cases/fourslash/goToDefinitionDynamicImport2.ts +++ b/tests/cases/fourslash/goToDefinitionDynamicImport2.ts @@ -5,7 +5,7 @@ //// var x = import("./foo"); //// x.then(foo => { -//// foo.b/*1*/ar(); +//// foo.[|b/*1*/ar|](); //// }) verify.goToDefinition("1", "Destination"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToDefinitionDynamicImport3.ts b/tests/cases/fourslash/goToDefinitionDynamicImport3.ts index f8c5962f9847e..dc63696d62a52 100644 --- a/tests/cases/fourslash/goToDefinitionDynamicImport3.ts +++ b/tests/cases/fourslash/goToDefinitionDynamicImport3.ts @@ -3,6 +3,6 @@ // @Filename: foo.ts //// export function /*Destination*/bar() { return "bar"; } -//// import('./foo').then(({ ba/*1*/r }) => undefined); +//// import('./foo').then(({ [|ba/*1*/r|] }) => undefined); verify.goToDefinition("1", "Destination"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToDefinitionDynamicImport4.ts b/tests/cases/fourslash/goToDefinitionDynamicImport4.ts index f8c5962f9847e..dc63696d62a52 100644 --- a/tests/cases/fourslash/goToDefinitionDynamicImport4.ts +++ b/tests/cases/fourslash/goToDefinitionDynamicImport4.ts @@ -3,6 +3,6 @@ // @Filename: foo.ts //// export function /*Destination*/bar() { return "bar"; } -//// import('./foo').then(({ ba/*1*/r }) => undefined); +//// import('./foo').then(({ [|ba/*1*/r|] }) => undefined); verify.goToDefinition("1", "Destination"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName.ts index 705cdd655832b..f91d8a9e34610 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName.ts @@ -1,7 +1,7 @@ /// // @Filename: b.ts -////import n = require('./a/*1*/'); +////import n = require([|'./a/*1*/'|]); ////var x = new n.Foo(); // @Filename: a.ts diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName2.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName2.ts index 866d21b363292..913b297feb898 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName2.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName2.ts @@ -1,7 +1,7 @@ /// // @Filename: b.ts -////import n = require('./a/*1*/'); +////import n = require([|'./a/*1*/'|]); ////var x = new n.Foo(); // @Filename: a.ts diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName3.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName3.ts index 7ac0376474d46..d6e28263239d8 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName3.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName3.ts @@ -1,7 +1,7 @@ /// // @Filename: b.ts -////import n = require('e/*1*/'); +////import n = require([|'e/*1*/'|]); ////var x = new n.Foo(); // @Filename: a.ts diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName5.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName5.ts index 36ae9dd716f53..9dede44a7bcd5 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName5.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName5.ts @@ -1,7 +1,7 @@ /// // @Filename: a.ts -////declare module /*2*/"external/*1*/" { +////declare module /*2*/[|"external/*1*/"|] { //// class Foo { } ////} diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName6.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName6.ts index a71030628e68f..51b96cfe3baeb 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName6.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName6.ts @@ -1,7 +1,7 @@ /// // @Filename: b.ts -////import * from 'e/*1*/'; +////import * from [|'e/*1*/'|]; // @Filename: a.ts ////declare module /*2*/"e" { diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName7.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName7.ts index b025944d012d0..591577bf47020 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName7.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName7.ts @@ -1,7 +1,7 @@ /// // @Filename: b.ts -////import {Foo, Bar} from 'e/*1*/'; +////import {Foo, Bar} from [|'e/*1*/'|]; // @Filename: a.ts ////declare module /*2*/"e" { diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName8.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName8.ts index ca9d7c83e66da..636c234c79e47 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName8.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName8.ts @@ -1,7 +1,7 @@ /// // @Filename: b.ts -////export {Foo, Bar} from 'e/*1*/'; +////export {Foo, Bar} from [|'e/*1*/'|]; // @Filename: a.ts ////declare module /*2*/"e" { diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName9.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName9.ts index 80971be100faa..60decba626cd5 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName9.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName9.ts @@ -1,7 +1,7 @@ /// // @Filename: b.ts -////export * from 'e/*1*/'; +////export * from [|'e/*1*/'|]; // @Filename: a.ts ////declare module /*2*/"e" { diff --git a/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts b/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts index 60c7a8111ee14..ca3883be86c9f 100644 --- a/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts +++ b/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts @@ -1,12 +1,12 @@ /// -////function /*functionOverload1*/functionOverload(value: number); +////function [|/*functionOverload1*/functionOverload|](value: number); ////function /*functionOverload2*/functionOverload(value: string); ////function /*functionOverloadDefinition*/functionOverload() {} //// -/////*functionOverloadReference1*/functionOverload(123); -/////*functionOverloadReference2*/functionOverload("123"); -/////*brokenOverload*/functionOverload({}); +////[|/*functionOverloadReference1*/functionOverload|](123); +////[|/*functionOverloadReference2*/functionOverload|]("123"); +////[|/*brokenOverload*/functionOverload|]({}); verify.goToDefinition({ functionOverloadReference1: "functionOverload1", diff --git a/tests/cases/fourslash/goToDefinitionFunctionOverloadsInClass.ts b/tests/cases/fourslash/goToDefinitionFunctionOverloadsInClass.ts index 04017123fd872..08ec93b5eeac5 100644 --- a/tests/cases/fourslash/goToDefinitionFunctionOverloadsInClass.ts +++ b/tests/cases/fourslash/goToDefinitionFunctionOverloadsInClass.ts @@ -2,9 +2,9 @@ ////class clsInOverload { //// static fnOverload(); -//// static /*staticFunctionOverload*/fnOverload(foo: string); +//// static [|/*staticFunctionOverload*/fnOverload|](foo: string); //// static /*staticFunctionOverloadDefinition*/fnOverload(foo: any) { } -//// public /*functionOverload*/fnOverload(): any; +//// public [|/*functionOverload*/fnOverload|](): any; //// public fnOverload(foo: string); //// public /*functionOverloadDefinition*/fnOverload(foo: any) { return "foo" } //// diff --git a/tests/cases/fourslash/goToDefinitionImportedNames.ts b/tests/cases/fourslash/goToDefinitionImportedNames.ts index 41a1c443b281b..c525783b9c2b7 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames.ts @@ -1,7 +1,7 @@ /// // @Filename: b.ts -////export {/*classAliasDefinition*/Class} from "./a"; +////export {[|/*classAliasDefinition*/Class|]} from "./a"; // @Filename: a.ts diff --git a/tests/cases/fourslash/goToDefinitionImportedNames2.ts b/tests/cases/fourslash/goToDefinitionImportedNames2.ts index fa3c5c862b7d8..58a5d018eefa8 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames2.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames2.ts @@ -1,7 +1,7 @@ /// // @Filename: b.ts -////import {/*classAliasDefinition*/Class} from "./a"; +////import {[|/*classAliasDefinition*/Class|]} from "./a"; // @Filename: a.ts diff --git a/tests/cases/fourslash/goToDefinitionImportedNames3.ts b/tests/cases/fourslash/goToDefinitionImportedNames3.ts index b9f598f30cde7..ea52f660c11f2 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames3.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames3.ts @@ -1,8 +1,8 @@ /// // @Filename: e.ts -//// import {M, /*classAliasDefinition*/C, I} from "./d"; -//// var c = new /*classReference*/C(); +//// import {M, [|/*classAliasDefinition*/C|], I} from "./d"; +//// var c = new [|/*classReference*/C|](); // @Filename: d.ts diff --git a/tests/cases/fourslash/goToDefinitionImportedNames4.ts b/tests/cases/fourslash/goToDefinitionImportedNames4.ts index 81f2e67126665..435ab41a2ad48 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames4.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames4.ts @@ -1,7 +1,7 @@ /// // @Filename: b.ts -////import {Class as /*classAliasDefinition*/ClassAlias} from "./a"; +////import {Class as [|/*classAliasDefinition*/ClassAlias|]} from "./a"; // @Filename: a.ts diff --git a/tests/cases/fourslash/goToDefinitionImportedNames5.ts b/tests/cases/fourslash/goToDefinitionImportedNames5.ts index b78110c95d950..7965b341d9efc 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames5.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames5.ts @@ -1,7 +1,7 @@ /// // @Filename: b.ts -////export {Class as /*classAliasDefinition*/ClassAlias} from "./a"; +////export {Class as [|/*classAliasDefinition*/ClassAlias|]} from "./a"; // @Filename: a.ts diff --git a/tests/cases/fourslash/goToDefinitionImportedNames6.ts b/tests/cases/fourslash/goToDefinitionImportedNames6.ts index 21603cded426b..a8acf33e42af0 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames6.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames6.ts @@ -1,7 +1,7 @@ /// // @Filename: b.ts -////import /*moduleAliasDefinition*/alias = require("./a"); +////import [|/*moduleAliasDefinition*/alias|] = require("./a"); // @Filename: a.ts diff --git a/tests/cases/fourslash/goToDefinitionImportedNames7.ts b/tests/cases/fourslash/goToDefinitionImportedNames7.ts index bdf1eff86eb77..d798dcfff0c05 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames7.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames7.ts @@ -1,7 +1,7 @@ /// // @Filename: b.ts -////import /*classAliasDefinition*/defaultExport from "./a"; +////import [|/*classAliasDefinition*/defaultExport|] from "./a"; // @Filename: a.ts diff --git a/tests/cases/fourslash/goToDefinitionImports.ts b/tests/cases/fourslash/goToDefinitionImports.ts index 4fdaedb5c3db7..1debd3c6b6f9c 100644 --- a/tests/cases/fourslash/goToDefinitionImports.ts +++ b/tests/cases/fourslash/goToDefinitionImports.ts @@ -12,10 +12,10 @@ ////import f, { x } from "./a"; ////import * as /*aDef*/a from "./a"; ////import b = require("./b"); -/////*fUse*/f; -/////*xUse*/x; -/////*aUse*/a; -/////*bUse*/b; +////[|/*fUse*/f|]; +////[|/*xUse*/x|]; +////[|/*aUse*/a|]; +////[|/*bUse*/b|]; verify.goToDefinition({ aUse: "aDef", // Namespace import isn't "skipped" diff --git a/tests/cases/fourslash/goToDefinitionInMemberDeclaration.ts b/tests/cases/fourslash/goToDefinitionInMemberDeclaration.ts index 93be208644083..4a09a931bf6e9 100644 --- a/tests/cases/fourslash/goToDefinitionInMemberDeclaration.ts +++ b/tests/cases/fourslash/goToDefinitionInMemberDeclaration.ts @@ -9,13 +9,13 @@ ////enum /*enumDefinition*/Enum { value1, value2 }; //// ////class /*selfDefinition*/Bar { -//// public _interface: IFo/*interfaceReference*/o = new Fo/*classReferenceInInitializer*/o(); -//// public _class: Fo/*classReference*/o = new Foo(); -//// public _list: IF/*interfaceReferenceInList*/oo[]=[]; -//// public _enum: E/*enumReference*/num = En/*enumReferenceInInitializer*/um.value1; -//// public _self: Ba/*selfReference*/r; +//// public _interface: [|IFo/*interfaceReference*/o|] = new [|Fo/*classReferenceInInitializer*/o|](); +//// public _class: [|Fo/*classReference*/o|] = new Foo(); +//// public _list: [|IF/*interfaceReferenceInList*/oo|][]=[]; +//// public _enum: [|E/*enumReference*/num|] = [|En/*enumReferenceInInitializer*/um|].value1; +//// public _self: [|Ba/*selfReference*/r|]; //// -//// constructor(public _inConstructor: IFo/*interfaceReferenceInConstructor*/o) { +//// constructor(public _inConstructor: [|IFo/*interfaceReferenceInConstructor*/o|]) { //// } ////} diff --git a/tests/cases/fourslash/goToDefinitionJsModuleName.ts b/tests/cases/fourslash/goToDefinitionJsModuleName.ts index cdd322158f7a7..8514e7070e465 100644 --- a/tests/cases/fourslash/goToDefinitionJsModuleName.ts +++ b/tests/cases/fourslash/goToDefinitionJsModuleName.ts @@ -5,6 +5,6 @@ /////*2*/module.exports = {}; // @Filename: bar.js -////var x = require(/*1*/"./foo"); +////var x = require([|/*1*/"./foo"|]); verify.goToDefinition("1", "2"); diff --git a/tests/cases/fourslash/goToDefinitionLabels.ts b/tests/cases/fourslash/goToDefinitionLabels.ts index 5cbf3ac8f2f05..3736d9207eeb0 100644 --- a/tests/cases/fourslash/goToDefinitionLabels.ts +++ b/tests/cases/fourslash/goToDefinitionLabels.ts @@ -2,9 +2,9 @@ /////*label1Definition*/label1: while (true) { //// /*label2Definition*/label2: while (true) { -//// break /*1*/label1; -//// continue /*2*/label2; -//// () => { break /*3*/label1; } +//// break [|/*1*/label1|]; +//// continue [|/*2*/label2|]; +//// () => { break [|/*3*/label1|]; } //// continue /*4*/unknownLabel; //// } ////} diff --git a/tests/cases/fourslash/goToDefinitionMethodOverloads.ts b/tests/cases/fourslash/goToDefinitionMethodOverloads.ts index 4dfe4753ce721..fa67b5dbef5ba 100644 --- a/tests/cases/fourslash/goToDefinitionMethodOverloads.ts +++ b/tests/cases/fourslash/goToDefinitionMethodOverloads.ts @@ -1,22 +1,22 @@ /// ////class MethodOverload { -//// static /*staticMethodOverload1*/method(); +//// static [|/*staticMethodOverload1*/method|](); //// static /*staticMethodOverload2*/method(foo: string); //// static /*staticMethodDefinition*/method(foo?: any) { } -//// public /*instanceMethodOverload1*/method(): any; +//// public [|/*instanceMethodOverload1*/method|](): any; //// public /*instanceMethodOverload2*/method(foo: string); //// public /*instanceMethodDefinition*/method(foo?: any) { return "foo" } ////} ////// static method -////MethodOverload./*staticMethodReference1*/method(); -////MethodOverload./*staticMethodReference2*/method("123"); +////MethodOverload.[|/*staticMethodReference1*/method|](); +////MethodOverload.[|/*staticMethodReference2*/method|]("123"); ////// instance method ////var methodOverload = new MethodOverload(); -////methodOverload./*instanceMethodReference1*/method(); -////methodOverload./*instanceMethodReference2*/method("456"); +////methodOverload.[|/*instanceMethodReference1*/method|](); +////methodOverload.[|/*instanceMethodReference2*/method|]("456"); verify.goToDefinition({ staticMethodReference1: "staticMethodOverload1", diff --git a/tests/cases/fourslash/goToDefinitionMultipleDefinitions.ts b/tests/cases/fourslash/goToDefinitionMultipleDefinitions.ts index fb022f7711fde..99b6d32e7f39b 100644 --- a/tests/cases/fourslash/goToDefinitionMultipleDefinitions.ts +++ b/tests/cases/fourslash/goToDefinitionMultipleDefinitions.ts @@ -14,7 +14,7 @@ //// instance3: number; ////} //// -////var ifoo: IFo/*interfaceReference*/o; +////var ifoo: [|IFo/*interfaceReference*/o|]; verify.goToDefinition("interfaceReference", ["interfaceDefinition1", "interfaceDefinition2", "interfaceDefinition3"]); @@ -29,6 +29,6 @@ verify.goToDefinition("interfaceReference", ["interfaceDefinition1", "interfaceD ////} // @Filename: e.ts -////Modul/*moduleReference*/e; +////[|Modul/*moduleReference*/e|]; verify.goToDefinition("moduleReference", ["moduleDefinition1", "moduleDefinition2"]); diff --git a/tests/cases/fourslash/goToDefinitionObjectBindingElementPropertyName01.ts b/tests/cases/fourslash/goToDefinitionObjectBindingElementPropertyName01.ts index 32b08ab710d57..1bcae72797166 100644 --- a/tests/cases/fourslash/goToDefinitionObjectBindingElementPropertyName01.ts +++ b/tests/cases/fourslash/goToDefinitionObjectBindingElementPropertyName01.ts @@ -6,6 +6,6 @@ ////} //// ////var foo: I; -////var { /*use*/property1: prop1 } = foo; +////var { [|/*use*/property1|]: prop1 } = foo; verify.goToDefinition("use", "def"); diff --git a/tests/cases/fourslash/goToDefinitionObjectLiteralProperties1.ts b/tests/cases/fourslash/goToDefinitionObjectLiteralProperties1.ts index a1c22ca4ca395..0024682dc71d3 100644 --- a/tests/cases/fourslash/goToDefinitionObjectLiteralProperties1.ts +++ b/tests/cases/fourslash/goToDefinitionObjectLiteralProperties1.ts @@ -5,11 +5,11 @@ //// } //// function foo(arg: PropsBag) {} //// foo({ -//// pr/*p1*/opx: 10 +//// [|pr/*p1*/opx|]: 10 //// }) //// function bar(firstarg: boolean, secondarg: PropsBag) {} //// bar(true, { -//// pr/*p2*/opx: 10 +//// [|pr/*p2*/opx|]: 10 //// }) diff --git a/tests/cases/fourslash/goToDefinitionObjectSpread.ts b/tests/cases/fourslash/goToDefinitionObjectSpread.ts index b23d0a8044832..918fa555f8649 100644 --- a/tests/cases/fourslash/goToDefinitionObjectSpread.ts +++ b/tests/cases/fourslash/goToDefinitionObjectSpread.ts @@ -5,5 +5,5 @@ ////let a1: A1; ////let a2: A2; ////let a12 = { ...a1, ...a2 }; -////a12.a/*3*/; +////a12.[|a/*3*/|]; verify.goToDefinition('3', [ '1', '2' ]); diff --git a/tests/cases/fourslash/goToDefinitionOverloadsInMultiplePropertyAccesses.ts b/tests/cases/fourslash/goToDefinitionOverloadsInMultiplePropertyAccesses.ts index 04a07f41a7f29..9898b6dad1ec6 100644 --- a/tests/cases/fourslash/goToDefinitionOverloadsInMultiplePropertyAccesses.ts +++ b/tests/cases/fourslash/goToDefinitionOverloadsInMultiplePropertyAccesses.ts @@ -9,6 +9,6 @@ //// export function f(value: number | string) {} //// } ////} -////A.B./*2*/f(""); +////A.B.[|/*2*/f|](""); verify.goToDefinition("2", "1"); diff --git a/tests/cases/fourslash/goToDefinitionPartialImplementation.ts b/tests/cases/fourslash/goToDefinitionPartialImplementation.ts index 81f19b578ed05..00cf6fd181966 100644 --- a/tests/cases/fourslash/goToDefinitionPartialImplementation.ts +++ b/tests/cases/fourslash/goToDefinitionPartialImplementation.ts @@ -13,7 +13,7 @@ //// x: number; //// } //// -//// var x: /*Part2Use*/IA; +//// var x: [|/*Part2Use*/IA|]; ////} verify.goToDefinition("Part2Use", ["Part1Definition", "Part2Definition"]); diff --git a/tests/cases/fourslash/goToDefinitionRest.ts b/tests/cases/fourslash/goToDefinitionRest.ts index 1459b9ffa8845..2577aafb62584 100644 --- a/tests/cases/fourslash/goToDefinitionRest.ts +++ b/tests/cases/fourslash/goToDefinitionRest.ts @@ -7,6 +7,6 @@ ////} ////let t: Gen; ////var { x, ...rest } = t; -////rest./*2*/parent; +////rest.[|/*2*/parent|]; const ranges = test.ranges(); verify.goToDefinition('2', [ '1' ]); diff --git a/tests/cases/fourslash/goToDefinitionShorthandProperty01.ts b/tests/cases/fourslash/goToDefinitionShorthandProperty01.ts index 4107049286c08..7e46894d244cd 100644 --- a/tests/cases/fourslash/goToDefinitionShorthandProperty01.ts +++ b/tests/cases/fourslash/goToDefinitionShorthandProperty01.ts @@ -3,9 +3,9 @@ //// var /*valueDeclaration1*/name = "hello"; //// var /*valueDeclaration2*/id = 100000; //// declare var /*valueDeclaration3*/id; -//// var obj = {/*valueDefinition1*/name, /*valueDefinition2*/id}; -//// obj./*valueReference1*/name; -//// obj./*valueReference2*/id; +//// var obj = {[|/*valueDefinition1*/name|], [|/*valueDefinition2*/id|]}; +//// obj.[|/*valueReference1*/name|]; +//// obj.[|/*valueReference2*/id|]; verify.goToDefinition({ valueDefinition1: "valueDeclaration1", diff --git a/tests/cases/fourslash/goToDefinitionShorthandProperty02.ts b/tests/cases/fourslash/goToDefinitionShorthandProperty02.ts index 0ecdcacdcd6ea..1d78ade426771 100644 --- a/tests/cases/fourslash/goToDefinitionShorthandProperty02.ts +++ b/tests/cases/fourslash/goToDefinitionShorthandProperty02.ts @@ -1,7 +1,7 @@ /// ////let x = { -//// f/*1*/oo +//// [|f/*1*/oo|] ////} verify.goToDefinition("1", []); diff --git a/tests/cases/fourslash/goToDefinitionShorthandProperty03.ts b/tests/cases/fourslash/goToDefinitionShorthandProperty03.ts index 42a9ee0a4d692..3a04d3efa0630 100644 --- a/tests/cases/fourslash/goToDefinitionShorthandProperty03.ts +++ b/tests/cases/fourslash/goToDefinitionShorthandProperty03.ts @@ -1,10 +1,10 @@ /// ////var /*varDef*/x = { -//// /*varProp*/x +//// [|/*varProp*/x|] ////} ////let /*letDef*/y = { -//// /*letProp*/y +//// [|/*letProp*/y|] ////} verify.goToDefinition({ diff --git a/tests/cases/fourslash/goToDefinitionSimple.ts b/tests/cases/fourslash/goToDefinitionSimple.ts index 9ae02f26bf2c9..3d1cdd632ba28 100644 --- a/tests/cases/fourslash/goToDefinitionSimple.ts +++ b/tests/cases/fourslash/goToDefinitionSimple.ts @@ -4,7 +4,7 @@ ////class /*2*/c { } // @Filename: Consumption.ts -//// var n = new /*1*/c(); -//// var n = new c/*3*/(); +//// var n = new [|/*1*/c|](); +//// var n = new [|c/*3*/|](); verify.goToDefinition(["1", "3"], "2"); diff --git a/tests/cases/fourslash/goToDefinitionSourceUnit.ts b/tests/cases/fourslash/goToDefinitionSourceUnit.ts index e66b5ef79606f..d823b366eee6b 100644 --- a/tests/cases/fourslash/goToDefinitionSourceUnit.ts +++ b/tests/cases/fourslash/goToDefinitionSourceUnit.ts @@ -4,7 +4,7 @@ //// //MyFile Comments //// //more comments //// /// -//// /// +//// /// //// //// class clsInOverload { //// static fnOverload(); diff --git a/tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts b/tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts index b01bace4febb1..fcb28f86d0572 100644 --- a/tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts +++ b/tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts @@ -4,8 +4,8 @@ ////function /*defFBool*/f(strs: TemplateStringsArray, x: boolean): void; ////function f(strs: TemplateStringsArray, x: number | boolean) {} //// -/////*useFNumber*/f`${0}`; -/////*useFBool*/f`${false}`; +////[|/*useFNumber*/f|]`${0}`; +////[|/*useFBool*/f|]`${false}`; verify.goToDefinition({ useFNumber: "defFNumber", diff --git a/tests/cases/fourslash/goToDefinitionThis.ts b/tests/cases/fourslash/goToDefinitionThis.ts index 923fb6c8febde..88cbcb8ca9631 100644 --- a/tests/cases/fourslash/goToDefinitionThis.ts +++ b/tests/cases/fourslash/goToDefinitionThis.ts @@ -1,11 +1,11 @@ /// ////function f(/*fnDecl*/this: number) { -//// return /*fnUse*/this; +//// return [|/*fnUse*/this|]; ////} ////class /*cls*/C { -//// constructor() { return /*clsUse*/this; } -//// get self(/*getterDecl*/this: number) { return /*getterUse*/this; } +//// constructor() { return [|/*clsUse*/this|]; } +//// get self(/*getterDecl*/this: number) { return [|/*getterUse*/this|]; } ////} verify.goToDefinition({ diff --git a/tests/cases/fourslash/goToDefinitionTypePredicate.ts b/tests/cases/fourslash/goToDefinitionTypePredicate.ts index 17e6fc1be6b25..9988611885c67 100644 --- a/tests/cases/fourslash/goToDefinitionTypePredicate.ts +++ b/tests/cases/fourslash/goToDefinitionTypePredicate.ts @@ -1,7 +1,7 @@ /// //// class /*classDeclaration*/A {} -//// function f(/*parameterDeclaration*/parameter: any): /*parameterName*/parameter is /*typeReference*/A { +//// function f(/*parameterDeclaration*/parameter: any): [|/*parameterName*/parameter|] is [|/*typeReference*/A|] { //// return typeof parameter === "string"; //// } diff --git a/tests/cases/fourslash/goToDefinitionTypeReferenceDirective.ts b/tests/cases/fourslash/goToDefinitionTypeReferenceDirective.ts index ad02bb9d85124..532390fb35e7d 100644 --- a/tests/cases/fourslash/goToDefinitionTypeReferenceDirective.ts +++ b/tests/cases/fourslash/goToDefinitionTypeReferenceDirective.ts @@ -5,7 +5,7 @@ /////*0*/declare let $: {x: number}; // @Filename: src/app.ts -//// /// +//// /// //// $.x; verify.goToDefinition("1", "0"); diff --git a/tests/cases/fourslash/goToDefinitionUnionTypeProperty1.ts b/tests/cases/fourslash/goToDefinitionUnionTypeProperty1.ts index 82bd07e32f04f..6baca39e01181 100644 --- a/tests/cases/fourslash/goToDefinitionUnionTypeProperty1.ts +++ b/tests/cases/fourslash/goToDefinitionUnionTypeProperty1.ts @@ -12,7 +12,7 @@ //// ////var x : One | Two; //// -////x./*propertyReference*/commonProperty; +////x.[|/*propertyReference*/commonProperty|]; ////x./*3*/commonFunction; verify.goToDefinition("propertyReference", ["propertyDefinition1", "propertyDefinition2"]); diff --git a/tests/cases/fourslash/goToDefinitionUnionTypeProperty2.ts b/tests/cases/fourslash/goToDefinitionUnionTypeProperty2.ts index 22ffb906e8e5a..3ade25ca62267 100644 --- a/tests/cases/fourslash/goToDefinitionUnionTypeProperty2.ts +++ b/tests/cases/fourslash/goToDefinitionUnionTypeProperty2.ts @@ -14,6 +14,6 @@ //// ////var x : One | Two; //// -////x.common./*propertyReference*/a; +////x.common.[|/*propertyReference*/a|]; verify.goToDefinition("propertyReference", ["propertyDefinition2", "propertyDefinition1"]); diff --git a/tests/cases/fourslash/goToDefinitionUnionTypeProperty3.ts b/tests/cases/fourslash/goToDefinitionUnionTypeProperty3.ts index fde4d2319fec6..3f5666f19b884 100644 --- a/tests/cases/fourslash/goToDefinitionUnionTypeProperty3.ts +++ b/tests/cases/fourslash/goToDefinitionUnionTypeProperty3.ts @@ -7,6 +7,6 @@ ////var strings: string[]; ////var numbers: number[]; //// -////var x = (strings || numbers)./*usage*/specialPop() +////var x = (strings || numbers).[|/*usage*/specialPop|]() verify.goToDefinition("usage", "definition"); diff --git a/tests/cases/fourslash/goToDefinitionUnionTypeProperty4.ts b/tests/cases/fourslash/goToDefinitionUnionTypeProperty4.ts index f69554098c52a..a4c5996159265 100644 --- a/tests/cases/fourslash/goToDefinitionUnionTypeProperty4.ts +++ b/tests/cases/fourslash/goToDefinitionUnionTypeProperty4.ts @@ -16,6 +16,6 @@ ////var magnitude: Magnitude; ////var snapcrackle: SnapCrackle; //// -////var x = (snapcrackle || magnitude || art)./*usage*/pop; +////var x = (snapcrackle || magnitude || art).[|/*usage*/pop|]; verify.goToDefinition("usage", ["def1", "def2", "def3"]); diff --git a/tests/cases/fourslash/goToDefinition_super.ts b/tests/cases/fourslash/goToDefinition_super.ts index 115e4a4a6edc5..22f00aff7dc34 100644 --- a/tests/cases/fourslash/goToDefinition_super.ts +++ b/tests/cases/fourslash/goToDefinition_super.ts @@ -7,10 +7,10 @@ ////class /*B*/B extends A {} ////class C extends B { //// constructor() { -//// /*super*/super(); +//// [|/*super*/super|](); //// } //// method() { -//// /*superExpression*/super.x(); +//// [|/*superExpression*/super|].x(); //// } ////} ////class D { diff --git a/tests/cases/fourslash/goToDefinition_untypedModule.ts b/tests/cases/fourslash/goToDefinition_untypedModule.ts index fe29f7104cfa7..8c9e83711a931 100644 --- a/tests/cases/fourslash/goToDefinition_untypedModule.ts +++ b/tests/cases/fourslash/goToDefinition_untypedModule.ts @@ -5,6 +5,6 @@ // @Filename: /a.ts ////import { /*def*/f } from "foo"; -/////*use*/f(); +////[|/*use*/f|](); verify.goToDefinition("use", "def"); diff --git a/tests/cases/fourslash/goToModuleAliasDefinition.ts b/tests/cases/fourslash/goToModuleAliasDefinition.ts index dfccc3393c59b..98724228a6e4c 100644 --- a/tests/cases/fourslash/goToModuleAliasDefinition.ts +++ b/tests/cases/fourslash/goToModuleAliasDefinition.ts @@ -5,7 +5,7 @@ // @Filename: b.ts //// import /*3*/n = require('a'); -//// var x = new /*1*/n.Foo(); +//// var x = new [|/*1*/n|].Foo(); // Won't-fixed: Should go to '2' instead verify.goToDefinition("1", "3"); diff --git a/tests/cases/fourslash/gotoDefinitionInObjectBindingPattern1.ts b/tests/cases/fourslash/gotoDefinitionInObjectBindingPattern1.ts index 98c06c06d7be4..dcc5a977be581 100644 --- a/tests/cases/fourslash/gotoDefinitionInObjectBindingPattern1.ts +++ b/tests/cases/fourslash/gotoDefinitionInObjectBindingPattern1.ts @@ -7,6 +7,6 @@ //// interface Test { //// /*destination*/prop2: number //// } -//// bar(({pr/*goto*/op2})=>{}); +//// bar(({[|pr/*goto*/op2|]})=>{}); verify.goToDefinition("goto", "destination"); \ No newline at end of file diff --git a/tests/cases/fourslash/gotoDefinitionInObjectBindingPattern2.ts b/tests/cases/fourslash/gotoDefinitionInObjectBindingPattern2.ts index 9e41f646c4635..6d513d6abee3a 100644 --- a/tests/cases/fourslash/gotoDefinitionInObjectBindingPattern2.ts +++ b/tests/cases/fourslash/gotoDefinitionInObjectBindingPattern2.ts @@ -1,7 +1,7 @@ /// //// var p0 = ({a/*1*/a}) => {console.log(aa)}; -//// function f2({ a/*a1*/1, b/*b1*/1 }: { /*a1_dest*/a1: number, /*b1_dest*/b1: number } = { a1: 0, b1: 0 }) {} +//// function f2({ [|a/*a1*/1|], [|b/*b1*/1|] }: { /*a1_dest*/a1: number, /*b1_dest*/b1: number } = { a1: 0, b1: 0 }) {} verify.goToDefinition("1", []); verify.goToDefinition("a1", "a1_dest"); diff --git a/tests/cases/fourslash/gotoDefinitionPropertyAccessExpressionHeritageClause.ts b/tests/cases/fourslash/gotoDefinitionPropertyAccessExpressionHeritageClause.ts index d46ea7c842220..3d58d869c49e2 100644 --- a/tests/cases/fourslash/gotoDefinitionPropertyAccessExpressionHeritageClause.ts +++ b/tests/cases/fourslash/gotoDefinitionPropertyAccessExpressionHeritageClause.ts @@ -4,7 +4,7 @@ //// function foo() { //// return {/*refB*/B: B}; //// } -//// class C extends (foo())./*B*/B {} -//// class C1 extends foo()./*B1*/B {} +//// class C extends (foo()).[|/*B*/B|] {} +//// class C1 extends foo().[|/*B1*/B|] {} verify.goToDefinition([["B", "refB"], ["B1", "refB"]]); \ No newline at end of file diff --git a/tests/cases/fourslash/javaScriptClass3.ts b/tests/cases/fourslash/javaScriptClass3.ts index fd67f6f53a536..60f51b4ac791c 100644 --- a/tests/cases/fourslash/javaScriptClass3.ts +++ b/tests/cases/fourslash/javaScriptClass3.ts @@ -12,8 +12,8 @@ //// method() { return this.alpha; } //// } //// var x = new Foo(); -//// x.alpha/*src1*/; -//// x.beta/*src2*/; +//// x.[|alpha/*src1*/|]; +//// x.[|beta/*src2*/|]; verify.goToDefinition({ src1: "dst1", diff --git a/tests/cases/fourslash/jsdocTypedefTagServices.ts b/tests/cases/fourslash/jsdocTypedefTagServices.ts index c97707e4d255b..e4b262c3ee43e 100644 --- a/tests/cases/fourslash/jsdocTypedefTagServices.ts +++ b/tests/cases/fourslash/jsdocTypedefTagServices.ts @@ -10,7 +10,7 @@ //// */ /////** -//// * @type {/*use*/[|Product|]} +//// * @type {[|/*use*/Product|]} //// */ ////const product = null; diff --git a/tests/cases/fourslash/server/definition01.ts b/tests/cases/fourslash/server/definition01.ts index 7889d185fcd72..70921b72ed409 100644 --- a/tests/cases/fourslash/server/definition01.ts +++ b/tests/cases/fourslash/server/definition01.ts @@ -1,7 +1,7 @@ /// // @Filename: b.ts -////import n = require('./a/*1*/'); +////import n = require([|'./a/*1*/'|]); ////var x = new n.Foo(); // @Filename: a.ts diff --git a/tests/cases/fourslash/server/jsdocTypedefTagGoToDefinition.ts b/tests/cases/fourslash/server/jsdocTypedefTagGoToDefinition.ts index 000adef90815f..dd72fdd42addb 100644 --- a/tests/cases/fourslash/server/jsdocTypedefTagGoToDefinition.ts +++ b/tests/cases/fourslash/server/jsdocTypedefTagGoToDefinition.ts @@ -14,10 +14,10 @@ //// */ //// //// /** @type {Person} */ -//// var person; person.personName/*3*/ +//// var person; person.[|personName/*3*/|] //// //// /** @type {Animal} */ -//// var animal; animal.animalName/*4*/ +//// var animal; animal.[|animalName/*4*/|] verify.goToDefinition({ 3: "1", diff --git a/tests/cases/fourslash/shims-pp/goToDefinitionTypeReferenceDirective.ts b/tests/cases/fourslash/shims-pp/goToDefinitionTypeReferenceDirective.ts index ad02bb9d85124..532390fb35e7d 100644 --- a/tests/cases/fourslash/shims-pp/goToDefinitionTypeReferenceDirective.ts +++ b/tests/cases/fourslash/shims-pp/goToDefinitionTypeReferenceDirective.ts @@ -5,7 +5,7 @@ /////*0*/declare let $: {x: number}; // @Filename: src/app.ts -//// /// +//// /// //// $.x; verify.goToDefinition("1", "0"); diff --git a/tests/cases/fourslash/shims/goToDefinitionTypeReferenceDirective.ts b/tests/cases/fourslash/shims/goToDefinitionTypeReferenceDirective.ts index 4669b7f62e902..f318de7c25e0e 100644 --- a/tests/cases/fourslash/shims/goToDefinitionTypeReferenceDirective.ts +++ b/tests/cases/fourslash/shims/goToDefinitionTypeReferenceDirective.ts @@ -5,7 +5,7 @@ /////*0*/declare let $: {x: number}; // @Filename: src/app.ts -//// /// +//// /// //// $.x; verify.goToDefinition("1", "0"); diff --git a/tests/cases/fourslash/tsxGoToDefinitionClasses.ts b/tests/cases/fourslash/tsxGoToDefinitionClasses.ts index 688ce879adfae..f0b58155bf5a8 100644 --- a/tests/cases/fourslash/tsxGoToDefinitionClasses.ts +++ b/tests/cases/fourslash/tsxGoToDefinitionClasses.ts @@ -11,9 +11,9 @@ //// /*pt*/foo: string; //// } //// } -//// var x = ; -//// var y = ; -//// var z = ; +//// var x = <[|My/*c*/Class|] />; +//// var y = ; +//// var z = <[|MyCl/*w*/ass|] wrong= 'hello' />; verify.goToDefinition({ c: "ct", diff --git a/tests/cases/fourslash/tsxGoToDefinitionIntrinsics.ts b/tests/cases/fourslash/tsxGoToDefinitionIntrinsics.ts index a82e813baa73d..9b202a64c213e 100644 --- a/tests/cases/fourslash/tsxGoToDefinitionIntrinsics.ts +++ b/tests/cases/fourslash/tsxGoToDefinitionIntrinsics.ts @@ -11,9 +11,9 @@ //// /*st*/span: { n: string; }; //// } //// } -//// var x = ; -//// var y = ; -//// var z =
; +//// var x = <[|di/*ds*/v|] />; +//// var y = <[|s/*ss*/pan|] />; +//// var z =
; verify.goToDefinition({ ds: "dt", diff --git a/tests/cases/fourslash/tsxGoToDefinitionStatelessFunction1.ts b/tests/cases/fourslash/tsxGoToDefinitionStatelessFunction1.ts index d620b3585af8e..6ef0e93445fb3 100644 --- a/tests/cases/fourslash/tsxGoToDefinitionStatelessFunction1.ts +++ b/tests/cases/fourslash/tsxGoToDefinitionStatelessFunction1.ts @@ -16,10 +16,10 @@ //// /*pt2*/optional?: boolean //// } //// declare function /*opt*/Opt(attributes: OptionPropBag): JSX.Element; -//// let opt = ; -//// let opt1 = ; -//// let opt2 = ; -//// let opt3 = ; +//// let opt = <[|O/*one*/pt|] />; +//// let opt1 = <[|Op/*two*/t|] [|pr/*p1*/opx|]={100} />; +//// let opt2 = <[|Op/*three*/t|] propx={100} [|opt/*p2*/ional|] />; +//// let opt3 = <[|Op/*four*/t|] wr/*p3*/ong />; verify.goToDefinition({ one: "opt", diff --git a/tests/cases/fourslash/tsxGoToDefinitionStatelessFunction2.ts b/tests/cases/fourslash/tsxGoToDefinitionStatelessFunction2.ts index 177379832307c..9d5efe2442be5 100644 --- a/tests/cases/fourslash/tsxGoToDefinitionStatelessFunction2.ts +++ b/tests/cases/fourslash/tsxGoToDefinitionStatelessFunction2.ts @@ -23,12 +23,12 @@ //// declare function /*firstSource*/MainButton(buttonProps: ButtonProps): JSX.Element; //// declare function /*secondSource*/MainButton(linkProps: LinkProps): JSX.Element; //// declare function /*thirdSource*/MainButton(props: ButtonProps | LinkProps): JSX.Element; -//// let opt =
; -//// let opt =
; -//// let opt =
{}} />; -//// let opt =
{}} ignore-prop />; -//// let opt =
; -//// let opt =
; +//// let opt = <[|Main/*firstTarget*/Button|] />; +//// let opt = <[|Main/*secondTarget*/Button|] children="chidlren" />; +//// let opt = <[|Main/*thirdTarget*/Button|] onClick={()=>{}} />; +//// let opt = <[|Main/*fourthTarget*/Button|] onClick={()=>{}} ignore-prop />; +//// let opt = <[|Main/*fivethTarget*/Button|] goTo="goTo" />; +//// let opt = <[|Main/*sixthTarget*/Button|] wrong />; verify.goToDefinition({ firstTarget: "thirdSource", diff --git a/tests/cases/fourslash/tsxGoToDefinitionUnionElementType1.ts b/tests/cases/fourslash/tsxGoToDefinitionUnionElementType1.ts index db78f46f3adf1..d6b5dfab70999 100644 --- a/tests/cases/fourslash/tsxGoToDefinitionUnionElementType1.ts +++ b/tests/cases/fourslash/tsxGoToDefinitionUnionElementType1.ts @@ -19,7 +19,7 @@ //// } //// var SFCComp = SFC1 || SFC2; -//// +//// <[|SFC/*one*/Comp|] x /> verify.goToDefinition({ "one": "pt1" diff --git a/tests/cases/fourslash/tsxGoToDefinitionUnionElementType2.ts b/tests/cases/fourslash/tsxGoToDefinitionUnionElementType2.ts index 75ca81998a07f..548ce94db5a29 100644 --- a/tests/cases/fourslash/tsxGoToDefinitionUnionElementType2.ts +++ b/tests/cases/fourslash/tsxGoToDefinitionUnionElementType2.ts @@ -19,7 +19,7 @@ //// var /*pt1*/RCComp = RC1 || RC2; -//// +//// <[|RC/*one*/Comp|] /> verify.goToDefinition({ "one": "pt1"