Class StaticExpressionValueComputer

java.lang.Object
com._1c.g5.v8.dt.internal.bsl.resource.StaticExpressionValueComputer
All Implemented Interfaces:
IStaticExpressionValueComputer

public class StaticExpressionValueComputer extends Object implements IStaticExpressionValueComputer
The computer allow to get various types of string static content from code. This computer supports only simple binary operations and variable assignments, so it returns only single and statically computed string content. In case of cycles or some variable computing logic of string concatenation this computer should brake and return null.
  • Constructor Details

    • StaticExpressionValueComputer

      @Inject public StaticExpressionValueComputer(TypesComputer typesComputer)
      Instantiates a new static expression value computer.
      Parameters:
      typesComputer - the types computer, cannot be null.
  • Method Details

    • getStringContent

      public IStringLiteralTextProvider getStringContent(org.eclipse.emf.ecore.EObject expression)
      Description copied from interface: IStaticExpressionValueComputer
      Gets the static string content of the expression.
      Specified by:
      getStringContent in interface IStaticExpressionValueComputer
      Parameters:
      expression - the expression, may be null.
      Returns:
      the expression string content and its source string literals, can return null Returns null if the expression is null or computing logic of content is not static (variable result), untyped code and etc.
    • getStructureOfStrings

      public Map<String,org.eclipse.xtext.util.Pair<IStringLiteralTextProvider,IStringLiteralTextProvider>> getStructureOfStrings(org.eclipse.emf.ecore.EObject expression)
      Description copied from interface: IStaticExpressionValueComputer
      Gets the 1C structure (aka Map<String, String>) with string content in keys and values for the given expression. This method computes all insertion of to the structure in current method.
      Specified by:
      getStructureOfStrings in interface IStaticExpressionValueComputer
      Parameters:
      expression - the expression, may be null.
      Returns:
      the structure expression string content, where map entry key is structure key and map entry value is a pair of key string literal text provider and 1C structure value string literal text provider, which may be null. Cannot return null.
    • getArrayOfStrings

      public List<IStringLiteralTextProvider> getArrayOfStrings(org.eclipse.emf.ecore.EObject expression)
      Description copied from interface: IStaticExpressionValueComputer
      Gets the list of string content for the expression that is Array in 1C code with adding strings to the array.
      Specified by:
      getArrayOfStrings in interface IStaticExpressionValueComputer
      Parameters:
      expression - the expression, may be null.
      Returns:
      the list of string content, cannot return null.
    • getBooleanContent

      public BooleanLiteral getBooleanContent(org.eclipse.emf.ecore.EObject expression)
      Description copied from interface: IStaticExpressionValueComputer
      Gets the boolean literal from the code.
      Specified by:
      getBooleanContent in interface IStaticExpressionValueComputer
      Parameters:
      expression - the expression, may be null.
      Returns:
      the boolean literal or returns null if cannot be computed due different reasons, including dynamic or variable result, untyped code and etc.
    • getNumberContent

      public org.eclipse.xtext.util.Pair<Double,Collection<NumberLiteral>> getNumberContent(org.eclipse.emf.ecore.EObject expression)
      Description copied from interface: IStaticExpressionValueComputer
      Gets the number content from the code.
      Specified by:
      getNumberContent in interface IStaticExpressionValueComputer
      Parameters:
      expression - the expression, may be null.
      Returns:
      the resulting number of all arithmetical operations of each NumberLiteral from the code and all number literals computing this value, or returns null if static value cannot be computed due different resons including dynamic or variable result, untyped code and etc.
    • getStringExpressionContent

      protected IStringLiteralTextProvider getStringExpressionContent(StaticFeatureAccess fa)
      Gets the expression string content for static feature access.
      Parameters:
      fa - the static feature access, cannot be null.
      Returns:
      the expression string content provider, can return null.
    • getStringExpressionContent

      protected IStringLiteralTextProvider getStringExpressionContent(BinaryExpression bo)
      Gets the computed string content for binary expression.
      Parameters:
      bo - the binary expression, cannot be null.
      Returns:
      the expression string content and source string literals, can return null.
    • getStringExpressionContent

      protected IStringLiteralTextProvider getStringExpressionContent(Invocation inv)
      Gets the string expression content.
      Parameters:
      inv - the invocation, may be null.
      Returns:
      the string expression content and source string literals, can return null.
    • getStringExpressionContent

      protected IStringLiteralTextProvider getStringExpressionContent(Function function)
      Gets the string expression content by the function return value if content is static.
      Parameters:
      function - the function, may be null.
      Returns:
      the string expression content and source string literals, can return null.
    • getStructureExpressionContent

      protected Map<String,org.eclipse.xtext.util.Pair<IStringLiteralTextProvider,IStringLiteralTextProvider>> getStructureExpressionContent(OperatorStyleCreator osc)
      Gets the structure expression string content for operator style creator of new structure.
      Parameters:
      osc - the operator style creator of new structure, cannot be null.
      Returns:
      the structure expression string content, where map entry key is structure key and map entry value is triple of string literal of the structure key, structure string value for this key and string literal of the structure value, cannot return null.
    • getStructureExpressionContent

      protected Map<String,org.eclipse.xtext.util.Pair<IStringLiteralTextProvider,IStringLiteralTextProvider>> getStructureExpressionContent(StaticFeatureAccess fa)
      Gets the structure expression string content for static feature access of the structure.
      Parameters:
      fa - the static feature access, cannot be null.
      Returns:
      the structure expression string content, where map entry key is structure key and map entry value is triple of string literal of the structure key, structure string value for this key and string literal of the structure value, cannot return null.
    • getArrayExpressionContent

      protected List<IStringLiteralTextProvider> getArrayExpressionContent(OperatorStyleCreator osc)
      Gets the list of string content for operator style creator of array.
      Parameters:
      osc - the operator style creator of array, cannot be null.
      Returns:
      the list of string content, cannot return null.
    • getArrayExpressionContent

      protected List<IStringLiteralTextProvider> getArrayExpressionContent(StaticFeatureAccess fa)
      Gets the list of string content for static feature access
      Parameters:
      fa - the static feature access, cannot be null.
      Returns:
      the list of string content providers, cannot return null.
    • getAllStatementsBefore

      protected List<? extends Statement> getAllStatementsBefore(StaticFeatureAccess fa)
      Gets the all statements in current scope: method or module statements. All statements should be before the StaticFeatureAccess.
      Parameters:
      fa - the static feature access, cannot be null.
      Returns:
      the all statements, cannot return null.
    • getBooleanContent

      protected BooleanLiteral getBooleanContent(StaticFeatureAccess fa)
      Gets the boolean content for the static feature access by last variable simple statement.
      Parameters:
      fa - the static feature access, cannot be null.
      Returns:
      the boolean content, can return null if cannot compute boolean.
    • getBooleanContent

      protected BooleanLiteral getBooleanContent(Invocation inv)
      Gets the boolean content of the invocation function.
      Parameters:
      inv - the invocation, cannot be null.
      Returns:
      the boolean content, can return null if cannot compute boolean.
    • getBooleanContent

      protected BooleanLiteral getBooleanContent(Function function)
      Gets the boolean content for the function return value.
      Parameters:
      function - the function, cannot be null.
      Returns:
      the boolean content, can return null if cannot compute boolean.
    • getNumberContent

      protected org.eclipse.xtext.util.Pair<Double,Collection<NumberLiteral>> getNumberContent(StaticFeatureAccess fa)
      Gets the number content and it's source number literals for the static feature access.
      Parameters:
      fa - the static feature access, cannot be null.
      Returns:
      the number content and collection of source literals, may return null if cannot compute the value.
    • getNumberContent

      protected org.eclipse.xtext.util.Pair<Double,Collection<NumberLiteral>> getNumberContent(BinaryExpression bo)
      Gets the number content and it's source number literals for the binary expression: PLUS, MINUS, MULITPLY, DIVIDE and MODULO
      Parameters:
      bo - the binary expression, cannot be null.
      Returns:
      the number content and collection of source literals, may return null if cannot be computed.
    • getNumberContent

      protected org.eclipse.xtext.util.Pair<Double,Collection<NumberLiteral>> getNumberContent(Invocation inv)
      Gets the number content and source literals for the local invocation of the function.
      Parameters:
      inv - the invocation, may not be null.
      Returns:
      the number content and collection of source literals, may return null if cannot be computed.
    • getNumberContent

      protected org.eclipse.xtext.util.Pair<Double,Collection<NumberLiteral>> getNumberContent(Function function)
      Gets the number content and source literals for the local function.
      Parameters:
      function - the function, may not be null.
      Returns:
      the number content and collection of source literals, may return null if cannot be computed.