New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

volar-service-typescript

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

volar-service-typescript - npm Package Compare versions

Comparing version

to
0.0.4

4

out/configs/getFormatCodeSettings.d.ts
import { SharedContext } from '../types';
import type * as ts from 'typescript/lib/tsserverlibrary';
import * as vscode from 'vscode-languageserver-protocol';
import type { FormattingOptions } from '@volar/language-service';
import type { TextDocument } from 'vscode-languageserver-textdocument';
export declare function getFormatCodeSettings(ctx: SharedContext, document: TextDocument, options?: vscode.FormattingOptions): Promise<ts.FormatCodeSettings>;
export declare function getFormatCodeSettings(ctx: SharedContext, document: TextDocument, options?: FormattingOptions): Promise<ts.FormatCodeSettings>;

@@ -6,8 +6,8 @@ import type { Service } from '@volar/language-service';

'typescript/typescript': () => typeof import('typescript/lib/tsserverlibrary');
'typescript/sourceFile': (_: TextDocument) => ts.SourceFile | undefined;
'typescript/languageService': (_: TextDocument) => ts.LanguageService | undefined;
'typescript/languageServiceHost': (_: TextDocument) => ts.LanguageServiceHost | undefined;
'typescript/sourceFile': (document: TextDocument) => ts.SourceFile | undefined;
'typescript/languageService': (document?: TextDocument) => ts.LanguageService | undefined;
'typescript/languageServiceHost': (document?: TextDocument) => ts.LanguageServiceHost | undefined;
'typescript/textDocument': (uri: string) => TextDocument | undefined;
}
declare const _default: () => Service;
declare const _default: () => Service<Provide>;
export default _default;

@@ -27,3 +27,2 @@ "use strict";

const semver = __importStar(require("semver"));
const vscode = __importStar(require("vscode-languageserver-protocol"));
const shared_1 = require("./shared");

@@ -159,4 +158,3 @@ const _callHierarchy = __importStar(require("./services/callHierarchy"));

