mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 12:19:20 +00:00
@@ -14,7 +14,7 @@ function isCancellationToken(value: any): value is vscode.CancellationToken {
|
|||||||
return value && typeof value.isCancellationRequested === 'boolean' && typeof value.onCancellationRequested === 'function';
|
return value && typeof value.isCancellationRequested === 'boolean' && typeof value.onCancellationRequested === 'function';
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RequestArgs {
|
export interface RequestArgs {
|
||||||
readonly file?: unknown;
|
readonly file?: unknown;
|
||||||
readonly $traceId?: unknown;
|
readonly $traceId?: unknown;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -777,8 +777,7 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider<
|
|||||||
dotAccessorContext = { range, text };
|
dotAccessorContext = { range, text };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
const isIncomplete = !!response.body.isIncomplete || !!(response.metadata as Record<string, unknown>)?.isIncomplete;
|
||||||
const isIncomplete = !!response.body.isIncomplete || (response.metadata as any)?.isIncomplete;
|
|
||||||
const entries = response.body.entries;
|
const entries = response.body.entries;
|
||||||
const metadata = response.metadata;
|
const metadata = response.metadata;
|
||||||
const defaultCommitCharacters = Object.freeze(response.body.defaultCommitCharacters);
|
const defaultCommitCharacters = Object.freeze(response.body.defaultCommitCharacters);
|
||||||
|
|||||||
@@ -105,11 +105,9 @@ function toTsTriggerReason(context: vscode.SignatureHelpContext): Proto.Signatur
|
|||||||
case vscode.SignatureHelpTriggerKind.TriggerCharacter:
|
case vscode.SignatureHelpTriggerKind.TriggerCharacter:
|
||||||
if (context.triggerCharacter) {
|
if (context.triggerCharacter) {
|
||||||
if (context.isRetrigger) {
|
if (context.isRetrigger) {
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
return { kind: 'retrigger', triggerCharacter: context.triggerCharacter as Proto.SignatureHelpRetriggerCharacter };
|
||||||
return { kind: 'retrigger', triggerCharacter: context.triggerCharacter as any };
|
|
||||||
} else {
|
} else {
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
return { kind: 'characterTyped', triggerCharacter: context.triggerCharacter as Proto.SignatureHelpTriggerCharacter };
|
||||||
return { kind: 'characterTyped', triggerCharacter: context.triggerCharacter as any };
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return { kind: 'invoked' };
|
return { kind: 'invoked' };
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ class SyncedBuffer {
|
|||||||
) { }
|
) { }
|
||||||
|
|
||||||
public open(): void {
|
public open(): void {
|
||||||
const args: Proto.OpenRequestArgs = {
|
const args: Proto.OpenRequestArgs & { plugins?: string[] } = {
|
||||||
file: this.filepath,
|
file: this.filepath,
|
||||||
fileContent: this.document.getText(),
|
fileContent: this.document.getText(),
|
||||||
projectRootPath: this.getProjectRootPath(this.document.uri),
|
projectRootPath: this.getProjectRootPath(this.document.uri),
|
||||||
@@ -183,8 +183,7 @@ class SyncedBuffer {
|
|||||||
.filter(x => x.languages.indexOf(this.document.languageId) >= 0);
|
.filter(x => x.languages.indexOf(this.document.languageId) >= 0);
|
||||||
|
|
||||||
if (tsPluginsForDocument.length) {
|
if (tsPluginsForDocument.length) {
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
args.plugins = tsPluginsForDocument.map(plugin => plugin.name);
|
||||||
(args as any).plugins = tsPluginsForDocument.map(plugin => plugin.name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.synchronizer.open(this.resource, args);
|
this.synchronizer.open(this.resource, args);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
import { Cancellation } from '@vscode/sync-api-common/lib/common/messageCancellation';
|
import { Cancellation } from '@vscode/sync-api-common/lib/common/messageCancellation';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
import { RequestArgs } from '../commands/tsserverRequests';
|
||||||
import { TypeScriptServiceConfiguration } from '../configuration/configuration';
|
import { TypeScriptServiceConfiguration } from '../configuration/configuration';
|
||||||
import { TelemetryReporter } from '../logging/telemetry';
|
import { TelemetryReporter } from '../logging/telemetry';
|
||||||
import Tracer from '../logging/tracer';
|
import Tracer from '../logging/tracer';
|
||||||
@@ -15,11 +16,11 @@ import { ServerResponse, ServerType, TypeScriptRequests } from '../typescriptSer
|
|||||||
import { Disposable } from '../utils/dispose';
|
import { Disposable } from '../utils/dispose';
|
||||||
import { isWebAndHasSharedArrayBuffers } from '../utils/platform';
|
import { isWebAndHasSharedArrayBuffers } from '../utils/platform';
|
||||||
import { OngoingRequestCanceller } from './cancellation';
|
import { OngoingRequestCanceller } from './cancellation';
|
||||||
|
import { NodeVersionManager } from './nodeManager';
|
||||||
import type * as Proto from './protocol/protocol';
|
import type * as Proto from './protocol/protocol';
|
||||||
import { EventName } from './protocol/protocol.const';
|
import { EventName } from './protocol/protocol.const';
|
||||||
import { TypeScriptVersionManager } from './versionManager';
|
import { TypeScriptVersionManager } from './versionManager';
|
||||||
import { TypeScriptVersion } from './versionProvider';
|
import { TypeScriptVersion } from './versionProvider';
|
||||||
import { NodeVersionManager } from './nodeManager';
|
|
||||||
|
|
||||||
export enum ExecutionTarget {
|
export enum ExecutionTarget {
|
||||||
Semantic,
|
Semantic,
|
||||||
@@ -283,8 +284,8 @@ export class SingleTsServer extends Disposable implements ITypeScriptServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._requestQueue.enqueue(requestInfo);
|
this._requestQueue.enqueue(requestInfo);
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
const traceId = (args as RequestArgs).$traceId;
|
||||||
if (args && typeof (args as any).$traceId === 'string') {
|
if (args && typeof traceId === 'string') {
|
||||||
const queueLength = this._requestQueue.length - 1;
|
const queueLength = this._requestQueue.length - 1;
|
||||||
const pendingResponses = this._pendingResponses.size;
|
const pendingResponses = this._pendingResponses.size;
|
||||||
const data: { command: string; queueLength: number; pendingResponses: number; queuedCommands?: string[]; pendingCommands?: string[] } = {
|
const data: { command: string; queueLength: number; pendingResponses: number; queuedCommands?: string[]; pendingCommands?: string[] } = {
|
||||||
@@ -299,8 +300,7 @@ export class SingleTsServer extends Disposable implements ITypeScriptServer {
|
|||||||
data.pendingCommands = this.getPendingCommands();
|
data.pendingCommands = this.getPendingCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
this._telemetryReporter.logTraceEvent('TSServer.enqueueRequest', traceId, JSON.stringify(data));
|
||||||
this._telemetryReporter.logTraceEvent('TSServer.enqueueRequest', (args as any).$traceId, JSON.stringify(data));
|
|
||||||
}
|
}
|
||||||
this.sendNextRequests();
|
this.sendNextRequests();
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ export function isWeb(): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isWebAndHasSharedArrayBuffers(): boolean {
|
export function isWebAndHasSharedArrayBuffers(): boolean {
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
return isWeb() && globalThis['crossOriginIsolated'];
|
||||||
return isWeb() && (globalThis as any)['crossOriginIsolated'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function supportsReadableByteStreams(): boolean {
|
export function supportsReadableByteStreams(): boolean {
|
||||||
|
|||||||
@@ -13,6 +13,31 @@ import { PathMapper, looksLikeNodeModules, mapUri } from './pathMapper';
|
|||||||
import { findArgument, hasArgument } from './util/args';
|
import { findArgument, hasArgument } from './util/args';
|
||||||
import { URI } from 'vscode-uri';
|
import { URI } from 'vscode-uri';
|
||||||
|
|
||||||
|
type TsModule = typeof ts;
|
||||||
|
|
||||||
|
interface TsInternals extends TsModule {
|
||||||
|
combinePaths(path: string, ...paths: (string | undefined)[]): string;
|
||||||
|
|
||||||
|
matchFiles(
|
||||||
|
path: string,
|
||||||
|
extensions: readonly string[] | undefined,
|
||||||
|
excludes: readonly string[] | undefined,
|
||||||
|
includes: readonly string[] | undefined,
|
||||||
|
useCaseSensitiveFileNames: boolean,
|
||||||
|
currentDirectory: string,
|
||||||
|
depth: number | undefined,
|
||||||
|
getFileSystemEntries: (path: string) => { files: readonly string[]; directories: readonly string[] },
|
||||||
|
realpath: (path: string) => string
|
||||||
|
): string[];
|
||||||
|
|
||||||
|
generateDjb2Hash(data: string): string;
|
||||||
|
|
||||||
|
memoize: <T>(callback: () => T) => () => T;
|
||||||
|
ensureTrailingDirectorySeparator: (path: string) => string;
|
||||||
|
getDirectoryPath: (path: string) => string;
|
||||||
|
directorySeparator: string;
|
||||||
|
}
|
||||||
|
|
||||||
type ServerHostWithImport = ts.server.ServerHost & { importPlugin(root: string, moduleName: string): Promise<ts.server.ModuleImportResult> };
|
type ServerHostWithImport = ts.server.ServerHost & { importPlugin(root: string, moduleName: string): Promise<ts.server.ModuleImportResult> };
|
||||||
|
|
||||||
function createServerHost(
|
function createServerHost(
|
||||||
@@ -29,33 +54,16 @@ function createServerHost(
|
|||||||
const fs = apiClient?.vscode.workspace.fileSystem;
|
const fs = apiClient?.vscode.workspace.fileSystem;
|
||||||
|
|
||||||
// Internals
|
// Internals
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
const combinePaths = (ts as TsInternals).combinePaths;
|
||||||
const combinePaths: (path: string, ...paths: (string | undefined)[]) => string = (ts as any).combinePaths;
|
|
||||||
const byteOrderMarkIndicator = '\uFEFF';
|
const byteOrderMarkIndicator = '\uFEFF';
|
||||||
const matchFiles: (
|
const matchFiles = (ts as TsInternals).matchFiles;
|
||||||
path: string,
|
const generateDjb2Hash = (ts as TsInternals).generateDjb2Hash;
|
||||||
extensions: readonly string[] | undefined,
|
|
||||||
excludes: readonly string[] | undefined,
|
|
||||||
includes: readonly string[] | undefined,
|
|
||||||
useCaseSensitiveFileNames: boolean,
|
|
||||||
currentDirectory: string,
|
|
||||||
depth: number | undefined,
|
|
||||||
getFileSystemEntries: (path: string) => { files: readonly string[]; directories: readonly string[] },
|
|
||||||
realpath: (path: string) => string
|
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
|
||||||
) => string[] = (ts as any).matchFiles;
|
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
|
||||||
const generateDjb2Hash = (ts as any).generateDjb2Hash;
|
|
||||||
|
|
||||||
// Legacy web
|
// Legacy web
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
const memoize = (ts as TsInternals).memoize;
|
||||||
const memoize: <T>(callback: () => T) => () => T = (ts as any).memoize;
|
const ensureTrailingDirectorySeparator = (ts as TsInternals).ensureTrailingDirectorySeparator;
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
const getDirectoryPath = (ts as TsInternals).getDirectoryPath;
|
||||||
const ensureTrailingDirectorySeparator: (path: string) => string = (ts as any).ensureTrailingDirectorySeparator;
|
const directorySeparator = (ts as TsInternals).directorySeparator;
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
|
||||||
const getDirectoryPath: (path: string) => string = (ts as any).getDirectoryPath;
|
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
|
||||||
const directorySeparator: string = (ts as any).directorySeparator;
|
|
||||||
const executingFilePath = findArgument(args, '--executingFilePath') || location + '';
|
const executingFilePath = findArgument(args, '--executingFilePath') || location + '';
|
||||||
const getExecutingDirectoryPath = memoize(() => memoize(() => ensureTrailingDirectorySeparator(getDirectoryPath(executingFilePath))));
|
const getExecutingDirectoryPath = memoize(() => memoize(() => ensureTrailingDirectorySeparator(getDirectoryPath(executingFilePath))));
|
||||||
const getWebPath = (path: string) => path.startsWith(directorySeparator) ? path.replace(directorySeparator, getExecutingDirectoryPath()) : undefined;
|
const getWebPath = (path: string) => path.startsWith(directorySeparator) ? path.replace(directorySeparator, getExecutingDirectoryPath()) : undefined;
|
||||||
|
|||||||
@@ -13,8 +13,13 @@ import { createSys } from './serverHost';
|
|||||||
import { findArgument, findArgumentStringArray, hasArgument, parseServerMode } from './util/args';
|
import { findArgument, findArgumentStringArray, hasArgument, parseServerMode } from './util/args';
|
||||||
import { StartSessionOptions, startWorkerSession } from './workerSession';
|
import { StartSessionOptions, startWorkerSession } from './workerSession';
|
||||||
|
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
type TsModule = typeof ts;
|
||||||
const setSys: (s: ts.System) => void = (ts as any).setSys;
|
|
||||||
|
interface TsInternals extends TsModule {
|
||||||
|
setSys(sys: ts.System): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const setSys: (s: ts.System) => void = (ts as TsInternals).setSys;
|
||||||
|
|
||||||
async function initializeSession(
|
async function initializeSession(
|
||||||
args: readonly string[],
|
args: readonly string[],
|
||||||
|
|||||||
@@ -22,6 +22,12 @@ export interface StartSessionOptions {
|
|||||||
readonly disableAutomaticTypingAcquisition: boolean;
|
readonly disableAutomaticTypingAcquisition: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ServerModule = typeof ts.server;
|
||||||
|
|
||||||
|
interface TsServerInternals extends ServerModule {
|
||||||
|
indent(str: string): string;
|
||||||
|
}
|
||||||
|
|
||||||
export function startWorkerSession(
|
export function startWorkerSession(
|
||||||
ts: typeof import('typescript/lib/tsserverlibrary'),
|
ts: typeof import('typescript/lib/tsserverlibrary'),
|
||||||
host: ts.server.ServerHost,
|
host: ts.server.ServerHost,
|
||||||
@@ -31,8 +37,7 @@ export function startWorkerSession(
|
|||||||
pathMapper: PathMapper,
|
pathMapper: PathMapper,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
): void {
|
): void {
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
const indent = (ts.server as TsServerInternals).indent;
|
||||||
const indent: (str: string) => string = (ts as any).server.indent;
|
|
||||||
|
|
||||||
const worker = new class WorkerSession extends ts.server.Session<{}> {
|
const worker = new class WorkerSession extends ts.server.Session<{}> {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user