Example usage for org.eclipse.jdt.internal.compiler.lookup ElementValuePair getName

List of usage examples for org.eclipse.jdt.internal.compiler.lookup ElementValuePair getName

Introduction

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

Prototype

public char[] getName() 

Source Link

Usage

From source file:com.android.tools.lint.psi.EcjPsiBinaryNameValuePair.java

License:Apache License

EcjPsiBinaryNameValuePair(@NonNull EcjPsiManager manager, @NonNull ElementValuePair pair) {
    super(manager, null);
    mPair = pair;/*w  ww .  j  a va 2  s .  co m*/
    mName = new String(pair.getName());
}

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

License:Open Source License

private static JsonElement toJsonElementValuePair(ElementValuePair pair) {
    JsonObject object = new JsonObject();
    object.add("name",
            pair.getName() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(pair.getName())));
    object.add("value", toJsonDefaultValue(pair.getValue()));
    return object;
}

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

License:Apache License

public static String getAnnotationParameterString(AnnotationBinding a, String paramName) {
    if (a != null) {
        for (ElementValuePair maybeValue : a.getElementValuePairs()) {
            if (maybeValue.getValue() instanceof StringConstant
                    && paramName.equals(String.valueOf(maybeValue.getName()))) {
                return ((StringConstant) maybeValue.getValue()).stringValue();
            }//from  w ww  .  j  a v  a  2  s  .  c o m
        }
    }
    return null;
}

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

License:Apache License

public static boolean getAnnotationParameterBoolean(AnnotationBinding a, String paramName) {
    if (a != null) {
        for (ElementValuePair maybeValue : a.getElementValuePairs()) {
            if (maybeValue.getValue() instanceof BooleanConstant
                    && paramName.equals(String.valueOf(maybeValue.getName()))) {
                return ((BooleanConstant) maybeValue.getValue()).booleanValue();
            }/* w w w .jav  a  2s. co m*/
        }
    }
    return false;
}

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

License:Apache License

public static TypeBinding getAnnotationParameterTypeBinding(AnnotationBinding a, String paramName) {
    if (a != null) {
        for (ElementValuePair maybeValue : a.getElementValuePairs()) {
            if (maybeValue.getValue() instanceof Class
                    && paramName.equals(String.valueOf(maybeValue.getName()))) {
                return (TypeBinding) maybeValue.getValue();
            }//from   www.  jav  a2  s .  com
        }
    }
    return null;
}

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

License:Apache License

public static TypeBinding[] getAnnotationParameterTypeBindingArray(AnnotationBinding annotationBinding,
        String paramName) {//from   ww  w.ja v a 2 s  .c  om
    if (annotationBinding == null) {
        return null;
    }

    for (ElementValuePair maybeValue : annotationBinding.getElementValuePairs()) {
        Object value = maybeValue.getValue();
        if (!paramName.equals(String.valueOf(maybeValue.getName()))) {
            continue;
        }
        if (value instanceof Object[]) {
            Object[] values = (Object[]) value;
            TypeBinding bindings[] = new TypeBinding[values.length];
            System.arraycopy(values, 0, bindings, 0, values.length);
            return bindings;
        }
        assert value instanceof TypeBinding;
        return new TypeBinding[] { (TypeBinding) value };
    }
    return null;
}

From source file:com.redhat.ceylon.eclipse.core.model.loader.JDTAnnotation.java

License:Open Source License

@Override
public Object getValue(String fieldName) {
    if (values == null) {
        values = new HashMap<String, Object>();
        ElementValuePair[] annotationVaues = annotation.getElementValuePairs();
        for (ElementValuePair annotationValue : annotationVaues) {
            String name = new String(annotationValue.getName());
            Object value = convertValue(annotationValue.getValue());
            values.put(name, value);/*  w ww. ja v  a 2  s .c  o  m*/
        }
    }
    return values.get(fieldName);
}

From source file:com.redhat.ceylon.eclipse.core.model.mirror.JDTAnnotation.java

License:Open Source License

public JDTAnnotation(AnnotationBinding annotation) {
    values = new HashMap<String, Object>();
    ElementValuePair[] annotationVaues = annotation.getElementValuePairs();
    for (ElementValuePair annotationValue : annotationVaues) {
        String name = new String(annotationValue.getName());
        MethodBinding elementMethod = annotationValue.getMethodBinding();
        Object value = null;/*www  . j  ava2  s .c o m*/
        if (elementMethod != null) {
            value = convertValue(annotationValue.getMethodBinding().returnType, annotationValue.getValue());
        } else {
            value = JDTType.UNKNOWN_TYPE;
        }
        values.put(name, value);
    }
}

From source file:org.codehaus.jdt.groovy.internal.compiler.ast.JDTAnnotationNode.java

License:Open Source License

private void ensureMembersInitialized() {
    if (membersInitialized) {
        return;/*from  w w  w .j  a  va 2  s .  co m*/
    }
    membersInitialized = true;
    ElementValuePair[] evpairs = annotationBinding.getElementValuePairs();
    for (ElementValuePair evpair : evpairs) {
        char[] name = evpair.getName();
        MethodBinding mb = evpair.binding;
        Expression valueExpression = null;
        // FIXASC needs more cases considering
        if (mb == null && (evpair.value instanceof StringConstant)) {
            String v = ((StringConstant) evpair.value).stringValue();
            valueExpression = new ConstantExpression(v);
        } else {
            valueExpression = createExpressionFor(mb.returnType, evpair.value);
        }
        super.addMember(new String(name), valueExpression);
    }
}