public final class PatternLanguageHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AGGREGATE_VARIABLE_PREFIX |
Modifier and Type | Method and Description |
---|---|
static java.util.List<IInputKey> |
calculateExpectedTypes(CallableRelation relation,
ITypeSystem typeSystem,
ITypeInferrer typeInferrer)
Returns the list of expected types for a given callable relation
|
static PVisibility |
calculatePVisibility(Pattern pattern) |
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.List<PackageImport> |
getAllPackageImports(PatternModel model)
Initializes a new list of package imports defined in a selected pattern model
|
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 java.util.List<ValueReference> |
getCallParameters(CallableRelation relation)
Extracts the parameters from a given callable relation
|
static java.lang.Iterable<org.eclipse.emf.ecore.EPackage> |
getEPackageImportsIterable(PatternModel model)
Returns an iterable of imported EPackages in a selected pattern model.
|
static java.util.Optional<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.Iterable<PackageImport> |
getPackageImportsIterable(PatternModel model)
Returns an iterable of package imports in a selected pattern model.
|
static java.lang.String |
getPackageName(Pattern pattern)
Returns the name of the container package of the selected pattern
|
static java.util.Optional<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.LinkedHashMap<java.lang.String,IInputKey> |
getParameterVariables(CallableRelation relation,
ITypeSystem typeSystem,
ITypeInferrer typeInferrer)
Returns the parameters required to call the mentioned patterns with their corresponding types.
|
static java.util.Optional<org.eclipse.emf.ecore.EClassifier> |
getPathExpressionEMFTailType(PathExpressionConstraint expression) |
static java.util.Optional<ReferenceType> |
getPathExpressionTailType(PathExpressionConstraint expression) |
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,
java.util.function.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.stream.Stream<VariableReference> |
getReferences(Variable var)
Returns a stream of all references from a given variable
|
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 |
isNegative(CallableRelation call)
Decides whether a call is negative
|
static boolean |
isNonSimpleConstraint(CallableRelation constraint) |
static boolean |
isParameter(Expression ex) |
static boolean |
isPrivate(Pattern pattern) |
static boolean |
isTransitive(CallableRelation call)
Decides whether a call is transitive or reflexive transitive
|
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 PVisibility calculatePVisibility(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 java.util.Optional<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, java.util.function.Predicate<Pattern> filter)
pattern
- the source patternorderPatterns
- if true, the returned set will be ordered based on the call edgesfilter
- the filter predicatepublic static java.util.Optional<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 java.util.stream.Stream<VariableReference> getReferences(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)
public static java.util.List<PackageImport> getAllPackageImports(PatternModel model)
model
- public static java.lang.Iterable<PackageImport> getPackageImportsIterable(PatternModel model)
public static java.lang.Iterable<org.eclipse.emf.ecore.EPackage> getEPackageImportsIterable(PatternModel model)
public static java.util.Optional<ReferenceType> getPathExpressionTailType(PathExpressionConstraint expression)
public static java.util.Optional<org.eclipse.emf.ecore.EClassifier> getPathExpressionEMFTailType(PathExpressionConstraint expression)
public static java.util.List<ValueReference> getCallParameters(CallableRelation relation)
public static java.util.LinkedHashMap<java.lang.String,IInputKey> getParameterVariables(CallableRelation relation, ITypeSystem typeSystem, ITypeInferrer typeInferrer)
relation
- public static java.util.List<IInputKey> calculateExpectedTypes(CallableRelation relation, ITypeSystem typeSystem, ITypeInferrer typeInferrer)
public static boolean isNonSimpleConstraint(CallableRelation constraint)
public static boolean isNegative(CallableRelation call)
public static boolean isTransitive(CallableRelation call)