Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
81ec4fd
Prototype resolving to JS when go-to-def aliases all resolve to ambie…
andrewbranch Feb 25, 2022
422d845
Add test infrastructure
andrewbranch Mar 1, 2022
1b43352
Start fleshing out test coverage
andrewbranch Mar 2, 2022
7aeb92f
Fix some go-to-def stuff
andrewbranch Mar 8, 2022
f2915e6
Finish lodash test case
andrewbranch Mar 10, 2022
309c4bb
Make go-to-implementation never return ambient results
andrewbranch Mar 10, 2022
381799d
Build new functionality into go-to-implementation
andrewbranch Mar 11, 2022
0727702
Update baselines
andrewbranch Mar 11, 2022
ebeda0b
Two more test cases
andrewbranch Mar 14, 2022
03ea413
Refine definition searches for unresolved imports
andrewbranch Mar 14, 2022
e5556b8
Revert "Build new functionality into go-to-implementation"
andrewbranch Mar 14, 2022
6104a5c
Fix tests
andrewbranch Mar 14, 2022
bea3de0
Merge branch 'main' into go-to-js
andrewbranch Mar 14, 2022
4e64659
Revert go-to-implementation changes
andrewbranch Mar 14, 2022
1cb2ba6
Wow a bunch of code was unnecessary
andrewbranch Mar 14, 2022
7e57890
Update baselines and go-to-def test
andrewbranch Mar 15, 2022
43c01e2
Fix navigation on symbols that are not aliases but resolve through al…
andrewbranch Mar 16, 2022
34c6cfd
Temporarily replace go-to-def with new command implementation
andrewbranch Mar 15, 2022
7357593
Revert "Temporarily replace go-to-def with new command implementation"
andrewbranch Mar 16, 2022
d14e43d
Revert "Wow a bunch of code was unnecessary"
andrewbranch Mar 21, 2022
4e1cf1c
Bring back some deleted code needed for a new test case
andrewbranch Mar 21, 2022
52a79d5
Clean up a little
andrewbranch Mar 22, 2022
e011f2d
Rename more stuff
andrewbranch Mar 22, 2022
05cfd27
Update test
andrewbranch Mar 22, 2022
b95f496
Update API baseline
andrewbranch Mar 22, 2022
b883898
Temporarily replace go-to-def with new command implementation
andrewbranch Mar 15, 2022
373bca2
PR review fixes
andrewbranch Apr 4, 2022
c05adbd
Merge branch 'main' into go-to-js
andrewbranch Apr 4, 2022
3a85dc8
Fix getTopMostDeclarationNamesInFile
andrewbranch Apr 4, 2022
7dd9db8
Rename local
andrewbranch Apr 4, 2022
0f3b29c
Use hash set
andrewbranch Apr 4, 2022
234c139
Remove option from commandLineParser
andrewbranch Apr 4, 2022
92ff999
Merge branch 'main' into go-to-js
andrewbranch Apr 6, 2022
1698930
Keep noDtsResolution project around
andrewbranch Apr 7, 2022
859ed79
Handle AuxiliaryProject kind in ScriptInfo getDefaultProject etc.
andrewbranch Apr 7, 2022
7be215a
Do not run updateGraph in the background for AuxiliaryProject
andrewbranch Apr 7, 2022
8f4e622
Don’t create auxiliary project outside of semantic mode
andrewbranch Apr 7, 2022
d633356
No-op on scheduled invalidation
andrewbranch Apr 7, 2022
b89b7cb
Add comments to unit test
andrewbranch Apr 7, 2022
a59024c
Sync compiler options to auxiliary project
andrewbranch Apr 7, 2022
7f290bb
Fix case sensitivity
andrewbranch Apr 7, 2022
c5bddbe
Update extensionIsOk with new file extensions
andrewbranch Apr 7, 2022
24c0d8a
PR feedback
andrewbranch Apr 13, 2022
f6bd9d8
Update API baseline
andrewbranch Apr 13, 2022
2cb2048
Mark scheduleInvalidateResolutionsOfFailedLookupLocations internal
andrewbranch Apr 13, 2022
f9f4592
Use same heuristics on property accesses of loosely-resolvable aliase…
andrewbranch Apr 14, 2022
e302f56
Rename command, and no need to return the bound span
andrewbranch Apr 14, 2022
3f15ed3
Update API baseline
andrewbranch Apr 14, 2022
f80c9ef
Merge branch 'main' into go-to-js
andrewbranch Apr 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "Build new functionality into go-to-implementation"
This reverts commit 381799d.
  • Loading branch information
andrewbranch committed Mar 14, 2022
commit e5556b8d53a03ac0a6c43dd7c9539ef23e55a911
20 changes: 20 additions & 0 deletions src/harness/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,26 @@ namespace ts.server {
}));
}

getSourceDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan {
const args: protocol.FileLocationRequestArgs = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.SourceDefinitionAndBoundSpanRequest>(CommandNames.SourceDefinitionAndBoundSpan, args);
const response = this.processResponse<protocol.DefinitionInfoAndBoundSpanResponse>(request);
const body = Debug.checkDefined(response.body); // TODO: GH#18217

return {
definitions: body.definitions.map(entry => ({
containerKind: ScriptElementKind.unknown,
containerName: "",
fileName: entry.file,
textSpan: this.decodeSpan(entry),
kind: ScriptElementKind.unknown,
name: "",
unverified: entry.unverified,
})),
textSpan: this.decodeSpan(body.textSpan, request.arguments.file)
};
}

getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[] {
const args = this.createFileLocationRequestArgs(fileName, position);

Expand Down
14 changes: 8 additions & 6 deletions src/harness/fourslashImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,13 @@ namespace FourSlash {
this.verifyGoToX(arg0, endMarkerNames, () => this.getGoToDefinitionAndBoundSpan());
}

public verifyGoToSourceDefinition(startMarkerNames: ArrayOrSingle<string>, end?: ArrayOrSingle<string | { marker: string, unverified?: boolean }> | { file: string, unverified?: boolean }) {
if (this.testType !== FourSlashTestType.Server) {
this.raiseError("goToSourceDefinition may only be used in fourslash/server tests.");
}
this.verifyGoToX(startMarkerNames, end, () => (this.languageService as ts.server.SessionClient).getSourceDefinitionAndBoundSpan(this.activeFile.fileName, this.currentCaretPosition)!);
}

private getGoToDefinition(): readonly ts.DefinitionInfo[] {
return this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition)!;
}
Expand Down Expand Up @@ -2440,12 +2447,7 @@ namespace FourSlash {
assert.isTrue(implementations && implementations.length > 0, "Expected at least one implementation but got 0");
}
else {
if (this.testType === FourSlashTestType.Server) {
assert.deepEqual(implementations, [], "Expected implementation list to be empty but implementations returned");
}
else {
assert.isUndefined(implementations, "Expected implementation list to be empty but implementations returned");
}
assert.isUndefined(implementations, "Expected implementation list to be empty but implementations returned");
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/harness/fourslashInterfaceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ namespace FourSlashInterface {
this.state.verifyGoToType(arg0, endMarkerName);
}

public goToSourceDefinition(startMarkerNames: ArrayOrSingle<string>, end: { file: string } | ArrayOrSingle<string>) {
this.state.verifyGoToSourceDefinition(startMarkerNames, end);
}

public goToDefinitionForMarkers(...markerNames: string[]) {
this.state.verifyGoToDefinitionForMarkers(markerNames);
}
Expand Down
7 changes: 7 additions & 0 deletions src/server/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ namespace ts.server.protocol {
SignatureHelp = "signatureHelp",
/* @internal */
SignatureHelpFull = "signatureHelp-full",
SourceDefinitionAndBoundSpan = "sourceDefinitionAndBoundSpan",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may already have discussed this but, unfortunately, I've forgotten. Why wouldn't this be modelled on definition[-full]? I believe the primary (only?) difference is that definitionAndBoundSpan includes the span for underlining, which this command seems unlikely to require, given the expected perf.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, when I made the protocol change, I didn’t yet realize that’s what the bound span was for, so I modeled it off the only go-to-def command that VS Code uses. I’ll switch it. Now that I have a handle on how I’m going to hook this up to VS Code, at least in the short term, I’ll switch it, as that span won’t be used.

/* @internal */
SourceDefinitionAndBoundSpanFull = "sourceDefinitionAndBoundSpan-full",
Status = "status",
TypeDefinition = "typeDefinition",
ProjectInfo = "projectInfo",
Expand Down Expand Up @@ -904,6 +907,10 @@ namespace ts.server.protocol {
readonly command: CommandTypes.DefinitionAndBoundSpan;
}

export interface SourceDefinitionAndBoundSpanRequest extends FileLocationRequest {
readonly command: CommandTypes.SourceDefinitionAndBoundSpan;
}

export interface DefinitionAndBoundSpanResponse extends Response {
readonly body: DefinitionInfoAndBoundSpan;
}
Expand Down
276 changes: 152 additions & 124 deletions src/server/session.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/services/callHierarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ namespace ts.CallHierarchy {
return [];
}
const location = getCallHierarchyDeclarationReferenceNode(declaration);
const calls = filter(FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, /*sourceMapper*/ undefined, { use: FindAllReferences.FindReferencesUse.References }, convertEntryToCallSite), isDefined);
const calls = filter(FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: FindAllReferences.FindReferencesUse.References }, convertEntryToCallSite), isDefined);
return calls ? group(calls, getCallSiteGroupKey, entries => convertCallSiteGroupToIncomingCall(program, entries)) : [];
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/documentHighlights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace ts {

function getSemanticDocumentHighlights(position: number, node: Node, program: Program, cancellationToken: CancellationToken, sourceFilesToSearch: readonly SourceFile[]): DocumentHighlights[] | undefined {
const sourceFilesSet = new Set(sourceFilesToSearch.map(f => f.fileName));
const referenceEntries = FindAllReferences.getReferenceEntriesForNode(position, node, program, sourceFilesToSearch, cancellationToken, /*sourceMapper*/ undefined, /*options*/ undefined, sourceFilesSet);
const referenceEntries = FindAllReferences.getReferenceEntriesForNode(position, node, program, sourceFilesToSearch, cancellationToken, /*options*/ undefined, sourceFilesSet);
if (!referenceEntries) return undefined;
const map = arrayToMultiMap(referenceEntries.map(FindAllReferences.toHighlightSpan), e => e.fileName, e => e.span);
const getCanonicalFileName = createGetCanonicalFileName(program.useCaseSensitiveFileNames());
Expand Down
Loading