當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript vscode.ExtensionContext類代碼示例

本文整理匯總了TypeScript中vscode.ExtensionContext的典型用法代碼示例。如果您正苦於以下問題:TypeScript ExtensionContext類的具體用法?TypeScript ExtensionContext怎麽用?TypeScript ExtensionContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ExtensionContext類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: activate

export function activate(context: ExtensionContext) {

	let serverOptions : ServerOptions;

	if (ideConfig["backend"] == "scry") {
		let arch : string = os.arch();
		let platform : string = os.platform();

		let command : string = context.asAbsolutePath(path.join("scry", platform, arch, "scry"));
		serverOptions = { command: command, args: [] };
	}
	else if (ideConfig["backend"] == "custom") {
		let command : string = ideConfig["customCommand"];
		let args : [string] = ideConfig["customCommandArgs"] || [];

		serverOptions = { command: command, args: args}

	} else {

		// The server is implemented in node
		let serverModule = context.asAbsolutePath(path.join('server', 'server.js'));
		// The debug options for the server
		let debugOptions = { execArgv: ["--nolazy", "--debug=6004"] };

		// If the extension is launched in debug mode then the debug server options are used
		// Otherwise the run options are used
		serverOptions = {
			run : { module: serverModule, transport: TransportKind.ipc },
			debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
		}

	}

	// Options to control the language client
	let clientOptions: LanguageClientOptions = {
		// Register the server for Crystal source files
		documentSelector: ['crystal'],
		synchronize: {
			// Synchronize the setting section to the server
			configurationSection: 'crystal-ide',
			// Notify the server about file changes to crystal files
			fileEvents: workspace.createFileSystemWatcher('**/*.cr')
		}
	}

	// Create the language client and start the client.
	let disposable = new LanguageClient('Crystal Language', serverOptions, clientOptions).start();

	// Push the disposable to the context's subscriptions so that the
	// client can be deactivated on extension deactivation
	context.subscriptions.push(disposable);
}
開發者ID:kofno,項目名稱:crystal-ide,代碼行數:52,代碼來源:extension.ts

示例2: activate

export function activate(context: ExtensionContext) {

	// lokalizacja modułu Node.js serwera
	let serverModule = context.asAbsolutePath(path.join('server', 'server.js'));
	// ustawienia umożliwiające debugowanie kodu serwera
	let debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] };
	
	// ustawienia serwera
	let serverOptions: ServerOptions = {
		run : { module: serverModule, transport: TransportKind.ipc },
		debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
	}
	
	// opcje klienta
	let clientOptions: LanguageClientOptions = {
		documentSelector: [{scheme: 'file', language: 'lua'}],
		synchronize: {
			configurationSection: 'lua-lang',
			fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
		}
	}
	
	// Uruchomienie klienta LSP
	let client = new LanguageClient('luaLanguage', 'Lua language extension', serverOptions, clientOptions).start();
	
	// Dodanie klienta do kolekcji elementów usuwanych przy zamknięciu rozszerzenia
	context.subscriptions.push(client);
}
開發者ID:Muchtrix,項目名稱:EngThesis,代碼行數:28,代碼來源:extension.ts

示例3: init

