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


TypeScript DiagnosticCollection.get方法代码示例

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


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

示例1: addUniqueDiagnostic

export function addUniqueDiagnostic(diagnostic: FileDiagnostic, diagnostics: DiagnosticCollection): void {
    const uri = Uri.file(diagnostic.filePath);

    const fileDiagnostics = diagnostics.get(uri);

    if (!fileDiagnostics) {
        // No diagnostics for the file
        // The diagnostic is unique
        diagnostics.set(uri, [diagnostic.diagnostic]);
    } else if (isUniqueDiagnostic(diagnostic.diagnostic, fileDiagnostics)) {
        const newFileDiagnostics = fileDiagnostics.concat([diagnostic.diagnostic]);
        diagnostics.set(uri, newFileDiagnostics);
    }
}
开发者ID:KalitaAlexey,项目名称:RustyCode,代码行数:14,代码来源:diagnostic_utils.ts

示例2: setTimeout

	context.subscriptions.push(workspace.onDidSaveTextDocument((td) => {
		if (!debug.activeDebugSession)
			return;

		const shouldHotReload =
			debugCommands.flutterExtensions.serviceIsRegistered(FlutterService.HotReload)
			&& config.flutterHotReloadOnSave;

		const shouldHotRestart =
			!debugCommands.flutterExtensions.serviceIsRegistered(FlutterService.HotReload)
			&& debugCommands.flutterExtensions.serviceIsRegistered(FlutterService.HotRestart)
			&& config.flutterHotRestartOnSave;

		// Don't do if there are no debug sessions that support it.
		if (!shouldHotReload && !shouldHotRestart)
			return;

		const commandToRun = shouldHotReload ? "flutter.hotReload" : "flutter.hotRestart";

		// Bail out if we're in an external file, or not Dart.
		if (!isAnalyzableAndInWorkspace(td) || path.extname(fsPath(td.uri)) !== ".dart")
			return;

		// Don't do if we have errors for the saved file.
		const errors = diagnostics.get(td.uri);
		const hasErrors = errors && !!errors.find((d) => d.severity === DiagnosticSeverity.Error);
		if (hasErrors)
			return;

		// Debounce to avoid reloading multiple times during multi-file-save (Save All).
		// Hopefully we can improve in future: https://github.com/Microsoft/vscode/issues/42913
		if (hotReloadDelayTimer) {
			clearTimeout(hotReloadDelayTimer);
		}

		hotReloadDelayTimer = setTimeout(() => {
			hotReloadDelayTimer = undefined;
			commands.executeCommand(commandToRun, { reason: restartReasonSave });
		}, 200);
	}));
开发者ID:DanTup,项目名称:Dart-Code,代码行数:40,代码来源:hot_reload_save_handler.ts


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