/** * @param varName * @return */ private static Variable initializeLocalVariable(String varName) { Variable decl; decl = PatternLanguageFactory.eINSTANCE.createVariable(); decl.setName(varName); return decl; }
/** * @param var * @return */ private static ParameterRef initializeParameterRef(Variable var) { ParameterRef refVar = PatternLanguageFactory.eINSTANCE.createParameterRef(); refVar.setName(var.getName()); // refVar.setType(var.getType()); refVar.setReferredParam(var); return refVar; }
public Annotation getAnnotationObject(String annotationName) { Annotation annotation = PatternLanguageFactory.eINSTANCE.createAnnotation(); annotation.setName(annotationName); return annotation; }
public boolean isDeprecated(AnnotationParameter parameter) { Annotation annotation = (Annotation) parameter.eContainer(); return isDeprecated(annotation.getName(), parameter.getName()); }
/** * Returns the name of the container package of the selected pattern * @return a name of the pattern; never null, but may be empty string */ public static String getPackageName(Pattern pattern) { if(pattern == null || pattern.eIsProxy()) { return ""; } PatternModel patternModel = (PatternModel) pattern.eContainer(); return (patternModel == null) ? null : patternModel.getPackageName(); }
private boolean isEqualVariables(Variable variable, VariableReference variableReference) { if (variable != null && variableReference != null) { final Variable variableReferenceVariable = variableReference.getVariable(); if (equal(variable, variableReferenceVariable) || equal(variable.getName(), variableReferenceVariable.getName())) { return true; } } return false; }
/** Compiles a map for name-based lookup of symbolic parameter positions. */ public static Map<String, Integer> getParameterPositionsByName(Pattern pattern) { EList<Variable> parameters = pattern.getParameters(); Map<String, Integer> posMapping = new HashMap<String, Integer>(); int parameterPosition = 0; for (Variable parameter : parameters) { posMapping.put(parameter.getName(), parameterPosition++); } return posMapping; }
private String getVariableName(Variable variable, PatternModelAcceptor<?> acceptor) { if (variable instanceof ParameterRef) // handle referenced parameter variables return getVariableName(((ParameterRef) variable).getReferredParam(), acceptor); // assumed to be non-null else { return variable.getName(); } }
private String prettyPrintPatternCall(PatternCall call) { return (isNegativePatternCall(call) ? "neg " : "") + call.getPatternRef().getName(); }
@Override public EClassifier getExplicitClassifierForPatternParameterVariable(Variable variable) { if (variable instanceof ParameterRef) { Variable referredParameter = ((ParameterRef) variable).getReferredParam(); return getClassifierForType(referredParameter.getType()); } else { return getClassifierForType(variable.getType()); } }
@Override public String apply(final Variable it) { return it.getName(); } };
private boolean isNegativePatternCall(PatternCall call) { return (call.eContainer() instanceof PatternCompositionConstraint && ((PatternCompositionConstraint) call .eContainer()).isNegative()); }
public AnnotationParameter getAnnotationParameter(Annotation annotation, String parameterName) { AnnotationParameter parameter = PatternLanguageFactory.eINSTANCE.createAnnotationParameter(); parameter.setName(parameterName); annotation.getParameters().add(parameter); return parameter; }
/** * @param pattern * @return true if the pattern has a private modifier, false otherwise. */ public static boolean isPrivate(Pattern pattern) { for (Modifiers mod : pattern.getModifiers()) { if (mod.isPrivate()) { return true; } } return false; }
/** * @return the string describing a metamodel type, for debug / exception purposes */ private String typeStr(Type type) { return type.getTypename() == null ? "(null)" : type.getTypename(); }
public String getDescription(AnnotationParameter parameter) { Annotation annotation = (Annotation) parameter.eContainer(); return getDescription(annotation.getName(), parameter.getName()); }
@Override public String apply(Variable variable) { return variable.getName(); } });
public String apply(final Variable var) { return var.getName(); } });
@Override public String apply(Variable var) { return var.getName(); } });