Package org.aspectj.org.eclipse.jdt.core

Examples of org.aspectj.org.eclipse.jdt.core.IType


        return (JavaElement) declaringMethod.getTypeParameter(typeVariableName);
      } else {
        ITypeBinding typeBinding2 = this.resolver.getTypeBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding) declaringElement);
        if (typeBinding2 == null) return null;
        declaringTypeBinding = typeBinding2;
        IType declaringType = (IType) declaringTypeBinding.getJavaElement();
        return (JavaElement) declaringType.getTypeParameter(typeVariableName);
      }
    } else {
      if (fileName == null) return null; // case of a WilCardBinding that doesn't have a corresponding Java element
      // member or top level type
      ITypeBinding declaringTypeBinding = null;
      if (this.isArray()) {
        declaringTypeBinding = this.getElementType().getDeclaringClass();
      } else {
        declaringTypeBinding = this.getDeclaringClass();
      }
      if (declaringTypeBinding == null) {
        // top level type
        if (Util.isClassFileName(fileName)) {
          ClassFile classFile = (ClassFile) getClassFile(fileName);
          if (classFile == null) return null;
          return (JavaElement) classFile.getType();
        }
        ICompilationUnit cu = getCompilationUnit(fileName);
        if (cu == null) return null;
        return (JavaElement) cu.getType(new String(referenceBinding.sourceName()));
      } else {
        // member type
        IType declaringType = (IType) declaringTypeBinding.getJavaElement();
        if (declaringType == null) return null;
        return (JavaElement) declaringType.getType(new String(referenceBinding.sourceName()));
      }
    }
  }
