vscode-languageclient
Advanced tools
Comparing version 6.1.1 to 6.1.2
@@ -440,5 +440,5 @@ import { TextDocumentChangeEvent, TextDocument, Disposable, OutputChannel, FileSystemWatcher as VFileSystemWatcher, DiagnosticCollection, Diagnostic as VDiagnostic, Uri, ProviderResult, CancellationToken, Position as VPosition, Location as VLocation, Range as VRange, CompletionItem as VCompletionItem, CompletionList as VCompletionList, SignatureHelp as VSignatureHelp, SignatureHelpContext as VSignatureHelpContext, Definition as VDefinition, DefinitionLink as VDefinitionLink, DocumentHighlight as VDocumentHighlight, SymbolInformation as VSymbolInformation, CodeActionContext as VCodeActionContext, Command as VCommand, CodeLens as VCodeLens, FormattingOptions as VFormattingOptions, TextEdit as VTextEdit, WorkspaceEdit as VWorkspaceEdit, Hover as VHover, CodeAction as VCodeAction, DocumentSymbol as VDocumentSymbol, DocumentLink as VDocumentLink, TextDocumentWillSaveEvent, WorkspaceFolder as VWorkspaceFolder, CompletionContext as VCompletionContext, CompletionItemProvider, HoverProvider, SignatureHelpProvider, DefinitionProvider, ReferenceProvider, DocumentHighlightProvider, CodeActionProvider, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, OnTypeFormattingEditProvider, RenameProvider, DocumentLinkProvider, DocumentColorProvider, DeclarationProvider, FoldingRangeProvider, ImplementationProvider, SelectionRangeProvider, TypeDefinitionProvider, WorkspaceSymbolProvider } from 'vscode'; | ||
private data2String; | ||
info(message: string, data?: any): void; | ||
warn(message: string, data?: any): void; | ||
error(message: string, data?: any): void; | ||
info(message: string, data?: any, showNotification?: boolean): void; | ||
warn(message: string, data?: any, showNotification?: boolean): void; | ||
error(message: string, data?: any, showNotification?: boolean): void; | ||
private showNotificationMessage; | ||
@@ -445,0 +445,0 @@ private logTrace; |
import * as code from 'vscode'; | ||
import * as proto from 'vscode-languageserver-protocol'; | ||
declare module 'vscode' { | ||
interface Diagnostic { | ||
code2?: { | ||
value: string | number; | ||
target: Uri; | ||
}; | ||
} | ||
} | ||
export interface Converter { | ||
@@ -4,0 +12,0 @@ asUri(uri: code.Uri): string; |
@@ -13,2 +13,10 @@ /* -------------------------------------------------------------------------------------------- | ||
const protocolDocumentLink_1 = require("./protocolDocumentLink"); | ||
var InsertReplaceRange; | ||
(function (InsertReplaceRange) { | ||
function is(value) { | ||
const candidate = value; | ||
return candidate && !!candidate.inserting && !!candidate.replacing; | ||
} | ||
InsertReplaceRange.is = is; | ||
})(InsertReplaceRange || (InsertReplaceRange = {})); | ||
function createConverter(uriConverter) { | ||
@@ -211,6 +219,2 @@ const nullConverter = (value) => value.toString(); | ||
} | ||
function isInsertReplace(value) { | ||
const candidate = value; | ||
return candidate && !!candidate.inserting && !!candidate.replacing; | ||
} | ||
function asRange(value) { | ||
@@ -220,6 +224,2 @@ if (value === undefined || value === null) { | ||
} | ||
// The LSP has no support yet for insert replace. So this can never happen. | ||
if (isInsertReplace(value)) { | ||
throw new Error(`Receving unknown insert replace range.`); | ||
} | ||
return { start: asPosition(value.start), end: asPosition(value.end) }; | ||
@@ -277,2 +277,11 @@ } | ||
} | ||
function asDiagnosticCode(value) { | ||
if (value === undefined || value === null) { | ||
return undefined; | ||
} | ||
if (Is.number(value) || Is.string(value)) { | ||
return value; | ||
} | ||
return { value: value.value, target: asUri(value.target) }; | ||
} | ||
function asDiagnostic(item) { | ||
@@ -283,8 +292,8 @@ let result = proto.Diagnostic.create(asRange(item.range), item.message); | ||
} | ||
if (Is.number(item.code) || Is.string(item.code)) { | ||
result.code = item.code; | ||
result.code = asDiagnosticCode(item.code2 || item.code); | ||
{ | ||
if (Array.isArray(item.tags)) { | ||
result.tags = asDiagnosticTags(item.tags); | ||
} | ||
} | ||
if (Array.isArray(item.tags)) { | ||
result.tags = asDiagnosticTags(item.tags); | ||
} | ||
if (item.relatedInformation) { | ||
@@ -406,3 +415,3 @@ result.relatedInformation = asRelatedInformations(item.relatedInformation); | ||
text = source.textEdit.newText; | ||
range = asRange(source.textEdit.range); | ||
range = source.textEdit.range; | ||
} | ||
@@ -417,7 +426,7 @@ else if (source.insertText instanceof code.SnippetString) { | ||
if (source.range) { | ||
range = asRange(source.range); | ||
range = source.range; | ||
} | ||
target.insertTextFormat = format; | ||
if (source.fromEdit && text !== undefined && range !== undefined) { | ||
target.textEdit = { newText: text, range: range }; | ||
target.textEdit = asCompletionTextEdit(text, range); | ||
} | ||
@@ -428,2 +437,10 @@ else { | ||
} | ||
function asCompletionTextEdit(newText, range) { | ||
if (InsertReplaceRange.is(range)) { | ||
return proto.InsertReplaceEdit.create(newText, asRange(range.inserting), asRange(range.replacing)); | ||
} | ||
else { | ||
return { newText, range: asRange(range) }; | ||
} | ||
} | ||
function asTextEdit(edit) { | ||
@@ -430,0 +447,0 @@ return { range: asRange(edit.range), newText: edit.newText }; |
@@ -58,3 +58,3 @@ import * as code from 'vscode'; | ||
asSymbolKind(item: ls.SymbolKind): code.SymbolKind; | ||
asSymbolTag(item: ls.SymbolTag): code.SymbolTag; | ||
asSymbolTag(item: ls.SymbolTag): code.SymbolTag | undefined; | ||
asSymbolTags(items: undefined | null): undefined; | ||
@@ -121,2 +121,10 @@ asSymbolTags(items: ReadonlyArray<ls.SymbolTag>): code.SymbolTag[]; | ||
} | ||
declare module 'vscode' { | ||
interface Diagnostic { | ||
code2?: { | ||
value: string | number; | ||
target: Uri; | ||
}; | ||
} | ||
} | ||
export declare function createConverter(uriConverter?: URIConverter): Converter; |
@@ -35,2 +35,5 @@ /* -------------------------------------------------------------------------------------------- | ||
} | ||
if (ls.DiagnosticCode.is(diagnostic.code)) { | ||
result.code2 = { value: diagnostic.code.value, target: asUri(diagnostic.code.target) }; | ||
} | ||
if (diagnostic.source) { | ||
@@ -262,6 +265,6 @@ result.source = diagnostic.source; | ||
if (item.insertTextFormat === ls.InsertTextFormat.Snippet) { | ||
return { text: new code.SnippetString(item.textEdit.newText), range: asRange(item.textEdit.range), fromEdit: true }; | ||
return { text: new code.SnippetString(item.textEdit.newText), range: asCompletionRange(item.textEdit), fromEdit: true }; | ||
} | ||
else { | ||
return { text: item.textEdit.newText, range: asRange(item.textEdit.range), fromEdit: true }; | ||
return { text: item.textEdit.newText, range: asCompletionRange(item.textEdit), fromEdit: true }; | ||
} | ||
@@ -281,2 +284,10 @@ } | ||
} | ||
function asCompletionRange(value) { | ||
if (ls.InsertReplaceEdit.is(value)) { | ||
return { inserting: asRange(value.insert), replacing: asRange(value.replace) }; | ||
} | ||
else { | ||
return asRange(value.range); | ||
} | ||
} | ||
function asTextEdit(edit) { | ||
@@ -442,3 +453,8 @@ if (!edit) { | ||
function asSymbolTag(value) { | ||
return value; | ||
switch (value) { | ||
case ls.SymbolTag.Deprecated: | ||
return code.SymbolTag.Deprecated; | ||
default: | ||
return undefined; | ||
} | ||
} | ||
@@ -449,3 +465,10 @@ function asSymbolTags(items) { | ||
} | ||
return items.map(asSymbolTag); | ||
const result = []; | ||
for (const item of items) { | ||
const converted = asSymbolTag(item); | ||
if (converted !== undefined) { | ||
result.push(converted); | ||
} | ||
} | ||
return result.length === 0 ? undefined : result; | ||
} | ||
@@ -455,2 +478,3 @@ function asSymbolInformation(item, uri) { | ||
let result = new code.SymbolInformation(item.name, asSymbolKind(item.kind), asRange(item.location.range), item.location.uri ? _uriConverter(item.location.uri) : uri); | ||
fillTags(result, item); | ||
if (item.containerName) { | ||
@@ -469,2 +493,3 @@ result.containerName = item.containerName; | ||
let result = new code.DocumentSymbol(value.name, value.detail || '', asSymbolKind(value.kind), asRange(value.range), asRange(value.selectionRange)); | ||
fillTags(result, value); | ||
if (value.children !== undefined && value.children.length > 0) { | ||
@@ -479,2 +504,15 @@ let children = []; | ||
} | ||
function fillTags(result, value) { | ||
result.tags = asSymbolTags(value.tags); | ||
if (value.deprecated) { | ||
if (!result.tags) { | ||
result.tags = [code.SymbolTag.Deprecated]; | ||
} | ||
else { | ||
if (!result.tags.includes(code.SymbolTag.Deprecated)) { | ||
result.tags = result.tags.concat(code.SymbolTag.Deprecated); | ||
} | ||
} | ||
} | ||
} | ||
function asCommand(item) { | ||
@@ -481,0 +519,0 @@ let result = { title: item.title, command: item.command }; |
@@ -76,3 +76,2 @@ /* -------------------------------------------------------------------------------------------- | ||
vscode_languageserver_protocol_1.Proposed.SemanticTokenModifiers.deprecated, | ||
vscode_languageserver_protocol_1.Proposed.SemanticTokenModifiers.async, | ||
vscode_languageserver_protocol_1.Proposed.SemanticTokenModifiers.readonly | ||
@@ -103,3 +102,3 @@ ]; | ||
client.logFailedRequest(vscode_languageserver_protocol_1.Proposed.SemanticTokensRequest.type, error); | ||
return undefined; | ||
throw error; | ||
}); | ||
@@ -129,3 +128,3 @@ }; | ||
client.logFailedRequest(vscode_languageserver_protocol_1.Proposed.SemanticTokensEditsRequest.type, error); | ||
return undefined; | ||
throw error; | ||
}); | ||
@@ -154,3 +153,3 @@ }; | ||
client.logFailedRequest(vscode_languageserver_protocol_1.Proposed.SemanticTokensRangeRequest.type, error); | ||
return undefined; | ||
throw error; | ||
}); | ||
@@ -157,0 +156,0 @@ }; |
{ | ||
"name": "vscode-languageclient", | ||
"description": "VSCode Language client implementation", | ||
"version": "6.1.1", | ||
"version": "6.1.2", | ||
"author": "Microsoft Corporation", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
Sorry, the diff of this file is too big to display
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
337519
6959
1