import { Diagnostic , Position , Range , DiagnosticCollection , languages , Uri , workspace , TextDocument } from 'vscode' ; export function buildDiagnosticsByFilePath ( componentFailures ) { let diagnosticsByFilePath = { } ; for ( let componentFailure of componentFailures ) { if ( ! diagnosticsByFilePath [ componentFailure . fullPath ] ) { diagnosticsByFilePath [ componentFailure . fullPath ] = [ ] ; } let diagnostic = buildDiagnostic ( componentFailure ) ; diagnosticsByFilePath [ componentFailure . fullPath ] . push ( diagnostic ) ; } return diagnosticsByFilePath ; } export function buildDiagnostic ( componentFailure ) { let lineNumber = 0 ; let columnNumber = 0 ; if ( componentFailure . lineNumber ) { lineNumber = componentFailure . lineNumber - 1 ; } if ( componentFailure . columnNumber ) { columnNumber = componentFailure . columnNumber - 1 ; } let start = new Position ( lineNumber , columnNumber ) ; let end = new Position ( lineNumber + 1 , 0 ) ; let range = new Range ( start , end ) ; if ( componentFailure . document ) { let document = componentFailure . document ; let wordRange = document . getWordRangeAtPosition ( start ) ; if ( wordRange ) { range = wordRange ; } } let newDiagnostic = new Diagnostic ( range , componentFailure . problem ) ; return newDiagnostic ; }