import * as vscode from "vscode" ; import { expressionsDiagnosticsSource } from "../../common" ; import { DeploymentDocument } from "../documents/DeploymentDocument" ; import { Issue } from "../language/Issue" ; import { getVSCodeRangeFromSpan } from "./vscodePosition" ; export function toVSCodeDiagnosticFromIssue ( deploymentDocument , issue , severity ) { const range = getVSCodeRangeFromSpan ( deploymentDocument , issue . span ) ; const message = issue . message ; let diagnostic = new vscode . Diagnostic ( range , message , severity ) ; diagnostic . source = expressionsDiagnosticsSource ; diagnostic . code = "" ; if ( issue . isUnnecessaryCode ) { diagnostic . tags = [ vscode . DiagnosticTag . Unnecessary ] ; } if ( issue . relatedInformation . length > 0 ) { diagnostic . relatedInformation = issue . relatedInformation . map ( ri => new vscode . DiagnosticRelatedInformation ( new vscode . Location ( ri . location . uri , getVSCodeRangeFromSpan ( deploymentDocument , ri . location . span ) ) , ri . message ) ) ; } return diagnostic ; }