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 classBslUtil.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 allDeclareStatementfromPreprocessorItemstatic <T extends org.eclipse.emf.ecore.EObject>
List<T>allDeclareStatements(org.eclipse.emf.ecore.EObject block)Gets allDeclareStatementfromBlockstatic Collection<Method>allMethods(PreprocessorItem item)Gets allMethodfromPreprocessorItemstatic <T extends org.eclipse.emf.ecore.EObject>
List<T>allMethods(org.eclipse.emf.ecore.EObject module)static Collection<Statement>allStatements(PreprocessorItem item)Gets allStatementfromPreprocessorItemstatic <T extends org.eclipse.emf.ecore.EObject>
List<T>allStatements(org.eclipse.emf.ecore.EObject block)static booleancanBeEventHandlerByParamCounts(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 allIfPreprocessorfromModulestatic List<IfPreprocessor>getAllIfPreprocessorsFromBlock(org.eclipse.emf.ecore.EObject block)Gets allIfPreprocessorfromBlockstatic List<LabeledStatement>getAllLabeledStatements(Block block)Retrieves all instances ofLabeledStatementcontained in theblock.static <T extends org.eclipse.emf.ecore.EObject>
List<T>getAllPreprocessorItems(org.eclipse.emf.ecore.EObject preprocessor)Gets allPreprocessorItemformPreprocessorstatic List<RegionPreprocessor>getAllRegionPreprocessors(org.eclipse.emf.ecore.EObject module)Gets allRegionPreprocessorfromModulestatic List<RegionPreprocessor>getAllRegionPreprocessorsFromBlock(org.eclipse.emf.ecore.EObject block)Gets allIfPreprocessorfromBlockstatic List<Pragma>getEffectivePragmas(PragmaTarget pragmaTarget)Returns effective pragmas forPragmaTargetinstance.
Effective pragmas are computed by following algorithm:
- if many-valued referencepragmasofPragmaTargetinstance contains at least one item, value of this reference is returned
- otherwise function attempts to findModulecontainingPragmaTarget.static InvocationgetInvocation(FeatureAccess acc)Determeines whether passed in the parameterFeatureAccessis invocation target.static InvocationgetInvocation(FeatureEntry entry)Determeines whether passed in the parameterFeatureEntryis invocation target.static intgetMaxCountOfParameters(Method method)Get maximum number of parameters of bsl methodstatic intgetMinCountOfParameters(Method method)Get minimum number of parameters of bsl methodstatic StringgetPragmaValue(Pragma pragma)Gets content of the feature "value" ofPragmaby 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 booleanhasEffectivePragma(PragmaTarget pragmaTarget, String... symbols)Function determines if effective pragmas ofPragmaTargetinstance contains at least onePragmawithsymbolequal (ignoring case) to one ofsymbols.static booleanhasPragma(PragmaTarget pragmaTarget, String... symbols)Function determines ifPragmaTargetinstance contains at least onePragmawithsymbolequal (ignoring case) to at least one ofsymbols.static booleanisAccessToObjectPropertiesOfMetadata(DynamicFeatureAccess feature)Checks thatfeatruecorresponding to the feature of global property 'Metadata' with name 'ObjectProperties'static booleanisAllowedForMobileApplication(Event event)Checks availability ofEventfor mobile applicationstatic booleanisEmptyPreprocessorItem(org.eclipse.emf.ecore.EObject item)ChecksPreprocessorItemfor emptystatic booleanisEventHandler(FeatureEntry entry)Determines whether passedFeatureEntryrepresents referense to the event handler method.static booleanisEventHandler(StaticFeatureAccess acc)Determines whether passedStaticFeatureAccessrepresents referense to the event handler method.static booleanisProcedureInvocation(Invocation inv)Determines whether passedInvocationis procedure invocation or not.static booleanisTargetOfAssignment(StaticFeatureAccess acc)Determines whether passed in the parameter instance ofStaticFeatureAccessis target of assignment.static booleanisValidAccessToSysEnumProperty(DynamicFeatureAccess feature)Checks access to system enum property
-
-
-
Method Detail
-
getAllLabeledStatements
public static List<LabeledStatement> getAllLabeledStatements(Block block)
Retrieves all instances ofLabeledStatementcontained in theblock.- Parameters:
block- block. May not benull.- Returns:
- list of
LabeledStatementinstances.
-
getInvocation
public static Invocation getInvocation(FeatureAccess acc)
Determeines whether passed in the parameterFeatureAccessis invocation target. If so returnsInvocationinstance. Otherwise returnsnull.- Parameters:
instance- ofFeatureAccess. May not benull.- Returns:
- instance of
Invocationornullif passedFeatureAccessisn't invocation target.
-
getInvocation
public static Invocation getInvocation(FeatureEntry entry)
Determeines whether passed in the parameterFeatureEntryis invocation target. If so returnsInvocationinstance. Otherwise returnsnull.- Parameters:
instance- ofFeatureEntry. May not benull.- Returns:
- instance of
Invocationornullif passedFeatureEntryisn't invocation target.
-
isProcedureInvocation
public static boolean isProcedureInvocation(Invocation inv)
Determines whether passedInvocationis procedure invocation or not. Procedure invocation is invocation not requiring return value.- Parameters:
inv- instance ofInvocation. May not benull.- Returns:
trueif passedInvocationis procedure invocation. Otherwisefalse.
-
isEventHandler
public static boolean isEventHandler(StaticFeatureAccess acc)
Determines whether passedStaticFeatureAccessrepresents referense to the event handler method.- Parameters:
acc- instance ofStaticFeatureAccess. May not benull.- Returns:
trueif passedStaticFeatureAccessrefers to the eventHandlermethod. Otherwisefalse.
-
isEventHandler
public static boolean isEventHandler(FeatureEntry entry)
Determines whether passedFeatureEntryrepresents referense to the event handler method.- Parameters:
acc- instance ofFeatureEntry. May not benull.- Returns:
trueif passedFeatureEntryrefers to the eventHandlermethod. Otherwisefalse.
-
isTargetOfAssignment
public static boolean isTargetOfAssignment(StaticFeatureAccess acc)
Determines whether passed in the parameter instance ofStaticFeatureAccessis target of assignment.- Parameters:
acc- instance ofStaticFeatureAccess. May benull.- Returns:
trueif passedStaticFeatureAccessis target of assignment. Otherwisefalse.
-
getEffectivePragmas
public static List<Pragma> getEffectivePragmas(PragmaTarget pragmaTarget)
Returns effective pragmas forPragmaTargetinstance.
Effective pragmas are computed by following algorithm:
- if many-valued referencepragmasofPragmaTargetinstance contains at least one item, value of this reference is returned
- otherwise function attempts to findModulecontainingPragmaTarget. IfModulefound, value of it'sdefaultPragmasreference is returned
- otherwise function returns empty list- Parameters:
pragmaTarget-PragmaTargetinstnace. 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 ifPragmaTargetinstance contains at least onePragmawithsymbolequal (ignoring case) to at least one ofsymbols.- Parameters:
pragmaTarget-PragmaTargetinstance. Can't benull.symbols- array of symbols. Can't benull- Returns:
trueifPragmaTargetcontains at leastPragmawithsymbolequal to at least one ofsymbols.
-
hasEffectivePragma
public static boolean hasEffectivePragma(PragmaTarget pragmaTarget, String... symbols)
Function determines if effective pragmas ofPragmaTargetinstance contains at least onePragmawithsymbolequal (ignoring case) to one ofsymbols.- Parameters:
pragmaTarget-PragmaTargetinstance. Can't benull.symbols- array of symbols. Can't benull- Returns:
trueif effective pragmas ofPragmaTargetcontains at least onePragmawithsymbolequal to at least one ofsymbols.
-
isEmptyPreprocessorItem
public static boolean isEmptyPreprocessorItem(org.eclipse.emf.ecore.EObject item)
ChecksPreprocessorItemfor empty- Parameters:
item-- Returns:
true, ifPreprocessorItemnull, 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 allDeclareStatementfromBlock- 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 allPreprocessorItemformPreprocessor- Parameters:
preprocessor- processingPreprocessor. Can't benull- Returns:
- list of all
PreprocessorItem
-
getAllIfPreprocessors
public static List<IfPreprocessor> getAllIfPreprocessors(org.eclipse.emf.ecore.EObject module)
Gets allIfPreprocessorfromModule- Parameters:
module- Bsl module. Can't benull- Returns:
- list of
IfPreprocessor
-
getAllIfPreprocessorsFromBlock
public static List<IfPreprocessor> getAllIfPreprocessorsFromBlock(org.eclipse.emf.ecore.EObject block)
Gets allIfPreprocessorfromBlock- 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 allRegionPreprocessorfromModule- Parameters:
module- Bsl module. Can't benull- Returns:
- list of
RegionPreprocessor
-
getAllRegionPreprocessorsFromBlock
public static List<RegionPreprocessor> getAllRegionPreprocessorsFromBlock(org.eclipse.emf.ecore.EObject block)
Gets allIfPreprocessorfromBlock- Parameters:
block- block in Bsl module. Can't benull- Returns:
- list of
IfPreprocessor
-
allMethods
public static Collection<Method> allMethods(PreprocessorItem item)
Gets allMethodfromPreprocessorItem- Parameters:
item-PreprocessorItem- Returns:
- list of
MethodfromPreprocessorItem
-
allStatements
public static Collection<Statement> allStatements(PreprocessorItem item)
Gets allStatementfromPreprocessorItem- Parameters:
item-PreprocessorItem- Returns:
- list of
StatementfromPreprocessorItem
-
allDeclareStatements
public static Collection<DeclareStatement> allDeclareStatements(PreprocessorItem item)
Gets allDeclareStatementfromPreprocessorItem- Parameters:
item-PreprocessorItem- Returns:
- list of
DeclareStatementfromPreprocessorItem
-
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 ofEventfor mobile application- Parameters:
event- checking event, can't benull- Returns:
trueifEventavailable for mobile application,falseotherwise
-
isValidAccessToSysEnumProperty
public static boolean isValidAccessToSysEnumProperty(DynamicFeatureAccess feature)
Checks access to system enum property- Parameters:
feature-DynamicFeatureAccesswhichDynamicFeatureAccess.getSource()corresponding to the system enum type, can't benull- Returns:
trueif access to system enum value get through system enum global property,falseotherwise
-
isAccessToObjectPropertiesOfMetadata
public static boolean isAccessToObjectPropertiesOfMetadata(DynamicFeatureAccess feature)
Checks thatfeatruecorresponding to the feature of global property 'Metadata' with name 'ObjectProperties'- Parameters:
feature- checkingDynamicFeatureAccess, can't benull- Returns:
trueiffeatruecorresponding to the feature of global property 'Metadata' with name 'ObjectProperties',falseotherwise
-
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 benulltrim- defines needing to removing leading and trailing whitespace- Returns:
- list of string line without service symbols, never
null
-
-