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

83.33% Statements 20/24
88.88% Branches 8/9
100% Functions 1/1
83.33% Lines 20/24

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 241x 1x 1x 1x 1x 1x 1x 13x 13x 13x 13x 13x 4x 4x 9x 13x         9x 9x 9x 1x
import {INode} from "../../nodes/_inode";
import {AnyType, DataReference, DataType, UnknownType, VoidType} from "../../types/basic";
import {AbstractType} from "../../types/basic/_abstract_type";
import {CheckSyntaxKey, SyntaxInput, syntaxIssue} from "../_syntax_input";
 
export class Dereference {
  public runSyntax(node: INode, type: AbstractType | undefined, input: SyntaxInput): AbstractType | undefined {
    if (type instanceof VoidType
        || type instanceof AnyType
        || type instanceof DataType
        || type === undefined
        || type instanceof UnknownType) {
      return type;
    }
 
    if (!(type instanceof DataReference)) {
      const message = "Not a data reference, cannot be dereferenced";
      input.issues.push(syntaxIssue(input, node.getFirstToken(), message));
      return new VoidType(CheckSyntaxKey);
    }
 
    return type.getType();
  }
}