Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.IField


    IAnnotationMetadata metadata = getAnnotationMetadata(type);
   
    Map<IField, Annotation> annotations = metadata.getFieldLevelAnnotations(Autowired.class.getName());
    assertEquals(1, annotations.size());
   
    IField field = type.getField("injectedDependency");
    Annotation annotation = annotations.get(field);
    assertEquals(Autowired.class.getName(), annotation.getAnnotationClass());
    Set<AnnotationMemberValuePair> members = annotation.getMembers();
    assertEquals(0, members.size());
  }
View Full Code Here


  public FieldVisitor visitField(final int access, final String name, final String desc, final String signature, Object value) {
    return new EmptyFieldVisitor() {
      @Override
      public AnnotationVisitor visitAnnotation(final String annotationDesc, boolean visible) {
        final String annotationClass = Type.getType(annotationDesc).getClassName();
        final IField field = getFieldFromSignature(name);

        if (field != null) {
          final Set<Annotation> fieldAnnotations = getAnnotationSet(field);
          final Annotation annotation = new Annotation(annotationClass);
          fieldAnnotations.add(annotation);
View Full Code Here

    }
    return result;
  }

  private IField getFieldFromSignature(final String name) {
    IField field = quickCheckForField(name);
    if (field == null) {
      field = JdtUtils.getField(type, name, false);
    }
    return field;
  }
View Full Code Here

    }
    return field;
  }

  private IField quickCheckForField(String name) {
    IField field = type.getField(name);
    return field != null && field.exists() ? field : null;
  }
View Full Code Here

      catch (JavaModelException e) {
      }
    }
    else if (element != null && element instanceof IField) {
      try {
        IField type = (IField) element;
        int lines = 0;
        ICompilationUnit cu = type.getCompilationUnit();
        if (cu != null) {
          String targetsource = cu.getSource();
          if (targetsource != null) {
            String sourceuptomethod = targetsource.substring(0, type.getNameRange().getOffset());
 
            char[] chars = new char[sourceuptomethod.length()];
            sourceuptomethod.getChars(0, sourceuptomethod.length(), chars, 0);
            for (char element0 : chars) {
              if (element0 == '\n') {
View Full Code Here

            .getAdvices()));
      }
      return nodes.toArray();
    }
    else if (parentElement instanceof IField && parentElement instanceof SourceField) {
      IField method = (IField) parentElement;
      List<IAopReference> references = Activator.getModel().getAllReferences();
      List<IAopReference> foundSourceReferences = new ArrayList<IAopReference>();
      for (IAopReference reference : references) {
        if (reference.getSource() != null && reference.getSource().equals(method)) {
          foundSourceReferences.add(reference);
View Full Code Here

    processor = new QualifierAnnotationQuickAssistProcessor();
  }

  public void testFieldWithNoAutowired() throws JavaModelException {
    IField field = type.getField("testBean1");
    ISourceRange sourceRange = field.getSourceRange();
    FieldDeclaration fieldDecl = (FieldDeclaration) getASTNode(sourceRange, type, viewer);
    IInvocationContext context = getContext(sourceRange, field, fieldDecl);

    List<IJavaCompletionProposal> proposals = processor.getAssists(fieldDecl, context);
    assertTrue("No proposals expected", proposals.isEmpty());
View Full Code Here

    List<IJavaCompletionProposal> proposals = processor.getAssists(fieldDecl, context);
    assertTrue("No proposals expected", proposals.isEmpty());
  }

  public void testField() throws JavaModelException {
    IField field = type.getField("testBean2");
    ISourceRange sourceRange = field.getSourceRange();
    FieldDeclaration fieldDecl = (FieldDeclaration) getASTNode(sourceRange, type, viewer);
    IInvocationContext context = getContext(sourceRange, field, fieldDecl);

    List<IJavaCompletionProposal> proposals = processor.getAssists(fieldDecl, context);
    assertEquals("1 proposal is expected", 1, proposals.size());
View Full Code Here

    List<IJavaCompletionProposal> proposals = processor.getAssists(methodDecl, context);
    assertTrue("No proposals expected", proposals.isEmpty());
  }

  public void testField() throws JavaModelException {
    IField field = type.getField("testBean1");
    ISourceRange sourceRange = field.getSourceRange();
    FieldDeclaration fieldDecl = (FieldDeclaration) getASTNode(sourceRange, type, viewer);
    IInvocationContext context = getContext(sourceRange, field, fieldDecl);

    List<IJavaCompletionProposal> proposals = processor.getAssists(fieldDecl, context);
    assertTrue("2 proposals are expected", proposals.size() == 2);
View Full Code Here

    assertTrue("AddAutowireCompletionProposal expected", proposals.get(0) instanceof AddAutowireCompletionProposal);
    assertTrue("AddAutowireCompletionProposal expected", proposals.get(1) instanceof AddAutowireCompletionProposal);
  }

  public void testFieldWithAutowired() throws JavaModelException {
    IField field = type.getField("testBean2");
    ISourceRange sourceRange = field.getSourceRange();
    FieldDeclaration fieldDecl = (FieldDeclaration) getASTNode(sourceRange, type, viewer);
    IInvocationContext context = getContext(sourceRange, field, fieldDecl);

    List<IJavaCompletionProposal> proposals = processor.getAssists(fieldDecl, context);
    assertTrue("No proposals expected", proposals.isEmpty());
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.IField

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.