typescript-language-server
Advanced tools
Comparing version 0.4.0-dev.5e314a9 to 0.4.0-dev.9e83a6b
@@ -12,2 +12,3 @@ "use strict"; | ||
const lsp = require("vscode-languageserver"); | ||
const lspcalls = require("./lsp-protocol.calls.proposed"); | ||
const protocol_translation_1 = require("./protocol-translation"); | ||
@@ -32,7 +33,6 @@ function computeCallers(tspClient, args) { | ||
} | ||
const uri = protocol_translation_1.pathToUri(callerReference.file, undefined); | ||
const location = protocol_translation_1.toLocation(callerReference, undefined); | ||
calls.push({ | ||
location, | ||
symbol: Object.assign({ uri }, symbol) | ||
symbol | ||
}); | ||
@@ -67,7 +67,6 @@ } | ||
} | ||
const uri = protocol_translation_1.pathToUri(definitionReference.file, undefined); | ||
const location = protocol_translation_1.toLocation(reference, undefined); | ||
calls.push({ | ||
location, | ||
symbol: Object.assign({ uri }, definitionSymbol) | ||
symbol: definitionSymbol | ||
}); | ||
@@ -118,3 +117,3 @@ } | ||
const calls = []; | ||
const file = protocol_translation_1.uriToPath(contextSymbol.uri); | ||
const file = protocol_translation_1.uriToPath(contextSymbol.location.uri); | ||
const document = documentProvider(file); | ||
@@ -124,3 +123,3 @@ if (!document) { | ||
} | ||
const candidateRanges = computeCallCandidates(document, contextSymbol.range); | ||
const candidateRanges = computeCallCandidates(document, contextSymbol.location.range); | ||
for (const candidateRange of candidateRanges) { | ||
@@ -159,4 +158,7 @@ const call = yield validateCall(file, candidateRange); | ||
const symbol = yield findEnclosingSymbolInTree(tree, lsp.Range.create(pos, pos)); | ||
if (!symbol) { | ||
return undefined; | ||
} | ||
const uri = protocol_translation_1.pathToUri(file, undefined); | ||
return Object.assign({ uri }, symbol); | ||
return lspcalls.DefinitionSymbol.create(uri, symbol); | ||
}); | ||
@@ -163,0 +165,0 @@ } |
import { RequestType, RequestHandler } from 'vscode-jsonrpc'; | ||
import { DocumentSymbol as LspDocumentSymbol, Location } from 'vscode-languageserver-types'; | ||
import { Location, SymbolKind, Range, DocumentSymbol } from 'vscode-languageserver-types'; | ||
import * as lsp from 'vscode-languageserver'; | ||
@@ -69,3 +69,3 @@ export interface CallsClientCapabilities { | ||
*/ | ||
symbol?: DocumentSymbol; | ||
symbol?: DefinitionSymbol; | ||
/** | ||
@@ -76,5 +76,2 @@ * List of calls. | ||
} | ||
export declare type DocumentSymbol = LspDocumentSymbol & { | ||
uri?: string; | ||
}; | ||
/** | ||
@@ -94,4 +91,32 @@ * Represents a directed call. | ||
*/ | ||
symbol: DocumentSymbol; | ||
symbol: DefinitionSymbol; | ||
} | ||
export interface DefinitionSymbol { | ||
/** | ||
* The name of this symbol. | ||
*/ | ||
name: string; | ||
/** | ||
* More detail for this symbol, e.g the signature of a function. | ||
*/ | ||
detail?: string; | ||
/** | ||
* The kind of this symbol. | ||
*/ | ||
kind: SymbolKind; | ||
/** | ||
* The range enclosing this symbol not including leading/trailing whitespace but everything else | ||
* like comments. This information is typically used to determine if the the clients cursor is | ||
* inside the symbol to reveal in the symbol in the UI. | ||
*/ | ||
location: Location; | ||
/** | ||
* The range that should be selected and revealed when this symbol is being picked, e.g the name of a function. | ||
* Must be contained by the the `range`. | ||
*/ | ||
selectionRange: Range; | ||
} | ||
export declare namespace DefinitionSymbol { | ||
function create(uri: string, symbol: DocumentSymbol): DefinitionSymbol; | ||
} | ||
//# sourceMappingURL=lsp-protocol.calls.proposed.d.ts.map |
@@ -31,2 +31,11 @@ /* -------------------------------------------------------------------------------------------- | ||
})(CallDirection = exports.CallDirection || (exports.CallDirection = {})); | ||
var DefinitionSymbol; | ||
(function (DefinitionSymbol) { | ||
function create(uri, symbol) { | ||
const { name, detail, kind, range, selectionRange } = symbol; | ||
const location = { uri, range }; | ||
return { name, detail, kind, location, selectionRange }; | ||
} | ||
DefinitionSymbol.create = create; | ||
})(DefinitionSymbol = exports.DefinitionSymbol || (exports.DefinitionSymbol = {})); | ||
//# sourceMappingURL=lsp-protocol.calls.proposed.js.map |
@@ -135,2 +135,3 @@ "use strict"; | ||
}; | ||
this.initializeResult.capabilities.callsProvider = true; | ||
this.logger.log('onInitialize result', this.initializeResult); | ||
@@ -137,0 +138,0 @@ return this.initializeResult; |
@@ -416,3 +416,3 @@ "use strict"; | ||
const arrow = lspcalls.CallDirection.Outgoing === direction ? '↖' : '↘'; | ||
const symbolToString = (symbol) => `${symbol.name} (${symbol.uri ? symbol.uri.split('/').pop() : '<no uri>'}#${symbol.selectionRange.start.line})`; | ||
const symbolToString = (symbol) => `${symbol.name} (${symbol.location.uri.split('/').pop()}#${symbol.selectionRange.start.line})`; | ||
const out = []; | ||
@@ -419,0 +419,0 @@ out.push(`${arrow} ${symbolToString(callsResult.symbol)}`); |
{ | ||
"name": "typescript-language-server", | ||
"version": "0.4.0-dev.5e314a9", | ||
"version": "0.4.0-dev.9e83a6b", | ||
"description": "Language Server Protocol (LSP) implementation for TypeScript using tsserver", | ||
@@ -37,3 +37,3 @@ "author": "TypeFox and others", | ||
}, | ||
"gitHead": "5e314a9223d04f6a061577c50dd17bc7b61488d9" | ||
"gitHead": "9e83a6bf6dc16729713d1aead821a6fed3f38635" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
300128
3994