Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
}
}
diagnostics.forEach(diagnostic => {
let { source, code, severity, message } = diagnostic
let s = getSeverityName(severity)[0]
let str = `[${source}${code ? ' ' + code : ''}] [${s}] ${message}`
let filetype = 'Error'
if (ft === '') {
switch (diagnostic.severity) {
case DiagnosticSeverity.Hint:
filetype = 'Hint'
break
case DiagnosticSeverity.Warning:
filetype = 'Warning'
break
case DiagnosticSeverity.Information:
filetype = 'Info'
break
}
} else {
filetype = ft
}
docs.push({ filetype, content: str })
})
if (useFloat) {
public setDiagnosticInfo(bufnr: number, diagnostics: ReadonlyArray): void {
let lnums = [0, 0, 0, 0]
let info = { error: 0, warning: 0, information: 0, hint: 0, lnums }
for (let diagnostic of diagnostics) {
switch (diagnostic.severity) {
case DiagnosticSeverity.Warning:
info.warning = info.warning + 1
lnums[1] = lnums[1] || diagnostic.range.start.line + 1
break
case DiagnosticSeverity.Information:
info.information = info.information + 1
lnums[2] = lnums[2] || diagnostic.range.start.line + 1
break
case DiagnosticSeverity.Hint:
info.hint = info.hint + 1
lnums[3] = lnums[3] || diagnostic.range.start.line + 1
break
default:
lnums[0] = lnums[0] || diagnostic.range.start.line + 1
info.error = info.error + 1
}
}
this.nvim.call('coc#util#set_buf_var', [this.bufnr, 'coc_diagnostic_info', info], true)
if (bufnr == this.bufnr) {
this.nvim.call('coc#util#do_autocmd', ['CocDiagnosticChange'], true)
}
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
}
}
export function getSeverityName(severity: DiagnosticSeverity): string {
switch (severity) {
case DiagnosticSeverity.Error:
return 'Error'
case DiagnosticSeverity.Warning:
return 'Warning'
case DiagnosticSeverity.Information:
return 'Information'
case DiagnosticSeverity.Hint:
return 'Hint'
default:
return 'Error'
}
}
this.client.diagnosticsManager.diagnosticsReceived(diagnosticsKind, file.toString(), diagnostics.filter(diag => {
if (!reportUnnecessary) {
diag.tags = undefined
if (diag.reportUnnecessary && diag.severity === DiagnosticSeverity.Information) {
return false
}
}
return true
}))
}