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

@volar/language-server

Package Overview
Dependencies
Maintainers
1
Versions
238
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@volar/language-server - npm Package Compare versions

Comparing version 1.0.18 to 1.0.19

14

out/common/project.d.ts

@@ -6,14 +6,14 @@ import * as embedded from '@volar/language-core';

import { URI } from 'vscode-uri';
import { WorkspaceParams } from './workspace';
import { LanguageServicePlugin } from '@volar/language-service';
export interface ProjectParams {
workspace: WorkspaceParams;
import { WorkspaceContext } from './workspace';
import { ServerConfig } from './utils/serverConfig';
export interface ProjectContext {
workspace: WorkspaceContext;
rootUri: URI;
tsConfig: path.PosixPath | ts.CompilerOptions;
documentRegistry: ts.DocumentRegistry;
workspacePlugins: LanguageServicePlugin[];
serverConfig: ServerConfig | undefined;
}
export type Project = ReturnType<typeof createProject>;
export declare function createProject(params: ProjectParams): Promise<{
tsConfig: path.PosixPath | ts.CompilerOptions;
export declare function createProject(context: ProjectContext): Promise<{
tsConfig: ts.CompilerOptions | path.PosixPath;
scripts: {

@@ -20,0 +20,0 @@ clear: () => void;

@@ -18,29 +18,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

const uriMap_1 = require("./utils/uriMap");
function createProject(params) {
function createProject(context) {
return __awaiter(this, void 0, void 0, function* () {
const { tsConfig, documentRegistry, rootUri } = params;
const { ts, fileSystemHost, documents, cancelTokenHost, tsLocalized, initOptions, configurationHost } = params.workspace.workspaces;
const { plugins } = params.workspace.workspaces;
const { runtimeEnv } = params.workspace.workspaces.server;
const sys = fileSystemHost.getWorkspaceFileSystem(rootUri);
const sys = context.workspace.workspaces.fileSystemHost.getWorkspaceFileSystem(context.rootUri);
let typeRootVersion = 0;
let projectVersion = 0;
let projectVersionUpdateTime = cancelTokenHost.getMtime();
let vueLs;
let parsedCommandLine = createParsedCommandLine(ts, sys, shared.getPathOfUri(rootUri.toString()), tsConfig, plugins);
let projectVersionUpdateTime = context.workspace.workspaces.cancelTokenHost.getMtime();
let languageService;
let parsedCommandLine = createParsedCommandLine(context.workspace.workspaces.ts, sys, shared.getPathOfUri(context.rootUri.toString()), context.tsConfig, context.workspace.workspaces.plugins);
const scripts = (0, uriMap_1.createUriMap)();
const languageServiceHost = createLanguageServiceHost();
const disposeWatchEvent = fileSystemHost.onDidChangeWatchedFiles(params => {
const disposeWatchEvent = context.workspace.workspaces.fileSystemHost.onDidChangeWatchedFiles(params => {
onWorkspaceFilesChanged(params.changes);
});
const disposeDocChange = documents.onDidChangeContent(() => {
const disposeDocChange = context.workspace.workspaces.documents.onDidChangeContent(() => {
projectVersion++;
projectVersionUpdateTime = cancelTokenHost.getMtime();
projectVersionUpdateTime = context.workspace.workspaces.cancelTokenHost.getMtime();
});
return {
tsConfig,
tsConfig: context.tsConfig,
scripts,
languageServiceHost,
getLanguageService,
getLanguageServiceDontCreate: () => vueLs,
getLanguageServiceDontCreate: () => languageService,
getParsedCommandLine: () => parsedCommandLine,

@@ -51,3 +47,3 @@ tryAddFile: (fileName) => {

projectVersion++;
projectVersionUpdateTime = cancelTokenHost.getMtime();
projectVersionUpdateTime = context.workspace.workspaces.cancelTokenHost.getMtime();
}

@@ -58,4 +54,4 @@ },

function getLanguageService() {
if (!vueLs) {
const languageModules = plugins.map(plugin => { var _a, _b, _c; return (_c = (_b = (_a = plugin.semanticService) === null || _a === void 0 ? void 0 : _a.getLanguageModules) === null || _b === void 0 ? void 0 : _b.call(_a, languageServiceHost)) !== null && _c !== void 0 ? _c : []; }).flat();
if (!languageService) {
const languageModules = context.workspace.workspaces.plugins.map(plugin => { var _a, _b, _c; return (_c = (_b = (_a = plugin.semanticService) === null || _a === void 0 ? void 0 : _a.getLanguageModules) === null || _b === void 0 ? void 0 : _b.call(_a, languageServiceHost)) !== null && _c !== void 0 ? _c : []; }).flat();
const languageContext = embedded.createLanguageContext(languageServiceHost, languageModules);

@@ -66,15 +62,16 @@ const languageServiceContext = embeddedLS.createLanguageServiceContext({

getPlugins() {
var _a, _b;
return [
...params.workspacePlugins,
...plugins.map(plugin => { var _a, _b, _c; return (_c = (_b = (_a = plugin.semanticService) === null || _a === void 0 ? void 0 : _a.getServicePlugins) === null || _b === void 0 ? void 0 : _b.call(_a, languageServiceHost, vueLs)) !== null && _c !== void 0 ? _c : []; }).flat(),
...(_b = (_a = context.serverConfig) === null || _a === void 0 ? void 0 : _a.plugins) !== null && _b !== void 0 ? _b : [],
...context.workspace.workspaces.plugins.map(plugin => { var _a, _b, _c; return (_c = (_b = (_a = plugin.semanticService) === null || _a === void 0 ? void 0 : _a.getServicePlugins) === null || _b === void 0 ? void 0 : _b.call(_a, languageServiceHost, languageService)) !== null && _c !== void 0 ? _c : []; }).flat(),
];
},
env: {
rootUri,
configurationHost: configurationHost,
fileSystemProvider: runtimeEnv.fileSystemProvide,
documentContext: getHTMLDocumentContext(ts, languageServiceHost),
rootUri: context.rootUri,
configurationHost: context.workspace.workspaces.configurationHost,
fileSystemProvider: context.workspace.workspaces.server.runtimeEnv.fileSystemProvide,
documentContext: getHTMLDocumentContext(context.workspace.workspaces.ts, languageServiceHost),
schemaRequestService: (uri) => __awaiter(this, void 0, void 0, function* () {
const protocol = uri.substring(0, uri.indexOf(':'));
const builtInHandler = runtimeEnv.schemaRequestHandlers[protocol];
const builtInHandler = context.workspace.workspaces.server.runtimeEnv.schemaRequestHandlers[protocol];
if (builtInHandler) {

@@ -86,7 +83,7 @@ return yield builtInHandler(uri);

},
documentRegistry,
documentRegistry: context.documentRegistry,
});
vueLs = embeddedLS.createLanguageService(languageServiceContext);
languageService = embeddedLS.createLanguageService(languageServiceContext);
}
return vueLs;
return languageService;
}

@@ -116,3 +113,3 @@ function onWorkspaceFilesChanged(changes) {

if (creates.length || deletes.length) {
parsedCommandLine = createParsedCommandLine(ts, sys, shared.getPathOfUri(rootUri.toString()), tsConfig, plugins);
parsedCommandLine = createParsedCommandLine(context.workspace.workspaces.ts, sys, shared.getPathOfUri(context.rootUri.toString()), context.tsConfig, context.workspace.workspaces.plugins);
projectVersion++;

@@ -122,3 +119,3 @@ typeRootVersion++;

if (_projectVersion !== projectVersion) {
projectVersionUpdateTime = cancelTokenHost.getMtime();
projectVersionUpdateTime = context.workspace.workspaces.cancelTokenHost.getMtime();
}

@@ -131,3 +128,3 @@ });

isCancellationRequested() {
return cancelTokenHost.getMtime() !== projectVersionUpdateTime;
return context.workspace.workspaces.cancelTokenHost.getMtime() !== projectVersionUpdateTime;
},

@@ -147,3 +144,3 @@ throwIfCancellationRequested() { },

fileExists: sys.fileExists,
getCurrentDirectory: () => shared.getPathOfUri(rootUri.toString()),
getCurrentDirectory: () => shared.getPathOfUri(context.rootUri.toString()),
getProjectReferences: () => parsedCommandLine.projectReferences,

@@ -154,7 +151,7 @@ getCancellationToken: () => token,

try {
return ts.getDefaultLibFilePath(options);
return context.workspace.workspaces.ts.getDefaultLibFilePath(options);
}
catch (_a) {
// web
return initOptions.typescript.tsdk + '/' + ts.getDefaultLibFileName(options);
return context.workspace.workspaces.initOptions.typescript.tsdk + '/' + context.workspace.workspaces.ts.getDefaultLibFileName(options);
}

@@ -168,14 +165,14 @@ },

getScriptSnapshot,
getTypeScriptModule: () => ts,
getTypeScriptModule: () => context.workspace.workspaces.ts,
};
if (initOptions.noProjectReferences) {
if (context.workspace.workspaces.initOptions.noProjectReferences) {
host.getProjectReferences = undefined;
host.getCompilationSettings = () => (Object.assign(Object.assign({}, parsedCommandLine.options), { rootDir: undefined, composite: false }));
}
if (tsLocalized) {
host.getLocalizedDiagnosticMessages = () => tsLocalized;
if (context.workspace.workspaces.tsLocalized) {
host.getLocalizedDiagnosticMessages = () => context.workspace.workspaces.tsLocalized;
}
for (const plugin of plugins) {
for (const plugin of context.workspace.workspaces.plugins) {
if ((_a = plugin.semanticService) === null || _a === void 0 ? void 0 : _a.resolveLanguageServiceHost) {
host = plugin.semanticService.resolveLanguageServiceHost(ts, sys, tsConfig, host);
host = plugin.semanticService.resolveLanguageServiceHost(context.workspace.workspaces.ts, sys, context.tsConfig, host);
}

@@ -186,3 +183,3 @@ }

var _a, _b;
const doc = documents.data.pathGet(fileName);
const doc = context.workspace.workspaces.documents.data.pathGet(fileName);
if (doc) {

@@ -195,3 +192,3 @@ return doc.version.toString();

var _a;
const doc = documents.data.pathGet(fileName);
const doc = context.workspace.workspaces.documents.data.pathGet(fileName);
if (doc) {

@@ -205,7 +202,7 @@ return doc.getSnapshot();

if (sys.fileExists(fileName)) {
if (initOptions.maxFileSize) {
if (context.workspace.workspaces.initOptions.maxFileSize) {
const fileSize = (_a = sys.getFileSize) === null || _a === void 0 ? void 0 : _a.call(sys, fileName);
if (fileSize !== undefined && fileSize > initOptions.maxFileSize) {
console.warn(`IGNORING "${fileName}" because it is too large (${fileSize}bytes > ${initOptions.maxFileSize}bytes)`);
return ts.ScriptSnapshot.fromString('');
if (fileSize !== undefined && fileSize > context.workspace.workspaces.initOptions.maxFileSize) {
console.warn(`IGNORING "${fileName}" because it is too large (${fileSize}bytes > ${context.workspace.workspaces.initOptions.maxFileSize}bytes)`);
return context.workspace.workspaces.ts.ScriptSnapshot.fromString('');
}

@@ -215,3 +212,3 @@ }

if (text !== undefined) {
const snapshot = ts.ScriptSnapshot.fromString(text);
const snapshot = context.workspace.workspaces.ts.ScriptSnapshot.fromString(text);
if (script) {

@@ -235,3 +232,3 @@ script.snapshot = snapshot;

function dispose() {
vueLs === null || vueLs === void 0 ? void 0 : vueLs.dispose();
languageService === null || languageService === void 0 ? void 0 : languageService.dispose();
scripts.clear();

@@ -238,0 +235,0 @@ disposeWatchEvent();

import * as vscode from 'vscode-languageserver';
import { LanguageServerPlugin, RuntimeEnvironment } from '../types';
export interface ServerParams {
export interface ServerContext {
connection: vscode.Connection;

@@ -8,2 +8,2 @@ runtimeEnv: RuntimeEnvironment;

}
export declare function createCommonLanguageServer(params: ServerParams): void;
export declare function createCommonLanguageServer(context: ServerContext): void;

@@ -21,4 +21,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

const workspaces_1 = require("./workspaces");
function createCommonLanguageServer(params) {
const { connection, runtimeEnv, plugins: _plugins } = params;
function createCommonLanguageServer(context) {
let initParams;

@@ -32,8 +31,8 @@ let options;

let plugins;
const documents = (0, documents_1.createDocuments)(connection);
connection.onInitialize((_params) => __awaiter(this, void 0, void 0, function* () {
const documents = (0, documents_1.createDocuments)(context.connection);
context.connection.onInitialize((_params) => __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d;
initParams = _params;
options = initParams.initializationOptions;
plugins = _plugins.map(plugin => plugin(options));
plugins = context.plugins.map(plugin => plugin(options));
if (((_a = initParams.capabilities.workspace) === null || _a === void 0 ? void 0 : _a.workspaceFolders) && initParams.workspaceFolders) {

@@ -53,3 +52,3 @@ roots = initParams.workspaceFolders.map(folder => vscode_uri_1.URI.parse(folder.uri));

};
configurationHost = ((_c = initParams.capabilities.workspace) === null || _c === void 0 ? void 0 : _c.configuration) ? (0, configurationHost_1.createConfigurationHost)(initParams, connection) : undefined;
configurationHost = ((_c = initParams.capabilities.workspace) === null || _c === void 0 ? void 0 : _c.configuration) ? (0, configurationHost_1.createConfigurationHost)(initParams, context.connection) : undefined;
const serverMode = (_d = options.serverMode) !== null && _d !== void 0 ? _d : types_1.ServerMode.Semantic;

@@ -73,8 +72,8 @@ (0, registerFeatures_1.setupSyntacticCapabilities)(initParams.capabilities, result.capabilities, options);

}));
connection.onInitialized(() => {
context.connection.onInitialized(() => {
var _a, _b, _c;
fsHost === null || fsHost === void 0 ? void 0 : fsHost.ready(connection);
fsHost === null || fsHost === void 0 ? void 0 : fsHost.ready(context.connection);
configurationHost === null || configurationHost === void 0 ? void 0 : configurationHost.ready();
if ((_a = initParams.capabilities.workspace) === null || _a === void 0 ? void 0 : _a.workspaceFolders) {
connection.workspace.onDidChangeWorkspaceFolders(e => {
context.connection.workspace.onDidChangeWorkspaceFolders(e => {
for (const folder of e.added) {

@@ -93,3 +92,3 @@ documentServiceHost === null || documentServiceHost === void 0 ? void 0 : documentServiceHost.add(vscode_uri_1.URI.parse(folder.uri));

&& ((_c = (_b = initParams.capabilities.workspace) === null || _b === void 0 ? void 0 : _b.didChangeWatchedFiles) === null || _c === void 0 ? void 0 : _c.dynamicRegistration)) {
connection.client.register(vscode.DidChangeWatchedFilesNotification.type, {
context.connection.client.register(vscode.DidChangeWatchedFilesNotification.type, {
watchers: [

@@ -114,14 +113,14 @@ {

});
connection.listen();
context.connection.listen();
function _createDocumentServiceHost() {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
const ts = runtimeEnv.loadTypescript(options.typescript.tsdk);
documentServiceHost = (0, syntaxServicesHost_1.createSyntaxServicesHost)(runtimeEnv, plugins, ts, configurationHost, options);
const ts = context.runtimeEnv.loadTypescript(options.typescript.tsdk);
documentServiceHost = (0, syntaxServicesHost_1.createSyntaxServicesHost)(context.runtimeEnv, plugins, ts, configurationHost, options);
for (const root of roots) {
documentServiceHost.add(root);
}
(yield Promise.resolve().then(() => require('./features/documentFeatures'))).register(connection, documents, documentServiceHost);
(yield Promise.resolve().then(() => require('./features/documentFeatures'))).register(context.connection, documents, documentServiceHost);
for (const plugin of plugins) {
(_b = (_a = plugin.syntacticService) === null || _a === void 0 ? void 0 : _a.onInitialize) === null || _b === void 0 ? void 0 : _b.call(_a, connection);
(_b = (_a = plugin.syntacticService) === null || _a === void 0 ? void 0 : _a.onInitialize) === null || _b === void 0 ? void 0 : _b.call(_a, context.connection);
}

@@ -133,8 +132,8 @@ });

return __awaiter(this, void 0, void 0, function* () {
const ts = runtimeEnv.loadTypescript(options.typescript.tsdk);
fsHost = runtimeEnv.createFileSystemHost(ts, initParams.capabilities);
const tsLocalized = initParams.locale ? yield runtimeEnv.loadTypescriptLocalized(options.typescript.tsdk, initParams.locale) : undefined;
const ts = context.runtimeEnv.loadTypescript(options.typescript.tsdk);
fsHost = context.runtimeEnv.createFileSystemHost(ts, initParams.capabilities);
const tsLocalized = initParams.locale ? yield context.runtimeEnv.loadTypescriptLocalized(options.typescript.tsdk, initParams.locale) : undefined;
const cancelTokenHost = (0, cancellationPipe_1.createCancellationTokenHost)(options.cancellationPipeName);
const _projects = (0, workspaces_1.createWorkspaces)({
server: params,
server: context,
fileSystemHost: fsHost,

@@ -154,6 +153,6 @@ configurationHost,

}
(yield Promise.resolve().then(() => require('./features/customFeatures'))).register(connection, projects);
(yield Promise.resolve().then(() => require('./features/languageFeatures'))).register(connection, projects, initParams, cancelTokenHost, getSemanticTokensLegend());
(yield Promise.resolve().then(() => require('./features/customFeatures'))).register(context.connection, projects);
(yield Promise.resolve().then(() => require('./features/languageFeatures'))).register(context.connection, projects, initParams, cancelTokenHost, getSemanticTokensLegend());
for (const plugin of plugins) {
(_b = (_a = plugin.semanticService) === null || _a === void 0 ? void 0 : _a.onInitialize) === null || _b === void 0 ? void 0 : _b.call(_a, connection, getLanguageService);
(_b = (_a = plugin.semanticService) === null || _a === void 0 ? void 0 : _a.onInitialize) === null || _b === void 0 ? void 0 : _b.call(_a, context.connection, getLanguageService);
}

@@ -160,0 +159,0 @@ function getLanguageService(uri) {

@@ -34,2 +34,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

};
const serverConfig = (0, serverConfig_1.loadServerConfig)(rootUri.fsPath, initOptions.configFilePath);
const serviceContext = embedded.createDocumentServiceContext({

@@ -42,4 +43,5 @@ ts,

getPlugins() {
var _a;
return [
...(0, serverConfig_1.loadCustomPlugins)(rootUri.fsPath, initOptions.configFilePath),
...(_a = serverConfig === null || serverConfig === void 0 ? void 0 : serverConfig.plugins) !== null && _a !== void 0 ? _a : [],
...plugins.map(plugin => { var _a, _b, _c; return (_c = (_b = (_a = plugin.syntacticService) === null || _a === void 0 ? void 0 : _a.getServicePlugins) === null || _b === void 0 ? void 0 : _b.call(_a, serviceContext)) !== null && _c !== void 0 ? _c : []; }).flat(),

@@ -46,0 +48,0 @@ ];

import { LanguageServicePlugin } from '@volar/language-service';
export declare function loadCustomPlugins(dir: string, configFile: string | undefined): LanguageServicePlugin[];
export interface ServerConfig {
plugins?: LanguageServicePlugin[];
}
export declare function loadServerConfig(dir: string, configFile: string | undefined): ServerConfig | undefined;
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadCustomPlugins = void 0;
function loadCustomPlugins(dir, configFile) {
var _a;
exports.loadServerConfig = void 0;
function loadServerConfig(dir, configFile) {
let configPath;

@@ -9,3 +8,3 @@ try {

}
catch (_b) { }
catch (_a) { }
try {

@@ -15,3 +14,3 @@ if (configPath) {

delete require.cache[configPath];
return (_a = config.plugins) !== null && _a !== void 0 ? _a : [];
return config;
}

@@ -22,5 +21,4 @@ }

}
return [];
}
exports.loadCustomPlugins = loadCustomPlugins;
exports.loadServerConfig = loadServerConfig;
//# sourceMappingURL=serverConfig.js.map

@@ -21,18 +21,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

exports.rootTsConfigNames = ['tsconfig.json', 'jsconfig.json'];
function createWorkspace(params) {
function createWorkspace(context) {
return __awaiter(this, void 0, void 0, function* () {
const { rootUri } = params;
const { ts, fileSystemHost, initOptions, configurationHost } = params.workspaces;
let inferredProject;
const workspacePlugins = (0, serverConfig_1.loadCustomPlugins)(shared.getPathOfUri(rootUri.toString()), initOptions.configFilePath);
const sys = fileSystemHost.getWorkspaceFileSystem(rootUri);
const documentRegistry = ts.createDocumentRegistry(sys.useCaseSensitiveFileNames, shared.getPathOfUri(rootUri.toString()));
const serverConfig = (0, serverConfig_1.loadServerConfig)(shared.getPathOfUri(context.rootUri.toString()), context.workspaces.initOptions.configFilePath);
const sys = context.workspaces.fileSystemHost.getWorkspaceFileSystem(context.rootUri);
const documentRegistry = context.workspaces.ts.createDocumentRegistry(sys.useCaseSensitiveFileNames, shared.getPathOfUri(context.rootUri.toString()));
const projects = (0, uriMap_1.createUriMap)();
const rootTsConfigs = new Set(sys.readDirectory(shared.getPathOfUri(rootUri.toString()), exports.rootTsConfigNames, undefined, ['**/*']).map(fileName => shared.normalizeFileName(fileName)));
const disposeWatch = fileSystemHost.onDidChangeWatchedFiles((params) => __awaiter(this, void 0, void 0, function* () {
const disposes = [];
for (const change of params.changes) {
const rootTsConfigs = new Set(sys.readDirectory(shared.getPathOfUri(context.rootUri.toString()), exports.rootTsConfigNames, undefined, ['**/*']).map(fileName => shared.normalizeFileName(fileName)));
const disposeTsConfigWatch = context.workspaces.fileSystemHost.onDidChangeWatchedFiles(({ changes }) => {
for (const change of changes) {
if (exports.rootTsConfigNames.includes(change.uri.substring(change.uri.lastIndexOf('/') + 1))) {
if (change.type === vscode.FileChangeType.Created) {
if (shared.isFileInDir(shared.getPathOfUri(change.uri), shared.getPathOfUri(rootUri.toString()))) {
if (shared.isFileInDir(shared.getPathOfUri(change.uri), shared.getPathOfUri(context.rootUri.toString()))) {
rootTsConfigs.add(shared.getPathOfUri(change.uri));

@@ -45,13 +42,9 @@ }

}
const _project = projects.uriGet(change.uri);
const project = projects.uriGet(change.uri);
projects.uriDelete(change.uri);
disposes.push((() => __awaiter(this, void 0, void 0, function* () {
var _a;
(_a = (yield _project)) === null || _a === void 0 ? void 0 : _a.dispose();
}))());
project === null || project === void 0 ? void 0 : project.then(project => project.dispose());
}
}
}
return Promise.all(disposes);
}));
});
return {

@@ -66,3 +59,3 @@ projects,

clearProjects();
disposeWatch();
disposeTsConfigWatch();
},

@@ -97,9 +90,9 @@ };

inferredProject = (() => __awaiter(this, void 0, void 0, function* () {
const inferOptions = yield (0, inferredCompilerOptions_1.getInferredCompilerOptions)(ts, configurationHost);
const inferOptions = yield (0, inferredCompilerOptions_1.getInferredCompilerOptions)(context.workspaces.ts, context.workspaces.configurationHost);
return (0, project_1.createProject)({
workspace: params,
workspacePlugins,
rootUri,
workspace: context,
rootUri: context.rootUri,
tsConfig: inferOptions,
documentRegistry,
serverConfig,
});

@@ -155,3 +148,3 @@ }))();

let chains = yield getReferencesChains(project.getParsedCommandLine(), rootTsConfig, []);
if (initOptions.reverseConfigFilePriority) {
if (context.workspaces.initOptions.reverseConfigFilePriority) {
chains = chains.reverse();

@@ -223,4 +216,4 @@ }

project = (0, project_1.createProject)({
workspace: params,
workspacePlugins,
workspace: context,
serverConfig,
rootUri: vscode_uri_1.URI.parse(shared.getUriByPath(path.dirname(tsConfig))),

@@ -227,0 +220,0 @@ tsConfig,

@@ -16,17 +16,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

const workspace_1 = require("./workspace");
function createWorkspaces(params) {
var _a;
const { fileSystemHost, configurationHost, initParams, initOptions, documents, cancelTokenHost } = params;
const { connection, runtimeEnv } = params.server;
function createWorkspaces(context) {
var _a, _b;
const workspaces = new Map();
let semanticTokensReq = 0;
let documentUpdatedReq = 0;
const workspaces = new Map();
documents.onDidChangeContent(params => {
updateDiagnostics(params.textDocument.uri);
context.documents.onDidChangeContent(({ textDocument }) => {
updateDiagnostics(textDocument.uri);
});
documents.onDidClose(params => {
connection.sendDiagnostics({ uri: params.textDocument.uri, diagnostics: [] });
context.documents.onDidClose(({ textDocument }) => {
context.server.connection.sendDiagnostics({ uri: textDocument.uri, diagnostics: [] });
});
fileSystemHost.onDidChangeWatchedFiles(params => {
const tsConfigChanges = params.changes.filter(change => workspace_1.rootTsConfigNames.includes(change.uri.substring(change.uri.lastIndexOf('/') + 1)));
context.fileSystemHost.onDidChangeWatchedFiles(({ changes }) => {
const tsConfigChanges = changes.filter(change => workspace_1.rootTsConfigNames.includes(change.uri.substring(change.uri.lastIndexOf('/') + 1)));
if (tsConfigChanges.length) {

@@ -36,11 +34,11 @@ reloadDiagnostics();

else {
onDriveFileUpdated();
updateDiagnosticsAndSemanticTokens();
}
});
(_a = runtimeEnv.onDidChangeConfiguration) === null || _a === void 0 ? void 0 : _a.call(runtimeEnv, () => __awaiter(this, void 0, void 0, function* () {
onDriveFileUpdated();
(_b = (_a = context.server.runtimeEnv).onDidChangeConfiguration) === null || _b === void 0 ? void 0 : _b.call(_a, () => __awaiter(this, void 0, void 0, function* () {
updateDiagnosticsAndSemanticTokens();
}));
return {
workspaces,
getProject,
getProject: getProjectAndTsConfig,
reloadProject,

@@ -50,3 +48,3 @@ add: (rootUri) => {

workspaces.set(rootUri.toString(), (0, workspace_1.createWorkspace)({
workspaces: params,
workspaces: context,
rootUri,

@@ -67,3 +65,3 @@ }));

return __awaiter(this, void 0, void 0, function* () {
fileSystemHost.reload();
context.fileSystemHost.reload();
for (const [_, workspace] of workspaces) {

@@ -76,18 +74,20 @@ (yield workspace).reload();

function reloadDiagnostics() {
for (const doc of documents.data.values()) {
connection.sendDiagnostics({ uri: doc.uri, diagnostics: [] });
for (const doc of context.documents.data.values()) {
context.server.connection.sendDiagnostics({ uri: doc.uri, diagnostics: [] });
}
onDriveFileUpdated();
updateDiagnosticsAndSemanticTokens();
}
function onDriveFileUpdated() {
var _a, _b;
function updateDiagnosticsAndSemanticTokens() {
var _a, _b, _c, _d;
return __awaiter(this, void 0, void 0, function* () {
const req = ++semanticTokensReq;
yield updateDiagnostics();
const delay = (_b = yield ((_a = context.configurationHost) === null || _a === void 0 ? void 0 : _a.getConfiguration('volar.diagnostics.delay'))) !== null && _b !== void 0 ? _b : 200;
yield shared.sleep(delay);
if (req === semanticTokensReq) {
if ((_a = initParams.capabilities.textDocument) === null || _a === void 0 ? void 0 : _a.semanticTokens) {
connection.languages.semanticTokens.refresh();
if ((_c = context.initParams.capabilities.textDocument) === null || _c === void 0 ? void 0 : _c.semanticTokens) {
context.server.connection.languages.semanticTokens.refresh();
}
if ((_b = initParams.capabilities.textDocument) === null || _b === void 0 ? void 0 : _b.inlayHint) {
connection.languages.inlayHint.refresh();
if ((_d = context.initParams.capabilities.textDocument) === null || _d === void 0 ? void 0 : _d.inlayHint) {
context.server.connection.languages.inlayHint.refresh();
}

@@ -98,9 +98,9 @@ }

function updateDiagnostics(docUri) {
var _a, _b;
var _a, _b, _c;
return __awaiter(this, void 0, void 0, function* () {
if (((_a = initOptions.diagnosticModel) !== null && _a !== void 0 ? _a : types_1.DiagnosticModel.Push) !== types_1.DiagnosticModel.Push)
if (((_a = context.initOptions.diagnosticModel) !== null && _a !== void 0 ? _a : types_1.DiagnosticModel.Push) !== types_1.DiagnosticModel.Push)
return;
const req = ++documentUpdatedReq;
const delay = (_b = yield (configurationHost === null || configurationHost === void 0 ? void 0 : configurationHost.getConfiguration('volar.diagnostics.delay'))) !== null && _b !== void 0 ? _b : 200;
const cancel = cancelTokenHost.createCancellationToken({
const delay = (_c = yield ((_b = context.configurationHost) === null || _b === void 0 ? void 0 : _b.getConfiguration('volar.diagnostics.delay'))) !== null && _c !== void 0 ? _c : 200;
const cancel = context.cancelTokenHost.createCancellationToken({
get isCancellationRequested() {

@@ -111,6 +111,9 @@ return req !== documentUpdatedReq;

});
const changeDoc = docUri ? documents.data.uriGet(docUri) : undefined;
const otherDocs = [...documents.data.values()].filter(doc => doc !== changeDoc);
const changeDoc = docUri ? context.documents.data.uriGet(docUri) : undefined;
const otherDocs = [...context.documents.data.values()].filter(doc => doc !== changeDoc);
if (changeDoc) {
yield shared.sleep(delay);
if (cancel.isCancellationRequested) {
return;
}
yield sendDocumentDiagnostics(changeDoc.uri, changeDoc.version, cancel);

@@ -120,34 +123,32 @@ }

yield shared.sleep(delay);
yield sendDocumentDiagnostics(doc.uri, doc.version, cancel);
if (cancel.isCancellationRequested) {
break;
}
yield sendDocumentDiagnostics(doc.uri, doc.version, cancel);
}
function sendDocumentDiagnostics(uri, version, cancel) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
if (cancel.isCancellationRequested)
return;
const project = (_a = (yield getProject(uri))) === null || _a === void 0 ? void 0 : _a.project;
if (!project)
return;
const languageService = project.getLanguageService();
const errors = yield languageService.doValidation(uri, cancel, result => {
connection.sendDiagnostics({ uri: uri, diagnostics: result.map(addVersion), version });
});
connection.sendDiagnostics({ uri: uri, diagnostics: errors.map(addVersion), version });
function addVersion(error) {
if (error.data === undefined) {
error.data = { version };
}
else if (typeof error.data === 'object') {
error.data.version = version;
}
return error;
}
});
});
}
function sendDocumentDiagnostics(uri, version, cancel) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const project = (_a = (yield getProjectAndTsConfig(uri))) === null || _a === void 0 ? void 0 : _a.project;
if (!project)
return;
const languageService = project.getLanguageService();
const errors = yield languageService.doValidation(uri, cancel, result => {
context.server.connection.sendDiagnostics({ uri: uri, diagnostics: result.map(addVersion), version });
});
context.server.connection.sendDiagnostics({ uri: uri, diagnostics: errors.map(addVersion), version });
function addVersion(error) {
if (error.data === undefined) {
error.data = { version };
}
else if (typeof error.data === 'object') {
error.data.version = version;
}
return error;
}
});
}
function getProject(uri) {
function getProjectAndTsConfig(uri) {
var _a;

@@ -160,5 +161,5 @@ return __awaiter(this, void 0, void 0, function* () {

const workspace = yield workspaces.get(rootUri);
const project = yield (workspace === null || workspace === void 0 ? void 0 : workspace.getProjectAndTsConfig(uri));
if (project) {
return project;
const projectAndTsConfig = yield (workspace === null || workspace === void 0 ? void 0 : workspace.getProjectAndTsConfig(uri));
if (projectAndTsConfig) {
return projectAndTsConfig;
}

@@ -165,0 +166,0 @@ }

{
"name": "@volar/language-server",
"version": "1.0.18",
"version": "1.0.19",
"main": "out/index.js",

@@ -20,5 +20,5 @@ "license": "MIT",

"dependencies": {
"@volar/language-core": "1.0.18",
"@volar/language-service": "1.0.18",
"@volar/shared": "1.0.18",
"@volar/language-core": "1.0.19",
"@volar/language-service": "1.0.19",
"@volar/shared": "1.0.19",
"request-light": "^0.6.0",

@@ -32,3 +32,3 @@ "typesafe-path": "^0.2.2",

},
"gitHead": "f102ee7bfc96792c63746a5dcb9742e3346d5cc7"
"gitHead": "02267fe83a5567b1cae7025e834cf084c8248546"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc