Package org.eclipse.jdt.internal.compiler.lookup

Examples of org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding


  private void maybeDispatch(Expression expression, TypeBinding binding) {
    assert (binding != null);

    if (binding instanceof SourceTypeBinding) {
      SourceTypeBinding type = (SourceTypeBinding) binding;
      onTypeRef(type, cud);
    } else if (binding instanceof ArrayBinding) {
      maybeDispatch(expression, ((ArrayBinding) binding).leafComponentType);
    } else if (binding instanceof BinaryTypeBinding) {
      onBinaryTypeRef((BinaryTypeBinding) binding, cud, expression);
View Full Code Here


  /**
   * Returns <code>true</code> if this is a local type, or if this type is
   * nested inside of any local type.
   */
  private static boolean isLocalType(SourceTypeBinding binding) {
    SourceTypeBinding b = binding;
    while (!b.isStatic()) {
      if (b instanceof LocalTypeBinding) {
        return true;
      }
      b = ((NestedTypeBinding) b).enclosingType;
    }
View Full Code Here

  private transient NameEnvironmentAnswer nameEnvironmentAnswer;

  CompiledClass(TypeDeclaration typeDeclaration, CompiledClass enclosingClass) {
    this.enclosingClass = enclosingClass;
    SourceTypeBinding binding = typeDeclaration.binding;
    this.internalName = CharOperation.charToString(binding.constantPoolName());
    ClassFile classFile = getClassFile(typeDeclaration, internalName);
    byte[] bytes = classFile.getBytes();
    this.cacheToken = diskCache.writeByteArray(bytes);
    this.isLocal = isLocalType(binding);
  }
View Full Code Here

      }
    }

    JExpression processExpression(AllocationExpression x) {
      SourceInfo info = makeSourceInfo(x);
      SourceTypeBinding typeBinding = erasure(x.resolvedType);
      if (typeBinding.constantPoolName() == null) {
        /*
         * Weird case: if JDT determines that this local class is totally
         * uninstantiable, it won't bother allocating a local name.
         */
        return program.getLiteralNull();
View Full Code Here

      }
    }

    JExpression processExpression(AllocationExpression x) {
      SourceInfo info = makeSourceInfo(x);
      SourceTypeBinding typeBinding = erasure(x.resolvedType);
      if (typeBinding.constantPoolName() == null) {
        /*
         * Weird case: if JDT determines that this local class is totally
         * uninstantiable, it won't bother allocating a local name.
         */
        return program.getLiteralNull();
View Full Code Here

     */
    private boolean process(TypeDeclaration typeDeclaration) {
      CompilationResult compResult = typeDeclaration.compilationResult;
      currentSeparatorPositions = compResult.lineSeparatorPositions;
      currentFileName = String.valueOf(compResult.fileName);
      SourceTypeBinding binding = typeDeclaration.binding;

      if (binding.constantPoolName() == null) {
        /*
         * Weird case: if JDT determines that this local class is totally
         * uninstantiable, it won't bother allocating a local name.
         */
        return false;
      }
      JDeclaredType type = (JDeclaredType) typeMap.get(binding);
      try {
        // Create an override for getClass().
        if (type instanceof JClassType
            && type != program.getTypeJavaLangObject()
            && type != program.getIndexedType("Array")) {
          JMethod getClassMethod = program.createMethod(
              type.getSourceInfo().makeChild(BuildDeclMapVisitor.class,
                  "Synthetic getClass()"), "getClass".toCharArray(), type,
              program.getTypeJavaLangClass(), false, false, false, false, false);
          assert (type.getMethods().get(2) == getClassMethod);
          getClassMethod.freezeParamTypes();
        }

        if (binding.isNestedType() && !binding.isStatic()) {
          // add synthetic fields for outer this and locals
          assert (type instanceof JClassType);
          NestedTypeBinding nestedBinding = (NestedTypeBinding) binding;
          if (nestedBinding.enclosingInstances != null) {
            for (int i = 0; i < nestedBinding.enclosingInstances.length; ++i) {
              SyntheticArgumentBinding arg = nestedBinding.enclosingInstances[i];
              if (arg.matchingField != null) {
                createField(arg, type);
              }
            }
          }

          if (nestedBinding.outerLocalVariables != null) {
            for (int i = 0; i < nestedBinding.outerLocalVariables.length; ++i) {
              SyntheticArgumentBinding arg = nestedBinding.outerLocalVariables[i];
              createField(arg, type);
            }
          }
        }

        ReferenceBinding superClassBinding = binding.superclass();
        if (superClassBinding != null) {
          // TODO: handle separately?
          assert (binding.superclass().isClass() || binding.superclass().isEnum());
          JClassType superClass = (JClassType) typeMap.get(superClassBinding);
          type.setSuperClass(superClass);
        }

        ReferenceBinding[] superInterfaces = binding.superInterfaces();
        for (int i = 0; i < superInterfaces.length; ++i) {
          ReferenceBinding superInterfaceBinding = superInterfaces[i];
          assert (superInterfaceBinding.isInterface());
          JInterfaceType superInterface = (JInterfaceType) typeMap.get(superInterfaceBinding);
          type.addImplements(superInterface);
View Full Code Here

    }

    private boolean process(TypeDeclaration typeDeclaration) {
      try {
        char[][] name = typeDeclaration.binding.compoundName;
        SourceTypeBinding binding = typeDeclaration.binding;
        if (binding instanceof LocalTypeBinding) {
          char[] localName = binding.constantPoolName();
          if (localName == null) {
            /*
             * Weird case: if JDT determines that this local class is totally
             * uninstantiable, it won't bother allocating a local name.
             */
            return false;
          }

          for (int i = 0, c = localName.length; i < c; ++i) {
            if (localName[i] == '/') {
              localName[i] = '.';
            }
          }
          name = new char[1][0];
          name[0] = localName;
        }

        SourceInfo info = makeSourceInfo(typeDeclaration);
        JDeclaredType newType;
        if (binding.isClass()) {
          newType = program.createClass(info, name, binding.isAbstract(),
              binding.isFinal());
        } else if (binding.isInterface() || binding.isAnnotationType()) {
          newType = program.createInterface(info, name);
        } else if (binding.isEnum()) {
          if (binding.isAnonymousType()) {
            // Don't model an enum subclass as a JEnumType.
            newType = program.createClass(info, name, false, true);
          } else {
            newType = program.createEnum(info, name);
          }
View Full Code Here

   * TypeParameters are mapped into JTypeParameters.
   */
  private JRealClassType createType(CompiledClass compiledClass,
      JRealClassType enclosingType) {
    TypeDeclaration typeDecl = compiledClass.getTypeDeclaration();
    SourceTypeBinding binding = typeDecl.binding;
    assert (binding.constantPoolName() != null);

    String qname = compiledClass.getSourceName();
    String className = Shared.getShortName(qname);
    String jpkgName = compiledClass.getPackageName();
    JPackage pkg = typeOracle.getOrCreatePackage(jpkgName);
    boolean isLocalType = binding instanceof LocalTypeBinding;
    boolean isIntf = TypeDeclaration.kind(typeDecl.modifiers) == TypeDeclaration.INTERFACE_DECL;
    boolean isAnnotation = TypeDeclaration.kind(typeDecl.modifiers) == TypeDeclaration.ANNOTATION_TYPE_DECL;

    JRealClassType resultType;
    if (isAnnotation) {
      resultType = new JAnnotationType(typeOracle, pkg, enclosingType,
          isLocalType, className, isIntf);
    } else if (maybeGeneric(typeDecl, enclosingType)) {
      // Go through and create declarations for each of the type parameters on
      // the generic class or method
      JTypeParameter[] jtypeParameters = declareTypeParameters(typeDecl.typeParameters);

      JGenericType jgenericType = new JGenericType(typeOracle, pkg,
          enclosingType, isLocalType, className, isIntf, jtypeParameters);

      resultType = jgenericType;
    } else if (binding.isEnum()) {
      resultType = new JEnumType(typeOracle, pkg, enclosingType, isLocalType,
          className, isIntf);
    } else {
      resultType = new JRealClassType(typeOracle, pkg, enclosingType,
          isLocalType, className, isIntf);
View Full Code Here

    }
    return true;
  }

  private boolean resolvePackage(TreeLogger logger, TypeDeclaration jclass) {
    SourceTypeBinding binding = jclass.binding;

    String packageName = String.valueOf(binding.fPackage.readableName());
    JPackage pkg = typeOracle.getOrCreatePackage(packageName);
    assert (pkg != null);
View Full Code Here

    return null;
  }

  private boolean resolveTypeDeclaration(TreeLogger logger,
      TypeDeclaration clazz) {
    SourceTypeBinding binding = clazz.binding;
    assert (binding.constantPoolName() != null);

    String qname = String.valueOf(binding.qualifiedSourceName());
    logger = logger.branch(TreeLogger.SPAM, "Found type '" + qname + "'", null);

    // Handle package-info classes.
    if (isPackageInfoTypeName(qname)) {
      return resolvePackage(logger, clazz);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding

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.