Class BslUtil


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

      • BslUtil

        public BslUtil()
    • Method Detail

      • 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​(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.
      • 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
      • 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
      • 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
      • 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