提交 a903c117 编写于 作者: M Matt Bierner

Restrict creation of TS client to known schemes

上级 17ab24fc
......@@ -16,6 +16,7 @@ import * as languageConfigurations from './utils/languageConfigurations';
import { standardLanguageDescriptions } from './utils/languageDescription';
import ManagedFileContextManager from './utils/managedFileContext';
import { lazy, Lazy } from './utils/lazy';
import TypeScriptServiceClient from './typescriptServiceClient';
export function activate(
context: vscode.ExtensionContext
......@@ -27,26 +28,21 @@ export function activate(
const lazyClientHost = createLazyClientHost(context, plugins, commandManager);
context.subscriptions.push(new ManagedFileContextManager(resource => {
// Don't force evaluation here.
if (lazyClientHost.hasValue) {
return lazyClientHost.value.serviceClient.normalizePath(resource);
}
return null;
}));
registerCommands(commandManager, lazyClientHost);
context.subscriptions.push(new TypeScriptTaskProviderManager(lazyClientHost.map(x => x.serviceClient)));
context.subscriptions.push(vscode.languages.setLanguageConfiguration(languageModeIds.jsxTags, languageConfigurations.jsxTags));
const supportedLanguage = [].concat.apply([], standardLanguageDescriptions.map(x => x.modeIds).concat(plugins.map(x => x.languages)));
function didOpenTextDocument(textDocument: vscode.TextDocument): boolean {
if (supportedLanguage.indexOf(textDocument.languageId) >= 0) {
if (isSupportedDocument(supportedLanguage, textDocument)) {
openListener.dispose();
// Force activation
// tslint:disable-next-line:no-unused-expression
void lazyClientHost.value;
context.subscriptions.push(new ManagedFileContextManager(resource => {
return lazyClientHost.value.serviceClient.normalizePath(resource);
}));
return true;
}
return false;
......@@ -89,3 +85,19 @@ function registerCommands(
commandManager.register(new commands.TypeScriptGoToProjectConfigCommand(lazyClientHost));
commandManager.register(new commands.JavaScriptGoToProjectConfigCommand(lazyClientHost));
}
function isSupportedDocument(
supportedLanguage: string[],
document: vscode.TextDocument
): boolean {
if (supportedLanguage.indexOf(document.languageId) < 0) {
return false;
}
const scheme = document.uri.scheme;
return (
scheme === TypeScriptServiceClient.WALK_THROUGH_SNIPPET_SCHEME
|| scheme === 'untitled'
|| scheme === 'file'
);
}
\ No newline at end of file
......@@ -107,7 +107,7 @@ class RequestQueue {
}
export default class TypeScriptServiceClient implements ITypeScriptServiceClient {
private static readonly WALK_THROUGH_SNIPPET_SCHEME = 'walkThroughSnippet';
public static readonly WALK_THROUGH_SNIPPET_SCHEME = 'walkThroughSnippet';
private static readonly WALK_THROUGH_SNIPPET_SCHEME_COLON = `${TypeScriptServiceClient.WALK_THROUGH_SNIPPET_SCHEME}:`;
private pathSeparator: string;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册