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 | 1x 1x 1x 1x 1x 1x 1x 442x 99x 99x 343x 343x 343x 343x 442x 337x 337x 3x 3x 3x 334x 334x 6x 442x 5x 5x 5x 5x 5x 5x 5x 5x 5x 1x 442x 1x 1x 1x 1x 1x | import {INode} from "../../nodes/_inode";
import {AbstractType} from "../../types/basic/_abstract_type";
import * as Basic from "../../types/basic";
import {CheckSyntaxKey, SyntaxInput, syntaxIssue} from "../_syntax_input";
export class ComponentName {
public static runSyntax(context: AbstractType | undefined, node: INode, input: SyntaxInput): AbstractType | undefined {
if (context instanceof Basic.VoidType) {
return context;
}
const nameToken = node.getFirstToken();
const name = nameToken.getStr();
if (context instanceof Basic.StructureType) {
const ret = context.getComponentByName(name);
if (ret === undefined) {
input.issues.push(syntaxIssue(input, nameToken, "Component \"" + name + "\" not found in structure"));
return Basic.VoidType.get(CheckSyntaxKey);
}
return ret;
}
if (context instanceof Basic.TableType && context.isWithHeader() === true) {
const rowType = context.getRowType();
if (rowType instanceof Basic.VoidType) {
return context;
} else if (name.toUpperCase() === "TABLE_LINE") {
return rowType;
} else if (rowType instanceof Basic.StructureType) {
const ret = rowType.getComponentByName(name);
if (ret === undefined) {
input.issues.push(syntaxIssue(input, nameToken, "Component \"" + name + "\" not found in structure"));
return Basic.VoidType.get(CheckSyntaxKey);
}
return ret;
}
}
if (!(context instanceof Basic.UnknownType)) {
input.issues.push(syntaxIssue(input, nameToken, "Not a structure, ComponentName, \"" + name + "\", (" + context?.constructor.name + ")"));
}
return Basic.VoidType.get(CheckSyntaxKey);
}
} |