View Full Code Here


  public void findIndexMatches(Index index, IndexQueryRequestor requestor, SearchParticipant participant, IJavaSearchScope scope, IProgressMonitor progressMonitor) {
      IPackageFragmentRoot root = (IPackageFragmentRoot) this.typeParameter.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
    String documentPath;
    String relativePath;
      if (root.isArchive()) {
         IType type = (IType) this.typeParameter.getAncestor(IJavaElement.TYPE);
          relativePath = (type.getFullyQualifiedName('/')).replace('.', '/') + SuffixConstants.SUFFIX_STRING_class;
          documentPath = root.getPath() + IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR + relativePath;
      } else {
      IPath path = this.typeParameter.getPath();
          documentPath = path.toString();
      relativePath = Util.relativePath(path, 1/*remove project segment*/);
 
View Full Code Here

        if (newElement != null) {
          knownScopes.put(scope, newElement);
        }
        break;
      case Scope.METHOD_SCOPE :
        IType parentType = (IType) createElement(scope.parent, elementPosition, unit, existingElements, knownScopes);
        MethodScope methodScope = (MethodScope) scope;
        if (methodScope.isInsideInitializer()) {
          // inside field or initializer, must find proper one
          TypeDeclaration type = methodScope.referenceType();
          int occurenceCount = 1;
          for (int i = 0, length = type.fields.length; i < length; i++) {
            FieldDeclaration field = type.fields[i];
            if (field.declarationSourceStart < elementPosition && field.declarationSourceEnd > elementPosition) {
              switch (field.getKind()) {
                case AbstractVariableDeclaration.FIELD :
                case AbstractVariableDeclaration.ENUM_CONSTANT :
                  newElement = parentType.getField(new String(field.name));
                  break;
                case AbstractVariableDeclaration.INITIALIZER :
                  newElement = parentType.getInitializer(occurenceCount);
                  break;
              }
              break;
            } else if (field.getKind() == AbstractVariableDeclaration.INITIALIZER) {
              occurenceCount++;
            }
          }
        } else {
          // method element
          AbstractMethodDeclaration method = methodScope.referenceMethod();
          newElement = parentType.getMethod(new String(method.selector), Util.typeParameterSignatures(method));
          if (newElement != null) {
            knownScopes.put(scope, newElement);
          }
        }
        break;       
View Full Code Here

    }
 
    /* convert type */
    TypeDeclaration typeDeclaration = convert(type, null, null, compilationResult);
   
    IType alreadyComputedMember = type;
    IType parent = type.getDeclaringType();
    TypeDeclaration previousDeclaration = typeDeclaration;
    while(parent != null) {
      TypeDeclaration declaration = convert(parent, alreadyComputedMember, previousDeclaration, compilationResult);
     
      alreadyComputedMember = parent;
      previousDeclaration = declaration;
      parent = parent.getDeclaringType();
    }
   
    compilationUnit.types = new TypeDeclaration[]{previousDeclaration};

    return typeDeclaration;
View Full Code Here

      return null;
    return element.resolved(this.binding);
  }

  private JavaElement getUnresolvedJavaElement() {
    IType declaringType = (IType) getDeclaringClass().getJavaElement();
    if (declaringType == null) return null;
    if (!(this.resolver instanceof DefaultBindingResolver)) return null;
    ASTNode node = (ASTNode) ((DefaultBindingResolver) this.resolver).bindingsToAstNodes.get(this);
    if (node != null && declaringType.getParent().getElementType() != IJavaElement.CLASS_FILE) {
      if (node instanceof MethodDeclaration) {
        MethodDeclaration methodDeclaration = (MethodDeclaration) node;
        ArrayList parameterSignatures = new ArrayList();
        Iterator iterator = methodDeclaration.parameters().iterator();
        while (iterator.hasNext()) {
          SingleVariableDeclaration parameter = (SingleVariableDeclaration) iterator.next();
          Type type = parameter.getType();
          String typeSig = Util.getSignature(type);
          int arrayDim = parameter.getExtraDimensions();
          if (parameter.getAST().apiLevel() >= AST.JLS3 && parameter.isVarargs()) {
            arrayDim++;
          }
          if (arrayDim > 0) {
            typeSig = Signature.createArraySignature(typeSig, arrayDim);
          }
          parameterSignatures.add(typeSig);
        }
        int parameterCount = parameterSignatures.size();
        String[] parameters = new String[parameterCount];
        parameterSignatures.toArray(parameters);
        return (JavaElement) declaringType.getMethod(getName(), parameters);
      } else {
        // annotation type member declaration
        AnnotationTypeMemberDeclaration typeMemberDeclaration = (AnnotationTypeMemberDeclaration) node;
        return (JavaElement) declaringType.getMethod(typeMemberDeclaration.getName().getIdentifier(), CharOperation.NO_STRINGS); // annotation type members don't have parameters
      }
    } else {
      // case of method not in the created AST, or a binary method
      org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding original = this.binding.original();
      String selector = original.isConstructor() ? declaringType.getElementName() : new String(original.selector);
      boolean isBinary = declaringType.isBinary();
      ReferenceBinding enclosingType = original.declaringClass.enclosingType();
      boolean isInnerBinaryTypeConstructor = isBinary && original.isConstructor() && enclosingType != null;
      TypeBinding[] parameters = original.parameters;
      int length = parameters == null ? 0 : parameters.length;
      int declaringIndex = isInnerBinaryTypeConstructor ? 1 : 0;
      String[] parameterSignatures = new String[declaringIndex + length];
      if (isInnerBinaryTypeConstructor)
        parameterSignatures[0] = new String(enclosingType.genericTypeSignature()).replace('/', '.');
      for (int i = 0;  i < length; i++) {
        parameterSignatures[declaringIndex + i] = new String(parameters[i].genericTypeSignature()).replace('/', '.');
      }
      IMethod result = declaringType.getMethod(selector, parameterSignatures);
      if (isBinary)
        return (JavaElement) result;
      IMethod[] methods = null;
      try {
        methods = declaringType.getMethods();
      } catch (JavaModelException e) {
        // declaring type doesn't exist
        return null;
      }
      IMethod[] candidates = Member.findMethods(result, methods);
View Full Code Here

    }
    this.typeNameRanges[typeDepth] =
      new SourceRange(typeInfo.nameSourceStart, typeInfo.nameSourceEnd - typeInfo.nameSourceStart + 1);
    this.typeDeclarationStarts[typeDepth] = typeInfo.declarationStart;

    IType currentType = this.types[typeDepth];
   
    // type parameters
    if (typeInfo.typeParameters != null) {
      for (int i = 0, length = typeInfo.typeParameters.length; i < length; i++) {
        TypeParameterInfo typeParameterInfo = typeInfo.typeParameters[i];
        ITypeParameter typeParameter = currentType.getTypeParameter(new String(typeParameterInfo.name));
        setSourceRange(
          typeParameter,
          new SourceRange(
            typeParameterInfo.declarationStart,
            typeParameterInfo.declarationEnd - typeParameterInfo.declarationStart + 1),
View Full Code Here

        new SourceRange(fieldInfo.nameSourceStart, fieldInfo.nameSourceEnd - fieldInfo.nameSourceStart + 1);
      String fieldName = new String(fieldInfo.name);
      this.memberName[typeDepth] = fieldName;
     
      // categories
      IType currentType = this.types[typeDepth];
      IField field = currentType.getField(fieldName);
      addCategories(field, fieldInfo.categories);
    }
  }
View Full Code Here

    if (typeDepth >= 0) {
      this.memberName[typeDepth] = new String(methodInfo.name);
      this.memberNameRange[typeDepth] =
        new SourceRange(methodInfo.nameSourceStart, methodInfo.nameSourceEnd - methodInfo.nameSourceStart + 1);
      this.memberDeclarationStart[typeDepth] = methodInfo.declarationStart;
      IType currentType = this.types[typeDepth];
      int currenTypeModifiers = this.typeModifiers[typeDepth];
      char[][] parameterTypes = methodInfo.parameterTypes;
      if (parameterTypes != null && methodInfo.isConstructor && currentType.getDeclaringType() != null && !Flags.isStatic(currenTypeModifiers)) {
        IType declaringType = currentType.getDeclaringType();
        String declaringTypeName = declaringType.getElementName();
        if (declaringTypeName.length() == 0) {
          IClassFile classFile = declaringType.getClassFile();
          int length = parameterTypes.length;
          char[][] newParameterTypes = new char[length+1][];
          declaringTypeName = classFile.getElementName();
          declaringTypeName = declaringTypeName.substring(0, declaringTypeName.indexOf('.'));
          newParameterTypes[0] = declaringTypeName.toCharArray();
View Full Code Here

  /**
   * @see ISourceElementRequestor
   */
  public void exitType(int declarationEnd) {
    if (typeDepth >= 0) {
      IType currentType = this.types[typeDepth];
      setSourceRange(
        currentType,
        new SourceRange(
          this.typeDeclarationStarts[typeDepth],
          declarationEnd - this.typeDeclarationStarts[typeDepth] + 1),
View Full Code Here

  /**
   * @see ISourceElementRequestor
   */
  public void exitField(int initializationStart, int declarationEnd, int declarationSourceEnd) {
    if (typeDepth >= 0) {
      IType currentType = this.types[typeDepth];
      setSourceRange(
        currentType.getField(this.memberName[typeDepth]),
        new SourceRange(
          this.memberDeclarationStart[typeDepth],
          declarationEnd - this.memberDeclarationStart[typeDepth] + 1),
        this.memberNameRange[typeDepth]);
    }
View Full Code Here

TOP

Related Classes of org.aspectj.org.eclipse.jdt.core.IType

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.