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

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


   */
  protected IType getHandle(IGenericType genericType, ReferenceBinding binding) {
    if (genericType == null)
      return null;
    if (genericType instanceof HierarchyType) {
      IType handle = (IType)this.infoToHandle.get(genericType);
      if (handle == null) {
        handle = ((HierarchyType)genericType).typeHandle;
        handle = (IType) ((JavaElement) handle).resolved(binding);
        this.infoToHandle.put(genericType, handle);
      }
      return handle;
    } else if (genericType.isBinaryType()) {
      ClassFile classFile = (ClassFile) this.infoToHandle.get(genericType);
      // if it's null, it's from outside the region, so do lookup
      if (classFile == null) {
        IType handle = lookupBinaryHandle((IBinaryType) genericType);
        if (handle == null)
          return null;
        // case of an anonymous type (see 1G2O5WK: ITPJCORE:WINNT - NullPointerException when selecting "Show in Type Hierarchy" for a inner class)
        // optimization: remember the handle for next call (case of java.io.Serializable that a lot of classes implement)
        classFile = (ClassFile) handle.getParent();
        this.infoToHandle.put(genericType, classFile);
      }
      return new ResolvedBinaryType(classFile, classFile.getTypeName(), new String(binding.computeUniqueKey()));
    } else if (genericType instanceof SourceTypeElementInfo) {
      IType handle = ((SourceTypeElementInfo) genericType).getHandle();
      return (IType) ((JavaElement) handle).resolved(binding);
    } else
      return null;
  }