'typescript/languageService': document => {
const sourceFile = getSemanticServiceSourceFile(document.uri);
if (sourceFile) {
if (!document || getSemanticServiceSourceFile(document.uri)) {
return semanticCtx.typescript.languageService;

@@ -168,4 +166,3 @@ }

'typescript/languageServiceHost': document => {
const sourceFile = getSemanticServiceSourceFile(document.uri);
if (sourceFile) {
if (!document || getSemanticServiceSourceFile(document.uri)) {
return semanticCtx.typescript.languageServiceHost;

@@ -204,3 +201,3 @@ }

};
if (!context || context.triggerKind !== vscode.CompletionTriggerKind.TriggerCharacter || (context.triggerCharacter && basicTriggerCharacters.includes(context.triggerCharacter))) {
if (!context || context.triggerKind !== 2 || (context.triggerCharacter && basicTriggerCharacters.includes(context.triggerCharacter))) {
const completeOptions = {

@@ -215,3 +212,3 @@ triggerCharacter: context?.triggerCharacter,

}
if (!context || context.triggerKind !== vscode.CompletionTriggerKind.TriggerCharacter || context.triggerCharacter === jsDocTriggerCharacter) {
if (!context || context.triggerKind !== 2 || context.triggerCharacter === jsDocTriggerCharacter) {
const jsdocResult = await doJsDocComplete(document.uri, position);

@@ -222,3 +219,3 @@ if (jsdocResult) {

}
if (!context || context.triggerKind !== vscode.CompletionTriggerKind.TriggerCharacter || context.triggerCharacter === directiveCommentTriggerCharacter) {
if (!context || context.triggerKind !== 2 || context.triggerCharacter === directiveCommentTriggerCharacter) {
const directiveCommentResult = await doDirectiveCommentComplete(document.uri, position);

@@ -225,0 +222,0 @@ if (directiveCommentResult) {

@@ -1,2 +0,2 @@

import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
import { SharedContext } from '../types';

@@ -3,0 +3,0 @@ export declare function register(ctx: SharedContext): {

@@ -27,3 +27,2 @@ "use strict";

exports.register = void 0;
const vscode = __importStar(require("vscode-languageserver-protocol"));
const PConst = __importStar(require("../protocol.const"));

@@ -101,3 +100,3 @@ const modifiers_1 = require("../utils/modifiers");

if (kindModifiers?.has(PConst.KindModifiers.deprecated)) {
result.tags = [vscode.SymbolTag.Deprecated];
result.tags = [1];
}

@@ -104,0 +103,0 @@ return result;

@@ -1,2 +0,2 @@

import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
import { SharedContext } from '../types';

@@ -3,0 +3,0 @@ export interface FixAllData {

@@ -27,3 +27,2 @@ "use strict";

exports.register = void 0;
const vscode = __importStar(require("vscode-languageserver-protocol"));
const rename_1 = require("./rename");

@@ -54,3 +53,3 @@ const fixNames = __importStar(require("../utils/fixNames"));

let result = [];
const onlyQuickFix = matchOnlyKind(`${vscode.CodeActionKind.QuickFix}.ts`);
const onlyQuickFix = matchOnlyKind(`${'quickfix'}.ts`);
if (!context.only || onlyQuickFix) {

@@ -60,3 +59,3 @@ for (const error of context.diagnostics) {

for (const codeFix of codeFixes) {
result = result.concat(transformCodeFix(codeFix, [error], onlyQuickFix ?? vscode.CodeActionKind.Empty));
result = result.concat(transformCodeFix(codeFix, [error], onlyQuickFix ?? ''));
}

@@ -67,3 +66,3 @@ }

for (const only of context.only) {
if (only.split('.')[0] === vscode.CodeActionKind.Refactor) {
if (only.split('.')[0] === 'refactor') {
const refactors = (0, shared_1.safeCall)(() => ctx.typescript.languageService.getApplicableRefactors(fileName, { pos: start, end: end }, preferences, undefined, only)) ?? [];

@@ -82,5 +81,8 @@ for (const refactor of refactors) {

}
const onlySourceOrganizeImports = matchOnlyKind(`${vscode.CodeActionKind.SourceOrganizeImports}.ts`);
const onlySourceOrganizeImports = matchOnlyKind(`${'source.organizeImports'}.ts`);
if (onlySourceOrganizeImports) {
const action = vscode.CodeAction.create('Organize Imports', onlySourceOrganizeImports);
const action = {
title: 'Organize Imports',
kind: onlySourceOrganizeImports,
};
const data = {

@@ -99,5 +101,8 @@ type: 'organizeImports',

}
const onlySourceFixAll = matchOnlyKind(`${vscode.CodeActionKind.SourceFixAll}.ts`);
const onlySourceFixAll = matchOnlyKind(`${'source.fixAll'}.ts`);
if (onlySourceFixAll) {
const action = vscode.CodeAction.create('Fix All', onlySourceFixAll);
const action = {
title: 'Fix All',
kind: onlySourceFixAll,
};
const data = {

@@ -121,5 +126,8 @@ uri,

}
const onlyRemoveUnused = matchOnlyKind(`${vscode.CodeActionKind.Source}.removeUnused.ts`);
const onlyRemoveUnused = matchOnlyKind(`${'source'}.removeUnused.ts`);
if (onlyRemoveUnused) {
const action = vscode.CodeAction.create('Remove all unused code', onlyRemoveUnused);
const action = {
title: 'Remove all unused code',
kind: onlyRemoveUnused,
};
const data = {

@@ -147,5 +155,8 @@ uri,

}
const onlyAddMissingImports = matchOnlyKind(`${vscode.CodeActionKind.Source}.addMissingImports.ts`);
const onlyAddMissingImports = matchOnlyKind(`${'source'}.addMissingImports.ts`);
if (onlyAddMissingImports) {
const action = vscode.CodeAction.create('Add all missing imports', onlyAddMissingImports);
const action = {
title: 'Add all missing imports',
kind: onlyAddMissingImports,
};
const data = {

@@ -197,7 +208,14 @@ uri,

const codeActions = [];
const fix = vscode.CodeAction.create(codeFix.description, edit, kind);
const fix = {
title: codeFix.description,
kind,
edit,
};
fix.diagnostics = diagnostics;
codeActions.push(fix);
if (codeFix.fixAllDescription && codeFix.fixId) {
const fixAll = vscode.CodeAction.create(codeFix.fixAllDescription, kind);
const fixAll = {
title: codeFix.fixAllDescription,
kind,
};
const data = {

@@ -223,3 +241,6 @@ uri,

for (const action of refactor.actions) {
const codeAction = vscode.CodeAction.create(action.description, action.kind);
const codeAction = {
title: action.description,
kind: action.kind,
};
if (action.notApplicableReason) {

@@ -226,0 +247,0 @@ codeAction.disabled = { reason: action.notApplicableReason };

import type * as ts from 'typescript/lib/tsserverlibrary';
import * as vscode from 'vscode-languageserver-protocol';
import { TextDocument } from 'vscode-languageserver-textdocument';
import type * as vscode from '@volar/language-service';
import type { TextDocument } from 'vscode-languageserver-textdocument';
import { SharedContext } from '../types';

@@ -5,0 +5,0 @@ import { Data, FixAllData, RefactorData } from './codeAction';

import { SharedContext } from '../../types';
import type * as ts from 'typescript/lib/tsserverlibrary';
import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
export interface Data {

@@ -5,0 +5,0 @@ uri: string;

@@ -28,3 +28,2 @@ "use strict";

const semver = __importStar(require("semver"));
const vscode = __importStar(require("vscode-languageserver-protocol"));
const getUserPreferences_1 = require("../../configs/getUserPreferences");

@@ -51,3 +50,6 @@ const PConst = __importStar(require("../../protocol.const"));

return;
const wordRange = completionContext.optionalReplacementSpan ? vscode.Range.create(document.positionAt(completionContext.optionalReplacementSpan.start), document.positionAt(completionContext.optionalReplacementSpan.start + completionContext.optionalReplacementSpan.length)) : undefined;
const wordRange = completionContext.optionalReplacementSpan ? {
start: document.positionAt(completionContext.optionalReplacementSpan.start),
end: document.positionAt(completionContext.optionalReplacementSpan.start + completionContext.optionalReplacementSpan.length),
} : undefined;
let line = document.getText({

@@ -68,3 +70,3 @@ start: { line: position.line, character: 0 },

function toVScodeItem(tsEntry, document) {
const item = vscode.CompletionItem.create(tsEntry.name);
const item = { label: tsEntry.name };
item.kind = convertKind(tsEntry.kind);

@@ -96,3 +98,3 @@ if (tsEntry.source && tsEntry.hasAction) {

item.insertText = tsEntry.insertText;
item.insertTextFormat = isSnippet ? vscode.InsertTextFormat.Snippet : vscode.InsertTextFormat.PlainText;
item.insertTextFormat = isSnippet ? 2 : 1;
item.filterText = getFilterText(tsEntry, wordRange, line, tsEntry.insertText);

@@ -118,3 +120,3 @@ if (completionContext?.isMemberCompletion && dotAccessorContext && !isSnippet) {

range = {
inserting: vscode.Range.create(wordRange.start, position),
inserting: { start: wordRange.start, end: position },
replacing: wordRange,

@@ -124,7 +126,14 @@ };

if (range) {
if (vscode.Range.is(range)) {
item.textEdit = vscode.TextEdit.replace(range, item.insertText || item.label);
if ('start' in range) {
item.textEdit = {
range,
newText: item.insertText || item.label,
};
}
else {
item.textEdit = vscode.InsertReplaceEdit.create(item.insertText || item.label, range.inserting, range.replacing);
item.textEdit = {
insert: range.inserting,
replace: range.replacing,
newText: item.insertText || item.label,
};
}

@@ -156,3 +165,6 @@ }

if (dotMatch) {
const range = vscode.Range.create({ line: position.line, character: position.character - dotMatch[0].length }, position);
const range = {
start: { line: position.line, character: position.character - dotMatch[0].length },
end: position,
};
const text = document.getText(range);

@@ -170,6 +182,18 @@ dotAccessorContext = { range, text };

}
let replaceRange = vscode.Range.create(document.positionAt(tsEntry.replacementSpan.start), document.positionAt(tsEntry.replacementSpan.start + tsEntry.replacementSpan.length));
let replaceRange = {
start: document.positionAt(tsEntry.replacementSpan.start),
end: document.positionAt(tsEntry.replacementSpan.start + tsEntry.replacementSpan.length),
};
// Make sure we only replace a single line at most
if (replaceRange.start.line !== replaceRange.end.line) {
replaceRange = vscode.Range.create(replaceRange.start.line, replaceRange.start.character, replaceRange.start.line, document.positionAt(document.offsetAt({ line: replaceRange.start.line + 1, character: 0 }) - 1).character);
replaceRange = {
start: {
line: replaceRange.start.line,
character: replaceRange.start.character,
},
end: {
line: replaceRange.start.line,
character: document.positionAt(document.offsetAt({ line: replaceRange.start.line + 1, character: 0 }) - 1).character,
},
};
}

@@ -219,3 +243,3 @@ // If TS returns an explicit replacement range, we should use it for both types of completion

case PConst.Kind.keyword:
return vscode.CompletionItemKind.Keyword;
return 14;
case PConst.Kind.const:

@@ -227,10 +251,10 @@ case PConst.Kind.let:

case PConst.Kind.parameter:
return vscode.CompletionItemKind.Variable;
return 6;
case PConst.Kind.memberVariable:
case PConst.Kind.memberGetAccessor:
case PConst.Kind.memberSetAccessor:
return vscode.CompletionItemKind.Field;
return 5;
case PConst.Kind.function:
case PConst.Kind.localFunction:
return vscode.CompletionItemKind.Function;
return 3;
case PConst.Kind.method:

@@ -240,25 +264,25 @@ case PConst.Kind.constructSignature:

case PConst.Kind.indexSignature:
return vscode.CompletionItemKind.Method;
return 2;
case PConst.Kind.enum:
return vscode.CompletionItemKind.Enum;
return 13;
case PConst.Kind.enumMember:
return vscode.CompletionItemKind.EnumMember;
return 20;
case PConst.Kind.module:
case PConst.Kind.externalModuleName:
return vscode.CompletionItemKind.Module;
return 9;
case PConst.Kind.class:
case PConst.Kind.type:
return vscode.CompletionItemKind.Class;
return 7;
case PConst.Kind.interface:
return vscode.CompletionItemKind.Interface;
return 8;
case PConst.Kind.warning:
return vscode.CompletionItemKind.Text;
return 1;
case PConst.Kind.script:
return vscode.CompletionItemKind.File;
return 17;
case PConst.Kind.directory:
return vscode.CompletionItemKind.Folder;
return 19;
case PConst.Kind.string:
return vscode.CompletionItemKind.Constant;
return 21;
default:
return vscode.CompletionItemKind.Property;
return 10;
}

@@ -285,3 +309,6 @@ }

if (position.character > 1) {
const preText = document.getText(vscode.Range.create(position.line, 0, position.line, position.character));
const preText = document.getText({
start: { line: position.line, character: 0 },
end: position,
});
return preText.match(/(\s|^)\.$/ig) === null;

@@ -308,6 +335,6 @@ }

if (kindModifiers.has(PConst.KindModifiers.deprecated)) {
item.tags = [vscode.CompletionItemTag.Deprecated];
item.tags = [1];
}
if (kindModifiers.has(PConst.KindModifiers.color)) {
item.kind = vscode.CompletionItemKind.Color;
item.kind = 16;
}

@@ -314,0 +341,0 @@ if (tsEntry.kind === PConst.Kind.script) {

@@ -1,3 +0,3 @@

import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
import { SharedContext } from '../../types';
export declare function register(ctx: SharedContext): (uri: string, position: vscode.Position) => vscode.CompletionItem[] | undefined;

@@ -27,3 +27,2 @@ "use strict";

exports.register = void 0;
const vscode = __importStar(require("vscode-languageserver-protocol"));
const nls = __importStar(require("vscode-nls"));

@@ -58,7 +57,16 @@ const localize = nls.loadMessageBundle(); // TODO: not working

return directives.map(directive => {
const item = vscode.CompletionItem.create(directive.value);
item.insertTextFormat = vscode.InsertTextFormat.Snippet;
const item = { label: directive.value };
item.insertTextFormat = 2;
item.detail = directive.description;
const range = vscode.Range.create(position.line, Math.max(0, position.character - (match[1] ? match[1].length : 0)), position.line, position.character);
item.textEdit = vscode.TextEdit.replace(range, directive.value);
const range = {
start: {
line: position.line,
character: Math.max(0, position.character - (match[1] ? match[1].length : 0)),
},
end: position,
};
item.textEdit = {
range,
newText: directive.value,
};
return item;

@@ -65,0 +73,0 @@ });

import { SharedContext } from '../../types';
import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
export declare function register(ctx: SharedContext): (uri: string, position: vscode.Position) => vscode.CompletionItem | undefined;

@@ -27,3 +27,2 @@ "use strict";

exports.register = void 0;
const vscode = __importStar(require("vscode-languageserver-protocol"));
const nls = __importStar(require("vscode-nls"));

@@ -61,14 +60,14 @@ const resolve_1 = require("./resolve");

function createCompletionItem(document, position, insertText) {
const item = vscode.CompletionItem.create('/** */');
item.kind = vscode.CompletionItemKind.Text;
const item = { label: '/** */' };
item.kind = 1;
item.detail = localize('typescript.jsDocCompletionItem.documentation', 'JSDoc comment');
item.sortText = '\0';
item.insertTextFormat = vscode.InsertTextFormat.Snippet;
item.insertTextFormat = 2;
const line = (0, resolve_1.getLineText)(document, position.line);
const prefix = line.slice(0, position.character).match(/\/\**\s*$/);
const suffix = line.slice(position.character).match(/^\s*\**\//);
const start = vscode.Position.create(position.line, position.character + (prefix ? -prefix[0].length : 0));
const end = vscode.Position.create(position.line, position.character + (suffix ? suffix[0].length : 0));
const range = vscode.Range.create(start, end);
item.textEdit = vscode.TextEdit.replace(range, insertText);
const start = { line: position.line, character: position.character + (prefix ? -prefix[0].length : 0) };
const end = { line: position.line, character: position.character + (suffix ? suffix[0].length : 0) };
const range = { start, end };
item.textEdit = { range, newText: insertText };
return item;

@@ -75,0 +74,0 @@ }

import { SharedContext } from '../../types';
import * as vscode from 'vscode-languageserver-protocol';
import { TextDocument } from 'vscode-languageserver-textdocument';
import type * as vscode from '@volar/language-service';
import type { TextDocument } from 'vscode-languageserver-textdocument';
export declare function register(ctx: SharedContext): (item: vscode.CompletionItem, newPosition?: vscode.Position) => Promise<vscode.CompletionItem>;
export declare function getLineText(document: TextDocument, line: number): string;

@@ -27,3 +27,2 @@ "use strict";

exports.getLineText = exports.register = void 0;
const vscode = __importStar(require("vscode-languageserver-protocol"));
const getFormatCodeSettings_1 = require("../../configs/getFormatCodeSettings");

@@ -82,3 +81,3 @@ const getUserPreferences_1 = require("../../configs/getUserPreferences");

locs.forEach((loc, index) => {
item.additionalTextEdits?.push(vscode.TextEdit.replace(loc.range, changes.textChanges[index].newText));
item.additionalTextEdits?.push({ range: loc.range, newText: changes.textChanges[index].newText });
});

@@ -103,3 +102,3 @@ }

const useCodeSnippetsOnMethodSuggest = await ctx.env.getConfiguration?.((0, shared_1.getConfigTitle)(document) + '.suggest.completeFunctionCalls') ?? false;
const useCodeSnippet = useCodeSnippetsOnMethodSuggest && (item.kind === vscode.CompletionItemKind.Function || item.kind === vscode.CompletionItemKind.Method);
const useCodeSnippet = useCodeSnippetsOnMethodSuggest && (item.kind === 3 || item.kind === 2);
if (useCodeSnippet) {

@@ -118,3 +117,3 @@ const shouldCompleteFunction = isValidFunctionCompletionContext(ctx.typescript.languageService, fileName, offset, document);

}
item.insertTextFormat = vscode.InsertTextFormat.Snippet;
item.insertTextFormat = 2;
if (parameterCount > 0) {

@@ -121,0 +120,0 @@ //Fix for https://github.com/microsoft/vscode/issues/104059

@@ -1,3 +0,3 @@

import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
import { SharedContext } from '../types';
export declare function register(ctx: SharedContext): (uri: string, position: vscode.Position) => vscode.LocationLink[];

@@ -1,2 +0,2 @@

import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
import type * as ts from 'typescript/lib/tsserverlibrary';

@@ -3,0 +3,0 @@ import { SharedContext } from '../types';

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEmitDeclarations = exports.register = void 0;
const vscode = __importStar(require("vscode-languageserver-protocol"));
const shared_1 = require("../shared");

@@ -81,3 +57,3 @@ function register(ctx) {

diagnostic.tags = [];
diagnostic.tags.push(vscode.DiagnosticTag.Unnecessary);
diagnostic.tags.push(1);
}

@@ -87,3 +63,3 @@ if (diag.reportsDeprecated) {

diagnostic.tags = [];
diagnostic.tags.push(vscode.DiagnosticTag.Deprecated);
diagnostic.tags.push(2);
}

@@ -117,8 +93,8 @@ return diagnostic;

switch (input) {
case ts.DiagnosticCategory.Warning: return vscode.DiagnosticSeverity.Warning;
case ts.DiagnosticCategory.Error: return vscode.DiagnosticSeverity.Error;
case ts.DiagnosticCategory.Suggestion: return vscode.DiagnosticSeverity.Hint;
case ts.DiagnosticCategory.Message: return vscode.DiagnosticSeverity.Information;
case ts.DiagnosticCategory.Warning: return 2;
case ts.DiagnosticCategory.Error: return 1;
case ts.DiagnosticCategory.Suggestion: return 4;
case ts.DiagnosticCategory.Message: return 3;
}
return vscode.DiagnosticSeverity.Error;
return 1;
}

@@ -125,0 +101,0 @@ };

import { SharedContext } from '../types';
import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
export declare function register(ctx: SharedContext): (uri: string, position: vscode.Position) => vscode.DocumentHighlight[];
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const vscode = __importStar(require("vscode-languageserver-protocol"));
const shared_1 = require("../shared");

@@ -44,3 +20,3 @@ function register(ctx) {

results.push({
kind: span.kind === ts.HighlightSpanKind.writtenReference ? vscode.DocumentHighlightKind.Write : vscode.DocumentHighlightKind.Read,
kind: span.kind === ts.HighlightSpanKind.writtenReference ? 3 : 2,
range: {

@@ -47,0 +23,0 @@ start: document.positionAt(span.textSpan.start),

@@ -1,3 +0,3 @@

import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
import { SharedContext } from '../types';
export declare function register(ctx: SharedContext): (uri: string) => vscode.DocumentSymbol[];

@@ -28,3 +28,2 @@ "use strict";

const PConst = __importStar(require("../protocol.const"));
const vscode = __importStar(require("vscode-languageserver-protocol"));
const modifiers_1 = require("../utils/modifiers");

@@ -34,19 +33,19 @@ const shared_1 = require("../shared");

switch (kind) {
case PConst.Kind.module: return vscode.SymbolKind.Module;
case PConst.Kind.class: return vscode.SymbolKind.Class;
case PConst.Kind.enum: return vscode.SymbolKind.Enum;
case PConst.Kind.interface: return vscode.SymbolKind.Interface;
case PConst.Kind.method: return vscode.SymbolKind.Method;
case PConst.Kind.memberVariable: return vscode.SymbolKind.Property;
case PConst.Kind.memberGetAccessor: return vscode.SymbolKind.Property;
case PConst.Kind.memberSetAccessor: return vscode.SymbolKind.Property;
case PConst.Kind.variable: return vscode.SymbolKind.Variable;
case PConst.Kind.const: return vscode.SymbolKind.Variable;
case PConst.Kind.localVariable: return vscode.SymbolKind.Variable;
case PConst.Kind.function: return vscode.SymbolKind.Function;
case PConst.Kind.localFunction: return vscode.SymbolKind.Function;
case PConst.Kind.constructSignature: return vscode.SymbolKind.Constructor;
case PConst.Kind.constructorImplementation: return vscode.SymbolKind.Constructor;
case PConst.Kind.module: return 2;
case PConst.Kind.class: return 5;
case PConst.Kind.enum: return 10;
case PConst.Kind.interface: return 11;
case PConst.Kind.method: return 6;
case PConst.Kind.memberVariable: return 7;
case PConst.Kind.memberGetAccessor: return 7;
case PConst.Kind.memberSetAccessor: return 7;
case PConst.Kind.variable: return 13;
case PConst.Kind.const: return 13;
case PConst.Kind.localVariable: return 13;
case PConst.Kind.function: return 12;
case PConst.Kind.localFunction: return 12;
case PConst.Kind.constructSignature: return 9;
case PConst.Kind.constructorImplementation: return 9;
}
return vscode.SymbolKind.Variable;
return 13;
};

@@ -87,3 +86,15 @@ function register(ctx) {

};
const symbol = vscode.DocumentSymbol.create(item.text, undefined, getSymbolKind(item.kind), vscode.Range.create(document.positionAt(fullRange.start), document.positionAt(fullRange.end)), vscode.Range.create(document.positionAt(nameSpan.start), document.positionAt(nameSpan.start + nameSpan.length)), childItems.map(convertNavTree).flat());
const symbol = {
name: item.text,
kind: getSymbolKind(item.kind),
range: {
start: document.positionAt(fullRange.start),
end: document.positionAt(fullRange.end),
},
selectionRange: {
start: document.positionAt(nameSpan.start),
end: document.positionAt(nameSpan.start + nameSpan.length),
},
children: childItems.map(convertNavTree).flat(),
};
const kindModifiers = (0, modifiers_1.parseKindModifier)(item.kindModifiers);

@@ -93,3 +104,3 @@ if (kindModifiers.has(PConst.KindModifiers.deprecated)) {

symbol.tags ??= [];
symbol.tags.push(vscode.SymbolTag.Deprecated);
symbol.tags.push(1);
}

@@ -96,0 +107,0 @@ return symbol;

@@ -1,3 +0,3 @@

import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
import { SharedContext } from '../types';
export declare function register(ctx: SharedContext): (uri: string) => vscode.Location[];

@@ -1,3 +0,3 @@

import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
import { SharedContext } from '../types';
export declare function register(ctx: SharedContext): (uri: string) => vscode.FoldingRange[];
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const vscode = __importStar(require("vscode-languageserver-protocol"));
const shared_1 = require("../shared");

@@ -43,3 +19,9 @@ function register(ctx) {

const end = adjustFoldingEnd(start, document.positionAt(outliningSpan.textSpan.start + outliningSpan.textSpan.length), document);
const foldingRange = vscode.FoldingRange.create(start.line, end.line, start.character, end.character, transformFoldingRangeKind(outliningSpan.kind));
const foldingRange = {
startLine: start.line,
endLine: end.line,
startCharacter: start.character,
endCharacter: end.character,
kind: transformFoldingRangeKind(outliningSpan.kind),
};
foldingRanges.push(foldingRange);

@@ -51,5 +33,5 @@ }

switch (tsKind) {
case ts.OutliningSpanKind.Comment: return vscode.FoldingRangeKind.Comment;
case ts.OutliningSpanKind.Imports: return vscode.FoldingRangeKind.Imports;
case ts.OutliningSpanKind.Region: return vscode.FoldingRangeKind.Region;
case ts.OutliningSpanKind.Comment: return 'comment';
case ts.OutliningSpanKind.Imports: return 'imports';
case ts.OutliningSpanKind.Region: return 'region';
}

@@ -56,0 +38,0 @@ }

@@ -1,2 +0,2 @@

import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
import { SharedContext } from '../types';

@@ -3,0 +3,0 @@ export declare function register(ctx: SharedContext): {

@@ -1,3 +0,3 @@

import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
import { SharedContext } from '../types';
export declare function register(ctx: SharedContext): (uri: string, position: vscode.Position, documentOnly?: boolean) => vscode.Hover | undefined;

@@ -27,3 +27,2 @@ "use strict";

exports.register = void 0;
const vscode = __importStar(require("vscode-languageserver-protocol"));
const previewer = __importStar(require("../utils/previewer"));

@@ -52,3 +51,3 @@ const shared_1 = require("../shared");

const markdown = {
kind: vscode.MarkupKind.Markdown,
kind: 'markdown',
value: parts.join('\n\n'),

@@ -58,3 +57,6 @@ };

contents: markdown,
range: vscode.Range.create(document.positionAt(info.textSpan.start), document.positionAt(info.textSpan.start + info.textSpan.length)),
range: {
start: document.positionAt(info.textSpan.start),
end: document.positionAt(info.textSpan.start + info.textSpan.length),
},
};

@@ -61,0 +63,0 @@ function toResource(path) {

import { SharedContext } from '../types';
import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
export declare function register(ctx: SharedContext): (uri: string, range: vscode.Range) => Promise<vscode.InlayHint[] | undefined>;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const vscode = __importStar(require("vscode-languageserver-protocol"));
const getUserPreferences_1 = require("../configs/getUserPreferences");

@@ -44,5 +20,9 @@ const shared_1 = require("../shared");

return inlayHints.map(inlayHint => {
const result = vscode.InlayHint.create(document.positionAt(inlayHint.position), inlayHint.text, inlayHint.kind === ts.InlayHintKind.Type ? vscode.InlayHintKind.Type
: inlayHint.kind === ts.InlayHintKind.Parameter ? vscode.InlayHintKind.Parameter
: undefined);
const result = {
position: document.positionAt(inlayHint.position),
label: inlayHint.text,
kind: inlayHint.kind === ts.InlayHintKind.Type ? 1
: inlayHint.kind === ts.InlayHintKind.Parameter ? 2
: undefined,
};
result.paddingLeft = inlayHint.whitespaceBefore;

@@ -49,0 +29,0 @@ result.paddingRight = inlayHint.whitespaceAfter;

import { SharedContext } from '../types';
import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
export declare const renameInfoOptions: {
allowRenameOfImportPath: boolean;
};
export declare function register(ctx: SharedContext): (uri: string, position: vscode.Position) => vscode.Range | undefined | vscode.ResponseError<void>;
export declare function register(ctx: SharedContext): (uri: string, position: vscode.Position) => vscode.Range | {
message: string;
} | undefined;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = exports.renameInfoOptions = void 0;
const vscode = __importStar(require("vscode-languageserver-protocol"));
const shared_1 = require("../shared");

@@ -42,3 +18,3 @@ /* typescript-language-features is hardcode true */

if (!renameInfo.canRename) {
return new vscode.ResponseError(0, renameInfo.localizedErrorMessage);
return { message: renameInfo.localizedErrorMessage };
}

@@ -45,0 +21,0 @@ return {

@@ -1,3 +0,3 @@

import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
import { SharedContext } from '../types';
export declare function register(ctx: SharedContext): (uri: string, position: vscode.Position) => vscode.Location[];
import type * as ts from 'typescript/lib/tsserverlibrary';
import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
import { SharedContext } from '../types';
export declare function register(ctx: SharedContext): (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
export declare function fileTextChangesToWorkspaceEdit(changes: readonly ts.FileTextChanges[], ctx: SharedContext): vscode.WorkspaceEdit;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.fileTextChangesToWorkspaceEdit = exports.register = void 0;
const vscode = __importStar(require("vscode-languageserver-protocol"));
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
const path_1 = require("path");

@@ -70,3 +45,7 @@ const prepareRename_1 = require("./prepareRename");

}
edits.documentChanges.push(vscode.RenameFile.create(ctx.env.fileNameToUri(fileToRename), ctx.env.fileNameToUri(newFilePath)));
edits.documentChanges.push({
kind: 'rename',
oldUri: ctx.env.fileNameToUri(fileToRename),
newUri: ctx.env.fileNameToUri(newFilePath),
});
return edits;

@@ -85,11 +64,13 @@ }

if (change.isNewFile) {
workspaceEdit.documentChanges.push(vscode.CreateFile.create(uri));
doc = vscode_languageserver_textdocument_1.TextDocument.create(uri, 'typescript', 0, '');
workspaceEdit.documentChanges.push({ kind: 'create', uri });
}
if (!doc)
if (!doc && !change.isNewFile)
continue;
const docEdit = vscode.TextDocumentEdit.create({
uri,
version: null, // fix https://github.com/johnsoncodehk/volar/issues/2025
}, []);
const docEdit = {
textDocument: {
uri,
version: null, // fix https://github.com/johnsoncodehk/volar/issues/2025
},
edits: [],
};
for (const textChange of change.textChanges) {

@@ -99,4 +80,4 @@ docEdit.edits.push({

range: {
start: doc.positionAt(textChange.span.start),
end: doc.positionAt(textChange.span.start + textChange.span.length),
start: doc?.positionAt(textChange.span.start) ?? { line: 0, character: 0 },
end: doc?.positionAt(textChange.span.start + textChange.span.length) ?? { line: 0, character: 0 },
},

@@ -103,0 +84,0 @@ });

import { SharedContext } from '../types';
import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
export declare function register(ctx: SharedContext): (uri: string, positions: vscode.Position[]) => vscode.SelectionRange[];
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const vscode = __importStar(require("vscode-languageserver-protocol"));
const shared_1 = require("../shared");

@@ -49,3 +25,6 @@ function register(ctx) {

return {
range: vscode.Range.create(document.positionAt(range.textSpan.start), document.positionAt(range.textSpan.start + range.textSpan.length)),
range: {
start: document.positionAt(range.textSpan.start),
end: document.positionAt(range.textSpan.start + range.textSpan.length),
},
parent: range.parent ? transformSelectionRange(range.parent, document) : undefined,

@@ -52,0 +31,0 @@ };

@@ -1,3 +0,3 @@

import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
import { SharedContext } from '../types';
export declare function register(ctx: SharedContext): (uri: string, range: vscode.Range, legend: vscode.SemanticTokensLegend) => [number, number, number, number, number][] | undefined;
import { SharedContext } from '../types';
import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
export declare function register(ctx: SharedContext): (uri: string, position: vscode.Position, context?: vscode.SignatureHelpContext) => vscode.SignatureHelp | undefined;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const vscode = __importStar(require("vscode-languageserver-protocol"));
const shared_1 = require("../shared");

@@ -36,3 +12,3 @@ function register(ctx) {

const options = {};
if (context?.triggerKind === vscode.SignatureHelpTriggerKind.Invoked) {
if (context?.triggerKind === 1) {
options.triggerReason = {

@@ -42,3 +18,3 @@ kind: 'invoked'

}
else if (context?.triggerKind === vscode.SignatureHelpTriggerKind.TriggerCharacter) {
else if (context?.triggerKind === 2) {
options.triggerReason = {

@@ -49,3 +25,3 @@ kind: 'characterTyped',

}
else if (context?.triggerKind === vscode.SignatureHelpTriggerKind.ContentChange) {
else if (context?.triggerKind === 3) {
options.triggerReason = {

@@ -52,0 +28,0 @@ kind: 'retrigger',

@@ -1,2 +0,2 @@

import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
import { SharedContext } from '../types';

@@ -3,0 +3,0 @@ export declare function register(ctx: SharedContext): {

@@ -29,3 +29,2 @@ "use strict";

const minimatch_1 = require("minimatch");
const vscode = __importStar(require("vscode-languageserver-protocol"));
const vscode_uri_1 = require("vscode-uri");

@@ -86,3 +85,6 @@ function mapChildren(node, f) {

};
const link = vscode.DocumentLink.create(getRange(document, extendsNode), undefined, args);
const link = {
range: getRange(document, extendsNode),
data: args,
};
// link.tooltip = vscode.l10n.t("Follow link");

@@ -101,5 +103,9 @@ link.tooltip = "Follow link";

}
return vscode.DocumentLink.create(getRange(document, pathNode), pathNode.value.endsWith('.json')
? getFileTarget(document, pathNode)
: getFolderTarget(document, pathNode));
const link = {
range: getRange(document, pathNode),
target: pathNode.value.endsWith('.json')
? getFileTarget(document, pathNode)
: getFolderTarget(document, pathNode)
};
return link;
});

@@ -109,3 +115,3 @@ }

return isPathValue(node)
? vscode.DocumentLink.create(getRange(document, node), getFileTarget(document, node))
? { range: getRange(document, node), target: getFileTarget(document, node) }
: undefined;

@@ -129,3 +135,3 @@ }

const end = document.positionAt(offset + (node.length - 1));
return vscode.Range.create(start, end);
return { start, end };
}

@@ -132,0 +138,0 @@ async function resolveNodeModulesPath(baseDirUri, pathCandidates) {

@@ -1,3 +0,3 @@

import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
import { SharedContext } from '../types';
export declare function register(ctx: SharedContext): (query: string) => vscode.WorkspaceSymbol[];

@@ -28,3 +28,2 @@ "use strict";

const PConst = __importStar(require("../protocol.const"));
const vscode = __importStar(require("vscode-languageserver-protocol"));
const modifiers_1 = require("../utils/modifiers");

@@ -34,14 +33,14 @@ const shared_1 = require("../shared");

switch (item.kind) {
case PConst.Kind.method: return vscode.SymbolKind.Method;
case PConst.Kind.enum: return vscode.SymbolKind.Enum;
case PConst.Kind.enumMember: return vscode.SymbolKind.EnumMember;
case PConst.Kind.function: return vscode.SymbolKind.Function;
case PConst.Kind.class: return vscode.SymbolKind.Class;
case PConst.Kind.interface: return vscode.SymbolKind.Interface;
case PConst.Kind.type: return vscode.SymbolKind.Class;
case PConst.Kind.memberVariable: return vscode.SymbolKind.Field;
case PConst.Kind.memberGetAccessor: return vscode.SymbolKind.Field;
case PConst.Kind.memberSetAccessor: return vscode.SymbolKind.Field;
case PConst.Kind.variable: return vscode.SymbolKind.Variable;
default: return vscode.SymbolKind.Variable;
case PConst.Kind.method: return 6;
case PConst.Kind.enum: return 10;
case PConst.Kind.enumMember: return 22;
case PConst.Kind.function: return 12;
case PConst.Kind.class: return 5;
case PConst.Kind.interface: return 11;
case PConst.Kind.type: return 5;
case PConst.Kind.memberVariable: return 8;
case PConst.Kind.memberGetAccessor: return 8;
case PConst.Kind.memberSetAccessor: return 8;
case PConst.Kind.variable: return 13;
default: return 13;
}

@@ -63,7 +62,14 @@ }

if (document) {
const range = vscode.Range.create(document.positionAt(item.textSpan.start), document.positionAt(item.textSpan.start + item.textSpan.length));
const info = vscode.WorkspaceSymbol.create(label, getSymbolKind(item), uri, range);
const range = {
start: document.positionAt(item.textSpan.start),
end: document.positionAt(item.textSpan.start + item.textSpan.length),
};
const info = {
name: label,
kind: getSymbolKind(item),
location: { uri, range },
};
const kindModifiers = item.kindModifiers ? (0, modifiers_1.parseKindModifier)(item.kindModifiers) : undefined;
if (kindModifiers?.has(PConst.KindModifiers.deprecated)) {
info.tags = [vscode.SymbolTag.Deprecated];
info.tags = [1];
}

@@ -70,0 +76,0 @@ return info;

import { SharedContext } from '../types';
import type * as ts from 'typescript/lib/tsserverlibrary';
import * as vscode from 'vscode-languageserver-protocol';
import type * as vscode from '@volar/language-service';
import type { TextDocument } from 'vscode-languageserver-textdocument';

@@ -5,0 +5,0 @@ export declare function entriesToLocations(entries: {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.boundSpanToLocationLinks = exports.entriesToLocationLinks = exports.entriesToLocations = void 0;
const vscode = __importStar(require("vscode-languageserver-protocol"));
function entriesToLocations(entries, ctx) {

@@ -35,4 +11,7 @@ const locations = [];

continue;
const range = vscode.Range.create(doc.positionAt(entry.textSpan.start), doc.positionAt(entry.textSpan.start + entry.textSpan.length));
const location = vscode.Location.create(entryUri, range);
const range = {
start: doc.positionAt(entry.textSpan.start),
end: doc.positionAt(entry.textSpan.start + entry.textSpan.length),
};
const location = { uri: entryUri, range };
locations.push(location);

@@ -50,6 +29,20 @@ }

continue;
const targetSelectionRange = vscode.Range.create(doc.positionAt(entry.textSpan.start), doc.positionAt(entry.textSpan.start + entry.textSpan.length));
const targetRange = entry.contextSpan ? vscode.Range.create(doc.positionAt(entry.contextSpan.start), doc.positionAt(entry.contextSpan.start + entry.contextSpan.length)) : targetSelectionRange;
const originSelectionRange = entry.originalTextSpan ? vscode.Range.create(doc.positionAt(entry.originalTextSpan.start), doc.positionAt(entry.originalTextSpan.start + entry.originalTextSpan.length)) : undefined;
const location = vscode.LocationLink.create(entryUri, targetRange, targetSelectionRange, originSelectionRange);
const targetSelectionRange = {
start: doc.positionAt(entry.textSpan.start),
end: doc.positionAt(entry.textSpan.start + entry.textSpan.length),
};
const targetRange = entry.contextSpan ? {
start: doc.positionAt(entry.contextSpan.start),
end: doc.positionAt(entry.contextSpan.start + entry.contextSpan.length),
} : targetSelectionRange;
const originSelectionRange = entry.originalTextSpan ? {
start: doc.positionAt(entry.originalTextSpan.start),
end: doc.positionAt(entry.originalTextSpan.start + entry.originalTextSpan.length),
} : undefined;
const location = {
targetUri: entryUri,
targetRange,
targetSelectionRange,
originSelectionRange,
};
locations.push(location);

@@ -64,3 +57,6 @@ }

return locations;
const originSelectionRange = vscode.Range.create(originalDoc.positionAt(info.textSpan.start), originalDoc.positionAt(info.textSpan.start + info.textSpan.length));
const originSelectionRange = {
start: originalDoc.positionAt(info.textSpan.start),
end: originalDoc.positionAt(info.textSpan.start + info.textSpan.length),
};
for (const entry of info.definitions) {

@@ -71,5 +67,16 @@ const entryUri = ctx.env.fileNameToUri(entry.fileName);

continue;
const targetSelectionRange = vscode.Range.create(doc.positionAt(entry.textSpan.start), doc.positionAt(entry.textSpan.start + entry.textSpan.length));
const targetRange = entry.contextSpan ? vscode.Range.create(doc.positionAt(entry.contextSpan.start), doc.positionAt(entry.contextSpan.start + entry.contextSpan.length)) : targetSelectionRange;
const location = vscode.LocationLink.create(entryUri, targetRange, targetSelectionRange, originSelectionRange);
const targetSelectionRange = {
start: doc.positionAt(entry.textSpan.start),
end: doc.positionAt(entry.textSpan.start + entry.textSpan.length),
};
const targetRange = entry.contextSpan ? {
start: doc.positionAt(entry.contextSpan.start),
end: doc.positionAt(entry.contextSpan.start + entry.contextSpan.length),
} : targetSelectionRange;
const location = {
targetUri: entryUri,
targetRange,
targetSelectionRange,
originSelectionRange,
};
locations.push(location);

@@ -76,0 +83,0 @@ }

import type * as ts from 'typescript/lib/tsserverlibrary';
export declare namespace SymbolKind {
function fromProtocolScriptElementKind(kind: ts.ScriptElementKind): 2 | 5 | 10 | 22 | 11 | 6 | 7 | 13 | 12 | 9 | 26 | 15;
function fromProtocolScriptElementKind(kind: ts.ScriptElementKind): 2 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 15 | 22 | 26;
}

@@ -31,6 +31,2 @@ "use strict";

exports.SymbolKind = void 0;
/**
* Helpers for converting FROM vscode types TO ts types
*/
const vscode = __importStar(require("vscode-languageserver-protocol"));
const PConst = __importStar(require("../protocol.const"));

@@ -41,25 +37,25 @@ var SymbolKind;

switch (kind) {
case PConst.Kind.module: return vscode.SymbolKind.Module;
case PConst.Kind.class: return vscode.SymbolKind.Class;
case PConst.Kind.enum: return vscode.SymbolKind.Enum;
case PConst.Kind.enumMember: return vscode.SymbolKind.EnumMember;
case PConst.Kind.interface: return vscode.SymbolKind.Interface;
case PConst.Kind.indexSignature: return vscode.SymbolKind.Method;
case PConst.Kind.callSignature: return vscode.SymbolKind.Method;
case PConst.Kind.method: return vscode.SymbolKind.Method;
case PConst.Kind.memberVariable: return vscode.SymbolKind.Property;
case PConst.Kind.memberGetAccessor: return vscode.SymbolKind.Property;
case PConst.Kind.memberSetAccessor: return vscode.SymbolKind.Property;
case PConst.Kind.variable: return vscode.SymbolKind.Variable;
case PConst.Kind.let: return vscode.SymbolKind.Variable;
case PConst.Kind.const: return vscode.SymbolKind.Variable;
case PConst.Kind.localVariable: return vscode.SymbolKind.Variable;
case PConst.Kind.alias: return vscode.SymbolKind.Variable;
case PConst.Kind.function: return vscode.SymbolKind.Function;
case PConst.Kind.localFunction: return vscode.SymbolKind.Function;
case PConst.Kind.constructSignature: return vscode.SymbolKind.Constructor;
case PConst.Kind.constructorImplementation: return vscode.SymbolKind.Constructor;
case PConst.Kind.typeParameter: return vscode.SymbolKind.TypeParameter;
case PConst.Kind.string: return vscode.SymbolKind.String;
default: return vscode.SymbolKind.Variable;
case PConst.Kind.module: return 2;
case PConst.Kind.class: return 5;
case PConst.Kind.enum: return 10;
case PConst.Kind.enumMember: return 22;
case PConst.Kind.interface: return 11;
case PConst.Kind.indexSignature: return 6;
case PConst.Kind.callSignature: return 6;
case PConst.Kind.method: return 6;
case PConst.Kind.memberVariable: return 7;
case PConst.Kind.memberGetAccessor: return 7;
case PConst.Kind.memberSetAccessor: return 7;
case PConst.Kind.variable: return 13;
case PConst.Kind.let: return 13;
case PConst.Kind.const: return 13;
case PConst.Kind.localVariable: return 13;
case PConst.Kind.alias: return 13;
case PConst.Kind.function: return 12;
case PConst.Kind.localFunction: return 12;
case PConst.Kind.constructSignature: return 9;
case PConst.Kind.constructorImplementation: return 9;
case PConst.Kind.typeParameter: return 26;
case PConst.Kind.string: return 15;
default: return 13;
}

@@ -66,0 +62,0 @@ }

{
"name": "volar-service-typescript",
"version": "0.0.3",
"version": "0.0.4",
"main": "out/index.js",

@@ -16,3 +16,4 @@ "license": "MIT",

"devDependencies": {
"@types/semver": "^7.3.13"
"@types/semver": "^7.3.13",
"vscode-languageserver-textdocument": "^1.0.8"
},

@@ -23,8 +24,6 @@ "dependencies": {

"semver": "^7.3.8",
"vscode-languageserver-protocol": "^3.17.3",
"vscode-languageserver-textdocument": "^1.0.8",
"vscode-nls": "^5.2.0",
"vscode-uri": "^3.0.7"
},
"gitHead": "28896539331e31b4ef1064b6839ea0924d5d28d0"
"gitHead": "f5d49495d6698761f4df8c9ef2747cc01fc777d6"
}