Examples of JavaElement


Examples of org.eclipse.jdt.internal.core.JavaElement

    }
    return this.interfaces = NO_TYPE_BINDINGS;
  }

  public IJavaElement getJavaElement() {
    JavaElement element = getUnresolvedJavaElement();
    if (element != null)
      return element.resolved(this.binding);
    if (isRecovered()) {
      IPackageBinding packageBinding = getPackage();
      if (packageBinding != null) {
        final IJavaElement javaElement = packageBinding.getJavaElement();
        if (javaElement != null && javaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
View Full Code Here

Examples of org.eclipse.jdt.internal.core.JavaElement

  /**
   * Return the java element corresponding to the given compiler binding.
   */
  public static JavaElement getUnresolvedJavaElement(FieldBinding binding, WorkingCopyOwner workingCopyOwner, BindingsToNodesMap bindingsToNodes) {
    if (binding.declaringClass == null) return null; // array length
    JavaElement unresolvedJavaElement = getUnresolvedJavaElement(binding.declaringClass, workingCopyOwner, bindingsToNodes);
    if (unresolvedJavaElement == null || unresolvedJavaElement.getElementType() != IJavaElement.TYPE) {
      return null;
    }
    return (JavaElement) ((IType) unresolvedJavaElement).getField(String.valueOf(binding.name));
  }
View Full Code Here

Examples of org.eclipse.jdt.internal.core.JavaElement

  /**
   * Return the java element corresponding to the given compiler binding.
   */
  public static JavaElement getUnresolvedJavaElement(MethodBinding methodBinding, WorkingCopyOwner workingCopyOwner, BindingsToNodesMap bindingsToNodes) {
    JavaElement unresolvedJavaElement = getUnresolvedJavaElement(methodBinding.declaringClass, workingCopyOwner, bindingsToNodes);
    if (unresolvedJavaElement == null || unresolvedJavaElement.getElementType() != IJavaElement.TYPE) {
      return null;
    }
    IType declaringType = (IType) unresolvedJavaElement;

    org.eclipse.jdt.internal.compiler.ast.ASTNode node = bindingsToNodes == null ? null : bindingsToNodes.get(methodBinding);
View Full Code Here

Examples of org.eclipse.jdt.internal.core.JavaElement

  }

  private JavaElement getJavaElement(LocalVariableBinding binding) {
    LocalDeclaration local = binding.declaration;

    JavaElement parent = null;
    ReferenceContext referenceContext = binding.declaringScope.referenceContext();
    if (referenceContext instanceof AbstractMethodDeclaration) {
      AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) referenceContext;
      parent = this.getJavaElementOfCompilationUnit(methodDeclaration, methodDeclaration.binding);
    } else if (referenceContext instanceof TypeDeclaration){
      // Local variable is declared inside an initializer
      TypeDeclaration typeDeclaration = (TypeDeclaration) referenceContext;

      JavaElement type = this.getJavaElementOfCompilationUnit(typeDeclaration, typeDeclaration.binding);
      parent = Util.getUnresolvedJavaElement(local.sourceStart, local.sourceEnd, type);
    }
    if (parent == null) return null;

    return new LocalVariable(
View Full Code Here

Examples of org.eclipse.jdt.internal.core.JavaElement

    if (size > 0) {
      next : for (int i = 0; i < size; i++) {
        try {
          LocalVariableBinding binding = (LocalVariableBinding) this.visibleLocalVariables.elementAt(i);
          if (binding.type == null || (assignableTypeBinding != null && !binding.type.isCompatibleWith(assignableTypeBinding))) continue next;
          JavaElement localVariable = getJavaElement(binding);
          if (localVariable != null) result[elementCount++] = localVariable;
        } catch(AbortCompilation e) {
          // log the exception and proceed
          Util.logRepeatedMessage(e.getKey(), e);
        }
      }

    }
    size = this.visibleFields.size();
    if (size > 0) {
      next : for (int i = 0; i < size; i++) {
        try {
          FieldBinding binding = (FieldBinding) this.visibleFields.elementAt(i);
          if (assignableTypeBinding != null && !binding.type.isCompatibleWith(assignableTypeBinding)) continue next;
          if (this.assistScope.isDefinedInSameUnit(binding.declaringClass)) {
            JavaElement field = getJavaElementOfCompilationUnit(binding);
            if (field != null) result[elementCount++] = field;
          } else {
            JavaElement field = Util.getUnresolvedJavaElement(binding, this.owner, EmptyNodeMap);
            if (field != null) result[elementCount++] = field.resolved(binding);
          }
        } catch(AbortCompilation e) {
          // log the exception and proceed
          Util.logRepeatedMessage(e.getKey(), e);
        }
      }

    }
    size = this.visibleMethods.size();
    if (size > 0) {
      next : for (int i = 0; i < size; i++) {
        try {
          MethodBinding binding = (MethodBinding) this.visibleMethods.elementAt(i);
          if (assignableTypeBinding != null && !binding.returnType.isCompatibleWith(assignableTypeBinding)) continue next;
          if (this.assistScope.isDefinedInSameUnit(binding.declaringClass)) {
            JavaElement method = getJavaElementOfCompilationUnit(binding);
            if (method != null) result[elementCount++] = method;
          } else {
            JavaElement method = Util.getUnresolvedJavaElement(binding, this.owner, EmptyNodeMap);
            if (method != null) result[elementCount++] = method.resolved(binding);
          }
        } catch(AbortCompilation e) {
          // log the exception and proceed
          Util.logRepeatedMessage(e.getKey(), e);
        }
View Full Code Here

Examples of org.eclipse.jdt.internal.core.JavaElement

public String toString() {
  StringBuffer result = new StringBuffer("JavaSearchScope on "); //$NON-NLS-1$
  if (this.elements != null) {
    result.append("["); //$NON-NLS-1$
    for (int i = 0, length = this.elements.size(); i < length; i++) {
      JavaElement element = (JavaElement)this.elements.get(i);
      result.append("\n\t"); //$NON-NLS-1$
      result.append(element.toStringWithAncestors());
    }
    result.append("\n]"); //$NON-NLS-1$
  } else {
    if (this.pathsCount == 0) {
      result.append("[empty scope]"); //$NON-NLS-1$
View Full Code Here

Examples of org.eclipse.jdt.internal.core.JavaElement

      }
    } catch (Exception e) {
      // it's just for debug purposes... ignore all exceptions in this area
    }
    try {
      JavaElement javaElement = (JavaElement)match.getElement();
      System.out.println("\tJava element: "+ javaElement.toStringWithAncestors()); //$NON-NLS-1$
      if (!javaElement.exists()) {
        System.out.println("\t\tWARNING: this element does NOT exist!"); //$NON-NLS-1$
      }
    } catch (Exception e) {
      // it's just for debug purposes... ignore all exceptions in this area
    }
    if (match instanceof ReferenceMatch) {
      try {
        ReferenceMatch refMatch = (ReferenceMatch) match;
        JavaElement local = (JavaElement) refMatch.getLocalElement();
        if (local != null) {
          System.out.println("\tLocal element: "+ local.toStringWithAncestors()); //$NON-NLS-1$
        }
        if (match instanceof TypeReferenceMatch) {
          IJavaElement[] others = ((TypeReferenceMatch) refMatch).getOtherElements();
          if (others != null) {
            int length = others.length;
            if (length > 0) {
              System.out.println("\tOther elements:"); //$NON-NLS-1$
              for (int i=0; i<length; i++) {
                JavaElement other = (JavaElement) others[i];
                System.out.println("\t\t- "+ other.toStringWithAncestors()); //$NON-NLS-1$
              }
            }
          }
        }
      } catch (Exception e) {
View Full Code Here

Examples of org.eclipse.jdt.internal.core.JavaElement

    }
    return this.exceptionTypes = exTypes;
  }

  public IJavaElement getJavaElement() {
    JavaElement element = getUnresolvedJavaElement();
    if (element == null)
      return null;
    return element.resolved(this.binding);
  }
View Full Code Here

Examples of org.eclipse.jdt.internal.core.JavaElement

  /**
   * Return the java element corresponding to the given compiler binding.
   */
  public static JavaElement getUnresolvedJavaElement(FieldBinding binding, WorkingCopyOwner workingCopyOwner, BindingsToNodesMap bindingsToNodes) {
    if (binding.declaringClass == null) return null; // array length
    JavaElement unresolvedJavaElement = getUnresolvedJavaElement(binding.declaringClass, workingCopyOwner, bindingsToNodes);
    if (unresolvedJavaElement == null || unresolvedJavaElement.getElementType() != IJavaElement.TYPE) {
      return null;
    }
    return (JavaElement) ((IType) unresolvedJavaElement).getField(String.valueOf(binding.name));
  }
View Full Code Here

Examples of org.eclipse.jdt.internal.core.JavaElement

  /**
   * Return the java element corresponding to the given compiler binding.
   */
  public static JavaElement getUnresolvedJavaElement(MethodBinding methodBinding, WorkingCopyOwner workingCopyOwner, BindingsToNodesMap bindingsToNodes) {
    JavaElement unresolvedJavaElement = getUnresolvedJavaElement(methodBinding.declaringClass, workingCopyOwner, bindingsToNodes);
    if (unresolvedJavaElement == null || unresolvedJavaElement.getElementType() != IJavaElement.TYPE) {
      return null;
    }
    IType declaringType = (IType) unresolvedJavaElement;

    org.eclipse.jdt.internal.compiler.ast.ASTNode node = bindingsToNodes == null ? null : bindingsToNodes.get(methodBinding);
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.