Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | 7x 7x 7x 7x 7x 7x 7x 10x 10x 10x 10x 10x 2x 2x 1x 1x 1x 7x 2x 2x 7x 7x 7x 4x 7x 16x 16x 16x 5x 11x 10x 1x 10x 10x | // Copyright (c) 2017-2022 The VSCode C/C++ Flylint Authors
//
// SPDX-License-Identifier: MIT
import * as path from 'path';
import * as _ from 'lodash';
import { FlexelintSeverityMaps, Settings, VS_DiagnosticSeverity } from '../settings';
import { headerExts, Linter } from './linter';
import { InternalDiagnostic } from '../server';
import { path as sysPath } from '../utils';
import { DiagnosticSeverity } from 'vscode-languageserver/node';
export class Flexelint extends Linter {
constructor(settings: Settings, workspaceRoot: string) {
super('Flexelint', settings, workspaceRoot, true);
this.cascadeCommonSettings('flexelint');
this.executable = settings.flexelint.executable;
this.configFile = settings.flexelint.configFile;
this.active = this.enabled = settings.flexelint.enable;
}
protected buildCommandLine(fileName: string, _tmpFileName: string): string[] {
var args = [
this.executable,
'-v',
'-b',
'-format=%f %l %c %t %n: %m',
this.configFile,
'-hsFr_1',
'-width(4096,0)',
'-zero(400)',
];
if (headerExts.indexOf(path.extname(fileName)) !== -1) {
var hArgs = this.settings.flexelint.headerArgs;
Iif (_.isString(hArgs)) {
args.push(hArgs);
} else {
hArgs.forEach(element => {
args.push(element);
});
}
}
args.push(sysPath(fileName));
return args;
}
protected transformParse(currentParsed: InternalDiagnostic | null, parsed: InternalDiagnostic | null) {
if (parsed) {
Iif ((parsed['code'] === '830' && parsed['message'] !== 'Location cited in prior message') || (parsed['code'] === '831' && parsed['message'] !== 'Reference cited in prior message')) {
currentParsed!['line'] = parsed['line'];
currentParsed!['column'] = parsed['column'];
parsed = null;
} else if (parsed['code'] === '830' || parsed['code'] === '831') {
parsed = null;
}
}
return { currentParsed: currentParsed, parsed: parsed };
}
protected parseLine(line: string): InternalDiagnostic | null {
let regex = /^(.+?)\s\s([0-9]+)\s([0-9]+\s)?\s(Info|Warning|Error|Note)\s([0-9]+):\s(.*)$/;
let regexArray: RegExpExecArray | null;
let excludeRegex = /^((During Specific Walk:|\s\sFile\s).*|)$/;
if (excludeRegex.exec(line) !== null) {
// skip this line
return null;
}
if ((regexArray = regex.exec(line)) !== null) {
return {
fileName: regexArray[1],
line: parseInt(regexArray[2]) - 1,
column: 0,
severity: this.getSeverityCode(regexArray[4]),
code: regexArray[5],
message: regexArray[6],
source: this.name,
};
} else {
return {
parseError: 'Line could not be parsed: ' + line,
fileName: '',
line: 0,
column: 0,
severity: DiagnosticSeverity.Error,
code: 0,
message: '',
source: this.name
};
}
}
private getSeverityCode(severity: string): DiagnosticSeverity {
let output = this.settings.flexelint.severityLevels[severity as keyof FlexelintSeverityMaps];
return VS_DiagnosticSeverity.from(output);
}
}
|