Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let parseLine = (line: string): void => {
if (startRegex.test(line)) {
this.setStatus(TscStatus.COMPILING)
entries = new Map()
} else if (errorRegex.test(line)) {
let ms = line.match(errorRegex)
let severity = /error/.test(ms[4]) ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning
let lnum = Number(ms[2]) - 1
let character = Number(ms[3]) - 1
let range = Range.create(lnum, character, lnum, character)
let uri = Uri.file(path.join(cwd, ms[1])).toString()
let diagnostics = entries.get(uri) || []
diagnostics.push(Diagnostic.create(range, ms[6], severity, ms[5], 'tsc'))
entries.set(uri, diagnostics)
} else if (countRegex.test(line)) {
let ms = line.match(countRegex)
if (ms[1] == '0') {
entries = new Map()
this.setStatus(TscStatus.RUNNING)
this.collection.clear()
uris = new Set()
return
}
) {
return DiagnosticSeverity.Warning
}
switch (diagnostic.category) {
case PConst.DiagnosticCategory.error:
return DiagnosticSeverity.Error
case PConst.DiagnosticCategory.warning:
return DiagnosticSeverity.Warning
case PConst.DiagnosticCategory.suggestion:
return DiagnosticSeverity.Information
default:
return DiagnosticSeverity.Error
}
}
export function getSeverityType(severity: DiagnosticSeverity): string {
switch (severity) {
case DiagnosticSeverity.Error:
return 'E'
case DiagnosticSeverity.Warning:
return 'W'
case DiagnosticSeverity.Information:
return 'I'
case DiagnosticSeverity.Hint:
return 'I'
default:
return 'Error'
}
}
private getDiagnosticSeverity(diagnostic: Proto.Diagnostic): DiagnosticSeverity {
if (
this.reportStyleCheckAsWarnings &&
this.isStyleCheckDiagnostic(diagnostic.code) &&
diagnostic.category === PConst.DiagnosticCategory.error
) {
return DiagnosticSeverity.Warning
}
switch (diagnostic.category) {
case PConst.DiagnosticCategory.error:
return DiagnosticSeverity.Error
case PConst.DiagnosticCategory.warning:
return DiagnosticSeverity.Warning
case PConst.DiagnosticCategory.suggestion:
return DiagnosticSeverity.Information
default:
return DiagnosticSeverity.Error
}
}
) {
return DiagnosticSeverity.Warning
}
switch (diagnostic.category) {
case PConst.DiagnosticCategory.error:
return DiagnosticSeverity.Error
case PConst.DiagnosticCategory.warning:
return DiagnosticSeverity.Warning
case PConst.DiagnosticCategory.suggestion:
return DiagnosticSeverity.Information
default:
return DiagnosticSeverity.Error
}
}
public setConfigurationErrors(init?: boolean): void {
let collections = this.collections
let collection = collections.find(o => o.name == 'config')
if (!collection) {
collection = this.create('config')
} else {
collection.clear()
}
let { errorItems } = workspace.configurations
if (errorItems && errorItems.length) {
if (init) workspace.showMessage(`settings file parse error, run ':CocList diagnostics'`, 'error')
let entries: Map = new Map()
for (let item of errorItems) {
let { uri } = item.location
let diagnostics: Diagnostic[] = entries.get(uri) || []
diagnostics.push(Diagnostic.create(item.location.range, item.message, DiagnosticSeverity.Error))
entries.set(uri, diagnostics)
}
collection.set(Array.from(entries))
}
}
private getDiagnosticSeverity(diagnostic: Proto.Diagnostic): DiagnosticSeverity {
if (
this.reportStyleCheckAsWarnings &&
this.isStyleCheckDiagnostic(diagnostic.code) &&
diagnostic.category === PConst.DiagnosticCategory.error
) {
return DiagnosticSeverity.Warning
}
switch (diagnostic.category) {
case PConst.DiagnosticCategory.error:
return DiagnosticSeverity.Error
case PConst.DiagnosticCategory.warning:
return DiagnosticSeverity.Warning
case PConst.DiagnosticCategory.suggestion:
return DiagnosticSeverity.Information
default:
return DiagnosticSeverity.Error
}
}