Example usage for org.eclipse.jdt.internal.compiler.lookup SourceTypeBinding constantPoolName

List of usage examples for org.eclipse.jdt.internal.compiler.lookup SourceTypeBinding constantPoolName

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.lookup SourceTypeBinding constantPoolName.

Prototype

@Override
public char[] constantPoolName()  

Source Link

Document

Answer the receiver's constant pool name.

Usage

From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java

License:Open Source License

public static String toJsonBinaryType(SourceTypeBinding binding) {
    JsonObject object = new JsonObject();
    if (!binding.isAnnotationType()) {
        object.add("annotations", toJsonAnnotations(binding.getAnnotations()));
    } else {//from   w ww  .  j  ava 2s . c o m
        object.add("annotations", JsonNull.INSTANCE);

    }
    object.add("enclosingMethod", null);
    object.add("enclosingTypeName", binding.enclosingType() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(binding.enclosingType().constantPoolName())));

    object.add("fields", toJsonFields(binding.fields()));
    object.add("genericSignature", binding.genericSignature() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(binding.genericSignature())));
    object.add("interfaceNames", toJsonInterfaces(binding.superInterfaces()));
    object.add("memberTypes", toJsonMemberTypes(binding.memberTypes()));
    object.add("methods", toJsonMethods(binding.methods()));
    object.add("missingTypeNames", null);
    object.add("name", binding.constantPoolName() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(binding.constantPoolName())));
    object.add("sourceName", binding.sourceName() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(binding.sourceName())));
    object.add("superclassName", binding.superclass() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(binding.superclass().constantPoolName())));
    long annotationTagBits = binding.getAnnotationTagBits();
    //remove AreMethodsComplete bit tag from type
    annotationTagBits &= ~TagBits.AreMethodsComplete;

    object.add("tagBits", new JsonPrimitive(String.valueOf(annotationTagBits)));
    object.add("anonymous", new JsonPrimitive(binding.isAnonymousType()));
    object.add("local", new JsonPrimitive(binding.isLocalType()));
    object.add("member", new JsonPrimitive(binding.isMemberType()));
    object.add("sourceFileName", binding.sourceName() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(binding.sourceName())));
    object.add("modifiers", new JsonPrimitive(binding.modifiers));
    object.add("binaryType", new JsonPrimitive(true));
    object.add("fileName", null);
    return gson.toJson(object);
}

From source file:com.google.gwt.dev.javac.CompiledClass.java

License:Open Source License

CompiledClass(TypeDeclaration typeDeclaration, CompiledClass enclosingClass) {
    this.enclosingClass = enclosingClass;
    SourceTypeBinding binding = typeDeclaration.binding;
    this.internalName = CharOperation.charToString(binding.constantPoolName());
    this.isLocal = isLocalType(binding);
    ClassFile classFile = getClassFile(typeDeclaration, internalName);
    if (classFile != null) {
        m_bytes = classFile.getBytes();/* ww w . j a  v a 2 s .  co  m*/
    } else {
        m_bytes = ArrayUtils.EMPTY_BYTE_ARRAY;
    }
}

From source file:com.google.gwt.dev.jjs.impl.GwtAstBuilder.java

License:Apache License

private void createTypes(TypeDeclaration x) {
    SourceInfo info = makeSourceInfo(x);
    try {//  w  w w .  j a  va  2  s .  co m
        SourceTypeBinding binding = x.binding;
        String name;
        if (binding instanceof LocalTypeBinding) {
            char[] localName = binding.constantPoolName();
            name = new String(localName).replace('/', '.');
        } else {
            name = JdtUtil.asDottedString(binding.compoundName);
        }
        name = intern(name);
        JDeclaredType type;
        String jsPrototype = JsInteropUtil.maybeGetJsTypePrototype(x);
        JsInteropType interopType = JsInteropUtil.maybeGetJsInteropType(x, jsPrototype);

        if (binding.isClass()) {
            type = new JClassType(info, name, binding.isAbstract(), binding.isFinal(), interopType);
            JsInteropUtil.maybeSetJsPrototypeFlag(x, (JClassType) type);
        } else if (binding.isInterface() || binding.isAnnotationType()) {
            type = new JInterfaceType(info, name, interopType, jsPrototype);
        } else if (binding.isEnum()) {
            if (binding.isAnonymousType()) {
                // Don't model an enum subclass as a JEnumType.
                type = new JClassType(info, name, false, true, interopType);
            } else {
                type = new JEnumType(info, name, binding.isAbstract(), interopType);
            }
        } else {
            throw new InternalCompilerException("ReferenceBinding is not a class, interface, or enum.");
        }
        typeMap.setSourceType(binding, type);
        newTypes.add(type);
        if (x.memberTypes != null) {
            for (TypeDeclaration memberType : x.memberTypes) {
                createTypes(memberType);
            }
        }
    } catch (Throwable e) {
        InternalCompilerException ice = translateException(null, e);
        StringBuffer sb = new StringBuffer();
        x.printHeader(0, sb);
        ice.addNode(x.getClass().getName(), sb.toString(), info);
        throw ice;
    }
}

From source file:spoon.support.compiler.jdt.JDTTreeBuilder.java

License:Open Source License

private String computeAnonymousName(SourceTypeBinding binding) {
    final String poolName = String.valueOf(binding.constantPoolName());
    final int lastIndexSeparator = poolName.lastIndexOf(CtType.INNERTTYPE_SEPARATOR);
    return poolName.substring(lastIndexSeparator + 1, poolName.length());
}