Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.Annotation


    String version= project.getOption(JavaCore.COMPILER_COMPLIANCE, true);

    if (!binding.getDeclaringClass().isInterface()
        || !JavaModelUtil.isVersionLessThan(version, JavaCore.VERSION_1_6))
    {
      final Annotation marker= rewrite.getAST().newMarkerAnnotation();
      marker.setTypeName(rewrite.getAST().newSimpleName(annotation)); //$NON-NLS-1$
      rewrite.getListRewrite(decl, MethodDeclaration.MODIFIERS2_PROPERTY).insertFirst(marker, null);
    }
  }
View Full Code Here


    if (node.getAST().apiLevel() >= AST.JLS3) {
      if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
      }
      for (Iterator it = node.annotations().iterator(); it.hasNext(); ) {
        Annotation p = (Annotation) it.next();
        p.accept(this);
        this.buffer.append(" ");//$NON-NLS-1$
      }
    }
    printIndent();
    this.buffer.append("package ");//$NON-NLS-1$
View Full Code Here

            }

            _output(_indent);

            for (Iterator it = node.annotations().iterator(); it.hasNext();) {
                Annotation p = (Annotation) it.next();
                p.accept(this);
                _output(" ");
            }
        } else {
            _output(_indent);
        }
View Full Code Here

        warnings.add(String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.1"), annotation.getCanonicalName(), targetClass)); //$NON-NLS-1$
        return;
      }

      addImportToCompilationUnit(annotation.getCanonicalName(), cu);
      Annotation modifier = createModifier(cu.getAST(), annotation, properties, cu);
      typeDeclaration.modifiers().add(0, modifier);
    } catch (Exception e) {
      warnings.add(String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.2"), annotation.getCanonicalName(), targetClass)); //$NON-NLS-1$
    }
  }
View Full Code Here

    for (IExtendedModifier modifier : modifiers) {
      if (!(modifier instanceof Annotation)) {
        continue;
      }

      Annotation annotationModifer = (Annotation) modifier;
      if (annotationModifer.getTypeName().toString().equals(annotation.getCanonicalName())
          || annotationModifer.getTypeName().toString().equals(annotation.getSimpleName())) {
        return true;
      }
    }

    return false;
View Full Code Here

      return null;
    }

    addImportToCompilationUnit(annotation.getCanonicalName(), cu);

    Annotation result = null;
    Name annotationTypeName = isClassImported(annotation.getCanonicalName(), cu) ? ast.newSimpleName(annotationType.getElementName()) : createQualifiedName(ast, annotationType.getFullyQualifiedName());

    if (properties != null) {
      result = ast.newNormalAnnotation();

      Method[] methods = annotation.getDeclaredMethods();
      for (Method method : methods) {
        Class<?> returnType = method.getReturnType();

        // get the matching value in the properties
        Object value = properties.get(method.getName());

        if (value == null && method.getDefaultValue() == null) {
          // TODO: throw an exception here
        }

        if (value == null) {
          // no need to do anything - the default will be used
          continue;
        }

        if (value.getClass().isArray() != returnType.isArray()) {
          // TODO: throw an exception here
        }

        MemberValuePair annotationProperty = ast.newMemberValuePair();
        annotationProperty.setName(ast.newSimpleName(method.getName()));

        Expression expression = createAnnotationPropertyValueExpression(cu, returnType, value);

        if (expression != null) {
          annotationProperty.setValue(expression);
          ((NormalAnnotation) result).values().add(annotationProperty);
        }

      }
    } else {
      result = ast.newMarkerAnnotation();
    }

    result.setTypeName(annotationTypeName);
    return result;
  }
View Full Code Here

        return;
      }
     
      addImportToCompilationUnit(annotationClass.getCanonicalName(), cu);
     
      Annotation modifier = createModifier(cu.getAST(), annotationClass, properties, cu);
      method.modifiers().add(0, modifier);
    } catch (CoreException e) {
      warnings.add(String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.3"), annotationClass.getCanonicalName(), methodName, fullyQualifiedClassName)); //$NON-NLS-1$
    }
  }
View Full Code Here

            return;
          }

          addImportToCompilationUnit(annotation.getCanonicalName(), cu);
         
          Annotation modifier = createModifier(cu.getAST(), annotation, properties, cu);
          field.modifiers().add(0, modifier);
        }
      }

    } catch (CoreException e) {
View Full Code Here

      Iterator iterator = modifiers.iterator();

      while (iterator.hasNext()) {
        IExtendedModifier modifier = (IExtendedModifier) iterator.next();
        if (modifier.isAnnotation()) {
          Annotation annotation = (Annotation) modifier;
          if (cls.getCanonicalName().equals(annotation.resolveTypeBinding().getQualifiedName())) {
            iterator.remove();
          }
        }
      }
View Full Code Here

          if (isAnnotationAlreadyUsedOnDeclaration(annotation, field)) {
            warnings.add(String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.1"), annotation.getCanonicalName(), targetClass + "." + varibleDeclaration.getName().toString())); //$NON-NLS-1$
            return;
          }
         
          Annotation modifier = createModifier(cu.getAST(), annotation, properties, cu);
          field.modifiers().add(0, modifier);

          addImportToCompilationUnit(annotation.getCanonicalName(), cu);
        }
      }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.Annotation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.