Class BslUtil

java.lang.Object
com._1c.g5.v8.dt.bsl.model.util.BslUtil

public class BslUtil extends Object
Useful utility methods to work with Bsl model.
  • Constructor Details

    • BslUtil

      public BslUtil()
  • Method Details

    • getAllLabeledStatements

      public static List<LabeledStatement> getAllLabeledStatements(Block block)
      Retrieves all instances of LabeledStatement contained in the block.
      Parameters:
      block - block. May not be null.
      Returns:
      list of LabeledStatement instances.
    • getInvocation

      public static Invocation getInvocation(FeatureAccess acc)
      Determeines whether passed in the parameter FeatureAccess is invocation target. If so returns Invocation instance. Otherwise returns null.
      Parameters:
      instance - of FeatureAccess. May not be null.
      Returns:
      instance of Invocation or null if passed FeatureAccess isn't invocation target.
    • getInvocation

      public static Invocation getInvocation(FeatureEntry entry)
      Determeines whether passed in the parameter FeatureEntry is invocation target. If so returns Invocation instance. Otherwise returns null.
      Parameters:
      instance - of FeatureEntry. May not be null.
      Returns:
      instance of Invocation or null if passed FeatureEntry isn't invocation target.
    • isProcedureInvocation

      public static boolean isProcedureInvocation(Invocation inv)
      Determines whether passed Invocation is procedure invocation or not. Procedure invocation is invocation not requiring return value.
      Parameters:
      inv - instance of Invocation. May not be null.
      Returns:
      true if passed Invocation is procedure invocation. Otherwise false.
    • isEventHandler

      public static boolean isEventHandler(StaticFeatureAccess acc)
      Determines whether passed StaticFeatureAccess represents referense to the event handler method.
      Parameters:
      acc - instance of StaticFeatureAccess. May not be null.
      Returns:
      true if passed StaticFeatureAccess refers to the event Handler method. Otherwise false.
    • isEventHandler

      public static boolean isEventHandler(FeatureEntry entry)
      Determines whether passed FeatureEntry represents referense to the event handler method.
      Parameters:
      acc - instance of FeatureEntry. May not be null.
      Returns:
      true if passed FeatureEntry refers to the event Handler method. Otherwise false.
    • isTargetOfAssignment

      public static boolean isTargetOfAssignment(StaticFeatureAccess acc)
      Determines whether passed in the parameter instance of StaticFeatureAccess is target of assignment.
      Parameters:
      acc - instance of StaticFeatureAccess. May be null.
      Returns:
      true if passed StaticFeatureAccess is target of assignment. Otherwise false.
    • getEffectivePragmas

      public static List<Pragma> getEffectivePragmas(PragmaTarget pragmaTarget)
      Returns effective pragmas for PragmaTarget instance.
      Effective pragmas are computed by following algorithm:
      - if many-valued reference pragmas of PragmaTarget instance contains at least one item, value of this reference is returned
      - otherwise function attempts to find Module containing PragmaTarget. If Module found, value of it's defaultPragmas reference is returned
      - otherwise function returns empty list
      Parameters:
      pragmaTarget - PragmaTarget instnace. Can't be null.
      Returns:
      list of effective pragmas. Client sholdn't modify this list.
    • hasPragma

      public static boolean hasPragma(PragmaTarget pragmaTarget, String... symbols)
      Function determines if PragmaTarget instance contains at least one Pragma with symbol equal (ignoring case) to at least one of symbols.
      Parameters:
      pragmaTarget - PragmaTarget instance. Can't be null.
      symbols - array of symbols. Can't be null
      Returns:
      true if PragmaTarget contains at least Pragma with symbol equal to at least one of symbols.
    • hasEffectivePragma

      public static boolean hasEffectivePragma(PragmaTarget pragmaTarget, String... symbols)
      Function determines if effective pragmas of PragmaTarget instance contains at least one Pragma with symbol equal (ignoring case) to one of symbols.
      Parameters:
      pragmaTarget - PragmaTarget instance. Can't be null.
      symbols - array of symbols. Can't be null
      Returns:
      true if effective pragmas of PragmaTarget contains at least one Pragma with symbol equal to at least one of symbols.
    • isEmptyPreprocessorItem

      public static boolean isEmptyPreprocessorItem(org.eclipse.emf.ecore.EObject item)
      Checks PreprocessorItem for empty
      Parameters:
      item -
      Returns:
      true, if PreprocessorItem null, empty or has empty element
    • allMethods

      public static <T extends org.eclipse.emf.ecore.EObject> List<T> allMethods(org.eclipse.emf.ecore.EObject module)
      Gets all Method from Module
      Parameters:
      module - process Module. Can't be null
      Returns:
      collection of Method
    • allDeclareStatements

      public static <T extends org.eclipse.emf.ecore.EObject> List<T> allDeclareStatements(org.eclipse.emf.ecore.EObject block)
      Gets all DeclareStatement from Block
      Parameters:
      module - process Block. Can't be null
      Returns:
      list of DeclareStatement
    • allStatements

      public static <T extends org.eclipse.emf.ecore.EObject> List<T> allStatements(org.eclipse.emf.ecore.EObject block)
      Gets all Statement from Block
      Parameters:
      module - process Block. Can't be null
      Returns:
      list of Statement
    • getAllPreprocessorItems

      public static <T extends org.eclipse.emf.ecore.EObject> List<T> getAllPreprocessorItems(org.eclipse.emf.ecore.EObject preprocessor)
      Parameters:
      preprocessor - processing Preprocessor. Can't be null
      Returns:
      list of all PreprocessorItem
    • getAllIfPreprocessors

      public static List<IfPreprocessor> getAllIfPreprocessors(org.eclipse.emf.ecore.EObject module)
      Gets all IfPreprocessor from Module
      Parameters:
      module - Bsl module. Can't be null
      Returns:
      list of IfPreprocessor
    • getAllIfPreprocessorsFromBlock

      public static List<IfPreprocessor> getAllIfPreprocessorsFromBlock(org.eclipse.emf.ecore.EObject block)
      Gets all IfPreprocessor from Block
      Parameters:
      block - block in Bsl module. Can't be null
      Returns:
      list of IfPreprocessor
    • getAllRegionPreprocessors

      public static List<RegionPreprocessor> getAllRegionPreprocessors(org.eclipse.emf.ecore.EObject module)
      Parameters:
      module - Bsl module. Can't be null
      Returns:
      list of RegionPreprocessor
    • getAllRegionPreprocessorsFromBlock

      public static List<RegionPreprocessor> getAllRegionPreprocessorsFromBlock(org.eclipse.emf.ecore.EObject block)
      Gets all IfPreprocessor from Block
      Parameters:
      block - block in Bsl module. Can't be null
      Returns:
      list of IfPreprocessor
    • allMethods

      public static Collection<Method> allMethods(PreprocessorItem item)
      Gets all Method from PreprocessorItem
      Parameters:
      item - PreprocessorItem
      Returns:
      list of Method from PreprocessorItem
    • allStatements

      public static Collection<Statement> allStatements(PreprocessorItem item)
      Parameters:
      item - PreprocessorItem
      Returns:
      list of Statement from PreprocessorItem
    • allDeclareStatements

      public static Collection<DeclareStatement> allDeclareStatements(PreprocessorItem item)
      Parameters:
      item - PreprocessorItem
      Returns:
      list of DeclareStatement from PreprocessorItem
    • getMinCountOfParameters

      public static int getMinCountOfParameters(Method method)
      Get minimum number of parameters of bsl method
      Parameters:
      method - actual bsl method, can't be null
      Returns:
      minimum number of parameters of bsl method
    • getMaxCountOfParameters

      public static int getMaxCountOfParameters(Method method)
      Get maximum number of parameters of bsl method
      Parameters:
      method - actual bsl method, can't be null
      Returns:
      maximum number of parameters of bsl method
    • canBeEventHandlerByParamCounts

      public static boolean canBeEventHandlerByParamCounts(Method method, ParamSet paramSet, int additionalIndex)
      Check Built-In language method that it can be event handler in form by parameters
      Parameters:
      method - checking Method, can't be null
      paramSet - ParamSet of checking from Event, can't be null
      additionalIndex - special additional parameter index
      Returns:
      true if checking method can be event handler in form for actual Event, false otherwise
    • isAllowedForMobileApplication

      public static boolean isAllowedForMobileApplication(Event event)
      Checks availability of Event for mobile application
      Parameters:
      event - checking event, can't be null
      Returns:
      true if Event available for mobile application, false otherwise
    • isValidAccessToSysEnumProperty

      public static boolean isValidAccessToSysEnumProperty(DynamicFeatureAccess feature)
      Checks access to system enum property
      Parameters:
      feature - DynamicFeatureAccess which DynamicFeatureAccess.getSource() corresponding to the system enum type, can't be null
      Returns:
      true if access to system enum value get through system enum global property, false otherwise
    • isAccessToObjectPropertiesOfMetadata

      public static boolean isAccessToObjectPropertiesOfMetadata(DynamicFeatureAccess feature)
      Checks that featrue corresponding to the feature of global property 'Metadata' with name 'ObjectProperties'
      Parameters:
      feature - checking DynamicFeatureAccess, can't be null
      Returns:
      true if featrue corresponding to the feature of global property 'Metadata' with name 'ObjectProperties', false otherwise
    • getStringLiteralContent

      public static List<String> getStringLiteralContent(StringLiteral literal, boolean trim)
      Gets content of the StringLiteral by its lines without service symbols ('"', '|')
      Parameters:
      literal - processing StringLiteral, can't be null
      trim - defines needing to removing leading and trailing whitespace
      Returns:
      list of string line without service symbols, never null
    • getPragmaValue

      public static String getPragmaValue(Pragma pragma)
      Gets content of the feature "value" of Pragma by its original content without service symbols ('"')
      Parameters:
      pragma - processing Pragma, can't be null
      Returns:
      content of the feature "value" of Pragma by its original content without service symbols ('"'), can be null if original content was null