mirror of
https://github.com/Microsoft/vscode
synced 2024-07-05 01:08:57 +00:00
extension linter: run parser with no regex error recovery
This commit is contained in:
parent
2add9e8ceb
commit
4c4639b888
|
@ -244,7 +244,7 @@ export class ExtensionLinter {
|
|||
|
||||
findWhens(findNodeAtLocation(contributesNode, ['commands']), 'enablement');
|
||||
|
||||
const parseResults = await commands.executeCommand<(string | undefined)[]>('_parseWhenExpressions', whens.map(w => w.value as string /* we make sure to capture only if `w.value` is string above */));
|
||||
const parseResults = await commands.executeCommand<string[]>('_parseWhenExpressions', whens.map(w => w.value as string /* we make sure to capture only if `w.value` is string above */));
|
||||
|
||||
const diagnostics: Diagnostic[] = [];
|
||||
for (let i = 0; i < parseResults.length; ++i) {
|
||||
|
@ -252,7 +252,8 @@ export class ExtensionLinter {
|
|||
if (parseRes) {
|
||||
const start = whens[i].offset;
|
||||
const end = whens[i].offset + whens[i].length;
|
||||
diagnostics.push(new Diagnostic(new Range(document.positionAt(start), document.positionAt(end)), parseRes, DiagnosticSeverity.Warning));
|
||||
const range = new Range(document.positionAt(start), document.positionAt(end));
|
||||
diagnostics.push(new Diagnostic(range, parseRes, DiagnosticSeverity.Warning));
|
||||
}
|
||||
}
|
||||
return diagnostics;
|
||||
|
|
|
@ -647,16 +647,16 @@ CommandsRegistry.registerCommand('_generateContextKeyInfo', function () {
|
|||
});
|
||||
|
||||
CommandsRegistry.registerCommand('_parseWhenExpressions', (_accessor: ServicesAccessor, whenClauses: string[]) => {
|
||||
const parser = new Parser();
|
||||
const parser = new Parser({ regexParsingWithErrorRecovery: false });
|
||||
return whenClauses.map(whenClause => {
|
||||
parser.parse(whenClause);
|
||||
|
||||
if (parser.lexingErrors.length > 0) {
|
||||
return parser.lexingErrors.map(errToken => Scanner.reportError(errToken));
|
||||
return parser.lexingErrors.map(errToken => Scanner.reportError(errToken)).join('\n');
|
||||
} else if (parser.parsingErrors.length > 0) {
|
||||
return parser.parsingErrors;
|
||||
return parser.parsingErrors.join('\n');
|
||||
} else {
|
||||
return undefined;
|
||||
return '';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user