Skip to content

Support find-all-references for default exports #13643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
5 commits merged into from
Jan 26, 2017
Merged

Conversation

ghost
Copy link

@ghost ghost commented Jan 23, 2017

Fixes #11551

@ghost ghost force-pushed the find_all_refs_default branch from 7049625 to 83b3df9 Compare January 23, 2017 22:27
// Compute the meaning from the location and the symbol it references
const searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations);

const result: ReferencedSymbol[] = [];
// Maps from a symbol ID to the ReferencedSymbol entry in 'result'.
const symbolToIndex: number[] = [];
Copy link
Author

Choose a reason for hiding this comment

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

Moved these out of getReferencesInNode to avoid recomputing.

@ghost ghost force-pushed the find_all_refs_default branch from 83b3df9 to 3d3e302 Compare January 23, 2017 22:30
@ghost ghost force-pushed the find_all_refs_default branch from 3d3e302 to 0ca4cb2 Compare January 23, 2017 22:31
@ghost
Copy link
Author

ghost commented Jan 24, 2017

Note: The old behavior was to rename default imports globally if they shared the same name as the default export, otherwise to rename locally. The new behavior is to always rename default imports locally. (You can globally rename by renaming the export.)

@@ -3,4 +3,6 @@
////import [|a|] from "module";
////export { [|a|] };

verify.rangesAreRenameLocations();
Copy link
Contributor

Choose a reason for hiding this comment

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

change the test name then?

Copy link
Author

Choose a reason for hiding this comment

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

Oh, didn't mean to check in that change.

@@ -1,7 +1,7 @@
/// <reference path='fourslash.ts' />

// @Filename: B.ts
////export default class /*1*/C {
////export default class /*1*/[|C|] {
Copy link
Contributor

Choose a reason for hiding this comment

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

also add a test for import * as m from "B"; m.default; renaming should do nothing in this case.

Copy link
Author

Choose a reason for hiding this comment

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

I'll have to change getRenameInfo for that. Created #13663.

@mhegazy
Copy link
Contributor

mhegazy commented Jan 24, 2017

We have the same problems with renamed exports/imports today as we do with default imports. our basic assumptions here are just wrong. we tried to expand the global find references logic to include modules, and just use the identity of the original declaration as a comparison point but we are still looking for a single name. we need to have a comprehensive solution for imports/exports in general. let's chat.

if (scope) {
result = [];
getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken);
getRefs(scope, declaredName);
Copy link
Contributor

Choose a reason for hiding this comment

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

the additonal indirection does not seem to be worth it.

if (shorthandModuleSymbol) {
searchSymbols.push(shorthandModuleSymbol);
}
function isSearchedFor(symbol: Symbol): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

i would switch this to a helper instead of a parameter and pass in searchSymbols.

@ghost ghost merged commit 6512579 into master Jan 26, 2017
@ghost ghost deleted the find_all_refs_default branch January 26, 2017 18:33
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant