boolean found = false; for (IAnnotation i : in) { String name = i.getElementName(); int li = name.lastIndexOf('.'); if (li > -1) name = name.substring(li + 1);
IAnnotation ruleAnnotation = field.getAnnotation("Rule"); IType declaringType = field.getDeclaringType(); String elementName = ruleAnnotation.getElementName(); String[][] fullyQualifiedName = declaringType.resolveType(elementName);
@Override public IAnnotation getAnnotation(String annotationName) { for (int i = 0, length = this.annotations.length; i < length; i++) { IAnnotation annotation = this.annotations[i]; if (annotation.getElementName().equals(annotationName)) return annotation; } return super.getAnnotation(annotationName); }
public IAnnotation getAnnotation(String annotationName) { for (int i = 0, length = this.annotations.length; i < length; i++) { IAnnotation annotation = this.annotations[i]; if (annotation.getElementName().equals(annotationName)) return annotation; } return super.getAnnotation(annotationName); }
public IAnnotation getAnnotation(String annotationName) { for (int i = 0, length = this.annotations.length; i < length; i++) { IAnnotation annotation = this.annotations[i]; if (annotation.getElementName().equals(annotationName)) return annotation; } return super.getAnnotation(annotationName); }
public IAnnotation getAnnotation(String annotationName) { for (int i = 0, length = this.annotations.length; i < length; i++) { IAnnotation annotation = this.annotations[i]; if (annotation.getElementName().equals(annotationName)) return annotation; } return super.getAnnotation(annotationName); }
protected IAnnotation transplantHandle(IAnnotatable parent, IAnnotation element) { return parent.getAnnotation(element.getElementName()); }
protected IAnnotation transplantHandle(IAnnotatable parent, IAnnotation element) { return parent.getAnnotation(element.getElementName()); }
public IAnnotation getAnnotation(String annotationName) { for (int i = 0, length = this.annotations.length; i < length; i++) { IAnnotation annotation = this.annotations[i]; if (annotation.getElementName().equals(annotationName)) return annotation; } return super.getAnnotation(annotationName); }
public IAnnotation getAnnotation(String annotationName) { for (int i = 0, length = this.annotations.length; i < length; i++) { IAnnotation annotation = this.annotations[i]; if (annotation.getElementName().equals(annotationName)) return annotation; } return super.getAnnotation(annotationName); }
private Set<IPath> getAnnotationTypes( final List<IAnnotation> annotations, final List<IImport> imports, final Path path) { final Set<IPath> annotationPaths = new HashSet<>(); for (final IAnnotation annotation : annotations) { final String qualifiedName = annotation.getElementName(); annotationPaths.add(createTypePath(imports, path, qualifiedName)); } return annotationPaths; }
protected IAnnotation transplantHandle(IAnnotatable parent, IAnnotation element) { return parent.getAnnotation(element.getElementName()); }
/** Replies the annotation with the given qualified name. * * @param element the annoted element. * @param qualifiedName the qualified name of the element. * @return the annotation, or <code>null</code> if the element is not annoted. */ public IAnnotation getAnnotation(IAnnotatable element, String qualifiedName) { if (element != null) { try { final int separator = qualifiedName.lastIndexOf('.'); final String simpleName; if (separator >= 0 && separator < (qualifiedName.length() - 1)) { simpleName = qualifiedName.substring(separator + 1, qualifiedName.length()); } else { simpleName = qualifiedName; } for (final IAnnotation annotation : element.getAnnotations()) { final String name = annotation.getElementName(); if (name.equals(simpleName) || name.equals(qualifiedName)) { return annotation; } } } catch (JavaModelException e) { // } } return null; }
private void appendAnnotation(IAnnotation annotation) throws JavaModelException { String name= annotation.getElementName(); if (!fStubInvisible && name.startsWith("sun.") || name.startsWith("jdk.internal.")) //$NON-NLS-1$ //$NON-NLS-2$ return; // skip Sun-internal annotations fBuffer.append('@'); fBuffer.append(name.replace('$', '.')); fBuffer.append('('); IMemberValuePair[] memberValuePairs= annotation.getMemberValuePairs(); for (IMemberValuePair pair : memberValuePairs) { fBuffer.append(pair.getMemberName()); fBuffer.append('='); appendAnnotationValue(pair.getValue(), pair.getValueKind()); fBuffer.append(','); } if (memberValuePairs.length > 0) fBuffer.deleteCharAt(fBuffer.length() - 1); fBuffer.append(')').append('\n'); }
private void appendAnnotation(IAnnotation annotation) throws JavaModelException { String name= annotation.getElementName(); if (!fStubInvisible && name.startsWith("sun.")) //$NON-NLS-1$ return; // skip Sun-internal annotations fBuffer.append('@'); fBuffer.append(name); fBuffer.append('('); IMemberValuePair[] memberValuePairs= annotation.getMemberValuePairs(); for (IMemberValuePair pair : memberValuePairs) { fBuffer.append(pair.getMemberName()); fBuffer.append('='); appendAnnotationValue(pair.getValue(), pair.getValueKind()); fBuffer.append(','); } if (memberValuePairs.length > 0) fBuffer.deleteCharAt(fBuffer.length() - 1); fBuffer.append(')').append('\n'); }
private static boolean isSilencedGeneratedAnnotation(IAnnotation annotation) throws JavaModelException { if ("javax.annotation.Generated".equals(annotation.getElementName()) || "javax.annotation.processing.Generated".equals(annotation.getElementName())) { IMemberValuePair[] memberValuePairs = annotation.getMemberValuePairs(); for (IMemberValuePair m : memberValuePairs) { if ("value".equals(m.getMemberName()) && IMemberValuePair.K_STRING == m.getValueKind()) { if (m.getValue() instanceof String) { return SILENCED_CODEGENS.contains(m.getValue()); } else if (m.getValue() instanceof Object[]) { for (Object val : (Object[])m.getValue()) { if(SILENCED_CODEGENS.contains(val)) { return true; } } } } } } return false; }
private static String getAnnotationSourceFixed(IMember member, IAnnotation annotation, String startSimple) { try { ISourceRange annotSourceRange = annotation.getSourceRange(); ISourceRange ownerSourceRange = member.getSourceRange(); if (SourceRange.isAvailable(ownerSourceRange) && SourceRange.isAvailable(annotSourceRange) && ownerSourceRange.getOffset() > annotSourceRange.getOffset()) { String icuSource = member.getCompilationUnit().getSource(); if (icuSource != null && icuSource.length() >= ownerSourceRange.getOffset()) { String diff = icuSource.substring(annotSourceRange.getOffset(), ownerSourceRange.getOffset()); int offset = diff.lastIndexOf(startSimple); if (offset >= 0) { offset += annotSourceRange.getOffset(); int end = offset + annotSourceRange.getLength(); if (icuSource.length() >= end) { return icuSource.substring(offset, end); } } } } } catch (JavaModelException e) { SdkLog.warning("Unable to find source for annotation '{}' in '{}'.", annotation.getElementName(), member.getElementName(), e); } return null; }
public void appendAnnotationLabel(IAnnotation annotation, long flags) throws JavaModelException { fBuilder.append('@'); appendTypeSignatureLabel(annotation, Signature.createTypeSignature(annotation.getElementName(), false), flags); IMemberValuePair[] memberValuePairs= annotation.getMemberValuePairs(); if (memberValuePairs.length == 0) { return; } fBuilder.append('('); for (int i= 0; i < memberValuePairs.length; i++) { if (i > 0) { fBuilder.append(JavaElementLabels.COMMA_STRING); } IMemberValuePair memberValuePair= memberValuePairs[i]; fBuilder.append(getMemberName(annotation, annotation.getElementName(), memberValuePair.getMemberName())); fBuilder.append('='); appendAnnotationValue(annotation, memberValuePair.getValue(), memberValuePair.getValueKind(), flags); } fBuilder.append(')'); }
public void appendAnnotationLabel(IAnnotation annotation, long flags) throws JavaModelException { fBuffer.append('@'); appendTypeSignatureLabel(annotation, Signature.createTypeSignature(annotation.getElementName(), false), flags); IMemberValuePair[] memberValuePairs= annotation.getMemberValuePairs(); if (memberValuePairs.length == 0) return; fBuffer.append('('); for (int i= 0; i < memberValuePairs.length; i++) { if (i > 0) fBuffer.append(JavaElementLabels.COMMA_STRING); IMemberValuePair memberValuePair= memberValuePairs[i]; fBuffer.append(getMemberName(annotation, annotation.getElementName(), memberValuePair.getMemberName())); fBuffer.append('='); appendAnnotationValue(annotation, memberValuePair.getValue(), memberValuePair.getValueKind(), flags); } fBuffer.append(')'); }
public void appendAnnotationLabel(IAnnotation annotation, long flags) throws JavaModelException { fBuffer.append('@'); appendTypeSignatureLabel(annotation, Signature.createTypeSignature(annotation.getElementName(), false), flags); IMemberValuePair[] memberValuePairs= annotation.getMemberValuePairs(); if (memberValuePairs.length == 0) { return; } fBuffer.append('('); for (int i= 0; i < memberValuePairs.length; i++) { if (i > 0) { fBuffer.append(JavaElementLabelsCore.COMMA_STRING); } IMemberValuePair memberValuePair= memberValuePairs[i]; fBuffer.append(getMemberName(annotation, annotation.getElementName(), memberValuePair.getMemberName())); fBuffer.append('='); appendAnnotationValue(annotation, memberValuePair.getValue(), memberValuePair.getValueKind(), flags); } fBuffer.append(')'); }