Java 类org.eclipse.jdt.core.IAnnotation 实例源码

项目:codelens-eclipse    文件:JDTUtils.java   
public static boolean isHiddenGeneratedElement(IJavaElement element) {
    // generated elements are tagged with javax.annotation.Generated and
    // they need to be filtered out
    if (element instanceof IAnnotatable) {
        try {
            IAnnotation[] annotations = ((IAnnotatable) element).getAnnotations();
            if (annotations.length != 0) {
                for (IAnnotation annotation : annotations) {
                    if (isSilencedGeneratedAnnotation(annotation)) {
                        return true;
                    }
                }
            }
        } catch (JavaModelException e) {
            // ignore
        }
    }
    return false;
}
项目:codelens-eclipse    文件:JDTUtils.java   
private static boolean isSilencedGeneratedAnnotation(IAnnotation annotation) throws JavaModelException {
    if ("javax.annotation.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;
}
项目:vertigo-chroma-kspplugin    文件:DtoUtils.java   
private static void parseVertigoDtoField(IMethod method, List<DtoField> fields) {
    try {
        if (method.isConstructor() || !Flags.isPublic(method.getFlags())) {
            return;
        }
        IAnnotation fieldAnnotation = JdtUtils.getAnnotation(method, FIELD_ANNOTATION_NAME);
        if (fieldAnnotation == null) {
            return;
        }
        String domain = (String) JdtUtils.getMemberValue(fieldAnnotation, DOMAIN_FIELD_NAME);

        /* Cas d'un champ de composition DTO/DTC : on filtre. */
        if (domain == null || domain.startsWith(DTO_DOMAIN_PREFIX)) {
            return;
        }

        String constantCaseName = StringUtils.toConstantCase(KspStringUtils.getFieldNameFromGetter(method.getElementName()));
        String label = (String) JdtUtils.getMemberValue(fieldAnnotation, LABEL_FIELD_NAME);
        Boolean persistent = (Boolean) JdtUtils.getMemberValue(fieldAnnotation, PERSISTENT_FIELD_NAME);

        DtoField field = new DtoField(constantCaseName, label, domain, persistent);
        fields.add(field);
    } catch (JavaModelException e) {
        ErrorUtils.handle(e);
    }
}
项目:google-cloud-eclipse    文件:PipelineOptionsPropertyTest.java   
@Test
public void testFromMethodWithBooleanReturnValueAndIsPropertyReturnsProperty()
    throws JavaModelException {
  IMethod method = mock(IMethod.class);
  when(method.getElementName()).thenReturn("isFoo");

  IAnnotation required = mock(IAnnotation.class);
  when(method.getAnnotation(PipelineOptionsNamespaces.validationRequired(version)))
      .thenReturn(required);
  when(required.exists()).thenReturn(false);
  when(required.getElementName())
      .thenReturn(PipelineOptionsNamespaces.validationRequired(version));
  when(method.getAnnotations()).thenReturn(new IAnnotation[] {required});

  IAnnotation description = mock(IAnnotation.class);
  when(description.exists()).thenReturn(false);
  when(method.getAnnotation(PipelineOptionsNamespaces.descriptionAnnotation(version)))
      .thenReturn(description);

  PipelineOptionsProperty property = PipelineOptionsProperty.fromMethod(method, version);

  assertEquals("foo", property.getName());
  assertFalse(property.isRequired());
  assertTrue(property.getGroups().isEmpty());
}
项目:google-cloud-eclipse    文件:PipelineOptionsPropertyTest.java   
@Test
public void testFromMethodWithNoValidationRequiredAnnotationIsNotRequired()
    throws JavaModelException {
  IMethod method = mock(IMethod.class);
  when(method.getElementName()).thenReturn("getFoo");

  IAnnotation required = mock(IAnnotation.class);
  when(method.getAnnotation(PipelineOptionsNamespaces.validationRequired(version)))
      .thenReturn(required);
  when(required.exists()).thenReturn(false);
  when(required.getElementName())
      .thenReturn(PipelineOptionsNamespaces.validationRequired(version));
  when(method.getAnnotations()).thenReturn(new IAnnotation[] {required});

  IAnnotation description = mock(IAnnotation.class);
  when(description.exists()).thenReturn(false);
  when(method.getAnnotation(PipelineOptionsNamespaces.descriptionAnnotation(version)))
      .thenReturn(description);

  PipelineOptionsProperty property = PipelineOptionsProperty.fromMethod(method, version);

  assertEquals("foo", property.getName());
  assertFalse(property.isRequired());
  assertTrue(property.getGroups().isEmpty());
}
项目:google-cloud-eclipse    文件:PipelineOptionsPropertyTest.java   
@Test
public void testFromMethodWithoutDescriptionHasAbsentOptional() throws Exception {
  IMethod method = mock(IMethod.class);
  when(method.getElementName()).thenReturn("getFoo");

  IAnnotation required = mock(IAnnotation.class);
  when(method.getAnnotation(PipelineOptionsNamespaces.validationRequired(version)))
      .thenReturn(required);
  when(required.exists()).thenReturn(false);
  when(required.getElementName())
      .thenReturn(PipelineOptionsNamespaces.validationRequired(version));
  when(method.getAnnotations()).thenReturn(new IAnnotation[] {required});

  IAnnotation description = mock(IAnnotation.class);
  when(description.exists()).thenReturn(false);
  when(method.getAnnotation(PipelineOptionsNamespaces.descriptionAnnotation(version)))
      .thenReturn(description);

  PipelineOptionsProperty property = PipelineOptionsProperty.fromMethod(method, version);

  assertNull(property.getDescription());
}
项目:eclipse.jdt.ls    文件:JDTUtils.java   
public static boolean isHiddenGeneratedElement(IJavaElement element) {
    // generated elements are tagged with javax.annotation.Generated and
    // they need to be filtered out
    if (element instanceof IAnnotatable) {
        try {
            IAnnotation[] annotations = ((IAnnotatable) element).getAnnotations();
            if (annotations.length != 0) {
                for (IAnnotation annotation : annotations) {
                    if (isSilencedGeneratedAnnotation(annotation)) {
                        return true;
                    }
                }
            }
        } catch (JavaModelException e) {
            //ignore
        }
    }
    return false;
}
项目:eclipse.jdt.ls    文件:JDTUtils.java   
private static boolean isSilencedGeneratedAnnotation(IAnnotation annotation) throws JavaModelException {
    if ("javax.annotation.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;
}
项目:eclipse.jdt.ls    文件:JavaElementLabelComposer.java   
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(')');
}
项目:Migrate-Skeletal-Implementation-to-Interface-Refactoring    文件:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java   
/**
 * Remove any annotations that we don't want considered.
 *
 * @param annotationSet
 *            The set of annotations to work with.
 * @param type
 *            The type declaring the annotations.
 * @throws JavaModelException
 *             When resolving the annotation FQN fails.
 */
private void removeSpecialAnnotations(Set<IAnnotation> annotationSet, IType type) throws JavaModelException {
    // Special case: don't consider the @Override annotation in the source
    // (the target will never have this) #67.
    annotationSet.removeIf(a -> a.getElementName().equals(Override.class.getName()));
    annotationSet.removeIf(a -> a.getElementName().equals(Override.class.getSimpleName()));

    // also remove nonstandard annotations if necessary.
    if (!this.shouldConsiderNonstandardAnnotationDifferences())
        for (Iterator<IAnnotation> iterator = annotationSet.iterator(); iterator.hasNext();) {
            IAnnotation annotation = iterator.next();

            String annotationName = annotation.getElementName();
            String[][] resolveTyped = type.resolveType(annotationName);

            for (String[] element : resolveTyped) {
                String[] strings = element;

                // first element is the package name.
                if (!strings[0].startsWith("java.lang"))
                    iterator.remove();
            }
        }
}
项目:che    文件:SourcesFromBytecodeGenerator.java   
public void appendAnnotationLabel(IAnnotation annotation, long flags, StringBuilder builder)
    throws JavaModelException {
  builder.append('@');
  appendTypeSignatureLabel(
      annotation,
      Signature.createTypeSignature(annotation.getElementName(), false),
      flags,
      builder);
  IMemberValuePair[] memberValuePairs = annotation.getMemberValuePairs();
  if (memberValuePairs.length == 0) return;
  builder.append('(');
  for (int i = 0; i < memberValuePairs.length; i++) {
    if (i > 0) builder.append(JavaElementLabels.COMMA_STRING);
    IMemberValuePair memberValuePair = memberValuePairs[i];
    builder.append(
        getMemberName(annotation, annotation.getElementName(), memberValuePair.getMemberName()));
    builder.append('=');
    appendAnnotationValue(
        annotation, memberValuePair.getValue(), memberValuePair.getValueKind(), flags, builder);
  }
  builder.append(')');
}
项目:che    文件:StubCreator.java   
protected void appendFlags(final IMember member) throws JavaModelException {
  if (member instanceof IAnnotatable)
    for (IAnnotation annotation : ((IAnnotatable) member).getAnnotations()) {
      appendAnnotation(annotation);
    }

  int flags = member.getFlags();
  final int kind = member.getElementType();
  if (kind == IJavaElement.TYPE) {
    flags &= ~Flags.AccSuper;
    final IType type = (IType) member;
    if (!type.isMember()) flags &= ~Flags.AccPrivate;
    if (Flags.isEnum(flags)) flags &= ~Flags.AccAbstract;
  }
  if (Flags.isEnum(flags)) flags &= ~Flags.AccFinal;
  if (kind == IJavaElement.METHOD) {
    flags &= ~Flags.AccVarargs;
    flags &= ~Flags.AccBridge;
  }
  if (flags != 0) fBuffer.append(Flags.toString(flags));
}
项目:che    文件:StubCreator.java   
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');
}
项目:che    文件:StubCreator.java   
private void appendAnnotationValue(Object value, int valueKind) throws JavaModelException {
  if (value instanceof Object[]) {
    Object[] objects = (Object[]) value;
    fBuffer.append('{');
    for (Object object : objects) {
      appendAnnotationValue(object, valueKind);
      fBuffer.append(',');
    }
    if (objects.length > 0) fBuffer.deleteCharAt(fBuffer.length() - 1);
    fBuffer.append('}');

  } else {
    switch (valueKind) {
      case IMemberValuePair.K_ANNOTATION:
        appendAnnotation((IAnnotation) value);
        break;
      case IMemberValuePair.K_STRING:
        fBuffer.append('"').append(value).append('"');
        break;

      default:
        fBuffer.append(value);
        break;
    }
  }
}
项目:che    文件:JavaElementLabelComposer.java   
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(')');
}
项目:che    文件:JavaTestFinder.java   
/**
 * Check if a method is test method.
 *
 * @param method method which should be checked
 * @param compilationUnit parent of the method
 * @param testAnnotation java annotation which describes test method in the test framework
 * @return {@code true} if the method is test method
 */
