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

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


  } else {
    SourceTypeBinding typeBinding = (SourceTypeBinding)typeVariableBinding.declaringElement;
    res = findLocalElement(typeBinding.sourceStart());
  }
  if (res != null && res.getElementType() == IJavaElement.TYPE) {
    IType type = (IType) res;
    ITypeParameter typeParameter = type.getTypeParameter(new String(typeVariableBinding.sourceName));
    if (typeParameter.exists()) {
      addElement(typeParameter);
      if(SelectionEngine.DEBUG){
        System.out.print("SELECTION - accept type parameter("); //$NON-NLS-1$
        System.out.print(typeParameter.toString());
View Full Code Here


  int previousElementIndex = this.elementIndex;
  this.elements = JavaElement.NO_ELEMENTS;
  this.elementIndex = -1;

  if(isDeclaration) {
    IType type = resolveTypeByLocation(declaringTypePackageName, declaringTypeName,
        NameLookup.ACCEPT_ALL,
        start, end);

    if(type != null) {
      this.acceptMethodDeclaration(type, selector, start, end);
    }
  } else {
    IType type = resolveType(declaringTypePackageName, declaringTypeName,
      NameLookup.ACCEPT_ALL);
    // fix for 1FWFT6Q
    if (type != null) {
      if (type.isBinary()) {

        // need to add a paramater for constructor in binary type
        IType declaringDeclaringType = type.getDeclaringType();

        boolean isStatic = false;
        try {
          isStatic = Flags.isStatic(type.getFlags());
        } catch (JavaModelException e) {
          // isStatic == false
        }

        if(declaringDeclaringType != null && isConstructor  && !isStatic) {
          int length = parameterPackageNames.length;
          System.arraycopy(parameterPackageNames, 0, parameterPackageNames = new char[length+1][], 1, length);
          System.arraycopy(parameterTypeNames, 0, parameterTypeNames = new char[length+1][], 1, length);
          System.arraycopy(parameterSignatures, 0, parameterSignatures = new String[length+1], 1, length);

          parameterPackageNames[0] = declaringDeclaringType.getPackageFragment().getElementName().toCharArray();
          parameterTypeNames[0] = declaringDeclaringType.getTypeQualifiedName().toCharArray();
          parameterSignatures[0] = Signature.getTypeErasure(enclosingDeclaringTypeSignature);
        }

        acceptBinaryMethod(type, selector, parameterPackageNames, parameterTypeNames, parameterSignatures, typeParameterNames, typeParameterBoundNames, uniqueKey, isConstructor);
      } else {
View Full Code Here

    System.out.println(")"); //$NON-NLS-1$
  }
  return;
}
public void acceptTypeParameter(char[] declaringTypePackageName, char[] declaringTypeName, char[] typeParameterName, boolean isDeclaration, int start, int end) {
  IType type;
  if(isDeclaration) {
    type = resolveTypeByLocation(declaringTypePackageName, declaringTypeName,
        NameLookup.ACCEPT_ALL,
        start, end);
  } else {
    type = resolveType(declaringTypePackageName, declaringTypeName,
        NameLookup.ACCEPT_ALL);
  }

  if(type != null) {
    ITypeParameter typeParameter = type.getTypeParameter(new String(typeParameterName));
    if(typeParameter == null) {
      addElement(type);
      if(SelectionEngine.DEBUG){
        System.out.print("SELECTION - accept type("); //$NON-NLS-1$
        System.out.print(type.toString());
        System.out.println(")"); //$NON-NLS-1$
      }
    } else {
      addElement(typeParameter);
      if(SelectionEngine.DEBUG){
View Full Code Here

      }
    }
  }
}
public void acceptMethodTypeParameter(char[] declaringTypePackageName, char[] declaringTypeName, char[] selector,int selectorStart, int selectorEnd, char[] typeParameterName, boolean isDeclaration, int start, int end) {
  IType type = resolveTypeByLocation(declaringTypePackageName, declaringTypeName,
      NameLookup.ACCEPT_ALL,
      selectorStart, selectorEnd);

  if(type != null) {
    IMethod method = null;

    String name = new String(selector);
    IMethod[] methods = null;

    try {
      methods = type.getMethods();
      done : for (int i = 0; i < methods.length; i++) {
        ISourceRange range = methods[i].getNameRange();
        if(range.getOffset() >= selectorStart
            && range.getOffset() + range.getLength() <= selectorEnd
            && methods[i].getElementName().equals(name)) {
          method = methods[i];
          break done;
        }
      }
    } catch (JavaModelException e) {
      //nothing to do
    }

    if(method == null) {
      addElement(type);
      if(SelectionEngine.DEBUG){
        System.out.print("SELECTION - accept type("); //$NON-NLS-1$
        System.out.print(type.toString());
        System.out.println(")"); //$NON-NLS-1$
      }
    } else {
      ITypeParameter typeParameter = method.getTypeParameter(new String(typeParameterName));
      if(typeParameter == null) {
View Full Code Here

/**
* Resolve the type
*/
protected IType resolveType(char[] packageName, char[] typeName, int acceptFlags) {

  IType type= null;

  if (this.openable instanceof CompilationUnit && ((CompilationUnit)this.openable).isWorkingCopy()) {
    CompilationUnit wc = (CompilationUnit) this.openable;
    try {
      if(((packageName == null || packageName.length == 0) && wc.getPackageDeclarations().length == 0) ||
        (!(packageName == null || packageName.length == 0) && wc.getPackageDeclaration(new String(packageName)).exists())) {

        char[][] compoundName = CharOperation.splitOn('.', typeName);
        if(compoundName.length > 0) {
          type = wc.getType(new String(compoundName[0]));
          for (int i = 1, length = compoundName.length; i < length; i++) {
            type = type.getType(new String(compoundName[i]));
          }
        }

        if(type != null && !type.exists()) {
          type = null;
        }
      }
    }catch (JavaModelException e) {
      // type is null
View Full Code Here

  }
  return type;
}
protected IType resolveTypeByLocation(char[] packageName, char[] typeName, int acceptFlags, int start, int end) {

  IType type= null;

  // TODO (david) post 3.0 should remove isOpen check, and investigate reusing ICompilationUnit#getElementAt. may need to optimize #getElementAt to remove recursions
  if (this.openable instanceof CompilationUnit && ((CompilationUnit)this.openable).isOpen()) {
    CompilationUnit wc = (CompilationUnit) this.openable;
    try {
      if(((packageName == null || packageName.length == 0) && wc.getPackageDeclarations().length == 0) ||
        (!(packageName == null || packageName.length == 0) && wc.getPackageDeclaration(new String(packageName)).exists())) {

        char[][] compoundName = CharOperation.splitOn('.', typeName);
        if(compoundName.length > 0) {

          IType[] tTypes = wc.getTypes();
          int i = 0;
          int depth = 0;
          done : while(i < tTypes.length) {
            ISourceRange range = tTypes[i].getSourceRange();
            if(range.getOffset() <= start
                && range.getOffset() + range.getLength() >= end
                && tTypes[i].getElementName().equals(new String(compoundName[depth]))) {
              if(depth == compoundName.length - 1) {
                type = tTypes[i];
                break done;
              }
              tTypes = tTypes[i].getTypes();
              i = 0;
              depth++;
              continue done;
            }
            i++;
          }
        }

        if(type != null && !type.exists()) {
          type = null;
        }
      }
    }catch (JavaModelException e) {
      // type is null
View Full Code Here

  if (innerTypes != null) {
    IPackageFragment pkg = (IPackageFragment) type.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
    for (int i = 0, typeCount = innerTypes.length; i < typeCount; i++) {
      IBinaryNestedType binaryType = innerTypes[i];
      IClassFile parentClassFile= pkg.getClassFile(new String(ClassFile.unqualifiedName(binaryType.getName())) + SUFFIX_STRING_class);
      IType innerType = new BinaryType((JavaElement) parentClassFile, ClassFile.simpleName(binaryType.getName()));
      childrenHandles.add(innerType);
    }
  }
}
View Full Code Here

    HashMap knownScopes = new HashMap(parsedUnit.localTypeCount);
    for (int i = 0; i < parsedUnit.localTypeCount; i++) {
      LocalTypeBinding localType = parsedUnit.localTypes[i];
      ClassScope classScope = localType.scope;
      TypeDeclaration typeDecl = classScope.referenceType();
      IType typeHandle = (IType)factory.createElement(classScope, cu, existingElements, knownScopes);
      rememberWithMemberTypes(typeDecl, typeHandle);
    }
  }
}
View Full Code Here

    if (!subOrSuperOfFocus(typeBinding)) {
      continue; // ignore types outside of hierarchy
    }

    IType superclass;
    if (typeBinding.isInterface()){ // do not connect interfaces to Object
      superclass = null;
    } else {
      superclass = findSuperClass(suppliedType, typeBinding);
    }
View Full Code Here

    org.aspectj.org.eclipse.jdt.core.ICompilationUnit[] cus = new org.aspectj.org.eclipse.jdt.core.ICompilationUnit[openablesLength];
    int unitsIndex = 0;
   
    CompilationUnitDeclaration focusUnit = null;
    ReferenceBinding focusBinaryBinding = null;
    IType focus = this.builder.getType();
    Openable focusOpenable = null;
    if (focus != null) {
      if (focus.isBinary()) {
        focusOpenable = (Openable)focus.getClassFile();
      } else {
        focusOpenable = (Openable)focus.getCompilationUnit();
      }
    }
   
    // build type bindings
    Parser parser = new Parser(this.lookupEnvironment.problemReporter, true);
    for (int i = 0; i < openablesLength; i++) {
      Openable openable = openables[i];
      if (openable instanceof org.aspectj.org.eclipse.jdt.core.ICompilationUnit) {
        org.aspectj.org.eclipse.jdt.core.ICompilationUnit cu = (org.aspectj.org.eclipse.jdt.core.ICompilationUnit)openable;

        // contains a potential subtype as a local or anonymous type?
        boolean containsLocalType = false;
        if (localTypes == null) { // case of hierarchy on region
          containsLocalType = true;
        } else {
          IPath path = cu.getPath();
          containsLocalType = localTypes.contains(path.toString());
        }
       
        // build parsed unit
        CompilationUnitDeclaration parsedUnit = null;
        if (cu.isOpen()) {
          // create parsed unit from source element infos
          CompilationResult result = new CompilationResult(((ICompilationUnit)cu).getFileName(), i, openablesLength, this.options.maxProblemsPerUnit);
          SourceTypeElementInfo[] typeInfos = null;
          try {
            IType[] topLevelTypes = cu.getTypes();
            int topLevelLength = topLevelTypes.length;
            if (topLevelLength == 0) continue; // empty cu: no need to parse (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=65677)
            typeInfos = new SourceTypeElementInfo[topLevelLength];
            for (int j = 0; j < topLevelLength; j++) {
              IType topLevelType = topLevelTypes[j];
              typeInfos[j] = (SourceTypeElementInfo)((JavaElement)topLevelType).getElementInfo();
            }
          } catch (JavaModelException e) {
            // types/cu exist since cu is opened
          }
          int flags = !containsLocalType
            ? SourceTypeConverter.MEMBER_TYPE
            : SourceTypeConverter.FIELD_AND_METHOD | SourceTypeConverter.MEMBER_TYPE | SourceTypeConverter.LOCAL_TYPE;
          parsedUnit =
            SourceTypeConverter.buildCompilationUnit(
              typeInfos,
              flags,
              this.lookupEnvironment.problemReporter,
              result);
          if (containsLocalType)   parsedUnit.bits |= ASTNode.HasAllMethodBodies;
        } else {
          // create parsed unit from file
          IFile file = (IFile) cu.getResource();
          ICompilationUnit sourceUnit = this.builder.createCompilationUnitFromPath(openable, file);
         
          CompilationResult unitResult = new CompilationResult(sourceUnit, i, openablesLength, this.options.maxProblemsPerUnit);
          parsedUnit = parser.dietParse(sourceUnit, unitResult);
        }

        if (parsedUnit != null) {
          hasLocalType[unitsIndex] = containsLocalType;
          cus[unitsIndex] = cu;
          parsedUnits[unitsIndex++] = parsedUnit;
          try {
            this.lookupEnvironment.buildTypeBindings(parsedUnit, null /*no access restriction*/);
            if (openable.equals(focusOpenable)) {
              focusUnit = parsedUnit;
            }
          } catch (AbortCompilation e) {
            // classpath problem for this type: ignore
          }
        }
      } else {
        // cache binary type binding
        ClassFile classFile = (ClassFile)openable;
        IBinaryType binaryType = null;
        if (classFile.isOpen()) {
          // create binary type from info
          IType type = classFile.getType();
          try {
            binaryType = (IBinaryType)((JavaElement)type).getElementInfo();
          } catch (JavaModelException e) {
            // type exists since class file is opened
          }
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.