當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。