Package com._1c.g5.v8.dt.bsl.model.util
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BslUtil.BslMethodContainerAdapter
-
Constructor Summary
Constructors Constructor Description BslUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Collection<DeclareStatement>
allDeclareStatements(PreprocessorItem item)
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>
allStatements(PreprocessorItem item)
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
static List<Pragma>
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
getInvocation(FeatureAccess acc)
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 ('"')static List<String>
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
isAccessToObjectPropertiesOfMetadata(DynamicFeatureAccess feature)
Checks thatfeatrue
corresponding to the feature of global property 'Metadata' with name 'ObjectProperties'static boolean
isAllowedForMobileApplication(Event event)
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
isEventHandler(StaticFeatureAccess acc)
Determines whether passedStaticFeatureAccess
represents referense to the event handler method.static boolean
isProcedureInvocation(Invocation inv)
Determines whether passedInvocation
is procedure invocation or not.static boolean
isTargetOfAssignment(StaticFeatureAccess acc)
Determines whether passed in the parameter instance ofStaticFeatureAccess
is target of assignment.static boolean
isValidAccessToSysEnumProperty(DynamicFeatureAccess feature)
Checks access to system enum property
-
-
-
Method Detail
-
getAllLabeledStatements
public static List<LabeledStatement> getAllLabeledStatements(Block block)
Retrieves all instances ofLabeledStatement
contained in theblock
.- Parameters:
block
- block. May not benull
.- Returns:
- list of
LabeledStatement
instances.
-
getInvocation
public static Invocation getInvocation(FeatureAccess acc)
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
public static Invocation getInvocation(FeatureEntry entry)
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
public static boolean isProcedureInvocation(Invocation inv)
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
public static boolean isEventHandler(StaticFeatureAccess acc)
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
public static boolean isEventHandler(FeatureEntry entry)
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
public static boolean isTargetOfAssignment(StaticFeatureAccess acc)
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
public static List<Pragma> 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
. 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
public static boolean hasPragma(PragmaTarget pragmaTarget, String... symbols)
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
public 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
.- 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
public static List<IfPreprocessor> getAllIfPreprocessors(org.eclipse.emf.ecore.EObject module)
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
public static Collection<Method> allMethods(PreprocessorItem item)
Gets allMethod
fromPreprocessorItem
- Parameters:
item
-PreprocessorItem
- Returns:
- list of
Method
fromPreprocessorItem
-
allStatements
public static Collection<Statement> allStatements(PreprocessorItem item)
Gets allStatement
fromPreprocessorItem
- Parameters:
item
-PreprocessorItem
- Returns:
- list of
Statement
fromPreprocessorItem
-
allDeclareStatements
public static Collection<DeclareStatement> allDeclareStatements(PreprocessorItem item)
Gets allDeclareStatement
fromPreprocessorItem
- Parameters:
item
-PreprocessorItem
- Returns:
- list of
DeclareStatement
fromPreprocessorItem
-
getMinCountOfParameters
public static int getMinCountOfParameters(Method method)
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
public static int getMaxCountOfParameters(Method method)
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
public static boolean isAllowedForMobileApplication(Event event)
Checks availability ofEvent
for mobile application- Parameters:
event
- checking event, can't benull
- Returns:
true
ifEvent
available for mobile application,false
otherwise
-
isValidAccessToSysEnumProperty
public static boolean isValidAccessToSysEnumProperty(DynamicFeatureAccess feature)
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
public static boolean isAccessToObjectPropertiesOfMetadata(DynamicFeatureAccess feature)
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
public static List<String> getStringLiteralContent(StringLiteral literal, boolean trim)
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
-
-