Examples of IAnnotation


Examples of org.eclipse.jdt.core.IAnnotation

      return;
    }

    private boolean hasEmbeddedAnnotation(IField f) {
      for (String s : EMBEDDED_ANNOTATIONS_FOR_FIELDS) {
        IAnnotation a = f.getAnnotation(s);
        if (a != null && a.exists()) {
          return true;
        }
      }
      return false;
    }
View Full Code Here

Examples of org.eclipse.jdt.core.IAnnotation

      if (fieldsAnnotationSet == null || fieldsAnnotationSet.length == 0) {
        return true;
      }

      for (String s : fieldsAnnotationSet) {
        IAnnotation ia = f.getAnnotation(s);
        if (ia != null && ia.exists()) {
          return true;
        }
      }

      return false;
View Full Code Here

Examples of org.eclipse.jdt.core.IAnnotation

    public void acceptSearchMatch(SearchMatch match) throws CoreException {
      Object element = match.getElement();
      if (element instanceof IType) {
        IType rst = (IType) element;
        IAnnotation ia = null;
        ia = getAppropriateAnnotation(rst);
        if (ia != null && ia.exists()) {
          IAnnotation ia2 = rst.getAnnotation("Table");
          if (ia2 != null && ia2.exists()) {
            String name = rst.getFullyQualifiedName();
            String[] els = name.split("\\.");
            types.add(els[els.length - 1]);
          } else {
            String name = rst.getFullyQualifiedName();
View Full Code Here

Examples of org.eclipse.jdt.core.IAnnotation

    String oldMethodPrefix = "on" + StringUtils.capitalize(m_oldName);
    String newMethodPrefix = "on" + StringUtils.capitalize(m_newName);
    IType type = (IType) m_field.getParent();
    for (IMethod method : type.getMethods()) {
      // prepare @UiHandler annotation
      IAnnotation annotation = getHandlerAnnotation(method);
      if (annotation == null) {
        continue;
      }
      // update @UiHandler name
      {
        ISourceRange annoRange = annotation.getSourceRange();
        ISourceRange nameRange = annotation.getNameRange();
        int nameEnd = nameRange.getOffset() + nameRange.getLength();
        int annoEnd = annoRange.getOffset() + annoRange.getLength();
        change.addEdit(new ReplaceEdit(nameEnd, annoEnd - nameEnd, "(\"" + m_newName + "\")"));
      }
      // rename method
View Full Code Here

Examples of org.eclipse.jdt.core.IAnnotation

    // try @UiTemplate
    IType uiTemplateType = m_javaProject.findType("com.google.gwt.uibinder.client.UiTemplate");
    List<IJavaElement> references = CodeUtils.searchReferences(uiTemplateType);
    for (IJavaElement reference : references) {
      if (reference instanceof IAnnotation) {
        IAnnotation annotation = (IAnnotation) reference;
        IMemberValuePair[] valuePairs = annotation.getMemberValuePairs();
        if (valuePairs.length == 1 && valuePairs[0].getValue() instanceof String) {
          String templateName = (String) valuePairs[0].getValue();
          // prepare ICompilationUnit
          ICompilationUnit compilationUnit =
              (ICompilationUnit) annotation.getAncestor(IJavaElement.COMPILATION_UNIT);
          // prepare qualified template name
          templateName = StringUtils.removeEnd(templateName, ".ui.xml");
          if (templateName.contains(".")) {
            templateName = templateName.replace('.', '/');
          } else {
            String packageName = compilationUnit.getPackageDeclarations()[0].getElementName();
            templateName = packageName.replace('.', '/') + "/" + templateName;
          }
          templateName += ".ui.xml";
          // if found, initialize "form" element
          if (m_binderResourceName.equals(templateName)) {
            m_formType = (IType) annotation.getParent().getParent();
            m_formClassName = m_formType.getFullyQualifiedName();
            m_formFile = (IFile) m_formType.getCompilationUnit().getUnderlyingResource();
            prepareBinderClass();
            if (m_binderClassName != null) {
              return;
View Full Code Here

Examples of org.eclipse.jdt.core.IAnnotation

        JavaElementLabelProvider.SHOW_DEFAULT);
    Suite4ClassesContentProvider cprovider = new Suite4ClassesContentProvider();

    /* find TestClasses already in Test Suite */
    IType testSuiteType = fTestSuite.findPrimaryType();
    IAnnotation runWithAnnotation = null;
    IAnnotation suiteClassesAnnotation = null;
    try {
      for (IAnnotation anno : testSuiteType.getAnnotations()) {
        if ("RunWith".equals(anno.getElementName())) {
          runWithAnnotation = anno;
        } else if ("SuiteClasses".equals(anno.getElementName())) {
View Full Code Here

Examples of org.eclipse.jdt.core.IAnnotation

  }
}
private void findAnnotationChanges(IAnnotation[] oldAnnotations, IAnnotation[] newAnnotations, IJavaElement parent) {
  ArrayList annotationDeltas = null;
  for (int i = 0, length = newAnnotations.length; i < length; i++) {
    IAnnotation newAnnotation = newAnnotations[i];
    Object oldInfo = this.annotationInfos.remove(newAnnotation);
    if (oldInfo == null) {
      JavaElementDelta annotationDelta = new JavaElementDelta(newAnnotation);
      annotationDelta.added();
      if (annotationDeltas == null) annotationDeltas = new ArrayList();
      annotationDeltas.add(annotationDelta);
      continue;
    } else {
      AnnotationInfo newInfo = null;
      try {
        newInfo = (AnnotationInfo) ((JavaElement) newAnnotation).getElementInfo();
      } catch (JavaModelException npe) {
        return;
      }
      if (!Util.equalArraysOrNull(((AnnotationInfo) oldInfo).members, newInfo.members)) {
        JavaElementDelta annotationDelta = new JavaElementDelta(newAnnotation);
        annotationDelta.changed(IJavaElementDelta.F_CONTENT);
        if (annotationDeltas == null) annotationDeltas = new ArrayList();
        annotationDeltas.add(annotationDelta);
      }
    }
  }
  for (int i = 0, length = oldAnnotations.length; i < length; i++) {
    IAnnotation oldAnnotation = oldAnnotations[i];
    if (this.annotationInfos.remove(oldAnnotation) != null) {
      JavaElementDelta annotationDelta = new JavaElementDelta(oldAnnotation);
      annotationDelta.removed();
      if (annotationDeltas == null) annotationDeltas = new ArrayList();
      annotationDeltas.add(annotationDelta);    }
View Full Code Here

Examples of org.eclipse.jdt.core.IAnnotation

  }

  public IMethodMockBuilder addTestAnnotation() {
    try {
      when(element.getSource()).thenReturn("@Test public void should_normal(){\n\n}");
      IAnnotation annotation = mock(IAnnotation.class);
      when(annotation.getElementName()).thenReturn("org.junit.Test");
      IAnnotation[] annotations = new IAnnotation[]{annotation};
      when(element.getAnnotations()).thenReturn(annotations );
    } catch (JavaModelException e) {
    }
    return this;
View Full Code Here

Examples of org.eclipse.jdt.core.IAnnotation

    IMethod[] methods = type.getMethods();
    for (int i = 0; i < methods.length; i++) {
      IMethod method = methods[i];
      IAnnotation[] annotations = method.getAnnotations();
      for (int j = 0; j < annotations.length; j++) {
        IAnnotation annotation = annotations[j];
        if(annotation.getElementName().equals(TEST_ANNOTATION_NAME) ||
            annotation.getElementName().equals(TEST_ANNOTATION_FULL_NAME)){
          return true;
        }
      }
    }
    ICompilationUnit compilationUnit = type.getCompilationUnit();
View Full Code Here

Examples of org.eclipse.jdt.core.IAnnotation

    IType testClass = project.getJavaProject().findType("test.TestClass");
    assertTrue(testClass.exists());
    IMethod method = testClass.getMethod("test_test", null);
    assertFalse(method.exists());
    IMethod doMethod = testClass.getMethod("do_test", null);
    IAnnotation annotation = doMethod.getAnnotation("org.junit.Test");
    assertTrue(annotation.exists());
    int length = doMethod.getJavadocRange().getLength();
    System.out.println(doMethod.getSource().substring(0,length));
    createAST(testClass);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.