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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1331x 1331x 1331x 1x 1x 1x 1x 63x 63x 63x 55x 55x 8x 8x 8x 8x | import {Issue} from "../../issue";
import {Severity} from "../../severity";
import {IEdit} from "../../edit_helper";
import {AbstractToken} from "../1_lexer/tokens/abstract_token";
import {CurrentScope} from "./_current_scope";
export const CheckSyntaxKey = "check_syntax";
// note: these typically doesnt change during the traversal
// so nothing to garbage collect
export type SyntaxInput = {
scope: CurrentScope,
filename: string,
issues: Issue[],
/** checks which can only run once the full object has been traversed, eg. PERFORM parameters,
* the FORM might be defined after the PERFORM */
deferred: (() => void)[],
/** the statement is inside a LOOP structure */
inLoop?: boolean,
};
export function syntaxIssue(input: SyntaxInput, token: AbstractToken, message: string, fix?: IEdit) {
return Issue.atTokenFilename(input.filename, token, message, CheckSyntaxKey, Severity.Error, fix);
}
/** the name in front of "=>" is looked up as a class or interface only, data objects are not considered.
* Call when no class or interface of the name was found: if a data object of the name is visible,
* it is not an unknown global class, so report it. Returns true if an issue was added */
export function dataObjectBeforeStaticArrow(input: SyntaxInput, token: AbstractToken): boolean {
const name = token.getStr();
if (input.scope.findVariable(name) === undefined) {
return false;
}
const message = `"${name}" is not a class or interface, => cannot be used with a data object`;
input.issues.push(syntaxIssue(input, token, message));
return true;
}
|