async function init(context: ExtensionContext, outputChannel: OutputChannel, disposables: Disposable[]): Promise<Model> {
	const { name, version, aiKey } = require(context.asAbsolutePath('./package.json')) as { name: string, version: string, aiKey: string };
	const telemetryReporter: TelemetryReporter = new TelemetryReporter(name, version, aiKey);
	disposables.push(telemetryReporter);

	const pathHint = workspace.getConfiguration('git').get<string>('path');
	const info = await findGit(pathHint, path => outputChannel.appendLine(localize('looking', "Looking for git in: {0}", path)));
	const askpass = new Askpass();
	const env = await askpass.getEnv();
	const git = new Git({ gitPath: info.path, version: info.version, env });
	const model = new Model(git, context.globalState);
	disposables.push(model);

	const onRepository = () => commands.executeCommand('setContext', 'gitOpenRepositoryCount', `${model.repositories.length}`);
	model.onDidOpenRepository(onRepository, null, disposables);
	model.onDidCloseRepository(onRepository, null, disposables);
	onRepository();

	outputChannel.appendLine(localize('using git', "Using git {0} from {1}", info.version, info.path));

	const onOutput = (str: string) => outputChannel.append(str);
	git.onOutput.addListener('log', onOutput);
	disposables.push(toDisposable(() => git.onOutput.removeListener('log', onOutput)));

	disposables.push(
		new CommandCenter(git, model, outputChannel, telemetryReporter),
		new GitContentProvider(model),
		new GitDecorations(model)
	);

	await checkGitVersion(info);

	return model;
}
開發者ID:servicesgpr,項目名稱:vscode,代碼行數:34,代碼來源:main.ts

示例4: activate

export function activate(context: ExtensionContext) {

	let packageInfo = getPackageInfo(context);
	let telemetryReporter: TelemetryReporter = packageInfo && new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
	context.subscriptions.push(telemetryReporter);

	// The server is implemented in node
	let serverModule = context.asAbsolutePath(path.join('server', 'out', 'jsonServerMain.js'));
	// The debug options for the server
	let debugOptions = { execArgv: ['--nolazy', '--debug=6004'] };

	// If the extension is launch in debug mode the debug server options are use
	// Otherwise the run options are used
	let serverOptions: ServerOptions = {
		run: { module: serverModule, transport: TransportKind.ipc },
		debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
	};

	// Options to control the language client
	let clientOptions: LanguageClientOptions = {
		// Register the server for json documents
		documentSelector: ['json'],
		synchronize: {
			// Synchronize the setting section 'json' to the server
			configurationSection: ['json', 'http.proxy', 'http.proxyStrictSSL'],
			fileEvents: workspace.createFileSystemWatcher('**/*.json')
		}
	};

	// Create the language client and start the client.
	let client = new LanguageClient('json', localize('jsonserver.name', 'JSON Language Server'), serverOptions, clientOptions);
	let disposable = client.start();
	client.onReady().then(() => {
		client.onTelemetry(e => {
			if (telemetryReporter) {
				telemetryReporter.sendTelemetryEvent(e.key, e.data);
			}
		});

		// handle content request
		client.onRequest(VSCodeContentRequest.type, (uriPath: string) => {
			let uri = Uri.parse(uriPath);
			return workspace.openTextDocument(uri).then(doc => {
				return doc.getText();
			}, error => {
				return Promise.reject(error);
			});
		});

		client.sendNotification(SchemaAssociationNotification.type, getSchemaAssociation(context));
	});

	// Push the disposable to the context's subscriptions so that the
	// client can be deactivated on extension deactivation
	context.subscriptions.push(disposable);

	languages.setLanguageConfiguration('json', {
		wordPattern: /("(?:[^\\\"]*(?:\\.)?)*"?)|[^\s{}\[\],:]+/
	});
}
開發者ID:yuit,項目名稱:vscode,代碼行數:60,代碼來源:jsonMain.ts

示例5: activate

export function activate(context: ExtensionContext) {

	// The language server is implemented in C#
	let serverProgram = context.asAbsolutePath(path.join('server', 'TypeCobol.LanguageServer.exe'));
	// Command line options for the language server
	let serverTraceOptions = [ "2", // Trace level : 0 Lifecycle, 1 Message, 2 Protocol
                               "TypeCobol.LanguageServer.txt" // Log file
                               ];
	
	// Options to launch the language server
	let serverOptions: Executable = {
		command: serverProgram,
        args: serverTraceOptions 
	}
	
	// Options to control the language client
	let clientOptions: LanguageClientOptions = {        
		// Register the server for TypeCobol documents
		documentSelector: ['typecobol'],		
        synchronize: {
            // Synchronize the setting section 'typecobol' to the server
			configurationSection: 'typecobol',
			// Notify the server about file changes to '.cpy' files contained in the workspace
			fileEvents: workspace.createFileSystemWatcher('**/.cpy')
		}
	}
	
	// Create the language client and start the client.
	let disposable = new LanguageClient('TypeCobol', serverOptions, clientOptions).start();
	
	// Push the disposable to the context's subscriptions so that the 
	// client can be deactivated on extension deactivation
	context.subscriptions.push(disposable);
}
開發者ID:DORNINEM,項目名稱:TypeCobol,代碼行數:34,代碼來源:extension.ts