public boolean isTest(IMethod method, ICompilationUnit compilationUnit, String testAnnotation) {
  try {
    IAnnotation[] annotations = method.getAnnotations();
    IAnnotation test = null;
    for (IAnnotation annotation : annotations) {
      String annotationElementName = annotation.getElementName();
      if ("Test".equals(annotationElementName)) {
        test = annotation;
        break;
      }
      if (testAnnotation.equals(annotationElementName)) {
        return true;
      }
    }
    return test != null && isImportOfTestAnnotationExist(compilationUnit, testAnnotation);
  } catch (JavaModelException e) {
    LOG.info("Can't read method's annotations.", e);
    return false;
  }
}
项目:vsminecraft    文件:JavaElementLabelComposer.java   
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(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(')');
}
项目:evosuite    文件:MarkerWriter.java   
private boolean shouldWriteMarkers(IJavaElement currentElement) {
    IJavaElement parent = currentElement;
    while (parent != null) {

        if (parent instanceof IAnnotatable) {
            IAnnotatable p = (IAnnotatable) parent;
            try {
                for (IAnnotation a : p.getAnnotations()) {
                    if (a.getElementName().equalsIgnoreCase("EvoIgnore")) {
                        return false;
                    }
                }
            } catch (JavaModelException e) {
                e.printStackTrace();
            }
        }
        parent = parent.getParent();
    }
    return true;
}
项目:strutsclipse    文件:AnnotationParser.java   
public Set<String> findAnnotationsActionNames(
        final IDocument currentDocument) {
    Set<String> names = new HashSet<String>();
    try {
        List<IAnnotation> annotations = parseActionAnnotation(currentDocument);
        for (IAnnotation annotation : annotations) {
            String name = fetchAnnotationStringValue(annotation);
            if (name != null) {
                names.add(name);
            }
        }
    } catch (JavaModelException e) {
        e.printStackTrace();
    }
    return names;
}
项目:strutsclipse    文件:AnnotationParser.java   
private boolean sameAnnotationStringValue(IAnnotation annotation,
        String actionValue) throws JavaModelException {
    boolean res = false;
    if (annotation.exists()) {
        IMemberValuePair[] valuePairs = annotation.getMemberValuePairs();
        for (IMemberValuePair valuePair : valuePairs) {
            res = valuePair.getValueKind() == IMemberValuePair.K_STRING
                    && valuePair.getValue() instanceof String
                    && ANNOTATION_VALUE.equals(valuePair.getMemberName())
                    && actionValue.equals(valuePair.getValue());
            if (res) {
                break;
            }
        }
    }
    return res;
}
项目:Eclipse-Postfix-Code-Completion    文件:StubCreator.java   
protected void appendFlags(final IMember member) throws JavaModelException {
    if (member instanceof IAnnotatable)
        for (IAnnotation annotation : ((IAnnotatable) member).getAnnotations()) {
            appendAnnotation(annotation);
        }

    int flags= member.getFlags();
    final int kind= member.getElementType();
    if (kind == IJavaElement.TYPE) {
        flags&= ~Flags.AccSuper;
        final IType type= (IType) member;
        if (!type.isMember())
            flags&= ~Flags.AccPrivate;
        if (Flags.isEnum(flags))
            flags&= ~Flags.AccAbstract;
    }
    if (Flags.isEnum(flags))
        flags&= ~Flags.AccFinal;
    if (kind == IJavaElement.METHOD) {
        flags&= ~Flags.AccVarargs;
        flags&= ~Flags.AccBridge;
    }
    if (flags != 0)
        fBuffer.append(Flags.toString(flags));
}
项目:Eclipse-Postfix-Code-Completion    文件:StubCreator.java   
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');
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaElementLabelComposer.java   
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(')');
}
项目:Eclipse-Postfix-Code-Completion    文件:BinaryMember.java   
protected IAnnotation[] getAnnotations(IBinaryAnnotation[] binaryAnnotations, long tagBits) {
    IAnnotation[] standardAnnotations = getStandardAnnotations(tagBits);
    if (binaryAnnotations == null)
        return standardAnnotations;
    int length = binaryAnnotations.length;
    int standardLength = standardAnnotations.length;
    int fullLength = length + standardLength;
    if (fullLength == 0) {
        return Annotation.NO_ANNOTATIONS;
    }
    IAnnotation[] annotations = new IAnnotation[fullLength];
    for (int i = 0; i < length; i++) {
        annotations[i] = Util.getAnnotation(this, binaryAnnotations[i], null);
    }
    System.arraycopy(standardAnnotations, 0, annotations, length, standardLength);
    return annotations;
}
项目:mybatipse    文件:JavaCompletionProposalComputer.java   
private List<ICompletionProposal> proposeResults(IJavaProject project, String mapperFqn,
    int offset, IAnnotation annotation, IMethod method) throws JavaModelException
{
    final List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
    AnnotationParser parser = new AnnotationParser(annotation, offset);
    String annotationAttrName = parser.getKey();
    if ("property".equals(annotationAttrName))
    {
        proposeProperty(proposals, project, mapperFqn, method, offset, parser);
    }
    else if ("select".equals(annotationAttrName))
    {
        String matchString = parser.getValue();
        proposals.addAll(ProposalComputorHelper.proposeReference(project, mapperFqn, matchString,
            offset - matchString.length(), parser.getValueLength(), "select",
            method.getElementName()));
    }
    return proposals;
}
项目:mybatipse    文件:JavaMapperUtil.java   
public static String getAnnotationMemberValue(IAnnotation annotation, String memberName)
{
    try
    {
        IMemberValuePair[] valuePairs = annotation.getMemberValuePairs();
        for (IMemberValuePair valuePair : valuePairs)
        {
            if (memberName.equals(valuePair.getMemberName()))
            {
                return (String)valuePair.getValue();
            }
        }
    }
    catch (JavaModelException e)
    {
        Activator.log(Status.ERROR, "Failed to get member value pairs.", e);
    }
    return null;
}
项目:mybatipse    文件:JavaMapperUtil.java   
@Override
public boolean matches(IMethod method) throws JavaModelException
{
    for (IAnnotation annotation : method.getAnnotations())
    {
        String annotationName = annotation.getElementName();
        if (MybatipseConstants.ANNOTATION_RESULTS.equals(annotationName))
        {
            IMemberValuePair[] valuePairs = annotation.getMemberValuePairs();
            for (IMemberValuePair valuePair : valuePairs)
            {
                if ("id".equals(valuePair.getMemberName()))
                {
                    String resultsId = (String)valuePair.getValue();
                    return nameMatches(resultsId, matchString, exactMatch);
                }
            }
        }
    }
    return false;
}
项目:mybatipse    文件:TypeAliasCache.java   
private String getAliasAnnotationValue(IType foundType) throws JavaModelException
{
    String alias = null;
    IAnnotation[] annotations = foundType.getAnnotations();
    for (IAnnotation annotation : annotations)
    {
        if ("Alias".equals(annotation.getElementName()))
        {
            IMemberValuePair[] params = annotation.getMemberValuePairs();
            if (params.length > 0)
            {
                alias = (String)params[0].getValue();
            }
        }
    }
    return alias;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:StubCreator.java   
protected void appendFlags(final IMember member) throws JavaModelException {
    if (member instanceof IAnnotatable)
        for (IAnnotation annotation : ((IAnnotatable) member).getAnnotations()) {
            appendAnnotation(annotation);
        }

    int flags= member.getFlags();
    final int kind= member.getElementType();
    if (kind == IJavaElement.TYPE) {
        flags&= ~Flags.AccSuper;
        final IType type= (IType) member;
        if (!type.isMember())
            flags&= ~Flags.AccPrivate;
        if (Flags.isEnum(flags))
            flags&= ~Flags.AccAbstract;
    }
    if (Flags.isEnum(flags))
        flags&= ~Flags.AccFinal;
    if (kind == IJavaElement.METHOD) {
        flags&= ~Flags.AccVarargs;
        flags&= ~Flags.AccBridge;
    }
    if (flags != 0)
        fBuffer.append(Flags.toString(flags));
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:StubCreator.java   
private void appendAnnotation(IAnnotation annotation) throws JavaModelException {
    fBuffer.append('@');
    fBuffer.append(annotation.getElementName());
    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');
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaElementLabelComposer.java   
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(')');
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:BinaryMember.java   
protected IAnnotation[] getAnnotations(IBinaryAnnotation[] binaryAnnotations, long tagBits) {
    IAnnotation[] standardAnnotations = getStandardAnnotations(tagBits);
    if (binaryAnnotations == null)
        return standardAnnotations;
    int length = binaryAnnotations.length;
    int standardLength = standardAnnotations.length;
    int fullLength = length + standardLength;
    if (fullLength == 0) {
        return Annotation.NO_ANNOTATIONS;
    }
    IAnnotation[] annotations = new IAnnotation[fullLength];
    for (int i = 0; i < length; i++) {
        annotations[i] = Util.getAnnotation(this, binaryAnnotations[i], null);
    }
    System.arraycopy(standardAnnotations, 0, annotations, length, standardLength);
    return annotations;
}
项目:eclipse-tapestry5-plugin    文件:TapestryModule.java   
public List<String> readMarkerAnnotation(IAnnotatable annotatable) throws JavaModelException
{
    List<String> markers = new ArrayList<String>();

    IAnnotation annotation = TapestryUtils.findAnnotation(annotatable.getAnnotations(),
            TapestryUtils.ORG_APACHE_TAPESTRY5_IOC_ANNOTATIONS_MARKER);

    if (annotation != null)
    {
        String[] typeLiterals = EclipseUtils.readValuesFromAnnotation(getEclipseProject(), annotation, "value");

        for (String typeLiteral : typeLiterals)
        {
            String typeName = EclipseUtils.resolveTypeName(moduleClass, typeLiteral);

            markers.add(typeName);
        }
    }

    return markers;
}
项目:eclipse-tapestry5-plugin    文件:TapestryContext.java   
private void processImportedFile(IAnnotation annotation, String type, String fileName)
{
    ISourceRange sourceRange = null;
    try
    {
        sourceRange = annotation.getSourceRange();
    }
    catch (JavaModelException e)
    {
        Activator.getDefault().logError("Error getting annotation location", e);
    }

    if ("stack".equals(type))
    {
        files.add(new JavaScriptStackReference(getJavaFile(), fileName, sourceRange));
    }
    else if ("module".equals(type))
    {
        files.add(new JavaScriptModuleReference(getJavaFile(), sourceRange, fileName));
    }
    else
    {
        files.add(new AssetReference(getJavaFile(), sourceRange, fileName));
    }
}
项目:eclipse-tapestry5-plugin    文件:TapestryComponentSpecification.java   
private Component createComponentFromInjection(IType type, final IField field, IAnnotation annotation) throws JavaModelException
{
    Component component = new Component();
    component.setSpecification(this);
    component.setName(field.getElementName());
    component.setNameRange(field.getNameRange());
    component.setJavadocValue(new LazyValue<String>()
    {
        @Override
        protected String eval() throws CoreException
        {
            return JavadocContentAccess2.getHTMLContent(field, true);
        }
    });

    for (IMemberValuePair pair : annotation.getMemberValuePairs())
    {
        component.setId(String.valueOf(pair.getValue()));
    }

    setComponentDefaults(type, field, component);

    return component;
}
项目:eclipse-tapestry5-plugin    文件:TapestryComponentSpecification.java   
protected Property createProperty(IType type, IField field, IAnnotation annotation) throws JavaModelException
{
    Property property = createProperty(field, field.getElementName());

    for (IMemberValuePair pair : annotation.getMemberValuePairs())
    {
        if ("read".equals(pair.getMemberName()))
        {
            property.setRead("true".equals(String.valueOf(pair.getValue())));
        }
        else if ("write".equals(pair.getMemberName()))
        {
            property.setWrite("true".equals(String.valueOf(pair.getValue())));
        }
    }

    return property;
}
项目:eclipse-tapestry5-plugin    文件:TapestryServiceDiscovery.java   
private List<String> extractMarkers(IAnnotatable annotatable, Set<String> skipAnnotations)
                throws JavaModelException
{
    List<String> markers = new ArrayList<String>();

    for (IAnnotation annotation : annotatable.getAnnotations())
    {
        String typeName = EclipseUtils.resolveTypeName(
                tapestryModule.getModuleClass(), annotation.getElementName());

        if (skipAnnotations.contains(typeName))
        {
            continue;
        }

        markers.add(typeName);
    }
    return markers;
}
项目:eclipse-tapestry5-plugin    文件:EclipseUtils.java   
public static String[] readValuesFromAnnotation(IProject project, IAnnotation annotation, String name) throws JavaModelException
{
    final List<String> values = new ArrayList<String>();

    readValueFromAnnotation(
            annotation,
            name,
            project,
            AST.newAST(getParserLevel()),
            new ObjectCallback<String, JavaModelException>()
            {
                @Override
                public void callback(String value) throws JavaModelException
                {
                    values.add(value);
                }
            });

    return values.toArray(new String[values.size()]);
}
项目:srcrepo    文件:ClassFileParser.java   
protected EnumConstantDeclaration visitEnumConstantDeclaration(final IField field)
        throws JavaModelException {
    EnumConstantDeclaration element = getFactory().createEnumConstantDeclaration();
    initializeNode(element);

    element.setName(field.getElementName());
    element.setModifier(getFactory().createModifier());

    // annotations
    for (IAnnotation annotation : field.getAnnotations()) {
        Annotation anno = getFactory().createAnnotation();
        element.getAnnotations().add(anno);
        visitAnnotation(annotation, anno);
    }

    ClassFileParserUtils.manageBindingDeclaration(element, field, this);

    return element;
}
项目:Hydrograph    文件:ClassDetails.java   
private boolean isMethodDepricated(IMethod iMethod) throws JavaModelException {
    for (IAnnotation annotation : iMethod.getAnnotations()) {
        if (StringUtils.equals(annotation.getElementName() , Deprecated.class.getCanonicalName())) {
            return true;
        }
    }
    return false;
}