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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 29x 29x 14x 14x 29x 29x 29x 29x 29x 29x 29x 29x 4x 4x 4x 2x 2x 2x 4x 29x 27x 27x 2x 27x 25x 25x 27x 27x 27x 27x 27x 3x 3x 3x 3x 27x 22x 22x 27x 29x 26x 29x 26x 29x 6x 6x 26x 26x 1x | import * as Expressions from "../../2_statements/expressions";
import {StatementNode} from "../../nodes";
import {Target} from "../expressions/target";
import {Source} from "../expressions/source";
import {ComponentCompare} from "../expressions/component_compare";
import {ComponentCond} from "../expressions/component_cond";
import {StatementSyntax} from "../_statement_syntax";
import {ILookupResult} from "../../../ddic";
import {AbstractType} from "../../types/basic/_abstract_type";
import {TableAccessType, TableType, VoidType} from "../../types/basic";
import {SyntaxInput, syntaxIssue} from "../_syntax_input";
export class DeleteInternal implements StatementSyntax {
public runSyntax(node: StatementNode, input: SyntaxInput): void {
for (const s of node.findDirectExpressions(Expressions.Source)) {
Source.runSyntax(s, input);
}
let targetType: AbstractType | undefined = undefined;
const target = node.findDirectExpression(Expressions.Target);
if (target) {
const targetName = target.concatTokens();
let tabl: ILookupResult | undefined = undefined;
const localVariable = input.scope.findVariable(targetName);
if (localVariable === undefined && node.getChildren().length === 5 && node.getChildren()[2].concatTokens().toUpperCase() === "FROM") {
// it might be a database table
const found = input.scope.getDDIC()?.lookupTableOrView(targetName);
if (found?.object !== undefined) {
tabl = found;
input.scope.getDDICReferences().addUsing(input.scope.getParentObj(), {object: tabl.object});
}
}
if (tabl === undefined) {
const ambigiousVoids = input.scope.getRegistry().getConfig().getSyntaxSetttings().ambigiousVoids || [];
if (ambigiousVoids.some(name => name.toUpperCase() === targetName.toUpperCase())) {
targetType = VoidType.get(targetName);
} else {
targetType = Target.runSyntax(target, input);
}
if (node.findDirectTokenByText("TABLE") === undefined
&& node.findDirectTokenByText("ADJACENT") === undefined
&& (node.findDirectTokenByText("FROM") || node.findDirectTokenByText("INDEX"))
&& targetType instanceof TableType
&& targetType.getAccessType() === TableAccessType.hashed) {
const message = "Implicit or explicit index operation on hashed table is not possible";
input.issues.push(syntaxIssue(input, node.getFirstToken(), message));
return;
}
if (targetType instanceof TableType) {
targetType = targetType.getRowType();
}
}
}
for (const t of node.findDirectExpressions(Expressions.ComponentCompare)) {
ComponentCompare.runSyntax(t, input, targetType);
}
for (const t of node.findDirectExpressions(Expressions.ComponentCond)) {
ComponentCond.runSyntax(t, input, targetType);
}
}
}
|