mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-16 05:58:32 -06:00
WIP - quickinfo
This commit is contained in:
parent
81905cd29e
commit
c14398317a
9
src/server/protocol.d.ts
vendored
9
src/server/protocol.d.ts
vendored
@ -147,12 +147,17 @@ declare namespace ts.server.protocol {
|
||||
/**
|
||||
* The line number for the request (1-based).
|
||||
*/
|
||||
line: number;
|
||||
line?: number;
|
||||
|
||||
/**
|
||||
* The character offset (on the line) for the request (1-based).
|
||||
*/
|
||||
offset: number;
|
||||
offset?: number;
|
||||
|
||||
/**
|
||||
* Position (can be specified instead of line/offset pair)
|
||||
*/
|
||||
position?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -608,19 +608,23 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
private getQuickInfo(line: number, offset: number, fileName: string): protocol.QuickInfoResponseBody {
|
||||
const file = ts.normalizePath(fileName);
|
||||
private getQuickInfo(args: protocol.FileLocationRequestArgs): protocol.QuickInfoResponseBody {
|
||||
const file = ts.normalizePath(args.file);
|
||||
const project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
const scriptInfo = project.getScriptInfo(file);
|
||||
const position = scriptInfo.lineOffsetToPosition(line, offset);
|
||||
const position = args.position !== undefined ? args.position : scriptInfo.lineOffsetToPosition(args.line, args.offset);
|
||||
const quickInfo = project.languageService.getQuickInfoAtPosition(file, position);
|
||||
if (!quickInfo) {
|
||||
return undefined;
|
||||
}
|
||||
if (args.position !== undefined) {
|
||||
// TODO: fixme
|
||||
return <any>quickInfo;
|
||||
}
|
||||
|
||||
const displayString = ts.displayPartsToString(quickInfo.displayParts);
|
||||
const docString = ts.displayPartsToString(quickInfo.documentation);
|
||||
@ -1107,9 +1111,8 @@ namespace ts.server {
|
||||
this.openClientFile(openArgs.file, openArgs.fileContent, scriptKind);
|
||||
return this.notRequired();
|
||||
},
|
||||
[CommandNames.Quickinfo]: (request: protocol.Request) => {
|
||||
const quickinfoArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
return { response: this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file), responseRequired: true };
|
||||
[CommandNames.Quickinfo]: (request: protocol.QuickInfoRequest) => {
|
||||
return this.requiredResponse(this.getQuickInfo(request.arguments));
|
||||
},
|
||||
[CommandNames.Format]: (request: protocol.Request) => {
|
||||
const formatArgs = <protocol.FormatRequestArgs>request.arguments;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user