Skip to content

goToDefinition: Reduce duplicate code around createDefinitionInfo#23473

Merged
3 commits merged into
masterfrom
createDefinitionInfo
Apr 17, 2018
Merged

goToDefinition: Reduce duplicate code around createDefinitionInfo#23473
3 commits merged into
masterfrom
createDefinitionInfo

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Apr 17, 2018

  • The result of getSymbolInfo is only ever sent to createDefinitionInfo -- so just compute it there.
  • Also reuse this code for shorthand declarations.
  • Use find in findReferenceInPosition.

@ghost ghost requested review from armanio123 and sheetalkamat April 17, 2018 17:38
Comment thread src/services/goToDefinition.ts Outdated
const shorthandContainerName = typeChecker.symbolToString(symbol.parent, node);
return map(shorthandDeclarations,
declaration => createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName));
return shorthandSymbol ? shorthandSymbol.declarations.map(decl => createDefinitionInfo(decl, typeChecker, shorthandSymbol, node)) : emptyArray;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if you are using emptyArray the return type should be ReadonlyArray to avoid messing up the whole system when emptyArray is not empty.. I think emptyArray should be types as ReadOnlyArray<any> but that would be a separate change and potentially a big one.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

See #16312 -- will change to [] for now.

@ghost ghost merged commit 0c17a2b into master Apr 17, 2018
@ghost ghost deleted the createDefinitionInfo branch April 17, 2018 18:28
@microsoft microsoft locked and limited conversation to collaborators Jul 26, 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