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

83.33% Statements 25/30
50% Branches 2/4
100% Functions 1/1
83.33% Lines 25/30

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 301x 1x 1x 1x 1x 1x 1x 1x 1x 1x 74x 74x 74x 74x 1x 1x 1x 74x 74x 74x 74x 74x 74x           74x 1x
import {ExpressionNode} from "../../nodes";
import * as Expressions from "../../2_statements/expressions";
import {TypedIdentifier, IdentifierMeta} from "../../types/_typed_identifier";
import {UnknownType} from "../../types/basic";
import {AbstractType} from "../../types/basic/_abstract_type";
import {ReferenceType} from "../_reference";
import {SyntaxInput, syntaxIssue} from "../_syntax_input";
 
export class InlineFS {
  public static runSyntax(node: ExpressionNode, input: SyntaxInput, type: AbstractType | undefined): void {
    const token = node.findFirstExpression(Expressions.TargetFieldSymbol)?.getFirstToken();
 
    const fs = node.findFirstExpression(Expressions.FieldSymbol);
    if (fs && fs.concatTokens().length > 30) {
      const message = "FIELD-SYMBOLS name too long, " + fs.concatTokens();
      input.issues.push(syntaxIssue(input, fs.getFirstToken(), message));
    }
 
    if (token && type) {
      const identifier = new TypedIdentifier(token, input.filename, type, [IdentifierMeta.InlineDefinition]);
      input.scope.addIdentifier(identifier);
      input.scope.addReference(token, identifier, ReferenceType.DataWriteReference, input.filename);
    } else if (token) {
      const message = "InlineFS, could not determine type for \"" + token.getStr() + "\"";
      const identifier = new TypedIdentifier(token, input.filename, new UnknownType(message), [IdentifierMeta.InlineDefinition]);
      input.scope.addIdentifier(identifier);
      input.scope.addReference(token, identifier, ReferenceType.DataWriteReference, input.filename);
    }
  }
}