当前位置: 首页>>代码示例>>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;未经允许,请勿转载。