vscode-languageclient
Advanced tools
Comparing version 0.10.0-pre.24 to 0.10.0-pre.25
import * as vs from 'vscode'; | ||
import { DidOpenTextDocumentParams, DidChangeTextDocumentParams, DidCloseTextDocumentParams, Diagnostic, Position, Range, TextDocumentPosition } from './protocol'; | ||
import { DidOpenTextDocumentParams, DidChangeTextDocumentParams, DidCloseTextDocumentParams, Diagnostic, Position, Range, TextDocumentPosition, Hover, CompletionItem, TextEdit, SignatureHelp, SignatureInformation, ParameterInformation } from './protocol'; | ||
export declare function asOpenTextDocumentParams(textDocument: vs.TextDocument): DidOpenTextDocumentParams; | ||
@@ -12,1 +12,10 @@ export declare function asChangeTextDocumentParams(textDocument: vs.TextDocument): DidChangeTextDocumentParams; | ||
export declare function asDiagnosticSeverity(value: number): vs.DiagnosticSeverity; | ||
export declare function asHover(hover: Hover): vs.Hover; | ||
export declare function asCompletionItems(items: CompletionItem[]): vs.CompletionItem[]; | ||
export declare function asCompletionItem(item: CompletionItem): vs.CompletionItem; | ||
export declare function asTextEdit(edit: TextEdit): vs.TextEdit; | ||
export declare function asSignatureHelp(item: SignatureHelp): vs.SignatureHelp; | ||
export declare function asSignatureInformations(items: SignatureInformation[]): vs.SignatureInformation[]; | ||
export declare function asSignatureInformation(item: SignatureInformation): vs.SignatureInformation; | ||
export declare function asParameterInformations(item: ParameterInformation[]): vs.ParameterInformation[]; | ||
export declare function asParameterInformation(item: ParameterInformation): vs.ParameterInformation; |
@@ -94,1 +94,59 @@ /*--------------------------------------------------------- | ||
exports.asDiagnosticSeverity = asDiagnosticSeverity; | ||
function asHover(hover) { | ||
return new vs.Hover(hover.contents, is.defined(hover.range) ? asRange(hover.range) : undefined); | ||
} | ||
exports.asHover = asHover; | ||
function asCompletionItems(items) { | ||
return items.map(asCompletionItem); | ||
} | ||
exports.asCompletionItems = asCompletionItems; | ||
function set(value, func) { | ||
if (is.defined(value)) { | ||
func(); | ||
} | ||
} | ||
function asCompletionItem(item) { | ||
var result = new vs.CompletionItem(item.label); | ||
set(item.detail, function () { return result.detail = item.detail; }); | ||
set(item.documentation, function () { return result.documentation = item.documentation; }); | ||
set(item.filterText, function () { return result.filterText = item.filterText; }); | ||
set(item.insertText, function () { return result.insertText = item.insertText; }); | ||
set(item.kind, function () { return result.kind = item.kind; }); | ||
set(item.sortText, function () { return result.sortText = item.sortText; }); | ||
set(item.textEdit, function () { return result.textEdit = asTextEdit(item.textEdit); }); | ||
return result; | ||
} | ||
exports.asCompletionItem = asCompletionItem; | ||
function asTextEdit(edit) { | ||
return new vs.TextEdit(asRange(edit.range), edit.newText); | ||
} | ||
exports.asTextEdit = asTextEdit; | ||
function asSignatureHelp(item) { | ||
var result = new vs.SignatureHelp(); | ||
set(item.activeParameter, function () { return result.activeParameter = item.activeParameter; }); | ||
set(item.activeSignature, function () { return result.activeSignature = item.activeSignature; }); | ||
set(item.signatures, function () { return result.signatures = asSignatureInformations(item.signatures); }); | ||
return result; | ||
} | ||
exports.asSignatureHelp = asSignatureHelp; | ||
function asSignatureInformations(items) { | ||
return items.map(asSignatureInformation); | ||
} | ||
exports.asSignatureInformations = asSignatureInformations; | ||
function asSignatureInformation(item) { | ||
var result = new vs.SignatureInformation(item.label); | ||
set(item.documentation, function () { return result.documentation = item.documentation; }); | ||
set(item.parameters, function () { return result.parameters = asParameterInformations(item.parameters); }); | ||
return result; | ||
} | ||
exports.asSignatureInformation = asSignatureInformation; | ||
function asParameterInformations(item) { | ||
return item.map(asParameterInformation); | ||
} | ||
exports.asParameterInformations = asParameterInformations; | ||
function asParameterInformation(item) { | ||
var result = new vs.ParameterInformation(item.label); | ||
set(item.documentation, function () { return result.documentation = item.documentation; }); | ||
return result; | ||
} | ||
exports.asParameterInformation = asParameterInformation; |
@@ -46,3 +46,3 @@ import * as cp from 'child_process'; | ||
export interface LanguageClientOptions { | ||
languageSelector?: string | string[]; | ||
documentSelector?: string | string[]; | ||
synchronize?: SynchronizeOptions; | ||
@@ -49,0 +49,0 @@ } |
@@ -122,20 +122,20 @@ /*--------------------------------------------------------- | ||
LanguageClient.prototype.computeSyncExpression = function () { | ||
var languageSelector = this._languageOptions.languageSelector; | ||
var documentSelector = this._languageOptions.documentSelector; | ||
var textDocumentFilter = this._languageOptions.synchronize.textDocumentFilter; | ||
if (!languageSelector && !textDocumentFilter) { | ||
if (!documentSelector && !textDocumentFilter) { | ||
return new FalseSyncExpression(); | ||
} | ||
if (textDocumentFilter && !languageSelector) { | ||
if (textDocumentFilter && !documentSelector) { | ||
return new FunctionSyncExpression(textDocumentFilter); | ||
} | ||
if (!textDocumentFilter && languageSelector) { | ||
if (is.string(languageSelector)) { | ||
return new LanguageIdExpression(languageSelector); | ||
if (!textDocumentFilter && documentSelector) { | ||
if (is.string(documentSelector)) { | ||
return new LanguageIdExpression(documentSelector); | ||
} | ||
else { | ||
return new CompositeSyncExpression(languageSelector); | ||
return new CompositeSyncExpression(documentSelector); | ||
} | ||
} | ||
if (textDocumentFilter && languageSelector) { | ||
return new CompositeSyncExpression(is.string(languageSelector) ? [languageSelector] : languageSelector, textDocumentFilter); | ||
if (textDocumentFilter && documentSelector) { | ||
return new CompositeSyncExpression(is.string(documentSelector) ? [documentSelector] : documentSelector, textDocumentFilter); | ||
} | ||
@@ -511,13 +511,12 @@ }; | ||
var _this = this; | ||
if (this._capabilites.hoverProvider && this._languageOptions.languageSelector) { | ||
this._providers.push(vscode_1.languages.registerHoverProvider(this._languageOptions.languageSelector, { | ||
var documentSelector = this._languageOptions.documentSelector; | ||
if (!documentSelector) { | ||
return; | ||
} | ||
if (this._capabilites.hoverProvider) { | ||
this._providers.push(vscode_1.languages.registerHoverProvider(documentSelector, { | ||
provideHover: function (document, position, token) { | ||
if (_this.isConnectionActive()) { | ||
return connection.sendRequest(protocol_1.HoverRequest.type, converters_1.asTextDocumentPosition(document, position)).then(function (result) { | ||
if (is.string(result.content)) { | ||
return new vscode_1.Hover(result.content, converters_1.asRange(result.range)); | ||
} | ||
else { | ||
return new vscode_1.Hover(result.content, converters_1.asRange(result.range)); | ||
} | ||
return converters_1.asHover(result); | ||
}); | ||
@@ -531,7 +530,9 @@ } | ||
} | ||
else if (this._capabilites.completionProvider && this._languageOptions.languageSelector) { | ||
this._providers.push(vscode_1.languages.registerCompletionItemProvider.apply(vscode_1.languages, [this._languageOptions.languageSelector, { | ||
if (this._capabilites.completionProvider) { | ||
this._providers.push(vscode_1.languages.registerCompletionItemProvider.apply(vscode_1.languages, [documentSelector, { | ||
provideCompletionItems: function (document, position, token) { | ||
if (_this.isConnectionActive()) { | ||
return connection.sendRequest(protocol_1.CompletionRequest.type, converters_1.asTextDocumentPosition(document, position)); | ||
return connection.sendRequest(protocol_1.CompletionRequest.type, converters_1.asTextDocumentPosition(document, position)).then(function (result) { | ||
return converters_1.asCompletionItems(result); | ||
}); | ||
} | ||
@@ -545,3 +546,5 @@ else { | ||
if (_this.isConnectionActive()) { | ||
return connection.sendRequest(protocol_1.CompletionResolveRequest.type, item); | ||
return connection.sendRequest(protocol_1.CompletionResolveRequest.type, item).then(function (result) { | ||
return converters_1.asCompletionItem(result); | ||
}); | ||
} | ||
@@ -555,2 +558,16 @@ else { | ||
} | ||
if (this._capabilites.signatureHelpProvider) { | ||
this._providers.push(vscode_1.languages.registerSignatureHelpProvider.apply(vscode_1.languages, [documentSelector, { | ||
provideSignatureHelp: function (document, position, token) { | ||
if (_this.isConnectionActive()) { | ||
return connection.sendRequest(protocol_1.SignatureHelpRequest.type, converters_1.asTextDocumentPosition(document, position)).then(function (result) { | ||
return converters_1.asSignatureHelp(result); | ||
}); | ||
} | ||
else { | ||
return Promise.resolve(null); | ||
} | ||
} | ||
}].concat(this._capabilites.signatureHelpProvider.triggerCharacters))); | ||
} | ||
}; | ||
@@ -557,0 +574,0 @@ return LanguageClient; |
@@ -13,2 +13,5 @@ import { RequestType, NotificationType } from 'vscode-jsonrpc'; | ||
} | ||
export interface SignatureHelpOptions { | ||
triggerCharacters?: string[]; | ||
} | ||
export interface ServerCapabilities { | ||
@@ -18,2 +21,3 @@ textDocumentSync?: number; | ||
completionProvider?: CompletionOptions; | ||
signatureHelpProvider?: SignatureHelpOptions; | ||
} | ||
@@ -120,12 +124,2 @@ /** | ||
} | ||
export interface HTMLContentElement { | ||
formattedText?: string; | ||
text?: string; | ||
className?: string; | ||
style?: string; | ||
customStyle?: any; | ||
tagName?: string; | ||
children?: HTMLContentElement[]; | ||
isText?: boolean; | ||
} | ||
export interface TextDocumentIdentifier { | ||
@@ -294,13 +288,14 @@ /** | ||
} | ||
export declare namespace HoverRequest { | ||
const type: RequestType<TextDocumentPosition, HoverResult, void>; | ||
} | ||
export declare type MarkedString = string | { | ||
language: string; | ||
value: string; | ||
}; | ||
/** | ||
* The result of a hove request. | ||
*/ | ||
export interface HoverResult { | ||
export interface Hover { | ||
/** | ||
* The hover's content | ||
*/ | ||
content: string | HTMLContentElement; | ||
contents: MarkedString | MarkedString[]; | ||
/** | ||
@@ -311,1 +306,27 @@ * An optional range | ||
} | ||
export declare namespace HoverRequest { | ||
const type: RequestType<TextDocumentPosition, Hover, void>; | ||
} | ||
export interface ParameterInformation { | ||
label: string; | ||
documentation?: string; | ||
} | ||
export declare namespace ParameterInformation { | ||
function create(label: string, documentation?: string): ParameterInformation; | ||
} | ||
export interface SignatureInformation { | ||
label: string; | ||
documentation?: string; | ||
parameters?: ParameterInformation[]; | ||
} | ||
export declare namespace SignatureInformation { | ||
function create(label: string, documentation?: string): SignatureInformation; | ||
} | ||
export interface SignatureHelp { | ||
signatures?: SignatureInformation[]; | ||
activeSignature?: number; | ||
activeParameter?: number; | ||
} | ||
export declare namespace SignatureHelpRequest { | ||
const type: RequestType<TextDocumentPosition, SignatureHelp, void>; | ||
} |
@@ -160,3 +160,2 @@ /*--------------------------------------------------------- | ||
})(CompletionResolveRequest = exports.CompletionResolveRequest || (exports.CompletionResolveRequest = {})); | ||
//---- Hover Support ------------------------------- | ||
var HoverRequest; | ||
@@ -166,1 +165,20 @@ (function (HoverRequest) { | ||
})(HoverRequest = exports.HoverRequest || (exports.HoverRequest = {})); | ||
var ParameterInformation; | ||
(function (ParameterInformation) { | ||
function create(label, documentation) { | ||
return documentation ? { label: label, documentation: documentation } : { label: label }; | ||
} | ||
ParameterInformation.create = create; | ||
; | ||
})(ParameterInformation = exports.ParameterInformation || (exports.ParameterInformation = {})); | ||
var SignatureInformation; | ||
(function (SignatureInformation) { | ||
function create(label, documentation) { | ||
return documentation ? { label: label, documentation: documentation } : { label: label }; | ||
} | ||
SignatureInformation.create = create; | ||
})(SignatureInformation = exports.SignatureInformation || (exports.SignatureInformation = {})); | ||
var SignatureHelpRequest; | ||
(function (SignatureHelpRequest) { | ||
SignatureHelpRequest.type = { method: 'textDocument/signatureHelp' }; | ||
})(SignatureHelpRequest = exports.SignatureHelpRequest || (exports.SignatureHelpRequest = {})); |
{ | ||
"name": "vscode-languageclient", | ||
"description": "VSCode Language client implementation", | ||
"version": "0.10.0-pre.24", | ||
"version": "0.10.0-pre.25", | ||
"author": "Visual Studio Code Team", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
75644
1799