List of usage examples for org.eclipse.jdt.internal.compiler.lookup FieldBinding constant
@Override
public Constant constant()
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonField(FieldBinding field) { JsonObject object = new JsonObject(); object.addProperty("modifiers", field.modifiers); object.add("constant", BinaryTypeConvector.toJsonConstant(field.constant())); object.add("genericSignature", field.genericSignature() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(field.genericSignature()))); object.add("name", field.name == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(field.name))); object.addProperty("tagBits", String.valueOf(field.tagBits)); object.add("typeName", field.type == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(field.type.signature()))); object.add("annotations", toJsonAnnotations(field.getAnnotations())); return object; }
From source file:com.google.gwt.dev.jjs.impl.GwtAstBuilder.java
License:Apache License
private static boolean isCompileTimeConstant(FieldBinding binding) { assert !binding.isFinal() || !binding.isVolatile(); boolean isCompileTimeConstant = binding.isStatic() && binding.isFinal() && binding.constant() != Constant.NotAConstant; assert !isCompileTimeConstant || binding.type.isBaseType() || (binding.type.id == TypeIds.T_JavaLangString); return isCompileTimeConstant; }
From source file:org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.java
License:Open Source License
private FieldNode fieldBindingToFieldNode(FieldBinding fieldBinding, TypeDeclaration groovyTypeDecl) { String name = new String(fieldBinding.name); int modifiers = fieldBinding.modifiers; ClassNode fieldType = resolver.convertToClassNode(fieldBinding.type); Constant c = fieldBinding.constant(); Expression initializerExpression = null; // FIXASC for performance reasons could fetch the initializer lazily if a JDTFieldNode were created if (c == Constant.NotAConstant) { /**// w w w . j a v a 2 s.c om * If the field binding is for a real source field, we should be able to see any initializer in it. */ if (groovyTypeDecl != null) { FieldDeclaration fieldDecl = groovyTypeDecl.declarationOf(fieldBinding); if (fieldDecl instanceof FieldDeclarationWithInitializer) { initializerExpression = ((FieldDeclarationWithInitializer) fieldDecl).getGroovyInitializer(); } } } else { if (c instanceof StringConstant) { initializerExpression = new ConstantExpression(((StringConstant) c).stringValue()); } else if (c instanceof BooleanConstant) { initializerExpression = new ConstantExpression(((BooleanConstant) c).booleanValue()); } else if (c instanceof IntConstant) { initializerExpression = new ConstantExpression(((IntConstant) c).intValue()); } else if (c instanceof LongConstant) { initializerExpression = new ConstantExpression(((LongConstant) c).longValue()); } else if (c instanceof DoubleConstant) { initializerExpression = new ConstantExpression(((DoubleConstant) c).doubleValue()); } else if (c instanceof FloatConstant) { initializerExpression = new ConstantExpression(((FloatConstant) c).floatValue()); } else if (c instanceof ByteConstant) { initializerExpression = new ConstantExpression(((ByteConstant) c).byteValue()); } else if (c instanceof CharConstant) { initializerExpression = new ConstantExpression(((CharConstant) c).charValue()); } else if (c instanceof ShortConstant) { initializerExpression = new ConstantExpression(((ShortConstant) c).shortValue()); } } FieldNode fNode = new JDTFieldNode(fieldBinding, resolver, name, modifiers, fieldType, this, initializerExpression); return fNode; }