public final class CorePatternLanguageHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AGGREGATE_VARIABLE_PREFIX |
Modifier and Type | Method and Description |
---|---|
static PatternBody |
containerPatternBody(ValueReference val) |
static java.util.Map<java.lang.String,java.lang.Object> |
evaluateAnnotationParameters(Annotation annotation)
Retains the first parameter of each parameter name.
|
static com.google.common.collect.LinkedHashMultimap<java.lang.String,java.lang.Object> |
evaluateAnnotationParametersWithMultiplicity(Annotation annotation)
Retains all parameters, even those with duplicate names.
|
static java.util.Collection<org.eclipse.xtext.xbase.XExpression> |
getAllTopLevelXBaseExpressions(org.eclipse.emf.ecore.EObject patternOrBody) |
static java.util.Collection<ValueReference> |
getAnnotationParameters(Annotation annotation,
java.lang.String parameterName)
Returns all annotation parameters with a selected name
|
static java.util.Collection<Annotation> |
getAnnotationsByName(Pattern pattern,
java.lang.String name)
Returns the collection of annotations of a pattern by a name.
|
static Annotation |
getFirstAnnotationByName(Pattern pattern,
java.lang.String name)
Returns the first annotation of a given name from a pattern.
|
static ValueReference |
getFirstAnnotationParameter(Annotation annotation,
java.lang.String parameterName)
Returns the first annotation parameter with a selected name.
|
static java.lang.String |
getFullyQualifiedName(Pattern pattern)
Returns the name of the pattern, qualified by package name.
|
static java.util.Set<Variable> |
getLocalReferencesOfParameter(Variable variable) |
static java.lang.String |
getModelFileName(org.eclipse.emf.ecore.EObject object) |
static java.lang.String |
getPackageName(Pattern pattern)
Returns the name of the container package of the selected pattern
|
static Variable |
getParameterByName(Pattern pattern,
java.lang.String name)
Returns the parameter of a pattern by name
|
static java.util.Map<java.lang.String,java.lang.Integer> |
getParameterPositionsByName(Pattern pattern)
Compiles a map for name-based lookup of symbolic parameter positions.
|
static java.util.Set<Pattern> |
getReferencedPatterns(Pattern sourcePattern)
Finds all patterns referenced from the given pattern.
|
static java.util.Set<Pattern> |
getReferencedPatternsTransitive(Pattern pattern)
This method returns a set of patterns that are reachable from the selected pattern through various pattern
composition calls.
|
static java.util.Set<Pattern> |
getReferencedPatternsTransitive(Pattern pattern,
boolean orderPatterns)
This method returns a set of patterns that are reachable from the selected pattern through various pattern
composition calls.
|
static java.util.Set<Pattern> |
getReferencedPatternsTransitive(Pattern pattern,
boolean orderPatterns,
com.google.common.base.Predicate<Pattern> filter)
This method returns a set of patterns that are reachable from the selected pattern through various pattern
composition calls, while each called element fulfills the filter predicate.
|
static java.util.Set<Variable> |
getReferencedPatternVariablesOfXExpression(org.eclipse.xtext.xbase.XExpression xExpression,
org.eclipse.xtext.xbase.jvmmodel.IJvmModelAssociations associations)
Finds all pattern variables referenced from the given XExpression.
|
static java.util.List<Variable> |
getUnnamedRunningVariables(PatternBody patternBody) |
static java.util.List<Variable> |
getUsedVariables(org.eclipse.xtext.xbase.XExpression xExpression,
java.lang.Iterable<Variable> allVariables) |
static <T> T |
getValue(ValueReference ref,
java.lang.Class<T> clazz)
Extracts the value stored by a selected reference
|
static boolean |
getValueOfFirstBooleanAnnotationParameter(Annotation annotation,
java.lang.String parameterName,
boolean defaultValue)
Returns the value of the first Boolean annotation parameter with the given name.
|
static java.util.Set<Variable> |
getVariablesFromValueReference(ValueReference valueReference) |
static boolean |
hasAggregateReference(Variable var)
Returns whether a variable has an aggregate reference.
|
static boolean |
hasXBaseExpression(Pattern pattern) |
static boolean |
isAggregateReference(VariableReference reference)
Returns whether a variable reference is an aggregate reference (e.g.
|
static boolean |
isNamedSingleUse(Variable variable) |
static boolean |
isParameter(Expression ex) |
static boolean |
isPrivate(Pattern pattern) |
static boolean |
isUnnamedSingleUseVariable(Variable variable) |
public static final java.lang.String AGGREGATE_VARIABLE_PREFIX
public static java.lang.String getPackageName(Pattern pattern)
public static java.lang.String getFullyQualifiedName(Pattern pattern)
public static boolean isPrivate(Pattern pattern)
pattern
- public static boolean hasXBaseExpression(Pattern pattern)
pattern
- public static java.util.Collection<org.eclipse.xtext.xbase.XExpression> getAllTopLevelXBaseExpressions(org.eclipse.emf.ecore.EObject patternOrBody)
public static Variable getParameterByName(Pattern pattern, java.lang.String name)
pattern
- name
- public static java.util.Map<java.lang.String,java.lang.Integer> getParameterPositionsByName(Pattern pattern)
public static java.util.Set<Variable> getReferencedPatternVariablesOfXExpression(org.eclipse.xtext.xbase.XExpression xExpression, org.eclipse.xtext.xbase.jvmmodel.IJvmModelAssociations associations)
Warning This method cannot be used in JvmModelInferrer, as that is used to set up the list of available local variables.
public static java.util.List<Variable> getUsedVariables(org.eclipse.xtext.xbase.XExpression xExpression, java.lang.Iterable<Variable> allVariables)
public static java.util.Set<Pattern> getReferencedPatterns(Pattern sourcePattern)
public static java.util.Set<Pattern> getReferencedPatternsTransitive(Pattern pattern)
pattern
- the source patternpublic static java.util.Set<Pattern> getReferencedPatternsTransitive(Pattern pattern, boolean orderPatterns)
pattern
- the source patternorderPatterns
- if true, the returned set will be ordered based on the call edgespublic static java.util.Set<Pattern> getReferencedPatternsTransitive(Pattern pattern, boolean orderPatterns, com.google.common.base.Predicate<Pattern> filter)
pattern
- the source patternorderPatterns
- if true, the returned set will be ordered based on the call edgesfilter
- the filter predicatepublic static Annotation getFirstAnnotationByName(Pattern pattern, java.lang.String name)
getAnnotationsByName(Pattern, String)
pattern
- the pattern instancename
- the name of the annotation to returnpublic static java.util.Collection<Annotation> getAnnotationsByName(Pattern pattern, java.lang.String name)
#getAnnotationByName(Pattern, String)
pattern
- the pattern instancename
- the name of the annotation to returnpublic static java.util.Collection<ValueReference> getAnnotationParameters(Annotation annotation, java.lang.String parameterName)
annotation
- parameterName
- public static ValueReference getFirstAnnotationParameter(Annotation annotation, java.lang.String parameterName)
annotation
- parameterName
- public static boolean getValueOfFirstBooleanAnnotationParameter(Annotation annotation, java.lang.String parameterName, boolean defaultValue)
annotation
- parameterName
- defaultValue
- public static java.util.Set<Variable> getVariablesFromValueReference(ValueReference valueReference)
valueReference
- public static PatternBody containerPatternBody(ValueReference val)
public static java.util.List<Variable> getUnnamedRunningVariables(PatternBody patternBody)
patternBody
- public static com.google.common.collect.LinkedHashMultimap<java.lang.String,java.lang.Object> evaluateAnnotationParametersWithMultiplicity(Annotation annotation)
public static java.util.Map<java.lang.String,java.lang.Object> evaluateAnnotationParameters(Annotation annotation)
public static <T> T getValue(ValueReference ref, java.lang.Class<T> clazz)
ref
- The value reference to extract the value fromclazz
- The class to cast the results; if the value of the reference cannot be expressed with this class, an
IllegalArgumentException
is thrown.public static boolean isParameter(Expression ex)
public static java.util.Set<Variable> getLocalReferencesOfParameter(Variable variable)
public static boolean isAggregateReference(VariableReference reference)
public static boolean hasAggregateReference(Variable var)
public static boolean isNamedSingleUse(Variable variable)
public static boolean isUnnamedSingleUseVariable(Variable variable)
public static java.lang.String getModelFileName(org.eclipse.emf.ecore.EObject object)