Skip to content

Session: don't return undefined if a response is required #17165

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
6 commits merged into from
Aug 9, 2017
Merged

Conversation

ghost
Copy link

@ghost ghost commented Jul 13, 2017

Sequel to #16773
This doesn't yet fix SignatureHelp, since that doesn't return an array. I'm not sure if VSCode is depending on us sending back an "error" response if the user isn't currently at a signature.

@ghost ghost requested a review from mjbvz July 13, 2017 15:33
@@ -606,7 +606,7 @@ namespace ts.server {

const definitions = project.getLanguageService().getDefinitionAtPosition(file, position);
if (!definitions) {
return undefined;
return [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these results mutable? Can we use a shared emptyArray construct?

@@ -995,7 +995,7 @@ namespace ts.server {
return args.position !== undefined ? args.position : scriptInfo.lineOffsetToPosition(args.line, args.offset);
}

private getFileAndProject(args: protocol.FileRequestArgs, errorOnMissingProject = true) {
private getFileAndProject(args: protocol.FileRequestArgs, errorOnMissingProject = true): { file: NormalizedPath, project: Project } {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the return type defined here, since it is correctly inferred?

@rbuckton
Copy link
Contributor

rbuckton commented Aug 8, 2017

Looks like the build is failing. Can you take a look?

@ghost
Copy link
Author

ghost commented Aug 8, 2017

Fix is #17685, will merge once that's in

@ghost
Copy link
Author

ghost commented Aug 8, 2017

@rbuckton Build is passing now, good to go?

@ghost ghost merged commit f124e19 into master Aug 9, 2017
@ghost ghost deleted the requiredResponse branch August 9, 2017 20:46
uniqueiniquity pushed a commit to uniqueiniquity/TypeScript that referenced this pull request Aug 9, 2017
…17165)

* Session: don't return undefined if a response is required

* Use ReadonlyArray and emptyArray

* Remove inferred return type
@@ -813,7 +815,7 @@ namespace ts.server {
if (!renameInfo.canRename) {
return {
info: renameInfo,
locs: []
locs: emptyArray
Copy link
Member

Choose a reason for hiding this comment

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

Missed one on line 812?

@@ -909,7 +911,7 @@ namespace ts.server {
if (simplifiedResult) {
const nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position);
if (!nameInfo) {
return undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Might break deserialization.

@@ -1172,7 +1174,7 @@ namespace ts.server {

const completions = project.getLanguageService().getCompletionsAtPosition(file, position);
if (!completions) {
return undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Might break deserialization.

@@ -615,7 +617,7 @@ namespace ts.server {
}
}

private getTypeDefinition(args: protocol.FileLocationRequestArgs): protocol.FileSpan[] {
private getTypeDefinition(args: protocol.FileLocationRequestArgs): ReadonlyArray<protocol.FileSpan> {
Copy link
Member

Choose a reason for hiding this comment

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

Line 627?

const { configFile, project } = this.getConfigFileAndProject(args);
if (configFile) {
return this.getConfigFileDiagnostics(configFile, project, args.includeLinePosition);
}
return this.getDiagnosticsWorker(args, /*isSemantic*/ true, (project, file) => project.getLanguageService().getSemanticDiagnostics(file), args.includeLinePosition);
}

private getDocumentHighlights(args: protocol.DocumentHighlightsRequestArgs, simplifiedResult: boolean): protocol.DocumentHighlightsItem[] | DocumentHighlights[] {
private getDocumentHighlights(args: protocol.DocumentHighlightsRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.DocumentHighlightsItem> | ReadonlyArray<DocumentHighlights> {
Copy link
Member

Choose a reason for hiding this comment

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

Line 717?

@amcasey
Copy link
Member

amcasey commented Aug 10, 2017

@Andy-MS It might be safest to revert this (and hold off on #17727) until we further discuss the implications for clients. (cc: @minestarks, @rbuckton)

@ghost
Copy link
Author

ghost commented Aug 10, 2017

Might be better to wait for release-2.5 and remove this from that, but not from master.

@amcasey
Copy link
Member

amcasey commented Aug 11, 2017

I think release-2.5 exists now. The plan is to revert this there and submit #17728 to master (and close #17727)?

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 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.

3 participants