All files / src/abap/5_syntax/structures class_data.ts

100% Statements 37/37
100% Branches 7/7
100% Functions 1/1
100% Lines 37/37

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 381x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 6x 6x 6x 6x 6x 19x 19x 6x 6x 6x 6x 6x 19x 1x 1x 1x 1x 1x 1x 19x 19x 6x 6x 6x 1x  
import * as Expressions from "../../2_statements/expressions";
import * as Statements from "../../2_statements/statements";
import * as Structures from "../../3_structures/structures";
import {StructureNode, StatementNode} from "../../nodes";
import {IdentifierMeta, TypedIdentifier} from "../../types/_typed_identifier";
import {IStructureComponent} from "../../types/basic";
import * as Basic from "../../types/basic";
import {ClassData as ClassDataSyntax} from "../statements/class_data";
import {SyntaxInput} from "../_syntax_input";
 
export class ClassData {
  public runSyntax(node: StructureNode, input: SyntaxInput): TypedIdentifier | undefined {
    const name = node.findFirstExpression(Expressions.NamespaceSimpleName)!.getFirstToken();
    const values: any = {};
 
    const components: IStructureComponent[] = [];
    for (const c of node.getChildren()) {
      const ctyp = c.get();
      if (c instanceof StatementNode && ctyp instanceof Statements.ClassData) {
        const found = new ClassDataSyntax().runSyntax(c, input);
        if (found) {
          components.push({name: found.getName(), type: found.getType()});
          values[found.getName()] = found.getValue() as string;
        }
      } else if (c instanceof StructureNode && ctyp instanceof Structures.ClassData) {
        const found = new ClassData().runSyntax(c, input);
        if (found) {
          components.push({name: found.getName(), type: found.getType()});
          values[found.getName()] = found.getValue();
        }
      }
      // todo, INCLUDES
    }
 
    return new TypedIdentifier(name, input.filename, new Basic.StructureType(components), [IdentifierMeta.Static], values);
  }
}