@Override public boolean apply(Annotation annotation) { return name.equals(annotation.getName()); } }
@Override public Iterable<AnnotationParameter> getUnknownAttributes(Annotation annotation) { final Iterable<String> parameterNames = Iterables.transform(definedAttributes, new AnnotationDefinitionParameterName()); return Iterables.filter(annotation.getParameters(), new Predicate<AnnotationParameter>() { @Override public boolean apply(AnnotationParameter input) { Preconditions.checkNotNull(input, "input"); return !Iterables.contains(parameterNames, input.getName()); } }); }
public Annotation getAnnotationObject(String annotationName) { Annotation annotation = PatternLanguageFactory.eINSTANCE.createAnnotation(); annotation.setName(annotationName); return annotation; }
@Check(CheckType.NORMAL) public void checkAnnotation(Annotation annotation) { if (annotationProvider.hasValidator(annotation.getName())) { IPatternAnnotationValidator validator = annotationProvider.getValidator(annotation.getName()); annotation.getParameters().indexOf(unknownParameter), IssueCodes.UNKNOWN_ANNOTATION_PARAMETER); for (AnnotationParameter parameter : annotation.getParameters()) { Class<? extends ValueReference> expectedParameterType = validator.getExpectedParameterType(parameter); if (expectedParameterType != null && parameter.getValue() != null error(String.format(ANNOTATION_PARAMETER_TYPE_ERROR, getTypeName(parameter.getValue().getClass()), getTypeName(expectedParameterType)), parameter, PatternLanguagePackage.Literals.ANNOTATION_PARAMETER__NAME, annotation.getParameters() .indexOf(parameter), IssueCodes.MISTYPED_ANNOTATION_PARAMETER); } else if (parameter.getValue() instanceof VariableValue) { if (value.getValue().getVariable() == null) { error(String.format("Unknown variable %s", value.getValue().getVar()), parameter, PatternLanguagePackage.Literals.ANNOTATION_PARAMETER__VALUE, annotation.getParameters() .indexOf(parameter), IssueCodes.MISTYPED_ANNOTATION_PARAMETER); warning("Unknown annotation " + annotation.getName(), PatternLanguagePackage.Literals.ANNOTATION__NAME, IssueCodes.UNKNOWN_ANNOTATION);
public String getDescription(Annotation annotation) { return getDescription(annotation.getName()); }
/** * Returns all annotation parameters with a selected name * * @param annotation * @param parameterName * @return a lazy collection of annotation parameters with the selected name. May be empty, but is never null. */ public static Collection<ValueReference> getAnnotationParameters(final Annotation annotation, final String parameterName) { return Collections2.transform( Collections2.filter(annotation.getParameters(), new Predicate<AnnotationParameter>() { @Override public boolean apply(AnnotationParameter parameter) { Preconditions.checkArgument(parameter != null); return parameter.getName().equals(parameterName); } }), new Function<AnnotationParameter, ValueReference>() { @Override public ValueReference apply(AnnotationParameter parameter) { Preconditions.checkArgument(parameter != null); return parameter.getValue(); } }); }
public boolean isDeprecated(Annotation annotation) { return isDeprecated(annotation.getName()); }
private Iterable<String> getParameterNames(Annotation annotation) { return Iterables.transform(annotation.getParameters(), new AnnotationParameterName()); }
protected void buildAnnotations(Pattern pattern, InitializablePQuery query) throws IncQueryException { for (Annotation annotation : pattern.getAnnotations()) { PAnnotation pAnnotation = new PAnnotation(annotation.getName()); for (Entry<String, Object> attribute : CorePatternLanguageHelper.evaluateAnnotationParameters(annotation).entrySet()) { pAnnotation.addAttribute(attribute.getKey(), attribute.getValue()); } query.addAnnotation(pAnnotation); } }
public AnnotationParameter getAnnotationParameter(Annotation annotation, String parameterName) { AnnotationParameter parameter = PatternLanguageFactory.eINSTANCE.createAnnotationParameter(); parameter.setName(parameterName); annotation.getParameters().add(parameter); return parameter; }
public boolean isDeprecated(AnnotationParameter parameter) { Annotation annotation = (Annotation) parameter.eContainer(); return isDeprecated(annotation.getName(), parameter.getName()); }
public static Map<String, Object> evaluateAnnotationParameters(Annotation annotation) { Map<String, Object> result = Maps.newHashMap(); for (AnnotationParameter param : annotation.getParameters()) { String parameterName = param.getName(); ValueReference ref = param.getValue(); if (ref != null) { final Object valueReference = CorePatternLanguageHelper.getValue(ref); if (!Strings.isNullOrEmpty(parameterName) && valueReference != null) { result.put(parameterName, valueReference); } } } return result; }
public String getDescription(AnnotationParameter parameter) { Annotation annotation = (Annotation) parameter.eContainer(); return getDescription(annotation.getName(), parameter.getName()); }
@Override public QualifiedName getFullyQualifiedName(EObject obj) { if (obj instanceof Annotation) { Annotation annotation = (Annotation) obj; String name = annotation.getName(); return nameConverter.toQualifiedName("annotation." + name); } else if (obj instanceof AnnotationParameter) { AnnotationParameter parameter = (AnnotationParameter) obj; Annotation annotation = (Annotation) parameter.eContainer(); return getFullyQualifiedName(annotation).append(parameter.getName()); } return super.getFullyQualifiedName(obj); }
_builder.append(PAnnotation.class, "\t"); _builder.append("(\""); String _name = annotation.getName(); _builder.append(_name, "\t"); _builder.append("\");");