• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript vscode.DiagnosticCollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了DiagnosticCollection类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: doValidate

async function doValidate(document: TextDocument) {
	let report = null;

	let documentWasClosed = false; // track whether the document was closed while getInstalledModules/'npm ls' runs
	const listener = workspace.onDidCloseTextDocument(doc => {
		if (doc.uri === document.uri) {
			documentWasClosed = true;
		}
	});

	try {
		report = await getInstalledModules(path.dirname(document.fileName));
	} catch (e) {
		listener.dispose();
		return;
	}
	try {
		diagnosticCollection.clear();

		if (report.invalid && report.invalid === true) {
			return;
		}
		if (!anyModuleErrors(report)) {
			return;
		}
		if (documentWasClosed || !document.getText()) {
			return;
		}
		const sourceRanges = parseSourceRanges(document.getText());
		const dependencies = report.dependencies;
		const diagnostics: Diagnostic[] = [];

		for (var moduleName in dependencies) {
			if (dependencies.hasOwnProperty(moduleName)) {
				const diagnostic = getDiagnostic(document, report, moduleName, sourceRanges);
				if (diagnostic) {
					diagnostic.source = 'npm';
					diagnostics.push(diagnostic);
				}
			}
		}
		//console.log("diagnostic count ", diagnostics.length, " ", document.uri.fsPath);
		diagnosticCollection.set(document.uri, diagnostics);
	} catch (e) {
		window.showInformationMessage(`[npm-script-runner] Cannot validate the package.json ` + e);
		console.log(`npm-script-runner: 'error while validating package.json stacktrace: ${e.stack}`);
	}
}
开发者ID:scytalezero,项目名称:vscode-npm-scripts,代码行数:48,代码来源:main.ts


示例3: resetDiagnostics

function resetDiagnostics() {
    diagnosticCollection.clear();

    diagnosticMap.forEach((diags, file) => {
        diagnosticCollection.set(Uri.parse(file), diags);
    });
}
开发者ID:TravisTheTechie,项目名称:vscode-write-good,代码行数:7,代码来源:extension.ts


示例4: loadConfiguration

function loadConfiguration(context: ExtensionContext): void {
	const section = workspace.getConfiguration('npm');
	if (section) {
		validationEnabled = section.get<boolean>('validate.enable', true);
	}
	diagnosticCollection.clear();

	if (validationEnabled) {
		workspace.onDidSaveTextDocument(document => {
			validateDocument(document);
		}, null, context.subscriptions);
		window.onDidChangeActiveTextEditor(editor => {
			if (editor && editor.document) {
				validateDocument(editor.document);
			}
		}, null, context.subscriptions);

		// remove markers on close
		workspace.onDidCloseTextDocument(_document => {
			diagnosticCollection.clear();
		}, null, context.subscriptions);

		// workaround for onDidOpenTextDocument
		// workspace.onDidOpenTextDocument(document => {
		// 	console.log("onDidOpenTextDocument ", document.fileName);
		// 	validateDocument(document);
		// }, null, context.subscriptions);
		validateAllDocuments();
	}
}
开发者ID:scytalezero,项目名称:vscode-npm-scripts,代码行数:30,代码来源:main.ts


示例5: reInitialize

	public reInitialize(): void {
		this.currentDiagnostics.clear();
		this.syntaxDiagnostics = Object.create(null);
		this.bufferSyncSupport.reOpenDocuments();
		this.bufferSyncSupport.requestAllDiagnostics();

	}
开发者ID:AntonovMM,项目名称:vscode,代码行数:7,代码来源:typescriptMain.ts


示例6: semanticDiagnosticsReceived

	public semanticDiagnosticsReceived(file: string, diagnostics: Diagnostic[]): void {
		let syntaxMarkers = this.syntaxDiagnostics[file];
		if (syntaxMarkers) {
			delete this.syntaxDiagnostics[file];
			diagnostics = syntaxMarkers.concat(diagnostics);
		}
		this.currentDiagnostics.set(Uri.file(file), diagnostics);
	}
开发者ID:fs814,项目名称:vscode,代码行数:8,代码来源:typescriptMain.ts


示例7: handleErrors

	private handleErrors(notification: as.AnalysisErrorsNotification) {
		let errors = notification.errors;
		if (!config.showTodos)
			errors = errors.filter((error) => error.type != "TODO");
		this.diagnostics.set(
			Uri.file(notification.file), 
			errors.map(e => this.createDiagnostic(e))
		);
	}
开发者ID:ikhwanhayat,项目名称:Dart-Code,代码行数:9,代码来源:dart_diagnostic_provider.ts


示例8:

	/* internal */ populateService(): void {
		this.currentDiagnostics.clear();
		this.syntaxDiagnostics = Object.create(null);
		// See https://github.com/Microsoft/TypeScript/issues/5530
		workspace.saveAll(false).then((value) => {
			this.bufferSyncSupports.forEach(support => {
				support.reOpenDocuments();
				support.requestAllDiagnostics();
			});
		});
	}
开发者ID:1424667164,项目名称:vscode,代码行数:11,代码来源:typescriptMain.ts


示例9: updateValidate

	private updateValidate(value: boolean) {
		if (this._validate === value) {
			return;
		}
		this._validate = value;
		this.bufferSyncSupport.validate = value;
		if (value) {
			this.triggerAllDiagnostics();
		} else {
			this.syntaxDiagnostics = Object.create(null);
			this.currentDiagnostics.clear();
		}
	}
开发者ID:fs814,项目名称:vscode,代码行数:13,代码来源:typescriptMain.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript vscode.Disposable类代码示例发布时间:2022-05-25
下一篇:
TypeScript vscode.CancellationTokenSource类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap