本文整理汇总了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);
}
}
示例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);
}));