All files / src/abap/5_syntax _type_utils.ts

100% Statements 13/13
100% Branches 21/21
100% Functions 1/1
100% Lines 13/13

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 371x     1x                 150x 15x 1x   14x       13x   1x 135x 20x         19x   1x     115x    
import {AnyType, GenericObjectReferenceType, ObjectReferenceType, TableType, UnknownType, VoidType} from "../types/basic";
import {AbstractType} from "../types/basic/_abstract_type";
 
export class TypeUtils {
  // public static isCharLike, todo
  // public static isHexLike, todo
 
  public static isAssignable(source: AbstractType | undefined, target: AbstractType | undefined): boolean {
    /*
    console.dir(source);
    console.dir(target);
*/
    if (target instanceof TableType) {
      if (target.isWithHeader()) {
        return true; // todo
      }
      if (source instanceof TableType
          || source instanceof VoidType
          || source instanceof AnyType
          || source instanceof UnknownType) {
        return true;
      }
      return false;
    } else if (target instanceof ObjectReferenceType || target instanceof GenericObjectReferenceType) {
      if (source instanceof ObjectReferenceType
          || source instanceof GenericObjectReferenceType
          || source instanceof VoidType
          || source instanceof AnyType
          || source instanceof UnknownType) {
        return true;
      }
      return false;
    }
 
    return true;
  }
}