當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript DiagnosticCollection.set方法代碼示例

本文整理匯總了TypeScript中vscode.DiagnosticCollection.set方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript DiagnosticCollection.set方法的具體用法?TypeScript DiagnosticCollection.set怎麽用?TypeScript DiagnosticCollection.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vscode.DiagnosticCollection的用法示例。


在下文中一共展示了DiagnosticCollection.set方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例3: 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

示例4:

	/* internal */ semanticDiagnosticsReceived(event: Proto.DiagnosticEvent): void {
		let body = event.body;
		if (body.diagnostics) {
			let diagnostics = this.createMarkerDatas(body.diagnostics);
			let syntaxMarkers = this.syntaxDiagnostics[body.file];
			if (syntaxMarkers) {
				delete this.syntaxDiagnostics[body.file];
				diagnostics = syntaxMarkers.concat(diagnostics);
			}
			this.currentDiagnostics.set(Uri.file(body.file), diagnostics);
		}
	}
開發者ID:1424667164,項目名稱:vscode,代碼行數:12,代碼來源:typescriptMain.ts

示例5: 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

示例6: configFileDiagnosticsReceived

	public configFileDiagnosticsReceived(file: string, diagnostics: Diagnostic[]): void {
		this.currentDiagnostics.set(Uri.file(file), diagnostics);
	}
開發者ID:fs814,項目名稱:vscode,代碼行數:3,代碼來源:typescriptMain.ts

示例7:

 diagnosticMap.forEach((diags, file) => {
     diagnosticCollection.set(Uri.parse(file), diags);
 });
開發者ID:TravisTheTechie,項目名稱:vscode-write-good,代碼行數:3,代碼來源:extension.ts

示例8: checkVariables

    public async checkVariables(document: TextDocument) {
        if (document.languageId !== 'http' || document.uri.scheme !== 'file') {
            return;
        }

        const diagnostics: Diagnostic[] = [];

        const allAvailableVariables = await VariableProcessor.getAllVariablesDefinitions(document);
        const variableReferences = this.findVariableReferences(document);

        // Variable not found
        [...variableReferences.entries()]
            .filter(([name]) => !allAvailableVariables.has(name))
            .forEach(([, variables]) => {
                variables.forEach(v => {
                    diagnostics.push(
                        new Diagnostic(
                            new Range(new Position(v.lineNumber, v.startIndex), new Position(v.lineNumber, v.endIndex)),
                            `${v.variableName} is not found`,
                            DiagnosticSeverity.Error));
                });
            });

        // Request variable not active
        [...variableReferences.entries()]
            .filter(([name]) =>
                allAvailableVariables.has(name)
                && allAvailableVariables.get(name)[0] === VariableType.Request
                && !RequestVariableCache.has(new RequestVariableCacheKey(name, document.uri.toString())))
            .forEach(([, variables]) => {
                variables.forEach(v => {
                    diagnostics.push(
                        new Diagnostic(
                            new Range(new Position(v.lineNumber, v.startIndex), new Position(v.lineNumber, v.endIndex)),
                            `Request '${v.variableName}' has not been sent`,
                            DiagnosticSeverity.Information));
                });
            });

        // Request variable resolve with warning or error
        [...variableReferences.entries()]
            .filter(([name]) =>
                allAvailableVariables.has(name)
                && allAvailableVariables.get(name)[0] === VariableType.Request
                && RequestVariableCache.has(new RequestVariableCacheKey(name, document.uri.toString())))
            .forEach(([name, variables]) => {
                const value = RequestVariableCache.get(new RequestVariableCacheKey(name, document.uri.toString()));
                variables.forEach(v => {
                    const path = v.variableValue.replace(/^\{{2}\s*/, '').replace(/\s*\}{2}$/, '');
                    const result = RequestVariableCacheValueProcessor.resolveRequestVariable(value, path);
                    if (result.state !== ResolveState.Success) {
                        diagnostics.push(
                            new Diagnostic(
                                new Range(new Position(v.lineNumber, v.startIndex), new Position(v.lineNumber, v.endIndex)),
                                result.message,
                                result.state === ResolveState.Error ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning));
                    }
                });
            });

        this.httpDiagnosticCollection.set(document.uri, diagnostics);
    }
開發者ID:Huachao,項目名稱:vscode-restclient,代碼行數:62,代碼來源:variableDiagnosticsProvider.ts

示例9: syntaxDiagnosticsReceived

	public syntaxDiagnosticsReceived(file: string, diagnostics: Diagnostic[]): void {
		this.syntaxDiagnostics[file] = diagnostics;
		this.currentDiagnostics.set(Uri.file(file), diagnostics);
	}
開發者ID:rajkumar42,項目名稱:vscode,代碼行數:4,代碼來源:typescriptMain.ts

示例10: flushResults

	private flushResults(notification: as.AnalysisFlushResultsNotification) {
		let entries = notification.files.map<[Uri, Diagnostic[]]>(file => [Uri.file(file), undefined]);
		this.diagnostics.set(entries);
	}
開發者ID:ikhwanhayat,項目名稱:Dart-Code,代碼行數:4,代碼來源:dart_diagnostic_provider.ts


注:本文中的vscode.DiagnosticCollection.set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。