当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript languages.match方法代码示例

本文整理汇总了TypeScript中vscode.languages.match方法的典型用法代码示例。如果您正苦于以下问题:TypeScript languages.match方法的具体用法?TypeScript languages.match怎么用?TypeScript languages.match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vscode.languages的用法示例。


在下文中一共展示了languages.match方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: render

	function render() {

		if (!vscode.window.activeTextEditor) {
			entry.hide();
			return;
		}

		let document = vscode.window.activeTextEditor.document;
		let status: Status;

		if (projectStatus && vscode.languages.match(projectStatus.selector, document)) {
			status = projectStatus;
		} else if (defaultStatus.text && vscode.languages.match(defaultStatus.selector, document)) {
			status = defaultStatus;
		}

		if (status) {
			entry.text = status.text;
			entry.command = status.command;
			entry.color = status.color;
			entry.show();
			return;
		}

		entry.hide();
	}
开发者ID:0xdeafcafe,项目名称:omnisharp-vscode,代码行数:26,代码来源:omnisharpStatus.ts

示例2: getLanguageEntry

/** Attempts to find the best-matching language entry for the language-id of the given document.
 * @param the document to match
 * @returns the best-matching language entry, or else `undefined` if none was found */
function getLanguageEntry(doc: vscode.TextDocument) : LanguageEntry {
  const rankings = settings.substitutions
    .map((entry) => ({rank: vscode.languages.match(entry.language, doc), entry: entry}))
    .filter(score => score.rank > 0)
    .sort((x,y) => (x.rank > y.rank) ? -1 : (x.rank==y.rank) ? 0 : 1);

  let entry : LanguageEntry = rankings.length > 0
    ? Object.assign({}, rankings[0].entry)
    : {
      language: doc.languageId,
      substitutions: [],
      adjustCursorMovement: settings.adjustCursorMovement,
      revealOn: settings.revealOn,
      prettyCursor: settings.prettyCursor,
      combineIdenticalScopes: true,
    };

  for(const language of additionalSubstitutions) {
    if(vscode.languages.match(language.language, doc) > 0) {
      entry.substitutions.push(...language.substitutions);
    }
  }

  return entry;
}
开发者ID:siegebell,项目名称:vsc-prettify-symbols-mode,代码行数:28,代码来源:extension.ts

示例3: applyConfigToTextEditor

function applyConfigToTextEditor(textEditor: vscode.TextEditor): any {

    if (!textEditor) {
        return;
    };
    let newOptions: vscode.TextEditorOptions = {
        "insertSpaces": false,
        "tabSize": 4
    };

    let defaultOptions: vscode.TextEditorOptions = {
        "insertSpaces": Boolean(vscode.workspace.getConfiguration("editor").get("insertSpaces")),
        "tabSize": Number(vscode.workspace.getConfiguration("editor").get("tabSize"))
    };

    if (vscode.languages.match(BSL_MODE, textEditor.document)) {
        if (textEditor.options.insertSpaces === defaultOptions.insertSpaces
            && (textEditor.options.tabSize === defaultOptions.tabSize)) {
            textEditor.options.insertSpaces = newOptions.insertSpaces;
            textEditor.options.tabSize = newOptions.tabSize;
        } else if (textEditor.options.insertSpaces === newOptions.insertSpaces && textEditor.options.tabSize === newOptions.tabSize) {
            textEditor.options.insertSpaces = defaultOptions.insertSpaces;
            textEditor.options.tabSize = defaultOptions.tabSize;
        }
    }
}
开发者ID:artbear,项目名称:vsc-language-1c-bsl,代码行数:26,代码来源:extension.ts

示例4:

				didOpen: (document, next) => {
					if (Languages.match(packageJsonFilter, document) || shouldBeValidated(document)) {
						next(document);
						syncedDocuments.set(document.uri.toString(), document);
						return;
					}
				},
开发者ID:chenxsan,项目名称:vscode-standardjs,代码行数:7,代码来源:extension.ts

示例5:

 (editor: vscode.TextEditor, edit: vscode.TextEditorEdit) => {
     if (!vscode.languages.match(CLANG_MODE, editor.document)) {
         vscode.window.showErrorMessage(`Current language is not C, C++ or Objective-C`);
         return;            
     }
     confViewer.show(editor.document);
 }));    
开发者ID:Sean1708,项目名称:vscode-clang,代码行数:7,代码来源:extension.ts

示例6: doBsllint

    public doBsllint(textDocument: vscode.TextDocument) {
        if (!vscode.languages.match(BSL_MODE, textDocument)) {
            return;
        }
        let linterEnabled = Boolean(vscode.workspace.getConfiguration("language-1c-bsl").get("enableOneScriptLinter"));
        let lintBSLFiles = Boolean(vscode.workspace.getConfiguration("language-1c-bsl").get("lintBSLFiles"));
        let diagnostics: vscode.Diagnostic[] = [];
        if (!linterEnabled) {
            return;
        }
        let filename = textDocument.uri.fsPath;
        if (filename.endsWith(".bsl") && !lintBSLFiles) {
            return;
        }
        let args = this.args.slice();
        args.push(filename);
        let options = {
            cwd: path.dirname(filename),
            env: process.env
        };
        let result = "";
        let phpcs = cp.spawn(this.commandId, args, options);
        phpcs.stderr.on("data", function (buffer) {
            result += buffer.toString();
        });
        phpcs.stdout.on("data", function (buffer) {
            result += buffer.toString();
        });
        phpcs.on("close", () => {
            try {
                result = result.trim();
                let lines = result.split(/\r?\n/);
                let regex = /^\{Модуль\s+(.*)\s\/\s.*:\s+(\d+)\s+\/\s+(.*)\}/;
                let vscodeDiagnosticArray = new Array<vscode.Diagnostic>();
                for (let line in lines) {
                    let match = null;
                    match = lines[line].match(regex);
                    if (match !== null) {
                        let range = new vscode.Range(
                                new vscode.Position(match[2] - 1, 0),
                                new vscode.Position(+match[2] - 1, vscode.window.activeTextEditor.document.lineAt(match[2] - 1).text.length)
                                );
                        let vscodeDiagnostic = new vscode.Diagnostic(range, match[3], vscode.DiagnosticSeverity.Error);
                        vscodeDiagnosticArray.push(vscodeDiagnostic);
                    }
                }
                this.diagnosticCollection.set(textDocument.uri, vscodeDiagnosticArray);
                if (vscodeDiagnosticArray.length !== 0 && vscode.workspace.rootPath === undefined) {
                    this.statusBarItem.text = vscodeDiagnosticArray.length === 0 ? "$(check) No Error" : "$(alert) " +  vscodeDiagnosticArray.length + " Errors";
                    this.statusBarItem.show();
                } else {
                    this.statusBarItem.hide();
                };
            } catch (e) {
                console.error(e);
            }
        });

    };
开发者ID:pumbaEO,项目名称:vsc-bsl-specflow,代码行数:59,代码来源:lintProvider.ts

示例7: matchExtensionAsHtml

async function matchExtensionAsHtml(extension: string) {
  const doc = await vscode.workspace.openTextDocument(
    vscode.Uri.parse(`untitled:fake/path/doc.${extension}`)
  );
  expect(vscode.languages.match({ language: 'html' }, doc)).to.equal(
    PERFECT_MATCH
  );
}
开发者ID:nertofiveone,项目名称:salesforcedx-vscode,代码行数:8,代码来源:fileAssociations.test.ts

示例8: onEditor

	function onEditor(editor: vscode.TextEditor): void {
		if (!editor
			|| !vscode.languages.match(selector, editor.document)
			|| !client.asAbsolutePath(editor.document.uri)) {

			item.hide();
			return;
		}

		const file = client.asAbsolutePath(editor.document.uri);
		isOpen(file).then(value => {
			if (!value) {
				return;
			}

			return client.execute('projectInfo', { file, needFileNameList: true }).then(res => {

				let {configFileName, fileNames} = res.body;

				if (projectHinted[configFileName] === true) {
					return;
				}

				if (fileNames.length > fileLimit) {

					let largeRoots = computeLargeRoots(configFileName, fileNames).map(f => `'/${f}/'`).join(', ');

					currentHint = {
						message: largeRoots.length > 0
							? localize('hintExclude', "For better performance exclude folders with many files, like: {0}", largeRoots)
							: localize('hintExclude.generic', "For better performance exclude folders with many files."),
						options: [{
							title: localize('open', "Configure Excludes"),
							execute: () => {
								client.logTelemetry('js.hintProjectExcludes.accepted');
								projectHinted[configFileName] = true;
								item.hide();

								return vscode.workspace.openTextDocument(configFileName)
									.then(vscode.window.showTextDocument);
							}
						}]
					};
					item.tooltip = currentHint.message;
					item.text = localize('large.label', "Configure Excludes");
					item.tooltip = localize('hintExclude.tooltip', "For better performance exclude folders with many files.");
					item.color = '#A5DF3B';
					item.show();
					client.logTelemetry('js.hintProjectExcludes');

				} else {
					item.hide();
				}
			});
		}).catch(err => {
			client.warn(err);
		});
	}
开发者ID:,项目名称:,代码行数:58,代码来源:

示例9:

 context.subscriptions.push(vscode.commands.registerCommand('clang.showExecConf', () => {
     let editor = vscode.window.activeTextEditor;
     if (editor == null) {
         vscode.window.showErrorMessage(`No active editor.`);
         return;
     }
     if (!vscode.languages.match(CLANG_MODE, editor.document)) {
         vscode.window.showErrorMessage(`Current language is not C, C++ or Objective-C`);
         return;            
     }
     confViewer.show(editor.document);
 }));    
开发者ID:alloy,项目名称:vscode-clang,代码行数:12,代码来源:extension.ts

示例10: updateStatusBarItemVisibility

 public updateStatusBarItemVisibility(): void {
     if (!this.canBeShown) {
         return;
     }
     if (!window.activeTextEditor) {
         this.statusBarItem.hide();
         return;
     }
     if (languages.match(getDocumentFilter(), window.activeTextEditor.document)) {
         this.statusBarItem.show();
     } else {
         this.statusBarItem.hide();
     }
 }
开发者ID:KalitaAlexey,项目名称:RustyCode,代码行数:14,代码来源:missing_tools_status_bar_item.ts


注:本文中的vscode.languages.match方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。