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


TypeScript languages.getLanguages方法代碼示例

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


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

示例1: provideLanguageCompletionItems

	private provideLanguageCompletionItems(location: Location, range: vscode.Range, formatFunc: (string) => string = (l) => JSON.stringify(l)): vscode.ProviderResult<vscode.CompletionItem[]> {
		return vscode.languages.getLanguages().then(languages => {
			return languages.map(l => {
				return this.newSimpleCompletionItem(formatFunc(l), range);
			});
		});
	}
開發者ID:FabianLauer,項目名稱:vscode,代碼行數:7,代碼來源:settingsDocumentHelper.ts

示例2: provideLanguageCompletionItems

	private provideLanguageCompletionItems(location: Location, range: vscode.Range, stringify: boolean = true): vscode.ProviderResult<vscode.CompletionItem[]> {
		return vscode.languages.getLanguages().then(languages => {
			return languages.map(l => {
				return this.newSimpleCompletionItem(stringify ? JSON.stringify(l) : l, range);
			});
		});
	}
開發者ID:yuit,項目名稱:vscode,代碼行數:7,代碼來源:settingsDocumentHelper.ts

示例3: activate

export function activate(context: vscode.ExtensionContext) {
    var completeProvider = new CompleteProvider();
    vscode.languages.getLanguages().then(data => console.log(data))
    var disposable = vscode.languages.registerCompletionItemProvider('*', 
    completeProvider, '"', '\'', '/');
	context.subscriptions.push(disposable);
}
開發者ID:Jerry-Hong,項目名稱:vscode-autofilename,代碼行數:7,代碼來源:extension.ts

示例4: provideLanguageCompletionItems

	private provideLanguageCompletionItems(location: Location, range: vscode.Range, formatFunc: (string: string) => string = (l) => JSON.stringify(l)): vscode.ProviderResult<vscode.CompletionItem[]> {
		return vscode.languages.getLanguages().then(languages => {
			const completionItems = [];
			const configuration = vscode.workspace.getConfiguration();
			for (const language of languages) {
				const inspect = configuration.inspect(`[${language}]`);
				if (!inspect || !inspect.defaultValue) {
					const item = new vscode.CompletionItem(formatFunc(language));
					item.kind = vscode.CompletionItemKind.Property;
					item.range = range;
					completionItems.push(item);
				}
			}
			return completionItems;
		});
	}
開發者ID:burhandodhy,項目名稱:azuredatastudio,代碼行數:16,代碼來源:settingsDocumentHelper.ts

示例5: provideLanguageOverridesCompletionItems

	private provideLanguageOverridesCompletionItems(location: Location, position: vscode.Position): vscode.ProviderResult<vscode.CompletionItem[]> {
		let range = this.document.getWordRangeAtPosition(position) || new vscode.Range(position, position);
		const text = this.document.getText(range);

		if (location.path.length === 2) {

			let snippet = '"[${1:language}]": {\n\t"$0"\n}';

			// Suggestion model word matching includes quotes,
			// hence exclude the starting quote from the snippet and the range
			// ending quote gets replaced
			if (text.startsWith('"')) {
				range = new vscode.Range(new vscode.Position(range.start.line, range.start.character + 1), range.end);
				snippet = snippet.substring(1);
			}

			return Promise.resolve([this.newSnippetCompletionItem({
				label: localize('languageSpecificEditorSettings', "Language specific editor settings"),
				documentation: localize('languageSpecificEditorSettingsDescription', "Override editor settings for language"),
				snippet,
				range
			})]);
		}

		if (location.path.length === 3 && location.previousNode && location.previousNode.value.startsWith('[')) {

			// Suggestion model word matching includes starting quote and open sqaure bracket
			// Hence exclude them from the proposal range
			range = new vscode.Range(new vscode.Position(range.start.line, range.start.character + 2), range.end);

			return vscode.languages.getLanguages().then(languages => {
				return languages.map(l => {

					// Suggestion model word matching includes closed sqaure bracket and ending quote
					// Hence include them in the proposal to replace
					return this.newSimpleCompletionItem(l, range, '', l + ']"');
				});
			});
		}
		return Promise.resolve([]);
	}
開發者ID:diarmaidm,項目名稱:vscode,代碼行數:41,代碼來源:packageDocumentHelper.ts

示例6: activate

export function activate(context: ExtensionContext) {

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

	// Resolve language ids to pass around as initialization data
	languages.getLanguages().then(languageIds => {

		// 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.schemas', 'http.proxy', 'http.proxyStrictSSL'],
				fileEvents: workspace.createFileSystemWatcher('**/*.json')
			},
			initializationOptions: {
				languageIds
			}
		};

		// Create the language client and start the client.
		let client = new LanguageClient('JSON Server', serverOptions, clientOptions);
		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);
			});
		});

		let disposable = client.start();

		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: /(-?\d*\.\d\w*)|([^\[\{\]\}\:\"\,\s]+)/g,
			__characterPairSupport: {
				autoClosingPairs: [
					{ open: '{', close: '}' },
					{ open: '[', close: ']' },
					{ open: '(', close: ')' },
					{ open: '"', close: '"', notIn: ['string'] },
					{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
					{ open: '`', close: '`', notIn: ['string', 'comment'] }
				]
			}
		});
	});
}
開發者ID:ArtsyLee,項目名稱:vscode,代碼行數:75,代碼來源:jsonMain.ts

示例7: activate

export function activate(context: ExtensionContext) {

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

	// Resolve language ids to pass around as initialization data
	languages.getLanguages().then(languageIds => {

		// 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 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 yaml documents
			documentSelector: ['yaml'],
			synchronize: {
				configurationSection: ['json.schemas', 'http.proxy', 'http.proxyStrictSSL', 'languageServerYamlSchema'],
				fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
				// fileEvents: workspace.createFileSystemWatcher('**/.yaml')
			},
			initializationOptions: {
				languageIds
			}
		};

		// Create the language client and start the client.
  	let client = new LanguageClient('Language Server YAML Schema', serverOptions, clientOptions);
		client.onNotification(TelemetryNotification.type, 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);
			});
		});

		let disposable = client.start();

		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('yaml', {
			comments: {
				"lineComment": "#"
			},
			"brackets": [
				["{", "}"],
				["[", "]"],
				["(", ")"]
			]
		});
	});
}
開發者ID:djabraham,項目名稱:vscode-yaml-validation,代碼行數:72,代碼來源:extension.ts

示例8: activate

export function activate(context: ExtensionContext) {

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

	// Resolve language ids to pass around as initialization data
	languages.getLanguages().then(languageIds => {

		// 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.schemas', 'http.proxy', 'http.proxyStrictSSL'],
				fileEvents: workspace.createFileSystemWatcher('**/*.json')
			},
			initializationOptions: {
				languageIds,
				['format.enable']: workspace.getConfiguration('json').get('format.enable')
			}
		};

		// 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:StateFarmIns,項目名稱:vscode,代碼行數:67,代碼來源:jsonMain.ts


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