Example usage for org.eclipse.jdt.internal.compiler.lookup TypeConstants VALUE

List of usage examples for org.eclipse.jdt.internal.compiler.lookup TypeConstants VALUE

Introduction

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

Prototype

null VALUE

To view the source code for org.eclipse.jdt.internal.compiler.lookup TypeConstants VALUE.

Click Source Link

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.ClassFileInfo.java

License:Open Source License

private IMemberValuePair[] getTargetElementTypes(long tagBits) {
    ArrayList values = new ArrayList();
    String elementType = new String(
            CharOperation.concatWith(TypeConstants.JAVA_LANG_ANNOTATION_ELEMENTTYPE, '.')) + '.';
    if ((tagBits & TagBits.AnnotationForType) != 0) {
        values.add(elementType + new String(TypeConstants.TYPE));
    }/*from w w  w  . ja  v  a  2 s.co m*/
    if ((tagBits & TagBits.AnnotationForField) != 0) {
        values.add(elementType + new String(TypeConstants.UPPER_FIELD));
    }
    if ((tagBits & TagBits.AnnotationForMethod) != 0) {
        values.add(elementType + new String(TypeConstants.UPPER_METHOD));
    }
    if ((tagBits & TagBits.AnnotationForParameter) != 0) {
        values.add(elementType + new String(TypeConstants.UPPER_PARAMETER));
    }
    if ((tagBits & TagBits.AnnotationForConstructor) != 0) {
        values.add(elementType + new String(TypeConstants.UPPER_CONSTRUCTOR));
    }
    if ((tagBits & TagBits.AnnotationForLocalVariable) != 0) {
        values.add(elementType + new String(TypeConstants.UPPER_LOCAL_VARIABLE));
    }
    if ((tagBits & TagBits.AnnotationForAnnotationType) != 0) {
        values.add(elementType + new String(TypeConstants.UPPER_ANNOTATION_TYPE));
    }
    if ((tagBits & TagBits.AnnotationForPackage) != 0) {
        values.add(elementType + new String(TypeConstants.UPPER_PACKAGE));
    }
    final Object value;
    if (values.size() == 0) {
        if ((tagBits & TagBits.AnnotationTarget) != 0)
            value = CharOperation.NO_STRINGS;
        else
            return Annotation.NO_MEMBER_VALUE_PAIRS;
    } else if (values.size() == 1) {
        value = values.get(0);
    } else {
        value = values.toArray(new String[values.size()]);
    }
    return new IMemberValuePair[] { new IMemberValuePair() {
        public int getValueKind() {
            return IMemberValuePair.K_QUALIFIED_NAME;
        }

        public Object getValue() {
            return value;
        }

        public String getMemberName() {
            return new String(TypeConstants.VALUE);
        }
    } };
}

From source file:com.codenvy.ide.ext.java.server.internal.core.ClassFileInfo.java

License:Open Source License

private IMemberValuePair[] getRetentionPolicy(long tagBits) {
    if ((tagBits & TagBits.AnnotationRetentionMASK) == 0)
        return Annotation.NO_MEMBER_VALUE_PAIRS;
    String retention = null;/*w w w . j  a  v  a  2s.com*/
    if ((tagBits & TagBits.AnnotationRuntimeRetention) == TagBits.AnnotationRuntimeRetention) {
        // TagBits.AnnotationRuntimeRetention combines both TagBits.AnnotationClassRetention & TagBits.AnnotationSourceRetention
        retention = new String(
                CharOperation.concatWith(TypeConstants.JAVA_LANG_ANNOTATION_RETENTIONPOLICY, '.')) + '.'
                + new String(TypeConstants.UPPER_RUNTIME);
    } else if ((tagBits & TagBits.AnnotationSourceRetention) != 0) {
        retention = new String(
                CharOperation.concatWith(TypeConstants.JAVA_LANG_ANNOTATION_RETENTIONPOLICY, '.')) + '.'
                + new String(TypeConstants.UPPER_SOURCE);
    } else {
        retention = new String(
                CharOperation.concatWith(TypeConstants.JAVA_LANG_ANNOTATION_RETENTIONPOLICY, '.')) + '.'
                + new String(TypeConstants.UPPER_CLASS);
    }
    final String value = retention;
    return new IMemberValuePair[] { new IMemberValuePair() {
        public int getValueKind() {
            return IMemberValuePair.K_QUALIFIED_NAME;
        }

        public Object getValue() {
            return value;
        }

        public String getMemberName() {
            return new String(TypeConstants.VALUE);
        }
    } };
}

