Package com._1c.g5.v8.dt.bsl.model.util
Class BslUtil
java.lang.Object
com._1c.g5.v8.dt.bsl.model.util.BslUtil
Useful utility methods to work with Bsl model.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Collection<DeclareStatement>
Gets allDeclareStatement
fromPreprocessorItem
static <T extends org.eclipse.emf.ecore.EObject>
List<T>allDeclareStatements
(org.eclipse.emf.ecore.EObject block) Gets allDeclareStatement
fromBlock
static Collection<Method>
allMethods
(PreprocessorItem item) Gets allMethod
fromPreprocessorItem
static <T extends org.eclipse.emf.ecore.EObject>
List<T>allMethods
(org.eclipse.emf.ecore.EObject module) static Collection<Statement>
Gets allStatement
fromPreprocessorItem
static <T extends org.eclipse.emf.ecore.EObject>
List<T>allStatements
(org.eclipse.emf.ecore.EObject block) static boolean
canBeEventHandlerByParamCounts
(Method method, ParamSet paramSet, int additionalIndex) Check Built-In language method that it can be event handler in form by parametersstatic List<IfPreprocessor>
getAllIfPreprocessors
(org.eclipse.emf.ecore.EObject module) Gets allIfPreprocessor
fromModule
static List<IfPreprocessor>
getAllIfPreprocessorsFromBlock
(org.eclipse.emf.ecore.EObject block) Gets allIfPreprocessor
fromBlock
static List<LabeledStatement>
getAllLabeledStatements
(Block block) Retrieves all instances ofLabeledStatement
contained in theblock
.static <T extends org.eclipse.emf.ecore.EObject>
List<T>getAllPreprocessorItems
(org.eclipse.emf.ecore.EObject preprocessor) Gets allPreprocessorItem
formPreprocessor
static List<RegionPreprocessor>
getAllRegionPreprocessors
(org.eclipse.emf.ecore.EObject module) Gets allRegionPreprocessor
fromModule
static List<RegionPreprocessor>
getAllRegionPreprocessorsFromBlock
(org.eclipse.emf.ecore.EObject block) Gets allIfPreprocessor
fromBlock
getEffectivePragmas
(PragmaTarget pragmaTarget) Returns effective pragmas forPragmaTarget
instance.
Effective pragmas are computed by following algorithm:
- if many-valued referencepragmas
ofPragmaTarget
instance contains at least one item, value of this reference is returned
- otherwise function attempts to findModule
containingPragmaTarget
.static Invocation
Determeines whether passed in the parameterFeatureAccess
is invocation target.static Invocation
getInvocation
(FeatureEntry entry) Determeines whether passed in the parameterFeatureEntry
is invocation target.static int
getMaxCountOfParameters
(Method method) Get maximum number of parameters of bsl methodstatic int
getMinCountOfParameters
(Method method) Get minimum number of parameters of bsl methodstatic String
getPragmaValue
(Pragma pragma) Gets content of the feature "value" ofPragma
by its original content without service symbols ('"')getStringLiteralContent
(StringLiteral literal, boolean trim) Gets content of the StringLiteral by its lines without service symbols ('"', '|')static boolean
hasEffectivePragma
(PragmaTarget pragmaTarget, String... symbols) Function determines if effective pragmas ofPragmaTarget
instance contains at least onePragma
withsymbol
equal (ignoring case) to one ofsymbols
.static boolean
hasPragma
(PragmaTarget pragmaTarget, String... symbols) Function determines ifPragmaTarget
instance contains at least onePragma
withsymbol
equal (ignoring case) to at least one ofsymbols
.static boolean
Checks thatfeatrue
corresponding to the feature of global property 'Metadata' with name 'ObjectProperties'static boolean
Checks availability ofEvent
for mobile applicationstatic boolean
isEmptyPreprocessorItem
(org.eclipse.emf.ecore.EObject item) ChecksPreprocessorItem
for emptystatic boolean
isEventHandler
(FeatureEntry entry) Determines whether passedFeatureEntry
represents referense to the event handler method.static boolean
Determines whether passedStaticFeatureAccess
represents referense to the event handler method.static boolean
Determines whether passedInvocation
is procedure invocation or not.static boolean
Determines whether passed in the parameter instance ofStaticFeatureAccess
is target of assignment.static boolean
Checks access to system enum property
-
Constructor Details
-
BslUtil
public BslUtil()
-
-
Method Details
-
getAllLabeledStatements
Retrieves all instances ofLabeledStatement
contained in theblock
.- Parameters:
block
- block. May not benull
.- Returns:
- list of
LabeledStatement
instances.
-
getInvocation
Determeines whether passed in the parameterFeatureAccess
is invocation target. If so returnsInvocation
instance. Otherwise returnsnull
.- Parameters:
instance
- ofFeatureAccess
. May not benull
.- Returns:
- instance of
Invocation
ornull
if passedFeatureAccess
isn't invocation target.
-
getInvocation
Determeines whether passed in the parameterFeatureEntry
is invocation target. If so returnsInvocation
instance. Otherwise returnsnull
.- Parameters:
instance
- ofFeatureEntry
. May not benull
.- Returns:
- instance of
Invocation
ornull
if passedFeatureEntry
isn't invocation target.
-
isProcedureInvocation
Determines whether passedInvocation
is procedure invocation or not. Procedure invocation is invocation not requiring return value.- Parameters:
inv
- instance ofInvocation
. May not benull
.- Returns:
true
if passedInvocation
is procedure invocation. Otherwisefalse
.
-
isEventHandler
Determines whether passedStaticFeatureAccess
represents referense to the event handler method.- Parameters:
acc
- instance ofStaticFeatureAccess
. May not benull
.- Returns:
true
if passedStaticFeatureAccess
refers to the eventHandler
method. Otherwisefalse
.
-
isEventHandler
Determines whether passedFeatureEntry
represents referense to the event handler method.- Parameters:
acc
- instance ofFeatureEntry
. May not benull
.- Returns:
true
if passedFeatureEntry
refers to the eventHandler
method. Otherwisefalse
.
-
isTargetOfAssignment
Determines whether passed in the parameter instance ofStaticFeatureAccess
is target of assignment.- Parameters:
acc
- instance ofStaticFeatureAccess
. May benull
.- Returns:
true
if passedStaticFeatureAccess
is target of assignment. Otherwisefalse
.
-
getEffectivePragmas
Returns effective pragmas forPragmaTarget
instance.
Effective pragmas are computed by following algorithm:
- if many-valued referencepragmas
ofPragmaTarget
instance contains at least one item, value of this reference is returned
- otherwise function attempts to findModule
containingPragmaTarget
. IfModule
found, value of it'sdefaultPragmas
reference is returned
- otherwise function returns empty list- Parameters:
pragmaTarget
-PragmaTarget
instnace. Can't benull
.- Returns:
- list of effective pragmas. Client sholdn't modify this list.
-
hasPragma
Function determines ifPragmaTarget
instance contains at least onePragma
withsymbol
equal (ignoring case) to at least one ofsymbols
.- Parameters:
pragmaTarget
-PragmaTarget
instance. Can't benull
.symbols
- array of symbols. Can't benull
- Returns:
true
ifPragmaTarget
contains at leastPragma
withsymbol
equal to at least one ofsymbols
.
-
hasEffectivePragma
Function determines if effective pragmas ofPragmaTarget
instance contains at least onePragma
withsymbol
equal (ignoring case) to one ofsymbols
.- Parameters:
pragmaTarget
-PragmaTarget
instance. Can't benull
.symbols
- array of symbols. Can't benull
- Returns:
true
if effective pragmas ofPragmaTarget
contains at least onePragma
withsymbol
equal to at least one ofsymbols
.
-
isEmptyPreprocessorItem
public static boolean isEmptyPreprocessorItem(org.eclipse.emf.ecore.EObject item) ChecksPreprocessorItem
for empty- Parameters:
item
-- Returns:
true
, ifPreprocessorItem
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) -
allDeclareStatements
public static <T extends org.eclipse.emf.ecore.EObject> List<T> allDeclareStatements(org.eclipse.emf.ecore.EObject block) Gets allDeclareStatement
fromBlock
- Parameters:
module
- processBlock
. Can't benull
- Returns:
- list of
DeclareStatement
-
allStatements
public static <T extends org.eclipse.emf.ecore.EObject> List<T> allStatements(org.eclipse.emf.ecore.EObject block) -
getAllPreprocessorItems
public static <T extends org.eclipse.emf.ecore.EObject> List<T> getAllPreprocessorItems(org.eclipse.emf.ecore.EObject preprocessor) Gets allPreprocessorItem
formPreprocessor
- Parameters:
preprocessor
- processingPreprocessor
. Can't benull
- Returns:
- list of all
PreprocessorItem
-
getAllIfPreprocessors
Gets allIfPreprocessor
fromModule
- Parameters:
module
- Bsl module. Can't benull
- Returns:
- list of
IfPreprocessor
-
getAllIfPreprocessorsFromBlock
public static List<IfPreprocessor> getAllIfPreprocessorsFromBlock(org.eclipse.emf.ecore.EObject block) Gets allIfPreprocessor
fromBlock
- Parameters:
block
- block in Bsl module. Can't benull
- Returns:
- list of
IfPreprocessor
-
getAllRegionPreprocessors
public static List<RegionPreprocessor> getAllRegionPreprocessors(org.eclipse.emf.ecore.EObject module) Gets allRegionPreprocessor
fromModule
- Parameters:
module
- Bsl module. Can't benull
- Returns:
- list of
RegionPreprocessor
-
getAllRegionPreprocessorsFromBlock
public static List<RegionPreprocessor> getAllRegionPreprocessorsFromBlock(org.eclipse.emf.ecore.EObject block) Gets allIfPreprocessor
fromBlock
- Parameters:
block
- block in Bsl module. Can't benull
- Returns:
- list of
IfPreprocessor
-
allMethods
Gets allMethod
fromPreprocessorItem
- Parameters:
item
-PreprocessorItem
- Returns:
- list of
Method
fromPreprocessorItem
-
allStatements
Gets allStatement
fromPreprocessorItem
- Parameters:
item
-PreprocessorItem
- Returns:
- list of
Statement
fromPreprocessorItem
-
allDeclareStatements
Gets allDeclareStatement
fromPreprocessorItem
- Parameters:
item
-PreprocessorItem
- Returns:
- list of
DeclareStatement
fromPreprocessorItem
-
getMinCountOfParameters
Get minimum number of parameters of bsl method- Parameters:
method
- actual bsl method, can't benull
- Returns:
- minimum number of parameters of bsl method
-
getMaxCountOfParameters
Get maximum number of parameters of bsl method- Parameters:
method
- actual bsl method, can't benull
- 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 -
isAllowedForMobileApplication
Checks availability ofEvent
for mobile application- Parameters:
event
- checking event, can't benull
- Returns:
true
ifEvent
available for mobile application,false
otherwise
-
isValidAccessToSysEnumProperty
Checks access to system enum property- Parameters:
feature
-DynamicFeatureAccess
whichDynamicFeatureAccess.getSource()
corresponding to the system enum type, can't benull
- Returns:
true
if access to system enum value get through system enum global property,false
otherwise
-
isAccessToObjectPropertiesOfMetadata
Checks thatfeatrue
corresponding to the feature of global property 'Metadata' with name 'ObjectProperties'- Parameters:
feature
- checkingDynamicFeatureAccess
, can't benull
- Returns:
true
iffeatrue
corresponding to the feature of global property 'Metadata' with name 'ObjectProperties',false
otherwise
-
getStringLiteralContent
Gets content of the StringLiteral by its lines without service symbols ('"', '|')- Parameters:
literal
- processingStringLiteral
, can't benull
trim
- defines needing to removing leading and trailing whitespace- Returns:
- list of string line without service symbols, never
null
-
getPragmaValue
Gets content of the feature "value" ofPragma
by its original content without service symbols ('"')
-