View Full Code Here


  while (sourceType.getEnclosingType() != null)
    sourceType = sourceType.getEnclosingType();
  if (sourceType instanceof SourceTypeElementInfo) {
    // get source
    SourceTypeElementInfo elementInfo = (SourceTypeElementInfo) sourceType;
    IType type = elementInfo.getHandle();
    ICompilationUnit sourceUnit = (ICompilationUnit) type.getCompilationUnit();
    accept(sourceUnit, accessRestriction);
  } else {
    CompilationResult result = new CompilationResult(sourceType.getFileName(), 1, 1, 0);
    CompilationUnitDeclaration unit =
      SourceTypeConverter.buildCompilationUnit(
View Full Code Here

* Caches the given binary type in the lookup environment and returns it.
* Returns the existing one if already cached.
* Returns null if source type binding was cached.
*/
protected BinaryTypeBinding cacheBinaryType(IType type, IBinaryType binaryType) throws JavaModelException {
  IType enclosingType = type.getDeclaringType();
  if (enclosingType != null)
    cacheBinaryType(enclosingType, null); // cache enclosing types first, so that binary type can be found in lookup enviroment
  if (binaryType == null) {
    ClassFile classFile = (ClassFile) type.getClassFile();
    try {
View Full Code Here

* Creates an IMethod from the given method declaration and type.
*/
protected IJavaElement createHandle(AbstractMethodDeclaration method, IJavaElement parent) {
  if (!(parent instanceof IType)) return parent;

  IType type = (IType) parent;
  Argument[] arguments = method.arguments;
  int argCount = arguments == null ? 0 : arguments.length;
  if (type.isBinary()) {
    // don't cache the methods of the binary type
    // fall thru if its a constructor with a synthetic argument... find it the slower way
    ClassFileReader reader = classFileReader(type);
    if (reader != null) {
      IBinaryMethod[] methods = reader.getMethods();
      if (methods != null) {
        // build arguments names
        boolean firstIsSynthetic = false;
        if (reader.isMember() && method.isConstructor() && !Flags.isStatic(reader.getModifiers())) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=48261
          firstIsSynthetic = true;
          argCount++;
        }
        char[][] argumentTypeNames = new char[argCount][];
        for (int i = 0; i < argCount; i++) {
          char[] typeName = null;
          if (i == 0 && firstIsSynthetic) {
            typeName = type.getDeclaringType().getFullyQualifiedName().toCharArray();
          } else if (arguments != null) {
            TypeReference typeRef = arguments[firstIsSynthetic ? i - 1 : i].type;
            typeName = CharOperation.concatWith(typeRef.getTypeName(), '.');
            for (int k = 0, dim = typeRef.dimensions(); k < dim; k++)
              typeName = CharOperation.concat(typeName, new char[] {'[', ']'});
View Full Code Here

/**
* Creates an IField from the given field declaration and type.
*/
protected IJavaElement createHandle(FieldDeclaration fieldDeclaration, TypeDeclaration typeDeclaration, IJavaElement parent) {
  if (!(parent instanceof IType)) return parent;
  IType type = (IType) parent;

  switch (fieldDeclaration.getKind()) {
    case AbstractVariableDeclaration.FIELD :
    case AbstractVariableDeclaration.ENUM_CONSTANT :
      return ((IType) parent).getField(new String(fieldDeclaration.name));
  }
  if (type.isBinary()) {
    // do not return initializer for binary types
    // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=98378
    return type;
  }
  // find occurence count of the given initializer in its type declaration
View Full Code Here

  Openable openable = this.currentPossibleMatch.openable;
  if (openable instanceof CompilationUnit)
    return ((CompilationUnit) openable).getImport(new String(importName));

  // binary types do not contain import statements so just answer the top-level type as the element
  IType binaryType = ((ClassFile) openable).getType();
  String typeName = binaryType.getElementName();
  int lastDollar = typeName.lastIndexOf('$');
  if (lastDollar == -1) return binaryType;
  return createTypeHandle(typeName.substring(0, lastDollar));
}
View Full Code Here

protected IType createTypeHandle(String simpleTypeName) {
  Openable openable = this.currentPossibleMatch.openable;
  if (openable instanceof CompilationUnit)
    return ((CompilationUnit) openable).getType(simpleTypeName);

  IType binaryType = ((ClassFile) openable).getType();
  String binaryTypeQualifiedName = binaryType.getTypeQualifiedName();
  if (simpleTypeName.equals(binaryTypeQualifiedName))
    return binaryType; // answer only top-level types, sometimes the classFile is for a member/local type

  // type name may be null for anonymous (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=164791)
  String classFileName = simpleTypeName.length() == 0 ? binaryTypeQualifiedName : simpleTypeName;
  IClassFile classFile = binaryType.getPackageFragment().getClassFile(classFileName + SuffixConstants.SUFFIX_STRING_class);
  return classFile.getType();
}
View Full Code Here

    }
    if (mustResolve)
      this.lookupEnvironment.completeTypeBindings();

    // create hierarchy resolver if needed
    IType focusType = getFocusType();
    if (focusType == null) {
      this.hierarchyResolver = null;
    } else if (!createHierarchyResolver(focusType, possibleMatches)) {
      // focus type is not visible, use the super type names instead of the bindings
      if (computeSuperTypeNames(focusType) == null) return;
View Full Code Here

  } else if (typeBinding.isClass()) {
    acceptFlag = NameLookup.ACCEPT_CLASSES;
  }
  if (pkgs != null) {
    for (int i = 0, length = pkgs.length; i < length; i++) {
      IType type = this.nameLookup.findType(typeName, pkgs[i],  false,  acceptFlag, true/*consider secondary types*/);
      if (type != null) return type;
    }
  }

  // search inside enclosing element
  char[][] qualifiedName = CharOperation.splitOn('.', sourceName);
  int length = qualifiedName.length;
  if (length == 0) return null;

  IType type = createTypeHandle(new String(qualifiedName[0])); // find the top-level type
  if (type == null) return null;

  for (int i = 1; i < length; i++) {
    type = type.getType(new String(qualifiedName[i]));
    if (type == null) return null;
  }
  if (type.exists()) return type;
  return null;
}
View Full Code Here

        ITypeParameter[] parameters = null;
        while (parent != null && parent.getElementType() == IJavaElement.TYPE) {
          if (++ptr > typeParameters.length) {
            System.arraycopy(typeParameters, 0, typeParameters = new char[typeParameters.length+10][][], 0, ptr);
          }
          IType parentType = (IType) parent;
          parameters = parentType.getTypeParameters();
          if (parameters !=null) {
            int length = parameters.length;
            if (length > 0) {
              hasParameters = true;
              typeParameters[ptr] = new char[length][];
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.