示例6: activate

export function activate(context: ExtensionContext) {

	// The server is implemented in node
	let serverModule = context.asAbsolutePath(path.join('server', 'out', 'serverMain.js'));
	// The debug options for the server
	let debugOptions = { execArgv: ["--nolazy", "--debug=6004"] };

	// If the extension is launched in debug mode then the debug server options are used
	// Otherwise the run options are used
	let serverOptions: ServerOptions = {
		run: { module: serverModule, transport: TransportKind.ipc },
		debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
	}

	// Options to control the language client
	let clientOptions: LanguageClientOptions = {
		// Register the server for plain text documents
		documentSelector: ['plaintext'],
		synchronize: {
			// Synchronize the setting section 'languageServerExample' to the server
			configurationSection: 'languageServerExample',
			// Notify the server about file changes to '.clientrc files contain in the workspace
			fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
		}
	}

	// Create the language client and start the client.
	let disposable = new LanguageClient('languageServerExample', 'Language Server Example', serverOptions, clientOptions).start();

	// Push the disposable to the context's subscriptions so that the 
	// client can be deactivated on extension deactivation
	context.subscriptions.push(disposable);
}
開發者ID:rlugojr,項目名稱:vscode-extension-samples,代碼行數:33,代碼來源:clientMain.ts

示例7: activate

export function activate(context: ExtensionContext) {
  // Construct the path to the language server
  const serverModule = context.asAbsolutePath(
      join('node_modules', '.bin', 'kythe-languageserver'));

  const debugOptions = {execArgv: ['--nolazy', '--debug=6009']};

  const serverOptions = {
    run: {module: serverModule, transport: TransportKind.ipc},
    debug: {
      module: serverModule,
      transport: TransportKind.ipc,
      options: debugOptions
    },
  };

  const clientOptions: LanguageClientOptions = {
    // Activate on all files and defer to the server to ignore stuff
    documentSelector: [{pattern: '**/*'}]
  }

  const disposable = new LanguageClient(
                         'kytheLanguageServer', 'Kythe Language Server',
                         serverOptions, clientOptions)
                         .start();

  context.subscriptions.push(disposable);
}
開發者ID:legrosbuffle,項目名稱:kythe,代碼行數:28,代碼來源:extension.ts

示例8: activate

export function activate(context: ExtensionContext) {

    // The server is implemented in node
    let serverModule = context.asAbsolutePath(path.join('server', 'src', 'server.js'));
    // The debug options for the server
    let debugOptions = { execArgv: ['--nolazy', '--debug=6004'] };

    // If the extension is launch in debug mode the debug server options are use
    // Otherwise the run options are used
    let serverOptions: ServerOptions = {
        run : { module: serverModule, transport: TransportKind.ipc },
        debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
    };

    // Options to control the language client
    let clientOptions: LanguageClientOptions = {
        // Register the server for plain text documents
        documentSelector: ['haskell'],
        synchronize: {
            // Synchronize the setting section 'ghcMod' to the server
            configurationSection: 'haskell.ghcMod'
        }
    };

    // Create the language client and start the client.
    let disposable = new LanguageClient('ghc-mod server', serverOptions, clientOptions).start();

    // Push the disposable to the context's subscriptions so that the
    // client can be deactivated on extension deactivation
    context.subscriptions.push(disposable);
}
開發者ID:bravomikekilo,項目名稱:vscode-ghc-mod,代碼行數:31,代碼來源:extension.ts

示例9: activate

export function activate(context: ExtensionContext): API {
	const config = workspace.getConfiguration('git', null);
	const enabled = config.get<boolean>('enabled');

	const disposables: Disposable[] = [];
	context.subscriptions.push(new Disposable(() => Disposable.from(...disposables).dispose()));

	const { name, version, aiKey } = require(context.asAbsolutePath('./package.json')) as { name: string, version: string, aiKey: string };
	telemetryReporter = new TelemetryReporter(name, version, aiKey);

	let activatePromise: Promise<Model | undefined>;

	if (enabled) {
		activatePromise = _activate(context, disposables);
	} else {
		const onConfigChange = filterEvent(workspace.onDidChangeConfiguration, e => e.affectsConfiguration('git'));
		const onEnabled = filterEvent(onConfigChange, () => workspace.getConfiguration('git', null).get<boolean>('enabled') === true);

		activatePromise = eventToPromise(onEnabled)
			.then(() => _activate(context, disposables));
	}

	const modelPromise = activatePromise
		.then(model => model || Promise.reject<Model>('Git model not found'));

	activatePromise.catch(err => console.error(err));

	return createApi(modelPromise);
}
開發者ID:jumpinjackie,項目名稱:sqlopsstudio,代碼行數:29,代碼來源:main.ts

示例10: activate

export function activate(context: ExtensionContext)
{
    let qol: QualityOfLife = new QualityOfLife();

    let serverModule = context.asAbsolutePath(path.join("server", "server.js"));
    let debugOptions = { execArgv: ["--nolazy", "--debug=6004"] };

    let serverOptions: ServerOptions = {
        run : { module: serverModule, transport: TransportKind.ipc },
        debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
    }

    let clientOptions: LanguageClientOptions = {
        documentSelector: ["php"],
        synchronize: {
            configurationSection: "languageServerExample",
            fileEvents: workspace.createFileSystemWatcher("**/.clientrc")
        }
    }

    // Create the language client and start the client.
    var langClient: LanguageClient = new LanguageClient("Crane Language Server", serverOptions, clientOptions);

    // Use this to handle a request sent from the server
    // https://github.com/Microsoft/vscode/blob/80bd73b5132268f68f624a86a7c3e56d2bbac662/extensions/json/client/src/jsonMain.ts
    // https://github.com/Microsoft/vscode/blob/580d19ab2e1fd6488c3e515e27fe03dceaefb819/extensions/json/server/src/server.ts
    //langClient.onRequest()

    let disposable = langClient.start();

    let crane: Crane = new Crane(langClient);

    var requestType: RequestType<any, any, any> = { method: "workDone" };
    langClient.onRequest(requestType, () => {
        // Load settings
        let craneSettings = workspace.getConfiguration("crane");
        if (craneSettings) {
            var showStatusBarItem = craneSettings.get<boolean>("showStatusBarBugReportLink", true);
            if (showStatusBarItem) {
                setTimeout(() => {
                    crane.statusBarItem.text = "$(bug) Report PHP Intellisense Bug";
                    crane.statusBarItem.tooltip = "Found a problem with the PHP Intellisense provided by Crane? Click here to file a bug report on Github";
                    crane.statusBarItem.command = "crane.reportBug";
                    crane.statusBarItem.show();
                }, 5000);
            } else {
                crane.statusBarItem.hide();
            }
        } else {
            crane.statusBarItem.hide();
        }
    });

    // Register commands for QoL improvements
    let duplicateLineCommand = commands.registerCommand("crane.duplicateLine", qol.duplicateLineOrSelection);
    let reportBugCommand = commands.registerCommand("crane.reportBug", crane.reportBug);

    context.subscriptions.push(disposable);
    context.subscriptions.push(duplicateLineCommand);
}
開發者ID:TheColorRed,項目名稱:crane,代碼行數:60,代碼來源:extension.ts


注:本文中的vscode.ExtensionContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。