From source file:org.eclipse.ajdt.core.parserbridge.AJSourceElementParser2.java

License:Open Source License

@Override
protected void consumeSingleMemberAnnotation(boolean isTypeAnnotation) {
    super.consumeSingleMemberAnnotation(isTypeAnnotation);
    SingleMemberAnnotation member = (SingleMemberAnnotation) expressionStack[expressionPtr];
    if (reportReferenceInfo) {
        requestor.acceptMethodReference(TypeConstants.VALUE, 0, member.sourceStart);
    }/*from   www .j ava  2s .  c o  m*/
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.util.AstConverter.java

License:Open Source License

public static FieldDeclaration createField(FieldBinding fieldBinding, TypeDeclaration roleDeclaration,
        AstGenerator gen) {/*  w ww.  jav a  2  s .c om*/

    if (fieldBinding == null)
        return null;

    FieldDeclaration fieldDeclaration = new FieldDeclaration();
    fieldDeclaration.type = gen.typeReference(fieldBinding.type);

    fieldDeclaration.modifiers = (fieldBinding.modifiers & ~ExtraCompilerModifiers.AccBlankFinal); // this modifier is not used on fieldDecl (AST), overlaps with AccReadOnly
    fieldDeclaration.name = fieldBinding.name;
    if (fieldBinding.copyInheritanceSrc != null)
        fieldDeclaration.copyInheritanceSrc = fieldBinding.copyInheritanceSrc;
    else
        fieldDeclaration.copyInheritanceSrc = fieldBinding;

    AnnotationBinding[] annotBindings = fieldBinding.getAnnotations();
    if (annotBindings != Binding.NO_ANNOTATIONS) {
        ProblemReporter pr = fieldBinding.isStatic() ? roleDeclaration.staticInitializerScope.problemReporter()
                : roleDeclaration.initializerScope.problemReporter();
        Annotation[] annotDecls = new Annotation[annotBindings.length];
        boolean hasAnnotationError = false;
        for (int i = 0; i < annotBindings.length; i++) {
            AnnotationBinding binding = annotBindings[i];
            ElementValuePair[] elementValuePairs = binding.getElementValuePairs();
            char[][] annotTypeName = binding.getAnnotationType().compoundName;
            if (elementValuePairs == Binding.NO_ELEMENT_VALUE_PAIRS) {
                annotDecls[i] = gen.markerAnnotation(annotTypeName);
            } else {
                int numPairs = elementValuePairs.length;
                char[][] names = new char[numPairs][];
                Expression[] values = new Expression[numPairs];
                for (int j = 0; j < names.length; j++) {
                    names[j] = elementValuePairs[j].getName();
                    Object elementValue = elementValuePairs[j].getValue();
                    values[j] = annotationValues(elementValue, gen, pr);
                }
                if (values.length == 0 || values[0] == null) {
                    pr.unexpectedAnnotationStructure(annotTypeName, fieldBinding.name, gen.sourceStart,
                            gen.sourceEnd);
                    hasAnnotationError = true;
                } else if (numPairs == 1 && CharOperation.equals(names[0], TypeConstants.VALUE)) {
                    annotDecls[i] = gen.singleMemberAnnotation(annotTypeName, values[0]);
                } else {
                    annotDecls[i] = gen.normalAnnotation(annotTypeName, names, values);
                }
            }
        }
        if (!hasAnnotationError)
            fieldDeclaration.annotations = annotDecls;
    }

    //field initializations are copied using a RoleInitializationMethod
    return fieldDeclaration;
}