-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Add maxResultCount optional field to NavtoRequestArgs. Change #2106
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
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,30 +52,6 @@ module ts.server { | |
return 1; | ||
} | ||
} | ||
|
||
function sortNavItems(items: ts.NavigateToItem[]) { | ||
return items.sort((a, b) => { | ||
if (a.matchKind < b.matchKind) { | ||
return -1; | ||
} | ||
else if (a.matchKind == b.matchKind) { | ||
var lowa = a.name.toLowerCase(); | ||
var lowb = b.name.toLowerCase(); | ||
if (lowa < lowb) { | ||
return -1; | ||
} | ||
else if (lowa == lowb) { | ||
return 0; | ||
} | ||
else { | ||
return 1; | ||
} | ||
} | ||
else { | ||
return 1; | ||
} | ||
}) | ||
} | ||
|
||
function formatDiag(fileName: string, project: Project, diag: ts.Diagnostic) { | ||
return { | ||
|
@@ -138,7 +114,18 @@ module ts.server { | |
changeSeq = 0; | ||
|
||
constructor(private host: ServerHost, private logger: Logger) { | ||
this.projectService = new ProjectService(host, logger); | ||
this.projectService = | ||
new ProjectService(host, logger, (eventName,project,fileName) => { | ||
this.handleEvent(eventName, project, fileName); | ||
}); | ||
} | ||
|
||
handleEvent(eventName: string, project: Project, fileName: string) { | ||
if (eventName == "context") { | ||
this.projectService.log("got context event, updating diagnostics for" + fileName, "Info"); | ||
this.updateErrorCheck([{ fileName, project }], this.changeSeq, | ||
(n) => n == this.changeSeq, 100); | ||
} | ||
} | ||
|
||
logError(err: Error, cmd: string) { | ||
|
@@ -215,6 +202,14 @@ module ts.server { | |
this.semanticCheck(file, project); | ||
} | ||
|
||
updateProjectStructure(seq: number, matchSeq: (seq: number) => boolean, ms = 1500) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can you spell out sequence in variable names |
||
setTimeout(() => { | ||
if (matchSeq(seq)) { | ||
this.projectService.updateProjectStructure(); | ||
} | ||
}, ms); | ||
} | ||
|
||
updateErrorCheck(checkList: PendingErrorCheck[], seq: number, | ||
matchSeq: (seq: number) => boolean, ms = 1500, followMs = 200) { | ||
if (followMs > ms) { | ||
|
@@ -231,7 +226,7 @@ module ts.server { | |
var checkOne = () => { | ||
if (matchSeq(seq)) { | ||
var checkSpec = checkList[index++]; | ||
if (checkSpec.project.getSourceFileFromName(checkSpec.fileName)) { | ||
if (checkSpec.project.getSourceFileFromName(checkSpec.fileName, true)) { | ||
this.syntacticCheck(checkSpec.fileName, checkSpec.project); | ||
this.immediateId = setImmediate(() => { | ||
this.semanticCheck(checkSpec.fileName, checkSpec.project); | ||
|
@@ -404,7 +399,7 @@ module ts.server { | |
var position = compilerService.host.lineColToPosition(file, line, col); | ||
var quickInfo = compilerService.languageService.getQuickInfoAtPosition(file, position); | ||
if (!quickInfo) { | ||
throw Errors.NoContent; | ||
return undefined; | ||
} | ||
|
||
var displayString = ts.displayPartsToString(quickInfo.displayParts); | ||
|
@@ -494,7 +489,7 @@ module ts.server { | |
var file = ts.normalizePath(fileName); | ||
var project = this.projectService.getProjectForFile(file); | ||
if (!project) { | ||
throw Errors.NoProject; | ||
return undefined; | ||
} | ||
|
||
var compilerService = project.compilerService; | ||
|
@@ -559,6 +554,10 @@ module ts.server { | |
compilerService.host.editScript(file, start, end, insertString); | ||
this.changeSeq++; | ||
} | ||
// update project structure on idle commented out | ||
// until we can have the host return only the root files | ||
// from getScriptFileNames() | ||
//this.updateProjectStructure(this.changeSeq, (n) => n == this.changeSeq); | ||
} | ||
} | ||
|
||
|
@@ -625,15 +624,15 @@ module ts.server { | |
return this.decorateNavigationBarItem(project, fileName, items); | ||
} | ||
|
||
getNavigateToItems(searchTerm: string, fileName: string): protocol.NavtoItem[] { | ||
getNavigateToItems(searchValue: string, fileName: string, maxResultCount?: number): protocol.NavtoItem[] { | ||
var file = ts.normalizePath(fileName); | ||
var project = this.projectService.getProjectForFile(file); | ||
if (!project) { | ||
throw Errors.NoProject; | ||
} | ||
|
||
var compilerService = project.compilerService; | ||
var navItems = sortNavItems(compilerService.languageService.getNavigateToItems(searchTerm)); | ||
var navItems = compilerService.languageService.getNavigateToItems(searchValue, maxResultCount); | ||
if (!navItems) { | ||
throw Errors.NoContent; | ||
} | ||
|
@@ -690,6 +689,7 @@ module ts.server { | |
try { | ||
var request = <protocol.Request>JSON.parse(message); | ||
var response: any; | ||
var errorMessage: string; | ||
switch (request.command) { | ||
case CommandNames.Definition: { | ||
var defArgs = <protocol.FileLocationRequestArgs>request.arguments; | ||
|
@@ -714,6 +714,9 @@ module ts.server { | |
case CommandNames.Quickinfo: { | ||
var quickinfoArgs = <protocol.FileLocationRequestArgs>request.arguments; | ||
response = this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.col, quickinfoArgs.file); | ||
if (!response) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i do not understand how this is diffrent from just throwing an error in getQuickInfo? |
||
errorMessage = "No info at this location"; | ||
} | ||
break; | ||
} | ||
case CommandNames.Format: { | ||
|
@@ -729,6 +732,9 @@ module ts.server { | |
case CommandNames.Completions: { | ||
var completionsArgs = <protocol.CompletionsRequestArgs>request.arguments; | ||
response = this.getCompletions(request.arguments.line, request.arguments.col, completionsArgs.prefix, request.arguments.file); | ||
if (!response) { | ||
errorMessage = "No completions at this location"; | ||
} | ||
break; | ||
} | ||
case CommandNames.CompletionDetails: { | ||
|
@@ -765,7 +771,7 @@ module ts.server { | |
} | ||
case CommandNames.Navto: { | ||
var navtoArgs = <protocol.NavtoRequestArgs>request.arguments; | ||
response = this.getNavigateToItems(navtoArgs.searchTerm, navtoArgs.file); | ||
response = this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount); | ||
break; | ||
} | ||
case CommandNames.Brace: { | ||
|
@@ -788,6 +794,9 @@ module ts.server { | |
if (response) { | ||
this.output(response, request.command, request.seq); | ||
} | ||
else if (errorMessage) { | ||
this.output(undefined, request.command, request.seq, errorMessage); | ||
} | ||
|
||
} catch (err) { | ||
if (err instanceof OperationCanceledException) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious, was that not working?