mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 04:09:28 +00:00
Prefer namespace imports for 'vscode'
This commit is contained in:
@@ -3,18 +3,18 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { CancellationToken, CodeLens, CodeLensProvider, Event, EventEmitter, Position, Range, TextDocument, Uri } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import * as Proto from '../protocol';
|
||||
import { ITypeScriptServiceClient } from '../typescriptService';
|
||||
import { escapeRegExp } from '../utils/regexp';
|
||||
import * as typeConverters from '../utils/typeConverters';
|
||||
|
||||
|
||||
export class ReferencesCodeLens extends CodeLens {
|
||||
export class ReferencesCodeLens extends vscode.CodeLens {
|
||||
constructor(
|
||||
public document: Uri,
|
||||
public document: vscode.Uri,
|
||||
public file: string,
|
||||
range: Range
|
||||
range: vscode.Range
|
||||
) {
|
||||
super(range);
|
||||
}
|
||||
@@ -26,7 +26,7 @@ export class CachedNavTreeResponse {
|
||||
private document: string = '';
|
||||
|
||||
public execute(
|
||||
document: TextDocument,
|
||||
document: vscode.TextDocument,
|
||||
f: () => Promise<Proto.NavTreeResponse>
|
||||
) {
|
||||
if (this.matches(document)) {
|
||||
@@ -36,12 +36,12 @@ export class CachedNavTreeResponse {
|
||||
return this.update(document, f());
|
||||
}
|
||||
|
||||
private matches(document: TextDocument): boolean {
|
||||
private matches(document: vscode.TextDocument): boolean {
|
||||
return this.version === document.version && this.document === document.uri.toString();
|
||||
}
|
||||
|
||||
private update(
|
||||
document: TextDocument,
|
||||
document: vscode.TextDocument,
|
||||
response: Promise<Proto.NavTreeResponse>
|
||||
): Promise<Proto.NavTreeResponse> {
|
||||
this.response = response;
|
||||
@@ -51,19 +51,19 @@ export class CachedNavTreeResponse {
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class TypeScriptBaseCodeLensProvider implements CodeLensProvider {
|
||||
private onDidChangeCodeLensesEmitter = new EventEmitter<void>();
|
||||
export abstract class TypeScriptBaseCodeLensProvider implements vscode.CodeLensProvider {
|
||||
private onDidChangeCodeLensesEmitter = new vscode.EventEmitter<void>();
|
||||
|
||||
public constructor(
|
||||
protected client: ITypeScriptServiceClient,
|
||||
private cachedResponse: CachedNavTreeResponse
|
||||
) { }
|
||||
|
||||
public get onDidChangeCodeLenses(): Event<void> {
|
||||
public get onDidChangeCodeLenses(): vscode.Event<void> {
|
||||
return this.onDidChangeCodeLensesEmitter.event;
|
||||
}
|
||||
|
||||
async provideCodeLenses(document: TextDocument, token: CancellationToken): Promise<CodeLens[]> {
|
||||
async provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): Promise<vscode.CodeLens[]> {
|
||||
const filepath = this.client.toPath(document.uri);
|
||||
if (!filepath) {
|
||||
return [];
|
||||
@@ -76,7 +76,7 @@ export abstract class TypeScriptBaseCodeLensProvider implements CodeLensProvider
|
||||
}
|
||||
|
||||
const tree = response.body;
|
||||
const referenceableSpans: Range[] = [];
|
||||
const referenceableSpans: vscode.Range[] = [];
|
||||
if (tree && tree.childItems) {
|
||||
tree.childItems.forEach(item => this.walkNavTree(document, item, null, referenceableSpans));
|
||||
}
|
||||
@@ -87,16 +87,16 @@ export abstract class TypeScriptBaseCodeLensProvider implements CodeLensProvider
|
||||
}
|
||||
|
||||
protected abstract extractSymbol(
|
||||
document: TextDocument,
|
||||
document: vscode.TextDocument,
|
||||
item: Proto.NavigationTree,
|
||||
parent: Proto.NavigationTree | null
|
||||
): Range | null;
|
||||
): vscode.Range | null;
|
||||
|
||||
private walkNavTree(
|
||||
document: TextDocument,
|
||||
document: vscode.TextDocument,
|
||||
item: Proto.NavigationTree,
|
||||
parent: Proto.NavigationTree | null,
|
||||
results: Range[]
|
||||
results: vscode.Range[]
|
||||
): void {
|
||||
if (!item) {
|
||||
return;
|
||||
@@ -109,7 +109,7 @@ export abstract class TypeScriptBaseCodeLensProvider implements CodeLensProvider
|
||||
|
||||
(item.childItems || []).forEach(child => this.walkNavTree(document, child, item, results));
|
||||
}
|
||||
protected getSymbolRange(document: TextDocument, item: Proto.NavigationTree): Range | null {
|
||||
protected getSymbolRange(document: vscode.TextDocument, item: Proto.NavigationTree): vscode.Range | null {
|
||||
if (!item) {
|
||||
return null;
|
||||
}
|
||||
@@ -131,8 +131,8 @@ export abstract class TypeScriptBaseCodeLensProvider implements CodeLensProvider
|
||||
const identifierMatch = new RegExp(`^(.*?(\\b|\\W))${escapeRegExp(item.text || '')}(\\b|\\W)`, 'gm');
|
||||
const match = identifierMatch.exec(text);
|
||||
const prefixLength = match ? match.index + match[1].length : 0;
|
||||
const startOffset = document.offsetAt(new Position(range.start.line, range.start.character)) + prefixLength;
|
||||
return new Range(
|
||||
const startOffset = document.offsetAt(new vscode.Position(range.start.line, range.start.character)) + prefixLength;
|
||||
return new vscode.Range(
|
||||
document.positionAt(startOffset),
|
||||
document.positionAt(startOffset + item.text.length));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as fs from 'fs';
|
||||
import { CancellationTokenSource, EventEmitter, TextDocument, TextDocumentChangeEvent, TextDocumentContentChangeEvent, Uri, workspace } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import * as Proto from '../protocol';
|
||||
import { ITypeScriptServiceClient } from '../typescriptService';
|
||||
import API from '../utils/api';
|
||||
@@ -32,7 +32,7 @@ function mode2ScriptKind(mode: string): 'TS' | 'TSX' | 'JS' | 'JSX' | undefined
|
||||
class SyncedBuffer {
|
||||
|
||||
constructor(
|
||||
private readonly document: TextDocument,
|
||||
private readonly document: vscode.TextDocument,
|
||||
public readonly filepath: string,
|
||||
private readonly client: ITypeScriptServiceClient
|
||||
) { }
|
||||
@@ -66,7 +66,7 @@ class SyncedBuffer {
|
||||
this.client.execute('open', args, false);
|
||||
}
|
||||
|
||||
public get resource(): Uri {
|
||||
public get resource(): vscode.Uri {
|
||||
return this.document.uri;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class SyncedBuffer {
|
||||
this.client.execute('close', args, false);
|
||||
}
|
||||
|
||||
public onContentChanged(events: TextDocumentContentChangeEvent[]): void {
|
||||
public onContentChanged(events: vscode.TextDocumentContentChangeEvent[]): void {
|
||||
for (const { range, text } of events) {
|
||||
const args: Proto.ChangeRequestArgs = {
|
||||
insertString: text,
|
||||
@@ -108,7 +108,7 @@ class SyncedBuffer {
|
||||
class SyncedBufferMap extends ResourceMap<SyncedBuffer> {
|
||||
|
||||
public getForPath(filePath: string): SyncedBuffer | undefined {
|
||||
return this.get(Uri.file(filePath));
|
||||
return this.get(vscode.Uri.file(filePath));
|
||||
}
|
||||
|
||||
public get allBuffers(): Iterable<SyncedBuffer> {
|
||||
@@ -131,7 +131,7 @@ class GetErrRequest {
|
||||
files: string[],
|
||||
onDone: () => void
|
||||
) {
|
||||
const token = new CancellationTokenSource();
|
||||
const token = new vscode.CancellationTokenSource();
|
||||
return new GetErrRequest(client, files, token, onDone);
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ class GetErrRequest {
|
||||
private constructor(
|
||||
client: ITypeScriptServiceClient,
|
||||
public readonly files: string[],
|
||||
private readonly _token: CancellationTokenSource,
|
||||
private readonly _token: vscode.CancellationTokenSource,
|
||||
onDone: () => void
|
||||
) {
|
||||
const args: Proto.GeterrRequestArgs = {
|
||||
@@ -191,15 +191,15 @@ export default class BufferSyncSupport extends Disposable {
|
||||
|
||||
this.diagnosticDelayer = new Delayer<any>(300);
|
||||
|
||||
const pathNormalizer = (path: Uri) => this.client.normalizedPath(path);
|
||||
const pathNormalizer = (path: vscode.Uri) => this.client.normalizedPath(path);
|
||||
this.syncedBuffers = new SyncedBufferMap(pathNormalizer);
|
||||
this.pendingDiagnostics = new PendingDiagnostics(pathNormalizer);
|
||||
|
||||
this.updateConfiguration();
|
||||
workspace.onDidChangeConfiguration(this.updateConfiguration, this, this._disposables);
|
||||
vscode.workspace.onDidChangeConfiguration(this.updateConfiguration, this, this._disposables);
|
||||
}
|
||||
|
||||
private readonly _onDelete = this._register(new EventEmitter<Uri>());
|
||||
private readonly _onDelete = this._register(new vscode.EventEmitter<vscode.Uri>());
|
||||
public readonly onDelete = this._onDelete.event;
|
||||
|
||||
public listen(): void {
|
||||
@@ -207,22 +207,22 @@ export default class BufferSyncSupport extends Disposable {
|
||||
return;
|
||||
}
|
||||
this.listening = true;
|
||||
workspace.onDidOpenTextDocument(this.openTextDocument, this, this._disposables);
|
||||
workspace.onDidCloseTextDocument(this.onDidCloseTextDocument, this, this._disposables);
|
||||
workspace.onDidChangeTextDocument(this.onDidChangeTextDocument, this, this._disposables);
|
||||
workspace.textDocuments.forEach(this.openTextDocument, this);
|
||||
vscode.workspace.onDidOpenTextDocument(this.openTextDocument, this, this._disposables);
|
||||
vscode.workspace.onDidCloseTextDocument(this.onDidCloseTextDocument, this, this._disposables);
|
||||
vscode.workspace.onDidChangeTextDocument(this.onDidChangeTextDocument, this, this._disposables);
|
||||
vscode.workspace.textDocuments.forEach(this.openTextDocument, this);
|
||||
}
|
||||
|
||||
public handles(resource: Uri): boolean {
|
||||
public handles(resource: vscode.Uri): boolean {
|
||||
return this.syncedBuffers.has(resource);
|
||||
}
|
||||
|
||||
public toResource(filePath: string): Uri {
|
||||
public toResource(filePath: string): vscode.Uri {
|
||||
const buffer = this.syncedBuffers.getForPath(filePath);
|
||||
if (buffer) {
|
||||
return buffer.resource;
|
||||
}
|
||||
return Uri.file(filePath);
|
||||
return vscode.Uri.file(filePath);
|
||||
}
|
||||
|
||||
public reOpenDocuments(): void {
|
||||
@@ -231,7 +231,7 @@ export default class BufferSyncSupport extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
public openTextDocument(document: TextDocument): void {
|
||||
public openTextDocument(document: vscode.TextDocument): void {
|
||||
if (!this.modeIds.has(document.languageId)) {
|
||||
return;
|
||||
}
|
||||
@@ -251,7 +251,7 @@ export default class BufferSyncSupport extends Disposable {
|
||||
this.requestDiagnostic(syncedBuffer);
|
||||
}
|
||||
|
||||
public closeResource(resource: Uri): void {
|
||||
public closeResource(resource: vscode.Uri): void {
|
||||
const syncedBuffer = this.syncedBuffers.get(resource);
|
||||
if (!syncedBuffer) {
|
||||
return;
|
||||
@@ -264,11 +264,11 @@ export default class BufferSyncSupport extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
private onDidCloseTextDocument(document: TextDocument): void {
|
||||
private onDidCloseTextDocument(document: vscode.TextDocument): void {
|
||||
this.closeResource(document.uri);
|
||||
}
|
||||
|
||||
private onDidChangeTextDocument(e: TextDocumentChangeEvent): void {
|
||||
private onDidChangeTextDocument(e: vscode.TextDocumentChangeEvent): void {
|
||||
const syncedBuffer = this.syncedBuffers.get(e.document.uri);
|
||||
if (!syncedBuffer) {
|
||||
return;
|
||||
@@ -294,7 +294,7 @@ export default class BufferSyncSupport extends Disposable {
|
||||
this.triggerDiagnostics();
|
||||
}
|
||||
|
||||
public getErr(resources: Uri[]): any {
|
||||
public getErr(resources: vscode.Uri[]): any {
|
||||
const handledResources = resources.filter(resource => this.handles(resource));
|
||||
if (!handledResources.length) {
|
||||
return;
|
||||
@@ -325,7 +325,7 @@ export default class BufferSyncSupport extends Disposable {
|
||||
return true;
|
||||
}
|
||||
|
||||
public hasPendingDiagnostics(resource: Uri): boolean {
|
||||
public hasPendingDiagnostics(resource: vscode.Uri): boolean {
|
||||
return this.pendingDiagnostics.has(resource);
|
||||
}
|
||||
|
||||
@@ -361,8 +361,8 @@ export default class BufferSyncSupport extends Disposable {
|
||||
}
|
||||
|
||||
private updateConfiguration() {
|
||||
const jsConfig = workspace.getConfiguration('javascript', null);
|
||||
const tsConfig = workspace.getConfiguration('typescript', null);
|
||||
const jsConfig = vscode.workspace.getConfiguration('javascript', null);
|
||||
const tsConfig = vscode.workspace.getConfiguration('typescript', null);
|
||||
|
||||
this._validateJavaScript = jsConfig.get<boolean>('validate.enable', true);
|
||||
this._validateTypeScript = tsConfig.get<boolean>('validate.enable', true);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { CancellationToken, Location, Position, TextDocument } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import * as Proto from '../protocol';
|
||||
import { ITypeScriptServiceClient } from '../typescriptService';
|
||||
import * as typeConverters from '../utils/typeConverters';
|
||||
@@ -16,10 +16,10 @@ export default class TypeScriptDefinitionProviderBase {
|
||||
|
||||
protected async getSymbolLocations(
|
||||
definitionType: 'definition' | 'implementation' | 'typeDefinition',
|
||||
document: TextDocument,
|
||||
position: Position,
|
||||
token: CancellationToken | boolean
|
||||
): Promise<Location[] | undefined> {
|
||||
document: vscode.TextDocument,
|
||||
position: vscode.Position,
|
||||
token: vscode.CancellationToken | boolean
|
||||
): Promise<vscode.Location[] | undefined> {
|
||||
const filepath = this.client.toPath(document.uri);
|
||||
if (!filepath) {
|
||||
return undefined;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { CancellationToken, Disposable, FormattingOptions, TextDocument, window, workspace as Workspace, workspace, WorkspaceConfiguration } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import * as Proto from '../protocol';
|
||||
import { ITypeScriptServiceClient } from '../typescriptService';
|
||||
import API from '../utils/api';
|
||||
@@ -35,13 +35,13 @@ function areFileConfigurationsEqual(a: FileConfiguration, b: FileConfiguration):
|
||||
}
|
||||
|
||||
export default class FileConfigurationManager {
|
||||
private onDidCloseTextDocumentSub: Disposable | undefined;
|
||||
private onDidCloseTextDocumentSub: vscode.Disposable | undefined;
|
||||
private formatOptions = new ResourceMap<FileConfiguration>();
|
||||
|
||||
public constructor(
|
||||
private readonly client: ITypeScriptServiceClient
|
||||
) {
|
||||
this.onDidCloseTextDocumentSub = Workspace.onDidCloseTextDocument((textDocument) => {
|
||||
this.onDidCloseTextDocumentSub = vscode.workspace.onDidCloseTextDocument((textDocument) => {
|
||||
// When a document gets closed delete the cached formatting options.
|
||||
// This is necessary since the tsserver now closed a project when its
|
||||
// last file in it closes which drops the stored formatting options
|
||||
@@ -58,23 +58,23 @@ export default class FileConfigurationManager {
|
||||
}
|
||||
|
||||
public async ensureConfigurationForDocument(
|
||||
document: TextDocument,
|
||||
token: CancellationToken | undefined
|
||||
document: vscode.TextDocument,
|
||||
token: vscode.CancellationToken | undefined
|
||||
): Promise<void> {
|
||||
const editor = window.visibleTextEditors.find(editor => editor.document.fileName === document.fileName);
|
||||
const editor = vscode.window.visibleTextEditors.find(editor => editor.document.fileName === document.fileName);
|
||||
if (editor) {
|
||||
const formattingOptions = {
|
||||
tabSize: editor.options.tabSize,
|
||||
insertSpaces: editor.options.insertSpaces
|
||||
} as FormattingOptions;
|
||||
} as vscode.FormattingOptions;
|
||||
return this.ensureConfigurationOptions(document, formattingOptions, token);
|
||||
}
|
||||
}
|
||||
|
||||
public async ensureConfigurationOptions(
|
||||
document: TextDocument,
|
||||
options: FormattingOptions,
|
||||
token: CancellationToken | undefined
|
||||
document: vscode.TextDocument,
|
||||
options: vscode.FormattingOptions,
|
||||
token: vscode.CancellationToken | undefined
|
||||
): Promise<void> {
|
||||
const file = this.client.toPath(document.uri);
|
||||
if (!file) {
|
||||
@@ -100,8 +100,8 @@ export default class FileConfigurationManager {
|
||||
}
|
||||
|
||||
private getFileOptions(
|
||||
document: TextDocument,
|
||||
options: FormattingOptions
|
||||
document: vscode.TextDocument,
|
||||
options: vscode.FormattingOptions
|
||||
): FileConfiguration {
|
||||
return {
|
||||
formatOptions: this.getFormatOptions(document, options),
|
||||
@@ -110,10 +110,10 @@ export default class FileConfigurationManager {
|
||||
}
|
||||
|
||||
private getFormatOptions(
|
||||
document: TextDocument,
|
||||
options: FormattingOptions
|
||||
document: vscode.TextDocument,
|
||||
options: vscode.FormattingOptions
|
||||
): Proto.FormatCodeSettings {
|
||||
const config = workspace.getConfiguration(
|
||||
const config = vscode.workspace.getConfiguration(
|
||||
isTypeScriptDocument(document) ? 'typescript.format' : 'javascript.format',
|
||||
document.uri);
|
||||
|
||||
@@ -141,12 +141,12 @@ export default class FileConfigurationManager {
|
||||
};
|
||||
}
|
||||
|
||||
private getPreferences(document: TextDocument): Proto.UserPreferences {
|
||||
private getPreferences(document: vscode.TextDocument): Proto.UserPreferences {
|
||||
if (!this.client.apiVersion.gte(API.v290)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const preferences = workspace.getConfiguration(
|
||||
const preferences = vscode.workspace.getConfiguration(
|
||||
isTypeScriptDocument(document) ? 'typescript.preferences' : 'javascript.preferences',
|
||||
document.uri);
|
||||
|
||||
@@ -158,7 +158,7 @@ export default class FileConfigurationManager {
|
||||
}
|
||||
}
|
||||
|
||||
function getQuoteStylePreference(config: WorkspaceConfiguration) {
|
||||
function getQuoteStylePreference(config: vscode.WorkspaceConfiguration) {
|
||||
switch (config.get<string>('quoteStyle')) {
|
||||
case 'single': return 'single';
|
||||
case 'double': return 'double';
|
||||
@@ -166,7 +166,7 @@ function getQuoteStylePreference(config: WorkspaceConfiguration) {
|
||||
}
|
||||
}
|
||||
|
||||
function getImportModuleSpecifierPreference(config: WorkspaceConfiguration) {
|
||||
function getImportModuleSpecifierPreference(config: vscode.WorkspaceConfiguration) {
|
||||
switch (config.get<string>('importModuleSpecifier')) {
|
||||
case 'relative': return 'relative';
|
||||
case 'non-relative': return 'non-relative';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { CancellationToken, CompletionItem, CompletionItemKind, CompletionItemProvider, Disposable, DocumentSelector, languages, Position, Range, SnippetString, TextDocument, TextEditor, Uri, window } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import * as Proto from '../protocol';
|
||||
import { ITypeScriptServiceClient } from '../typescriptService';
|
||||
@@ -14,12 +14,12 @@ import * as typeConverters from '../utils/typeConverters';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
class JsDocCompletionItem extends CompletionItem {
|
||||
class JsDocCompletionItem extends vscode.CompletionItem {
|
||||
constructor(
|
||||
document: TextDocument,
|
||||
position: Position
|
||||
document: vscode.TextDocument,
|
||||
position: vscode.Position
|
||||
) {
|
||||
super('/** */', CompletionItemKind.Snippet);
|
||||
super('/** */', vscode.CompletionItemKind.Snippet);
|
||||
this.detail = localize('typescript.jsDocCompletionItem.documentation', 'JSDoc comment');
|
||||
this.insertText = '';
|
||||
this.sortText = '\0';
|
||||
@@ -28,7 +28,7 @@ class JsDocCompletionItem extends CompletionItem {
|
||||
const prefix = line.slice(0, position.character).match(/\/\**\s*$/);
|
||||
const suffix = line.slice(position.character).match(/^\s*\**\//);
|
||||
const start = position.translate(0, prefix ? -prefix[0].length : 0);
|
||||
this.range = new Range(
|
||||
this.range = new vscode.Range(
|
||||
start,
|
||||
position.translate(0, suffix ? suffix[0].length : 0));
|
||||
|
||||
@@ -40,7 +40,7 @@ class JsDocCompletionItem extends CompletionItem {
|
||||
}
|
||||
}
|
||||
|
||||
class JsDocCompletionProvider implements CompletionItemProvider {
|
||||
class JsDocCompletionProvider implements vscode.CompletionItemProvider {
|
||||
|
||||
constructor(
|
||||
private readonly client: ITypeScriptServiceClient,
|
||||
@@ -50,10 +50,10 @@ class JsDocCompletionProvider implements CompletionItemProvider {
|
||||
}
|
||||
|
||||
public async provideCompletionItems(
|
||||
document: TextDocument,
|
||||
position: Position,
|
||||
token: CancellationToken
|
||||
): Promise<CompletionItem[]> {
|
||||
document: vscode.TextDocument,
|
||||
position: vscode.Position,
|
||||
token: vscode.CancellationToken
|
||||
): Promise<vscode.CompletionItem[]> {
|
||||
const file = this.client.toPath(document.uri);
|
||||
if (!file) {
|
||||
return [];
|
||||
@@ -72,8 +72,8 @@ class JsDocCompletionProvider implements CompletionItemProvider {
|
||||
|
||||
private async isCommentableLocation(
|
||||
file: string,
|
||||
position: Position,
|
||||
token: CancellationToken
|
||||
position: vscode.Position,
|
||||
token: vscode.CancellationToken
|
||||
): Promise<boolean> {
|
||||
const args: Proto.FileRequestArgs = {
|
||||
file
|
||||
@@ -104,7 +104,7 @@ class JsDocCompletionProvider implements CompletionItemProvider {
|
||||
return matchesPosition(body);
|
||||
}
|
||||
|
||||
private isValidCursorPosition(document: TextDocument, position: Position): boolean {
|
||||
private isValidCursorPosition(document: vscode.TextDocument, position: vscode.Position): boolean {
|
||||
// Only show the JSdoc completion when the everything before the cursor is whitespace
|
||||
// or could be the opening of a comment
|
||||
const line = document.lineAt(position.line).text;
|
||||
@@ -112,7 +112,7 @@ class JsDocCompletionProvider implements CompletionItemProvider {
|
||||
return prefix.match(/^\s*$|\/\*\*\s*$|^\s*\/\*\*+\s*$/) !== null;
|
||||
}
|
||||
|
||||
public resolveCompletionItem(item: CompletionItem, _token: CancellationToken) {
|
||||
public resolveCompletionItem(item: vscode.CompletionItem, _token: vscode.CancellationToken) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -129,13 +129,13 @@ class TryCompleteJsDocCommand implements Command {
|
||||
* Try to insert a jsdoc comment, using a template provide by typescript
|
||||
* if possible, otherwise falling back to a default comment format.
|
||||
*/
|
||||
public async execute(resource: Uri, start: Position): Promise<boolean> {
|
||||
public async execute(resource: vscode.Uri, start: vscode.Position): Promise<boolean> {
|
||||
const file = this.client.toPath(resource);
|
||||
if (!file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const editor = window.activeTextEditor;
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
if (!editor || editor.document.uri.fsPath !== resource.fsPath) {
|
||||
return false;
|
||||
}
|
||||
@@ -148,7 +148,7 @@ class TryCompleteJsDocCommand implements Command {
|
||||
return this.tryInsertDefaultDoc(editor, start);
|
||||
}
|
||||
|
||||
private async tryInsertJsDocFromTemplate(editor: TextEditor, file: string, position: Position): Promise<boolean> {
|
||||
private async tryInsertJsDocFromTemplate(editor: vscode.TextEditor, file: string, position: vscode.Position): Promise<boolean> {
|
||||
const snippet = await TryCompleteJsDocCommand.getSnippetTemplate(this.client, file, position);
|
||||
if (!snippet) {
|
||||
return false;
|
||||
@@ -159,7 +159,7 @@ class TryCompleteJsDocCommand implements Command {
|
||||
{ undoStopBefore: false, undoStopAfter: true });
|
||||
}
|
||||
|
||||
public static getSnippetTemplate(client: ITypeScriptServiceClient, file: string, position: Position): Promise<SnippetString | undefined> {
|
||||
public static getSnippetTemplate(client: ITypeScriptServiceClient, file: string, position: vscode.Position): Promise<vscode.SnippetString | undefined> {
|
||||
const args = typeConverters.Position.toFileLocationRequestArgs(file, position);
|
||||
return Promise.race([
|
||||
client.execute('docCommentTemplate', args),
|
||||
@@ -181,14 +181,14 @@ class TryCompleteJsDocCommand implements Command {
|
||||
/**
|
||||
* Insert the default JSDoc
|
||||
*/
|
||||
private tryInsertDefaultDoc(editor: TextEditor, position: Position): Thenable<boolean> {
|
||||
const snippet = new SnippetString(`/**\n * $0\n */`);
|
||||
private tryInsertDefaultDoc(editor: vscode.TextEditor, position: vscode.Position): Thenable<boolean> {
|
||||
const snippet = new vscode.SnippetString(`/**\n * $0\n */`);
|
||||
return editor.insertSnippet(snippet, position, { undoStopBefore: false, undoStopAfter: true });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function templateToSnippet(template: string): SnippetString {
|
||||
export function templateToSnippet(template: string): vscode.SnippetString {
|
||||
// TODO: use append placeholder
|
||||
let snippetIndex = 1;
|
||||
template = template.replace(/\$/g, '\\$');
|
||||
@@ -204,16 +204,16 @@ export function templateToSnippet(template: string): SnippetString {
|
||||
out += post + ` \${${snippetIndex++}}`;
|
||||
return out;
|
||||
});
|
||||
return new SnippetString(template);
|
||||
return new vscode.SnippetString(template);
|
||||
}
|
||||
|
||||
export function register(
|
||||
selector: DocumentSelector,
|
||||
selector: vscode.DocumentSelector,
|
||||
client: ITypeScriptServiceClient,
|
||||
commandManager: CommandManager
|
||||
): Disposable {
|
||||
): vscode.Disposable {
|
||||
return new ConfigurationDependentRegistration('jsDocCompletion', 'enabled', () => {
|
||||
return languages.registerCompletionItemProvider(selector,
|
||||
return vscode.languages.registerCompletionItemProvider(selector,
|
||||
new JsDocCompletionProvider(client, commandManager),
|
||||
'*');
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* https://github.com/Microsoft/TypeScript-Sublime-Plugin/blob/master/TypeScript%20Indent.tmPreferences
|
||||
* ------------------------------------------------------------------------------------------ */
|
||||
|
||||
import { Diagnostic, DiagnosticRelatedInformation, DiagnosticSeverity, DiagnosticTag, Memento, Range, Uri, workspace } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import { DiagnosticKind } from './features/diagnostics';
|
||||
import FileConfigurationManager from './features/fileConfigurationManager';
|
||||
import { register as registerUpdatePathsOnRename } from './features/updatePathsOnRename';
|
||||
@@ -48,7 +48,7 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||
|
||||
constructor(
|
||||
descriptions: LanguageDescription[],
|
||||
workspaceState: Memento,
|
||||
workspaceState: vscode.Memento,
|
||||
plugins: TypeScriptServerPlugin[],
|
||||
private readonly commandManager: CommandManager,
|
||||
logDirectoryProvider: LogDirectoryProvider
|
||||
@@ -63,7 +63,7 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||
this.triggerAllDiagnostics();
|
||||
}, 1500);
|
||||
};
|
||||
const configFileWatcher = workspace.createFileSystemWatcher('**/[tj]sconfig.json');
|
||||
const configFileWatcher = vscode.workspace.createFileSystemWatcher('**/[tj]sconfig.json');
|
||||
this._register(configFileWatcher);
|
||||
configFileWatcher.onDidCreate(handleProjectCreateOrDelete, this, this._disposables);
|
||||
configFileWatcher.onDidDelete(handleProjectCreateOrDelete, this, this._disposables);
|
||||
@@ -133,7 +133,7 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||
this.triggerAllDiagnostics();
|
||||
});
|
||||
|
||||
workspace.onDidChangeConfiguration(this.configurationChanged, this, this._disposables);
|
||||
vscode.workspace.onDidChangeConfiguration(this.configurationChanged, this, this._disposables);
|
||||
this.configurationChanged();
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||
this.triggerAllDiagnostics();
|
||||
}
|
||||
|
||||
public async handles(resource: Uri): Promise<boolean> {
|
||||
public async handles(resource: vscode.Uri): Promise<boolean> {
|
||||
const provider = await this.findLanguage(resource);
|
||||
if (provider) {
|
||||
return true;
|
||||
@@ -163,14 +163,14 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||
}
|
||||
|
||||
private configurationChanged(): void {
|
||||
const typescriptConfig = workspace.getConfiguration('typescript');
|
||||
const typescriptConfig = vscode.workspace.getConfiguration('typescript');
|
||||
|
||||
this.reportStyleCheckAsWarnings = typescriptConfig.get('reportStyleChecksAsWarnings', true);
|
||||
}
|
||||
|
||||
private async findLanguage(resource: Uri): Promise<LanguageProvider | undefined> {
|
||||
private async findLanguage(resource: vscode.Uri): Promise<LanguageProvider | undefined> {
|
||||
try {
|
||||
const doc = await workspace.openTextDocument(resource);
|
||||
const doc = await vscode.workspace.openTextDocument(resource);
|
||||
return this.languages.find(language => language.handles(resource, doc));
|
||||
} catch {
|
||||
return undefined;
|
||||
@@ -189,7 +189,7 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||
this.client.bufferSyncSupport.requestAllDiagnostics();
|
||||
|
||||
// See https://github.com/Microsoft/TypeScript/issues/5530
|
||||
workspace.saveAll(false).then(() => {
|
||||
vscode.workspace.saveAll(false).then(() => {
|
||||
for (const language of this.languagePerId.values()) {
|
||||
language.reInitialize();
|
||||
}
|
||||
@@ -198,7 +198,7 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||
|
||||
private async diagnosticsReceived(
|
||||
kind: DiagnosticKind,
|
||||
resource: Uri,
|
||||
resource: vscode.Uri,
|
||||
diagnostics: Proto.Diagnostic[]
|
||||
): Promise<void> {
|
||||
const language = await this.findLanguage(resource);
|
||||
@@ -224,10 +224,10 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||
if (body.diagnostics.length === 0) {
|
||||
language.configFileDiagnosticsReceived(this.client.toResource(body.configFile), []);
|
||||
} else if (body.diagnostics.length >= 1) {
|
||||
workspace.openTextDocument(Uri.file(body.configFile)).then((document) => {
|
||||
vscode.workspace.openTextDocument(vscode.Uri.file(body.configFile)).then((document) => {
|
||||
let curly: [number, number, number] | undefined = undefined;
|
||||
let nonCurly: [number, number, number] | undefined = undefined;
|
||||
let diagnostic: Diagnostic;
|
||||
let diagnostic: vscode.Diagnostic;
|
||||
for (let index = 0; index < document.lineCount; index++) {
|
||||
const line = document.lineAt(index);
|
||||
const text = line.text;
|
||||
@@ -246,16 +246,16 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||
}
|
||||
const match = curly || nonCurly;
|
||||
if (match) {
|
||||
diagnostic = new Diagnostic(new Range(match[0], match[1], match[0], match[2]), body.diagnostics[0].text);
|
||||
diagnostic = new vscode.Diagnostic(new vscode.Range(match[0], match[1], match[0], match[2]), body.diagnostics[0].text);
|
||||
} else {
|
||||
diagnostic = new Diagnostic(new Range(0, 0, 0, 0), body.diagnostics[0].text);
|
||||
diagnostic = new vscode.Diagnostic(new vscode.Range(0, 0, 0, 0), body.diagnostics[0].text);
|
||||
}
|
||||
if (diagnostic) {
|
||||
diagnostic.source = language.diagnosticSource;
|
||||
language.configFileDiagnosticsReceived(this.client.toResource(body.configFile), [diagnostic]);
|
||||
}
|
||||
}, _error => {
|
||||
language.configFileDiagnosticsReceived(this.client.toResource(body.configFile), [new Diagnostic(new Range(0, 0, 0, 0), body.diagnostics[0].text)]);
|
||||
language.configFileDiagnosticsReceived(this.client.toResource(body.configFile), [new vscode.Diagnostic(new vscode.Range(0, 0, 0, 0), body.diagnostics[0].text)]);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -264,14 +264,14 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||
private createMarkerDatas(
|
||||
diagnostics: Proto.Diagnostic[],
|
||||
source: string
|
||||
): (Diagnostic & { reportUnnecessary: any })[] {
|
||||
): (vscode.Diagnostic & { reportUnnecessary: any })[] {
|
||||
return diagnostics.map(tsDiag => this.tsDiagnosticToVsDiagnostic(tsDiag, source));
|
||||
}
|
||||
|
||||
private tsDiagnosticToVsDiagnostic(diagnostic: Proto.Diagnostic, source: string): Diagnostic & { reportUnnecessary: any } {
|
||||
private tsDiagnosticToVsDiagnostic(diagnostic: Proto.Diagnostic, source: string): vscode.Diagnostic & { reportUnnecessary: any } {
|
||||
const { start, end, text } = diagnostic;
|
||||
const range = new Range(typeConverters.Position.fromLocation(start), typeConverters.Position.fromLocation(end));
|
||||
const converted = new Diagnostic(range, text);
|
||||
const range = new vscode.Range(typeConverters.Position.fromLocation(start), typeConverters.Position.fromLocation(end));
|
||||
const converted = new vscode.Diagnostic(range, text);
|
||||
converted.severity = this.getDiagnosticSeverity(diagnostic);
|
||||
converted.source = diagnostic.source || source;
|
||||
if (diagnostic.code) {
|
||||
@@ -284,36 +284,36 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||
if (!span) {
|
||||
return undefined;
|
||||
}
|
||||
return new DiagnosticRelatedInformation(typeConverters.Location.fromTextSpan(this.client.toResource(span.file), span), info.message);
|
||||
}).filter((x: any) => !!x) as DiagnosticRelatedInformation[];
|
||||
return new vscode.DiagnosticRelatedInformation(typeConverters.Location.fromTextSpan(this.client.toResource(span.file), span), info.message);
|
||||
}).filter((x: any) => !!x) as vscode.DiagnosticRelatedInformation[];
|
||||
}
|
||||
if (diagnostic.reportsUnnecessary) {
|
||||
converted.tags = [DiagnosticTag.Unnecessary];
|
||||
converted.tags = [vscode.DiagnosticTag.Unnecessary];
|
||||
}
|
||||
(converted as Diagnostic & { reportUnnecessary: any }).reportUnnecessary = diagnostic.reportsUnnecessary;
|
||||
return converted as Diagnostic & { reportUnnecessary: any };
|
||||
(converted as vscode.Diagnostic & { reportUnnecessary: any }).reportUnnecessary = diagnostic.reportsUnnecessary;
|
||||
return converted as vscode.Diagnostic & { reportUnnecessary: any };
|
||||
}
|
||||
|
||||
private getDiagnosticSeverity(diagnostic: Proto.Diagnostic): DiagnosticSeverity {
|
||||
private getDiagnosticSeverity(diagnostic: Proto.Diagnostic): vscode.DiagnosticSeverity {
|
||||
if (this.reportStyleCheckAsWarnings
|
||||
&& this.isStyleCheckDiagnostic(diagnostic.code)
|
||||
&& diagnostic.category === PConst.DiagnosticCategory.error
|
||||
) {
|
||||
return DiagnosticSeverity.Warning;
|
||||
return vscode.DiagnosticSeverity.Warning;
|
||||
}
|
||||
|
||||
switch (diagnostic.category) {
|
||||
case PConst.DiagnosticCategory.error:
|
||||
return DiagnosticSeverity.Error;
|
||||
return vscode.DiagnosticSeverity.Error;
|
||||
|
||||
case PConst.DiagnosticCategory.warning:
|
||||
return DiagnosticSeverity.Warning;
|
||||
return vscode.DiagnosticSeverity.Warning;
|
||||
|
||||
case PConst.DiagnosticCategory.suggestion:
|
||||
return DiagnosticSeverity.Hint;
|
||||
return vscode.DiagnosticSeverity.Hint;
|
||||
|
||||
default:
|
||||
return DiagnosticSeverity.Error;
|
||||
return vscode.DiagnosticSeverity.Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { CancellationToken, Event, Uri } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import BufferSyncSupport from './features/bufferSyncSupport';
|
||||
import * as Proto from './protocol';
|
||||
import API from './utils/api';
|
||||
@@ -17,27 +17,27 @@ export interface ITypeScriptServiceClient {
|
||||
*
|
||||
* Does not try handling case insensitivity.
|
||||
*/
|
||||
normalizedPath(resource: Uri): string | null;
|
||||
normalizedPath(resource: vscode.Uri): string | null;
|
||||
|
||||
/**
|
||||
* Map a resource to a normalized path
|
||||
*
|
||||
* This will attempt to handle case insensitivity.
|
||||
*/
|
||||
toPath(resource: Uri): string | null;
|
||||
toPath(resource: vscode.Uri): string | null;
|
||||
|
||||
/**
|
||||
* Convert a path to a resource.
|
||||
*/
|
||||
toResource(filepath: string): Uri;
|
||||
toResource(filepath: string): vscode.Uri;
|
||||
|
||||
getWorkspaceRootForResource(resource: Uri): string | undefined;
|
||||
getWorkspaceRootForResource(resource: vscode.Uri): string | undefined;
|
||||
|
||||
readonly onTsServerStarted: Event<API>;
|
||||
readonly onProjectLanguageServiceStateChanged: Event<Proto.ProjectLanguageServiceStateEventBody>;
|
||||
readonly onDidBeginInstallTypings: Event<Proto.BeginInstallTypesEventBody>;
|
||||
readonly onDidEndInstallTypings: Event<Proto.EndInstallTypesEventBody>;
|
||||
readonly onTypesInstallerInitializationFailed: Event<Proto.TypesInstallerInitializationFailedEventBody>;
|
||||
readonly onTsServerStarted: vscode.Event<API>;
|
||||
readonly onProjectLanguageServiceStateChanged: vscode.Event<Proto.ProjectLanguageServiceStateEventBody>;
|
||||
readonly onDidBeginInstallTypings: vscode.Event<Proto.BeginInstallTypesEventBody>;
|
||||
readonly onDidEndInstallTypings: vscode.Event<Proto.EndInstallTypesEventBody>;
|
||||
readonly onTypesInstallerInitializationFailed: vscode.Event<Proto.TypesInstallerInitializationFailedEventBody>;
|
||||
|
||||
readonly apiVersion: API;
|
||||
readonly plugins: TypeScriptServerPlugin[];
|
||||
@@ -45,42 +45,42 @@ export interface ITypeScriptServiceClient {
|
||||
readonly logger: Logger;
|
||||
readonly bufferSyncSupport: BufferSyncSupport;
|
||||
|
||||
execute(command: 'configure', args: Proto.ConfigureRequestArguments, token?: CancellationToken): Promise<Proto.ConfigureResponse>;
|
||||
execute(command: 'open', args: Proto.OpenRequestArgs, expectedResult: boolean, token?: CancellationToken): Promise<any>;
|
||||
execute(command: 'close', args: Proto.FileRequestArgs, expectedResult: boolean, token?: CancellationToken): Promise<any>;
|
||||
execute(command: 'change', args: Proto.ChangeRequestArgs, expectedResult: boolean, token?: CancellationToken): Promise<any>;
|
||||
execute(command: 'quickinfo', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.QuickInfoResponse>;
|
||||
execute(command: 'completions', args: Proto.CompletionsRequestArgs, token?: CancellationToken): Promise<Proto.CompletionsResponse>;
|
||||
execute(command: 'completionInfo', args: Proto.CompletionsRequestArgs, token?: CancellationToken): Promise<Proto.CompletionInfoResponse>;
|
||||
execute(command: 'completionEntryDetails', args: Proto.CompletionDetailsRequestArgs, token?: CancellationToken): Promise<Proto.CompletionDetailsResponse>;
|
||||
execute(command: 'signatureHelp', args: Proto.SignatureHelpRequestArgs, token?: CancellationToken): Promise<Proto.SignatureHelpResponse>;
|
||||
execute(command: 'definition', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.DefinitionResponse>;
|
||||
execute(command: 'definitionAndBoundSpan', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.DefinitionInfoAndBoundSpanReponse>;
|
||||
execute(command: 'implementation', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.ImplementationResponse>;
|
||||
execute(command: 'typeDefinition', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.TypeDefinitionResponse>;
|
||||
execute(command: 'references', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.ReferencesResponse>;
|
||||
execute(command: 'navto', args: Proto.NavtoRequestArgs, token?: CancellationToken): Promise<Proto.NavtoResponse>;
|
||||
execute(command: 'format', args: Proto.FormatRequestArgs, token?: CancellationToken): Promise<Proto.FormatResponse>;
|
||||
execute(command: 'formatonkey', args: Proto.FormatOnKeyRequestArgs, token?: CancellationToken): Promise<Proto.FormatResponse>;
|
||||
execute(command: 'rename', args: Proto.RenameRequestArgs, token?: CancellationToken): Promise<Proto.RenameResponse>;
|
||||
execute(command: 'occurrences', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.OccurrencesResponse>;
|
||||
execute(command: 'projectInfo', args: Proto.ProjectInfoRequestArgs, token?: CancellationToken): Promise<Proto.ProjectInfoResponse>;
|
||||
execute(command: 'reloadProjects', args: any, expectedResult: boolean, token?: CancellationToken): Promise<any>;
|
||||
execute(command: 'reload', args: Proto.ReloadRequestArgs, expectedResult: boolean, token?: CancellationToken): Promise<any>;
|
||||
execute(command: 'compilerOptionsForInferredProjects', args: Proto.SetCompilerOptionsForInferredProjectsArgs, token?: CancellationToken): Promise<any>;
|
||||
execute(command: 'navtree', args: Proto.FileRequestArgs, token?: CancellationToken): Promise<Proto.NavTreeResponse>;
|
||||
execute(command: 'getCodeFixes', args: Proto.CodeFixRequestArgs, token?: CancellationToken): Promise<Proto.GetCodeFixesResponse>;
|
||||
execute(command: 'getSupportedCodeFixes', args: null, token?: CancellationToken): Promise<Proto.GetSupportedCodeFixesResponse>;
|
||||
execute(command: 'getCombinedCodeFix', args: Proto.GetCombinedCodeFixRequestArgs, token?: CancellationToken): Promise<Proto.GetCombinedCodeFixResponse>;
|
||||
execute(command: 'docCommentTemplate', args: Proto.FileLocationRequestArgs, token?: CancellationToken): Promise<Proto.DocCommandTemplateResponse>;
|
||||
execute(command: 'getApplicableRefactors', args: Proto.GetApplicableRefactorsRequestArgs, token?: CancellationToken): Promise<Proto.GetApplicableRefactorsResponse>;
|
||||
execute(command: 'getEditsForRefactor', args: Proto.GetEditsForRefactorRequestArgs, token?: CancellationToken): Promise<Proto.GetEditsForRefactorResponse>;
|
||||
execute(command: 'applyCodeActionCommand', args: Proto.ApplyCodeActionCommandRequestArgs, token?: CancellationToken): Promise<Proto.ApplyCodeActionCommandResponse>;
|
||||
execute(command: 'organizeImports', args: Proto.OrganizeImportsRequestArgs, token?: CancellationToken): Promise<Proto.OrganizeImportsResponse>;
|
||||
execute(command: 'getOutliningSpans', args: Proto.FileRequestArgs, token: CancellationToken): Promise<Proto.OutliningSpansResponse>;
|
||||
execute(command: 'configure', args: Proto.ConfigureRequestArguments, token?: vscode.CancellationToken): Promise<Proto.ConfigureResponse>;
|
||||
execute(command: 'open', args: Proto.OpenRequestArgs, expectedResult: boolean, token?: vscode.CancellationToken): Promise<any>;
|
||||
execute(command: 'close', args: Proto.FileRequestArgs, expectedResult: boolean, token?: vscode.CancellationToken): Promise<any>;
|
||||
execute(command: 'change', args: Proto.ChangeRequestArgs, expectedResult: boolean, token?: vscode.CancellationToken): Promise<any>;
|
||||
execute(command: 'quickinfo', args: Proto.FileLocationRequestArgs, token?: vscode.CancellationToken): Promise<Proto.QuickInfoResponse>;
|
||||
execute(command: 'completions', args: Proto.CompletionsRequestArgs, token?: vscode.CancellationToken): Promise<Proto.CompletionsResponse>;
|
||||
execute(command: 'completionInfo', args: Proto.CompletionsRequestArgs, token?: vscode.CancellationToken): Promise<Proto.CompletionInfoResponse>;
|
||||
execute(command: 'completionEntryDetails', args: Proto.CompletionDetailsRequestArgs, token?: vscode.CancellationToken): Promise<Proto.CompletionDetailsResponse>;
|
||||
execute(command: 'signatureHelp', args: Proto.SignatureHelpRequestArgs, token?: vscode.CancellationToken): Promise<Proto.SignatureHelpResponse>;
|
||||
execute(command: 'definition', args: Proto.FileLocationRequestArgs, token?: vscode.CancellationToken): Promise<Proto.DefinitionResponse>;
|
||||
execute(command: 'definitionAndBoundSpan', args: Proto.FileLocationRequestArgs, token?: vscode.CancellationToken): Promise<Proto.DefinitionInfoAndBoundSpanReponse>;
|
||||
execute(command: 'implementation', args: Proto.FileLocationRequestArgs, token?: vscode.CancellationToken): Promise<Proto.ImplementationResponse>;
|
||||
execute(command: 'typeDefinition', args: Proto.FileLocationRequestArgs, token?: vscode.CancellationToken): Promise<Proto.TypeDefinitionResponse>;
|
||||
execute(command: 'references', args: Proto.FileLocationRequestArgs, token?: vscode.CancellationToken): Promise<Proto.ReferencesResponse>;
|
||||
execute(command: 'navto', args: Proto.NavtoRequestArgs, token?: vscode.CancellationToken): Promise<Proto.NavtoResponse>;
|
||||
execute(command: 'format', args: Proto.FormatRequestArgs, token?: vscode.CancellationToken): Promise<Proto.FormatResponse>;
|
||||
execute(command: 'formatonkey', args: Proto.FormatOnKeyRequestArgs, token?: vscode.CancellationToken): Promise<Proto.FormatResponse>;
|
||||
execute(command: 'rename', args: Proto.RenameRequestArgs, token?: vscode.CancellationToken): Promise<Proto.RenameResponse>;
|
||||
execute(command: 'occurrences', args: Proto.FileLocationRequestArgs, token?: vscode.CancellationToken): Promise<Proto.OccurrencesResponse>;
|
||||
execute(command: 'projectInfo', args: Proto.ProjectInfoRequestArgs, token?: vscode.CancellationToken): Promise<Proto.ProjectInfoResponse>;
|
||||
execute(command: 'reloadProjects', args: any, expectedResult: boolean, token?: vscode.CancellationToken): Promise<any>;
|
||||
execute(command: 'reload', args: Proto.ReloadRequestArgs, expectedResult: boolean, token?: vscode.CancellationToken): Promise<any>;
|
||||
execute(command: 'compilerOptionsForInferredProjects', args: Proto.SetCompilerOptionsForInferredProjectsArgs, token?: vscode.CancellationToken): Promise<any>;
|
||||
execute(command: 'navtree', args: Proto.FileRequestArgs, token?: vscode.CancellationToken): Promise<Proto.NavTreeResponse>;
|
||||
execute(command: 'getCodeFixes', args: Proto.CodeFixRequestArgs, token?: vscode.CancellationToken): Promise<Proto.GetCodeFixesResponse>;
|
||||
execute(command: 'getSupportedCodeFixes', args: null, token?: vscode.CancellationToken): Promise<Proto.GetSupportedCodeFixesResponse>;
|
||||
execute(command: 'getCombinedCodeFix', args: Proto.GetCombinedCodeFixRequestArgs, token?: vscode.CancellationToken): Promise<Proto.GetCombinedCodeFixResponse>;
|
||||
execute(command: 'docCommentTemplate', args: Proto.FileLocationRequestArgs, token?: vscode.CancellationToken): Promise<Proto.DocCommandTemplateResponse>;
|
||||
execute(command: 'getApplicableRefactors', args: Proto.GetApplicableRefactorsRequestArgs, token?: vscode.CancellationToken): Promise<Proto.GetApplicableRefactorsResponse>;
|
||||
execute(command: 'getEditsForRefactor', args: Proto.GetEditsForRefactorRequestArgs, token?: vscode.CancellationToken): Promise<Proto.GetEditsForRefactorResponse>;
|
||||
execute(command: 'applyCodeActionCommand', args: Proto.ApplyCodeActionCommandRequestArgs, token?: vscode.CancellationToken): Promise<Proto.ApplyCodeActionCommandResponse>;
|
||||
execute(command: 'organizeImports', args: Proto.OrganizeImportsRequestArgs, token?: vscode.CancellationToken): Promise<Proto.OrganizeImportsResponse>;
|
||||
execute(command: 'getOutliningSpans', args: Proto.FileRequestArgs, token: vscode.CancellationToken): Promise<Proto.OutliningSpansResponse>;
|
||||
execute(command: 'getEditsForFileRename', args: Proto.GetEditsForFileRenameRequestArgs): Promise<Proto.GetEditsForFileRenameResponse>;
|
||||
execute(command: 'jsxClosingTag', args: Proto.JsxClosingTagRequestArgs, token: CancellationToken): Promise<Proto.JsxClosingTagResponse>;
|
||||
execute(command: string, args: any, expectedResult: boolean | CancellationToken, token?: CancellationToken): Promise<any>;
|
||||
execute(command: 'jsxClosingTag', args: Proto.JsxClosingTagRequestArgs, token: vscode.CancellationToken): Promise<Proto.JsxClosingTagResponse>;
|
||||
execute(command: string, args: any, expectedResult: boolean | vscode.CancellationToken, token?: vscode.CancellationToken): Promise<any>;
|
||||
|
||||
executeAsync(command: 'geterr', args: Proto.GeterrRequestArgs, token: CancellationToken): Promise<any>;
|
||||
executeAsync(command: 'geterr', args: Proto.GeterrRequestArgs, token: vscode.CancellationToken): Promise<any>;
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as cp from 'child_process';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { CancellationToken, commands, env, EventEmitter, Memento, MessageItem, Uri, window, workspace } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import BufferSyncSupport from './features/bufferSyncSupport';
|
||||
import { DiagnosticKind, DiagnosticsManager } from './features/diagnostics';
|
||||
@@ -152,7 +152,7 @@ class ForkedTsServerProcess {
|
||||
|
||||
export interface TsDiagnostics {
|
||||
readonly kind: DiagnosticKind;
|
||||
readonly resource: Uri;
|
||||
readonly resource: vscode.Uri;
|
||||
readonly diagnostics: Proto.Diagnostic[];
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
public readonly diagnosticsManager: DiagnosticsManager;
|
||||
|
||||
constructor(
|
||||
private readonly workspaceState: Memento,
|
||||
private readonly workspaceState: vscode.Memento,
|
||||
private readonly onDidChangeTypeScriptVersion: (version: TypeScriptVersion) => void,
|
||||
public readonly plugins: TypeScriptServerPlugin[],
|
||||
private readonly logDirectoryProvider: LogDirectoryProvider,
|
||||
@@ -233,7 +233,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
this.diagnosticsManager.delete(resource);
|
||||
}, null, this._disposables);
|
||||
|
||||
workspace.onDidChangeConfiguration(() => {
|
||||
vscode.workspace.onDidChangeConfiguration(() => {
|
||||
const oldConfiguration = this._configuration;
|
||||
this._configuration = TypeScriptServiceConfiguration.loadFromWorkspace();
|
||||
|
||||
@@ -291,28 +291,28 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
}
|
||||
}
|
||||
|
||||
private readonly _onTsServerStarted = this._register(new EventEmitter<API>());
|
||||
private readonly _onTsServerStarted = this._register(new vscode.EventEmitter<API>());
|
||||
public readonly onTsServerStarted = this._onTsServerStarted.event;
|
||||
|
||||
private readonly _onDiagnosticsReceived = this._register(new EventEmitter<TsDiagnostics>());
|
||||
private readonly _onDiagnosticsReceived = this._register(new vscode.EventEmitter<TsDiagnostics>());
|
||||
public readonly onDiagnosticsReceived = this._onDiagnosticsReceived.event;
|
||||
|
||||
private readonly _onConfigDiagnosticsReceived = this._register(new EventEmitter<Proto.ConfigFileDiagnosticEvent>());
|
||||
private readonly _onConfigDiagnosticsReceived = this._register(new vscode.EventEmitter<Proto.ConfigFileDiagnosticEvent>());
|
||||
public readonly onConfigDiagnosticsReceived = this._onConfigDiagnosticsReceived.event;
|
||||
|
||||
private readonly _onResendModelsRequested = this._register(new EventEmitter<void>());
|
||||
private readonly _onResendModelsRequested = this._register(new vscode.EventEmitter<void>());
|
||||
public readonly onResendModelsRequested = this._onResendModelsRequested.event;
|
||||
|
||||
private readonly _onProjectLanguageServiceStateChanged = this._register(new EventEmitter<Proto.ProjectLanguageServiceStateEventBody>());
|
||||
private readonly _onProjectLanguageServiceStateChanged = this._register(new vscode.EventEmitter<Proto.ProjectLanguageServiceStateEventBody>());
|
||||
public readonly onProjectLanguageServiceStateChanged = this._onProjectLanguageServiceStateChanged.event;
|
||||
|
||||
private readonly _onDidBeginInstallTypings = this._register(new EventEmitter<Proto.BeginInstallTypesEventBody>());
|
||||
private readonly _onDidBeginInstallTypings = this._register(new vscode.EventEmitter<Proto.BeginInstallTypesEventBody>());
|
||||
public readonly onDidBeginInstallTypings = this._onDidBeginInstallTypings.event;
|
||||
|
||||
private readonly _onDidEndInstallTypings = this._register(new EventEmitter<Proto.EndInstallTypesEventBody>());
|
||||
private readonly _onDidEndInstallTypings = this._register(new vscode.EventEmitter<Proto.EndInstallTypesEventBody>());
|
||||
public readonly onDidEndInstallTypings = this._onDidEndInstallTypings.event;
|
||||
|
||||
private readonly _onTypesInstallerInitializationFailed = this._register(new EventEmitter<Proto.TypesInstallerInitializationFailedEventBody>());
|
||||
private readonly _onTypesInstallerInitializationFailed = this._register(new vscode.EventEmitter<Proto.TypesInstallerInitializationFailedEventBody>());
|
||||
public readonly onTypesInstallerInitializationFailed = this._onTypesInstallerInitializationFailed.event;
|
||||
|
||||
public get apiVersion(): API {
|
||||
@@ -360,7 +360,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
|
||||
this.info(`Using tsserver from: ${currentVersion.path}`);
|
||||
if (!fs.existsSync(currentVersion.tsServerPath)) {
|
||||
window.showWarningMessage(localize('noServerFound', 'The path {0} doesn\'t point to a valid tsserver install. Falling back to bundled TypeScript version.', currentVersion.path));
|
||||
vscode.window.showWarningMessage(localize('noServerFound', 'The path {0} doesn\'t point to a valid tsserver install. Falling back to bundled TypeScript version.', currentVersion.path));
|
||||
|
||||
this.versionPicker.useBundledVersion();
|
||||
currentVersion = this.versionPicker.currentVersion;
|
||||
@@ -384,7 +384,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
if (err || !childProcess) {
|
||||
this.lastError = err;
|
||||
this.error('Starting TSServer failed with error.', err);
|
||||
window.showErrorMessage(localize('serverCouldNotBeStarted', 'TypeScript language server couldn\'t be started. Error message is: {0}', err.message || err));
|
||||
vscode.window.showErrorMessage(localize('serverCouldNotBeStarted', 'TypeScript language server couldn\'t be started. Error message is: {0}', err.message || err));
|
||||
/* __GDPR__
|
||||
"error" : {
|
||||
"${include}": [
|
||||
@@ -471,7 +471,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
|
||||
public async openTsServerLogFile(): Promise<boolean> {
|
||||
if (!this.apiVersion.gte(API.v222)) {
|
||||
window.showErrorMessage(
|
||||
vscode.window.showErrorMessage(
|
||||
localize(
|
||||
'typescript.openTsServerLog.notSupported',
|
||||
'TS Server logging requires TS 2.2.2+'));
|
||||
@@ -479,7 +479,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
}
|
||||
|
||||
if (this._configuration.tsServerLogLevel === TsServerLogLevel.Off) {
|
||||
window.showErrorMessage<MessageItem>(
|
||||
vscode.window.showErrorMessage<vscode.MessageItem>(
|
||||
localize(
|
||||
'typescript.openTsServerLog.loggingNotEnabled',
|
||||
'TS Server logging is off. Please set `typescript.tsserver.log` and restart the TS server to enable logging'),
|
||||
@@ -490,7 +490,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
})
|
||||
.then(selection => {
|
||||
if (selection) {
|
||||
return workspace.getConfiguration().update('typescript.tsserver.log', 'verbose', true).then(() => {
|
||||
return vscode.workspace.getConfiguration().update('typescript.tsserver.log', 'verbose', true).then(() => {
|
||||
this.restartTsServer();
|
||||
});
|
||||
}
|
||||
@@ -500,17 +500,17 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
}
|
||||
|
||||
if (!this.tsServerLogFile) {
|
||||
window.showWarningMessage(localize(
|
||||
vscode.window.showWarningMessage(localize(
|
||||
'typescript.openTsServerLog.noLogFile',
|
||||
'TS Server has not started logging.'));
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
await commands.executeCommand('revealFileInOS', Uri.parse(this.tsServerLogFile));
|
||||
await vscode.commands.executeCommand('revealFileInOS', vscode.Uri.parse(this.tsServerLogFile));
|
||||
return true;
|
||||
} catch {
|
||||
window.showWarningMessage(localize(
|
||||
vscode.window.showWarningMessage(localize(
|
||||
'openTsServerLog.openFileFailedFailed',
|
||||
'Could not open TS Server log file'));
|
||||
return false;
|
||||
@@ -553,7 +553,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
reportIssue
|
||||
}
|
||||
|
||||
interface MyMessageItem extends MessageItem {
|
||||
interface MyMessageItem extends vscode.MessageItem {
|
||||
id: MessageAction;
|
||||
}
|
||||
|
||||
@@ -574,7 +574,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
if (diff < 10 * 1000 /* 10 seconds */) {
|
||||
this.lastStart = Date.now();
|
||||
startService = false;
|
||||
prompt = window.showErrorMessage<MyMessageItem>(
|
||||
prompt = vscode.window.showErrorMessage<MyMessageItem>(
|
||||
localize('serverDiedAfterStart', 'The TypeScript language service died 5 times right after it got started. The service will not be restarted.'),
|
||||
{
|
||||
title: localize('serverDiedReportIssue', 'Report Issue'),
|
||||
@@ -591,7 +591,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
this.resetClientVersion();
|
||||
} else if (diff < 60 * 1000 /* 1 Minutes */) {
|
||||
this.lastStart = Date.now();
|
||||
prompt = window.showWarningMessage<MyMessageItem>(
|
||||
prompt = vscode.window.showWarningMessage<MyMessageItem>(
|
||||
localize('serverDied', 'The TypeScript language service died unexpectedly 5 times in the last 5 Minutes.'),
|
||||
{
|
||||
title: localize('serverDiedReportIssue', 'Report Issue'),
|
||||
@@ -601,7 +601,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
if (prompt) {
|
||||
prompt.then(item => {
|
||||
if (item && item.id === MessageAction.reportIssue) {
|
||||
return commands.executeCommand('workbench.action.reportIssues');
|
||||
return vscode.commands.executeCommand('workbench.action.reportIssues');
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
@@ -613,7 +613,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
}
|
||||
}
|
||||
|
||||
public normalizedPath(resource: Uri): string | null {
|
||||
public normalizedPath(resource: vscode.Uri): string | null {
|
||||
if (this._apiVersion.gte(API.v213)) {
|
||||
if (resource.scheme === fileSchemes.walkThroughSnippet || resource.scheme === fileSchemes.untitled) {
|
||||
const dirName = path.dirname(resource.path);
|
||||
@@ -635,7 +635,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
return result.replace(new RegExp('\\' + this.pathSeparator, 'g'), '/');
|
||||
}
|
||||
|
||||
public toPath(resource: Uri): string | null {
|
||||
public toPath(resource: vscode.Uri): string | null {
|
||||
return this.normalizedPath(resource);
|
||||
}
|
||||
|
||||
@@ -643,11 +643,11 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
return this._apiVersion.gte(API.v270) ? '^' : '';
|
||||
}
|
||||
|
||||
public toResource(filepath: string): Uri {
|
||||
public toResource(filepath: string): vscode.Uri {
|
||||
if (this._apiVersion.gte(API.v213)) {
|
||||
if (filepath.startsWith(TypeScriptServiceClient.WALK_THROUGH_SNIPPET_SCHEME_COLON) || (filepath.startsWith(fileSchemes.untitled + ':'))
|
||||
) {
|
||||
let resource = Uri.parse(filepath);
|
||||
let resource = vscode.Uri.parse(filepath);
|
||||
if (this.inMemoryResourcePrefix) {
|
||||
const dirName = path.dirname(resource.path);
|
||||
const fileName = path.basename(resource.path);
|
||||
@@ -661,8 +661,8 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
return this.bufferSyncSupport.toResource(filepath);
|
||||
}
|
||||
|
||||
public getWorkspaceRootForResource(resource: Uri): string | undefined {
|
||||
const roots = workspace.workspaceFolders;
|
||||
public getWorkspaceRootForResource(resource: vscode.Uri): string | undefined {
|
||||
const roots = vscode.workspace.workspaceFolders;
|
||||
if (!roots || !roots.length) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -679,12 +679,12 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public executeAsync(command: string, args: Proto.GeterrRequestArgs, token: CancellationToken): Promise<any> {
|
||||
public executeAsync(command: string, args: Proto.GeterrRequestArgs, token: vscode.CancellationToken): Promise<any> {
|
||||
return this.executeImpl(command, args, { isAsync: true, token, expectsResult: true });
|
||||
}
|
||||
|
||||
public execute(command: string, args: any, expectsResultOrToken?: boolean | CancellationToken): Promise<any> {
|
||||
let token: CancellationToken | undefined = undefined;
|
||||
public execute(command: string, args: any, expectsResultOrToken?: boolean | vscode.CancellationToken): Promise<any> {
|
||||
let token: vscode.CancellationToken | undefined = undefined;
|
||||
let expectsResult = true;
|
||||
if (typeof expectsResultOrToken === 'boolean') {
|
||||
expectsResult = expectsResultOrToken;
|
||||
@@ -694,7 +694,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
return this.executeImpl(command, args, { isAsync: false, token, expectsResult });
|
||||
}
|
||||
|
||||
private executeImpl(command: string, args: any, executeInfo: { isAsync: boolean, token?: CancellationToken, expectsResult: boolean }): Promise<any> {
|
||||
private executeImpl(command: string, args: any, executeInfo: { isAsync: boolean, token?: vscode.CancellationToken, expectsResult: boolean }): Promise<any> {
|
||||
const request = this.requestQueue.createRequest(command, args);
|
||||
const requestInfo: RequestItem = {
|
||||
request: request,
|
||||
@@ -874,7 +874,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
case 'projectsUpdatedInBackground':
|
||||
if (event.body) {
|
||||
const body = (event as Proto.ProjectsUpdatedInBackgroundEvent).body;
|
||||
const resources = body.openFiles.map(Uri.file);
|
||||
const resources = body.openFiles.map(vscode.Uri.file);
|
||||
this.bufferSyncSupport.getErr(resources);
|
||||
}
|
||||
break;
|
||||
@@ -1048,7 +1048,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
const getTsLocale = (configuration: TypeScriptServiceConfiguration): string | undefined =>
|
||||
(configuration.locale
|
||||
? configuration.locale
|
||||
: env.language);
|
||||
: vscode.env.language);
|
||||
|
||||
function getDignosticsKind(event: Proto.Event) {
|
||||
switch (event.event) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { workspace, WorkspaceEdit } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import * as Proto from '../protocol';
|
||||
import { ITypeScriptServiceClient } from '../typescriptService';
|
||||
import * as typeConverters from './typeConverters';
|
||||
@@ -11,7 +11,7 @@ import * as typeConverters from './typeConverters';
|
||||
export function getEditForCodeAction(
|
||||
client: ITypeScriptServiceClient,
|
||||
action: Proto.CodeAction
|
||||
): WorkspaceEdit | undefined {
|
||||
): vscode.WorkspaceEdit | undefined {
|
||||
return action.changes && action.changes.length
|
||||
? typeConverters.WorkspaceEdit.fromFileCodeEdits(client, action.changes)
|
||||
: undefined;
|
||||
@@ -23,7 +23,7 @@ export async function applyCodeAction(
|
||||
): Promise<boolean> {
|
||||
const workspaceEdit = getEditForCodeAction(client, action);
|
||||
if (workspaceEdit) {
|
||||
if (!(await workspace.applyEdit(workspaceEdit))) {
|
||||
if (!(await vscode.workspace.applyEdit(workspaceEdit))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { workspace, WorkspaceConfiguration } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import * as arrays from './arrays';
|
||||
|
||||
export enum TsServerLogLevel {
|
||||
@@ -58,7 +58,7 @@ export class TypeScriptServiceConfiguration {
|
||||
}
|
||||
|
||||
private constructor() {
|
||||
const configuration = workspace.getConfiguration();
|
||||
const configuration = vscode.workspace.getConfiguration();
|
||||
|
||||
this.locale = TypeScriptServiceConfiguration.extractLocale(configuration);
|
||||
this.globalTsdk = TypeScriptServiceConfiguration.extractGlobalTsdk(configuration);
|
||||
@@ -83,7 +83,7 @@ export class TypeScriptServiceConfiguration {
|
||||
&& arrays.equals(this.tsServerPluginPaths, other.tsServerPluginPaths);
|
||||
}
|
||||
|
||||
private static extractGlobalTsdk(configuration: WorkspaceConfiguration): string | null {
|
||||
private static extractGlobalTsdk(configuration: vscode.WorkspaceConfiguration): string | null {
|
||||
const inspect = configuration.inspect('typescript.tsdk');
|
||||
if (inspect && inspect.globalValue && 'string' === typeof inspect.globalValue) {
|
||||
return inspect.globalValue;
|
||||
@@ -91,7 +91,7 @@ export class TypeScriptServiceConfiguration {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static extractLocalTsdk(configuration: WorkspaceConfiguration): string | null {
|
||||
private static extractLocalTsdk(configuration: vscode.WorkspaceConfiguration): string | null {
|
||||
const inspect = configuration.inspect('typescript.tsdk');
|
||||
if (inspect && inspect.workspaceValue && 'string' === typeof inspect.workspaceValue) {
|
||||
return inspect.workspaceValue;
|
||||
@@ -99,32 +99,32 @@ export class TypeScriptServiceConfiguration {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static readTsServerLogLevel(configuration: WorkspaceConfiguration): TsServerLogLevel {
|
||||
private static readTsServerLogLevel(configuration: vscode.WorkspaceConfiguration): TsServerLogLevel {
|
||||
const setting = configuration.get<string>('typescript.tsserver.log', 'off');
|
||||
return TsServerLogLevel.fromString(setting);
|
||||
}
|
||||
|
||||
private static readTsServerPluginPaths(configuration: WorkspaceConfiguration): string[] {
|
||||
private static readTsServerPluginPaths(configuration: vscode.WorkspaceConfiguration): string[] {
|
||||
return configuration.get<string[]>('typescript.tsserver.pluginPaths', []);
|
||||
}
|
||||
|
||||
private static readCheckJs(configuration: WorkspaceConfiguration): boolean {
|
||||
private static readCheckJs(configuration: vscode.WorkspaceConfiguration): boolean {
|
||||
return configuration.get<boolean>('javascript.implicitProjectConfig.checkJs', false);
|
||||
}
|
||||
|
||||
private static readExperimentalDecorators(configuration: WorkspaceConfiguration): boolean {
|
||||
private static readExperimentalDecorators(configuration: vscode.WorkspaceConfiguration): boolean {
|
||||
return configuration.get<boolean>('javascript.implicitProjectConfig.experimentalDecorators', false);
|
||||
}
|
||||
|
||||
private static readNpmLocation(configuration: WorkspaceConfiguration): string | null {
|
||||
private static readNpmLocation(configuration: vscode.WorkspaceConfiguration): string | null {
|
||||
return configuration.get<string | null>('typescript.npm', null);
|
||||
}
|
||||
|
||||
private static readDisableAutomaticTypeAcquisition(configuration: WorkspaceConfiguration): boolean {
|
||||
private static readDisableAutomaticTypeAcquisition(configuration: vscode.WorkspaceConfiguration): boolean {
|
||||
return configuration.get<boolean>('typescript.disableAutomaticTypeAcquisition', false);
|
||||
}
|
||||
|
||||
private static extractLocale(configuration: WorkspaceConfiguration): string | null {
|
||||
private static extractLocale(configuration: vscode.WorkspaceConfiguration): string | null {
|
||||
return configuration.get<string | null>('typescript.locale', null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { OutputChannel, window } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import * as is from './is';
|
||||
import { memoize } from './memoize';
|
||||
@@ -13,8 +13,8 @@ const localize = nls.loadMessageBundle();
|
||||
export default class Logger {
|
||||
|
||||
@memoize
|
||||
private get output(): OutputChannel {
|
||||
return window.createOutputChannel(localize('channelName', 'TypeScript'));
|
||||
private get output(): vscode.OutputChannel {
|
||||
return vscode.window.createOutputChannel(localize('channelName', 'TypeScript'));
|
||||
}
|
||||
|
||||
private data2String(data: any): string {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as path from 'path';
|
||||
import { workspace } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import { TypeScriptServiceConfiguration } from './configuration';
|
||||
import { RelativeWorkspacePathResolver } from './relativePathResolver';
|
||||
|
||||
@@ -37,7 +37,7 @@ export class TypeScriptPluginPathsProvider {
|
||||
return [workspacePath];
|
||||
}
|
||||
|
||||
return (workspace.workspaceFolders || [])
|
||||
return (vscode.workspace.workspaceFolders || [])
|
||||
.map(workspaceFolder => path.join(workspaceFolder.uri.fsPath, pluginPath));
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { extensions } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export interface TypeScriptServerPlugin {
|
||||
readonly path: string;
|
||||
@@ -13,7 +13,7 @@ export interface TypeScriptServerPlugin {
|
||||
|
||||
export function getContributedTypeScriptServerPlugins(): TypeScriptServerPlugin[] {
|
||||
const plugins: TypeScriptServerPlugin[] = [];
|
||||
for (const extension of extensions.all) {
|
||||
for (const extension of vscode.extensions.all) {
|
||||
const pack = extension.packageJSON;
|
||||
if (pack.contributes && pack.contributes.typescriptServerPlugins && Array.isArray(pack.contributes.typescriptServerPlugins)) {
|
||||
for (const plugin of pack.contributes.typescriptServerPlugins) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { MarkdownString } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import * as Proto from '../protocol';
|
||||
|
||||
function getTagBodyText(tag: Proto.JSDocTagInfo): string | undefined {
|
||||
@@ -64,17 +64,17 @@ export function tagsMarkdownPreview(tags: Proto.JSDocTagInfo[]): string {
|
||||
export function markdownDocumentation(
|
||||
documentation: Proto.SymbolDisplayPart[],
|
||||
tags: Proto.JSDocTagInfo[]
|
||||
): MarkdownString {
|
||||
const out = new MarkdownString();
|
||||
): vscode.MarkdownString {
|
||||
const out = new vscode.MarkdownString();
|
||||
addMarkdownDocumentation(out, documentation, tags);
|
||||
return out;
|
||||
}
|
||||
|
||||
export function addMarkdownDocumentation(
|
||||
out: MarkdownString,
|
||||
out: vscode.MarkdownString,
|
||||
documentation: Proto.SymbolDisplayPart[] | undefined,
|
||||
tags: Proto.JSDocTagInfo[] | undefined
|
||||
): MarkdownString {
|
||||
): vscode.MarkdownString {
|
||||
if (documentation) {
|
||||
out.appendMarkdown(plain(documentation));
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as path from 'path';
|
||||
import { workspace } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export class RelativeWorkspacePathResolver {
|
||||
public asAbsoluteWorkspacePath(relativePath: string): string | undefined {
|
||||
for (const root of workspace.workspaceFolders || []) {
|
||||
for (const root of vscode.workspace.workspaceFolders || []) {
|
||||
const rootPrefixes = [`./${root.name}/`, `${root.name}/`, `.\\${root.name}\\`, `${root.name}\\`];
|
||||
for (const rootPrefix of rootPrefixes) {
|
||||
if (relativePath.startsWith(rootPrefix)) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as fs from 'fs';
|
||||
import { Uri } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import { memoize } from './memoize';
|
||||
import { getTempFile } from './temp';
|
||||
|
||||
@@ -18,27 +18,27 @@ export class ResourceMap<T> {
|
||||
private readonly _map = new Map<string, T>();
|
||||
|
||||
constructor(
|
||||
private readonly _normalizePath?: (resource: Uri) => string | null
|
||||
private readonly _normalizePath?: (resource: vscode.Uri) => string | null
|
||||
) { }
|
||||
|
||||
public has(resource: Uri): boolean {
|
||||
public has(resource: vscode.Uri): boolean {
|
||||
const file = this.toKey(resource);
|
||||
return !!file && this._map.has(file);
|
||||
}
|
||||
|
||||
public get(resource: Uri): T | undefined {
|
||||
public get(resource: vscode.Uri): T | undefined {
|
||||
const file = this.toKey(resource);
|
||||
return file ? this._map.get(file) : undefined;
|
||||
}
|
||||
|
||||
public set(resource: Uri, value: T) {
|
||||
public set(resource: vscode.Uri, value: T) {
|
||||
const file = this.toKey(resource);
|
||||
if (file) {
|
||||
this._map.set(file, value);
|
||||
}
|
||||
}
|
||||
|
||||
public delete(resource: Uri): void {
|
||||
public delete(resource: vscode.Uri): void {
|
||||
const file = this.toKey(resource);
|
||||
if (file) {
|
||||
this._map.delete(file);
|
||||
@@ -57,7 +57,7 @@ export class ResourceMap<T> {
|
||||
return this._map.entries();
|
||||
}
|
||||
|
||||
private toKey(resource: Uri): string | null {
|
||||
private toKey(resource: vscode.Uri): string | null {
|
||||
const key = this._normalizePath ? this._normalizePath(resource) : resource.fsPath;
|
||||
if (!key) {
|
||||
return key;
|
||||
|
||||
@@ -3,12 +3,10 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { workspace } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import * as Proto from '../protocol';
|
||||
import Logger from './logger';
|
||||
|
||||
|
||||
|
||||
enum Trace {
|
||||
Off,
|
||||
Messages,
|
||||
@@ -45,7 +43,7 @@ export default class Tracer {
|
||||
}
|
||||
|
||||
private static readTrace(): Trace {
|
||||
let result: Trace = Trace.fromString(workspace.getConfiguration().get<string>('typescript.tsserver.trace', 'off'));
|
||||
let result: Trace = Trace.fromString(vscode.workspace.getConfiguration().get<string>('typescript.tsserver.trace', 'off'));
|
||||
if (result === Trace.Off && !!process.env.TSS_TRACE) {
|
||||
result = Trace.Messages;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Disposable, MessageItem, ProgressLocation, window, workspace } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import { loadMessageBundle } from 'vscode-nls';
|
||||
import { ITypeScriptServiceClient } from '../typescriptService';
|
||||
|
||||
@@ -11,10 +11,10 @@ const localize = loadMessageBundle();
|
||||
|
||||
const typingsInstallTimeout = 30 * 1000;
|
||||
|
||||
export default class TypingsStatus extends Disposable {
|
||||
export default class TypingsStatus extends vscode.Disposable {
|
||||
private _acquiringTypings: { [eventId: string]: NodeJS.Timer } = Object.create({});
|
||||
private _client: ITypeScriptServiceClient;
|
||||
private _subscriptions: Disposable[] = [];
|
||||
private _subscriptions: vscode.Disposable[] = [];
|
||||
|
||||
constructor(client: ITypeScriptServiceClient) {
|
||||
super(() => this.dispose());
|
||||
@@ -60,10 +60,10 @@ export default class TypingsStatus extends Disposable {
|
||||
export class AtaProgressReporter {
|
||||
|
||||
private _promises = new Map<number, Function>();
|
||||
private _disposable: Disposable;
|
||||
private _disposable: vscode.Disposable;
|
||||
|
||||
constructor(client: ITypeScriptServiceClient) {
|
||||
this._disposable = Disposable.from(
|
||||
this._disposable = vscode.Disposable.from(
|
||||
client.onDidBeginInstallTypings(e => this._onBegin(e.eventId)),
|
||||
client.onDidEndInstallTypings(e => this._onEndOrTimeout(e.eventId)),
|
||||
client.onTypesInstallerInitializationFailed(_ => this.onTypesInstallerInitializationFailed()));
|
||||
@@ -83,8 +83,8 @@ export class AtaProgressReporter {
|
||||
});
|
||||
});
|
||||
|
||||
window.withProgress({
|
||||
location: ProgressLocation.Window,
|
||||
vscode.window.withProgress({
|
||||
location: vscode.ProgressLocation.Window,
|
||||
title: localize('installingPackages', "Fetching data for better TypeScript IntelliSense")
|
||||
}, () => promise);
|
||||
}
|
||||
@@ -98,12 +98,12 @@ export class AtaProgressReporter {
|
||||
}
|
||||
|
||||
private onTypesInstallerInitializationFailed() {
|
||||
interface MyMessageItem extends MessageItem {
|
||||
interface MyMessageItem extends vscode.MessageItem {
|
||||
id: number;
|
||||
}
|
||||
|
||||
if (workspace.getConfiguration('typescript').get<boolean>('check.npmIsInstalled', true)) {
|
||||
window.showWarningMessage<MyMessageItem>(
|
||||
if (vscode.workspace.getConfiguration('typescript').get<boolean>('check.npmIsInstalled', true)) {
|
||||
vscode.window.showWarningMessage<MyMessageItem>(
|
||||
localize(
|
||||
'typesInstallerInitializationFailed.title',
|
||||
"Could not install typings files for JavaScript language features. Please ensure that NPM is installed or configure 'typescript.npm' in your user settings. Click [here]({0}) to learn more.",
|
||||
@@ -118,7 +118,7 @@ export class AtaProgressReporter {
|
||||
}
|
||||
switch (selected.id) {
|
||||
case 1:
|
||||
const tsConfig = workspace.getConfiguration('typescript');
|
||||
const tsConfig = vscode.workspace.getConfiguration('typescript');
|
||||
tsConfig.update('check.npmIsInstalled', false, true);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { commands, Memento, QuickPickItem, Uri, window, workspace } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { TypeScriptVersion, TypeScriptVersionProvider } from './versionProvider';
|
||||
|
||||
@@ -11,7 +11,7 @@ const localize = nls.loadMessageBundle();
|
||||
|
||||
const useWorkspaceTsdkStorageKey = 'typescript.useWorkspaceTsdk';
|
||||
|
||||
interface MyQuickPickItem extends QuickPickItem {
|
||||
interface MyQuickPickItem extends vscode.QuickPickItem {
|
||||
id: MessageAction;
|
||||
version?: TypeScriptVersion;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ export class TypeScriptVersionPicker {
|
||||
|
||||
public constructor(
|
||||
private readonly versionProvider: TypeScriptVersionProvider,
|
||||
private readonly workspaceState: Memento
|
||||
private readonly workspaceState: vscode.Memento
|
||||
) {
|
||||
this._currentVersion = this.versionProvider.defaultVersion;
|
||||
|
||||
@@ -82,7 +82,7 @@ export class TypeScriptVersionPicker {
|
||||
id: MessageAction.learnMore
|
||||
});
|
||||
|
||||
const selected = await window.showQuickPick<MyQuickPickItem>(pickOptions, {
|
||||
const selected = await vscode.window.showQuickPick<MyQuickPickItem>(pickOptions, {
|
||||
placeHolder: localize(
|
||||
'selectTsVersion',
|
||||
'Select the TypeScript version used for JavaScript and TypeScript language features'),
|
||||
@@ -97,7 +97,7 @@ export class TypeScriptVersionPicker {
|
||||
case MessageAction.useLocal:
|
||||
await this.workspaceState.update(useWorkspaceTsdkStorageKey, true);
|
||||
if (selected.version) {
|
||||
const tsConfig = workspace.getConfiguration('typescript');
|
||||
const tsConfig = vscode.workspace.getConfiguration('typescript');
|
||||
await tsConfig.update('tsdk', selected.version.pathLabel, false);
|
||||
|
||||
const previousVersion = this.currentVersion;
|
||||
@@ -114,7 +114,7 @@ export class TypeScriptVersionPicker {
|
||||
|
||||
|
||||
case MessageAction.learnMore:
|
||||
commands.executeCommand('vscode.open', Uri.parse('https://go.microsoft.com/fwlink/?linkid=839919'));
|
||||
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://go.microsoft.com/fwlink/?linkid=839919'));
|
||||
return { oldVersion: this.currentVersion };
|
||||
|
||||
default:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { window, workspace } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import API from './api';
|
||||
import { TypeScriptServiceConfiguration } from './configuration';
|
||||
@@ -12,9 +12,6 @@ import { RelativeWorkspacePathResolver } from './relativePathResolver';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export class TypeScriptVersion {
|
||||
constructor(
|
||||
public readonly path: string,
|
||||
@@ -40,7 +37,7 @@ export class TypeScriptVersion {
|
||||
}
|
||||
|
||||
// Allow TS developers to provide custom version
|
||||
const tsdkVersion = workspace.getConfiguration().get<string | undefined>('typescript.tsdk_version', undefined);
|
||||
const tsdkVersion = vscode.workspace.getConfiguration().get<string | undefined>('typescript.tsdk_version', undefined);
|
||||
if (tsdkVersion) {
|
||||
return API.fromVersionString(tsdkVersion);
|
||||
}
|
||||
@@ -152,7 +149,7 @@ export class TypeScriptVersionProvider {
|
||||
} catch (e) {
|
||||
// noop
|
||||
}
|
||||
window.showErrorMessage(localize(
|
||||
vscode.window.showErrorMessage(localize(
|
||||
'noBundledServerFound',
|
||||
'VS Code\'s tsserver was deleted by another application such as a misbehaving virus detection tool. Please reinstall VS Code.'));
|
||||
throw new Error('Could not find bundled tsserver.js');
|
||||
@@ -182,14 +179,14 @@ export class TypeScriptVersionProvider {
|
||||
}
|
||||
|
||||
private loadTypeScriptVersionsFromPath(relativePath: string): TypeScriptVersion[] {
|
||||
if (!workspace.workspaceFolders) {
|
||||
if (!vscode.workspace.workspaceFolders) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const versions: TypeScriptVersion[] = [];
|
||||
for (const root of workspace.workspaceFolders) {
|
||||
for (const root of vscode.workspace.workspaceFolders) {
|
||||
let label: string = relativePath;
|
||||
if (workspace.workspaceFolders && workspace.workspaceFolders.length > 1) {
|
||||
if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 1) {
|
||||
label = path.join(root.name, relativePath);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user