All files / src/abap/5_syntax/expressions inline_data.ts

66.67% Statements 10/15
60% Branches 6/10
100% Functions 1/1
66.67% Lines 10/15

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  1x   1x 1x   1x   1x   148x 148x 148x 148x 148x                
import {ExpressionNode} from "../../nodes";
import * as Expressions from "../../2_statements/expressions";
import {CurrentScope} from "../_current_scope";
import {TypedIdentifier, IdentifierMeta} from "../../types/_typed_identifier";
import {UnknownType} from "../../types/basic";
import {AbstractType} from "../../types/basic/_abstract_type";
import {ReferenceType} from "../_reference";
 
export class InlineData {
  public runSyntax(node: ExpressionNode, scope: CurrentScope, filename: string, type: AbstractType | undefined): void {
    const token = node.findFirstExpression(Expressions.TargetField)?.getFirstToken();
    Eif (token && type) {
      const identifier = new TypedIdentifier(token, filename, type, [IdentifierMeta.InlineDefinition]);
      scope.addIdentifier(identifier);
      scope.addReference(token, identifier, ReferenceType.DataWriteReference, filename);
    } else if (token) {
      const message = "InlineData, could not determine type for \"" + token.getStr() + "\"";
      const identifier = new TypedIdentifier(token, filename, new UnknownType(message), [IdentifierMeta.InlineDefinition]);
      scope.addIdentifier(identifier);
      scope.addReference(token, identifier, ReferenceType.DataWriteReference, filename);
    }
  }
}