Example usage for org.eclipse.jdt.internal.compiler.ast ClassLiteralAccess ClassLiteralAccess

List of usage examples for org.eclipse.jdt.internal.compiler.ast ClassLiteralAccess ClassLiteralAccess

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.ast ClassLiteralAccess ClassLiteralAccess.

Prototype

public ClassLiteralAccess(int sourceEnd, TypeReference type) 

Source Link

Usage

From source file:lombok.eclipse.handlers.HandleLog.java

License:Open Source License

public static ClassLiteralAccess selfType(EclipseNode type, Annotation source) {
    int pS = source.sourceStart, pE = source.sourceEnd;
    long p = (long) pS << 32 | pE;

    TypeDeclaration typeDeclaration = (TypeDeclaration) type.get();
    TypeReference typeReference = new SingleTypeReference(typeDeclaration.name, p);
    setGeneratedBy(typeReference, source);

    ClassLiteralAccess result = new ClassLiteralAccess(source.sourceEnd, typeReference);
    setGeneratedBy(result, source);/*from   w w w .  j  a va2 s.c o m*/

    return result;
}

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

License:Open Source License

/**
 * Convert groovy annotations into JDT annotations
 * /*from   w  ww. j  a v a 2s .c  o  m*/
 * @return an array of annotations or null if there are none
 */
private Annotation[] transformAnnotations(List<AnnotationNode> groovyAnnotations) {
    // FIXASC positions are crap
    if (groovyAnnotations != null && groovyAnnotations.size() > 0) {
        List<Annotation> annotations = new ArrayList<Annotation>();
        for (AnnotationNode annotationNode : groovyAnnotations) {
            ClassNode annoType = annotationNode.getClassNode();
            Map<String, Expression> memberValuePairs = annotationNode.getMembers();
            // FIXASC (M3) do more than pure marker annotations and do annotation values

            if (memberValuePairs == null || memberValuePairs.size() == 0) {
                // Marker annotation:
                TypeReference annotationReference = createTypeReferenceForClassNode(annoType);
                annotationReference.sourceStart = annotationNode.getStart();
                annotationReference.sourceEnd = annotationNode.getEnd();

                MarkerAnnotation annotation = new MarkerAnnotation(annotationReference,
                        annotationNode.getStart());
                annotation.declarationSourceEnd = annotation.sourceEnd;
                annotations.add(annotation);
            } else {

                if (memberValuePairs.size() == 1 && memberValuePairs.containsKey("value")) {
                    // Single member annotation

                    // Code written to only manage a single class literal value annotation - so that @RunWith works
                    Expression value = memberValuePairs.get("value");
                    if (value instanceof PropertyExpression) {
                        String pExpression = ((PropertyExpression) value).getPropertyAsString();
                        if (pExpression.equals("class")) {
                            TypeReference annotationReference = createTypeReferenceForClassNode(annoType);
                            annotationReference.sourceStart = annotationNode.getStart();
                            annotationReference.sourceEnd = annotationNode.getEnd();
                            SingleMemberAnnotation annotation = new SingleMemberAnnotation(annotationReference,
                                    annotationNode.getStart());
                            annotation.memberValue = new ClassLiteralAccess(value.getEnd(),
                                    classLiteralToTypeReference((PropertyExpression) value));
                            annotation.declarationSourceEnd = annotation.sourceStart
                                    + annoType.getNameWithoutPackage().length();
                            annotations.add(annotation);
                        }
                    } else if (value instanceof VariableExpression && annoType.getName().endsWith("RunWith")) {
                        // FIXASC special case for 'RunWith(Foo)' where for some reason groovy doesn't mind the missing
                        // '.class'
                        // FIXASC test this
                        TypeReference annotationReference = createTypeReferenceForClassNode(annoType);
                        annotationReference.sourceStart = annotationNode.getStart();
                        annotationReference.sourceEnd = annotationNode.getEnd();
                        SingleMemberAnnotation annotation = new SingleMemberAnnotation(annotationReference,
                                annotationNode.getStart());
                        String v = ((VariableExpression) value).getName();
                        TypeReference ref = null;
                        int start = annotationReference.sourceStart;
                        int end = annotationReference.sourceEnd;
                        if (v.indexOf(".") == -1) {
                            ref = new SingleTypeReference(v.toCharArray(), toPos(start, end - 1));
                        } else {
                            char[][] splits = CharOperation.splitOn('.', v.toCharArray());
                            ref = new QualifiedTypeReference(splits, positionsFor(splits, start, end - 2));
                        }
                        annotation.memberValue = new ClassLiteralAccess(value.getEnd(), ref);
                        annotation.declarationSourceEnd = annotation.sourceStart
                                + annoType.getNameWithoutPackage().length();
                        annotations.add(annotation);
                        // FIXASC underlining for SuppressWarnings doesn't seem right when included in messages
                    } else if (annoType.getName().equals("SuppressWarnings")
                            && (value instanceof ConstantExpression || value instanceof ListExpression)) {
                        if (value instanceof ListExpression) {
                            ListExpression listExpression = (ListExpression) value;
                            // FIXASC tidy up all this junk (err, i mean 'refactor') once we have confidence in test
                            // coverage
                            List<Expression> listOfExpressions = listExpression.getExpressions();
                            TypeReference annotationReference = createTypeReferenceForClassNode(annoType);
                            annotationReference.sourceStart = annotationNode.getStart();
                            annotationReference.sourceEnd = annotationNode.getEnd() - 1;
                            SingleMemberAnnotation annotation = new SingleMemberAnnotation(annotationReference,
                                    annotationNode.getStart());

                            ArrayInitializer arrayInitializer = new ArrayInitializer();
                            arrayInitializer.expressions = new org.eclipse.jdt.internal.compiler.ast.Expression[listOfExpressions
                                    .size()];
                            for (int c = 0; c < listOfExpressions.size(); c++) {
                                ConstantExpression cExpression = (ConstantExpression) listOfExpressions.get(c);
                                String v = (String) cExpression.getValue();
                                TypeReference ref = null;
                                int start = cExpression.getStart();
                                int end = cExpression.getEnd() - 1;
                                if (v.indexOf(".") == -1) {
                                    ref = new SingleTypeReference(v.toCharArray(), toPos(start, end - 1));
                                    annotation.declarationSourceEnd = annotation.sourceStart
                                            + annoType.getNameWithoutPackage().length() - 1;
                                } else {
                                    char[][] splits = CharOperation.splitOn('.', v.toCharArray());
                                    ref = new QualifiedTypeReference(splits,
                                            positionsFor(splits, start, end - 2));
                                    annotation.declarationSourceEnd = annotation.sourceStart
                                            + annoType.getName().length() - 1;
                                }
                                arrayInitializer.expressions[c] = new StringLiteral(v.toCharArray(), start, end,
                                        -1);
                            }
                            annotation.memberValue = arrayInitializer;
                            annotations.add(annotation);
                        } else {
                            ConstantExpression constantExpression = (ConstantExpression) value;
                            if (value.getType().getName().equals("java.lang.String")) {
                                // single value, eg. @SuppressWarnings("unchecked")
                                // FIXASC tidy up all this junk (err, i mean 'refactor') once we have confidence in test
                                // coverage
                                // FIXASC test positional info for conjured up anno refs
                                TypeReference annotationReference = createTypeReferenceForClassNode(annoType);
                                annotationReference.sourceStart = annotationNode.getStart();
                                annotationReference.sourceEnd = annotationNode.getEnd() - 1;
                                SingleMemberAnnotation annotation = new SingleMemberAnnotation(
                                        annotationReference, annotationNode.getStart());
                                String v = (String) constantExpression.getValue();
                                TypeReference ref = null;
                                int start = constantExpression.getStart();
                                int end = constantExpression.getEnd() - 1;
                                if (v.indexOf(".") == -1) {
                                    ref = new SingleTypeReference(v.toCharArray(), toPos(start, end - 1));
                                    annotation.declarationSourceEnd = annotation.sourceStart
                                            + annoType.getNameWithoutPackage().length() - 1;
                                } else {
                                    char[][] splits = CharOperation.splitOn('.', v.toCharArray());
                                    ref = new QualifiedTypeReference(splits,
                                            positionsFor(splits, start, end - 2));
                                    annotation.declarationSourceEnd = annotation.sourceStart
                                            + annoType.getName().length() - 1;
                                }
                                annotation.memberValue = new StringLiteral(v.toCharArray(), start, end, -1);
                                annotations.add(annotation);
                            }
                        }
                    }
                } else if (annoType.getNameWithoutPackage().equals("Test")) {
                    // normal annotation (with at least one member value pair)
                    // GRECLIPSE-569
                    // treat as a marker annotation
                    // this is specifically written so that annotations like @Test(expected = FooException) can be found
                    TypeReference annotationReference = createTypeReferenceForClassNode(annoType);
                    annotationReference.sourceStart = annotationNode.getStart();
                    annotationReference.sourceEnd = annotationNode.getEnd();

                    MarkerAnnotation annotation = new MarkerAnnotation(annotationReference,
                            annotationNode.getStart());
                    annotation.declarationSourceEnd = annotation.sourceEnd;
                    annotations.add(annotation);
                }
            }
        }
        if (annotations.size() > 0) {
            return annotations.toArray(new Annotation[annotations.size()]);
        }
    }
    return null;
}

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

License:Open Source License

/**
 * Only handle certain kinds of expressions
 * all others will be returned as null//from   ww  w  . java  2  s.c  o m
 * 
 * String constants
 * int constants
 * arrays
 * ClassRefs
 * Enum ref
 * Annotation ref
 * 
 * @param ajExpr
 * @return jdtExpr
 */
private Expression convertToJDTExpression(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression ajExpr) {
    if (ajExpr == null) {
        return null;
    }
    Expression jdtExpr = null;
    if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteralConcatenation) {
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteralConcatenation castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteralConcatenation) ajExpr;
        StringLiteralConcatenation castedJDT = new StringLiteralConcatenation(
                (StringLiteral) convertToJDTExpression(castedAJ.literals[0]),
                (StringLiteral) convertToJDTExpression(castedAJ.literals[1]));
        for (int i = 2; i < castedAJ.literals.length; i++) {
            // may not be able to handle non-string constants here
            castedJDT.extendsWith((StringLiteral) convertToJDTExpression(castedAJ.literals[i]));
        }
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.CharLiteral) {
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.CharLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.CharLiteral) ajExpr;
        CharLiteral castedJDT = new CharLiteral(castedAJ.source(), castedAJ.sourceStart, castedAJ.sourceEnd);
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.DoubleLiteral) {
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.DoubleLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.DoubleLiteral) ajExpr;
        DoubleLiteral castedJDT = new DoubleLiteral(castedAJ.source(), castedAJ.sourceStart,
                castedAJ.sourceEnd);
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FloatLiteral) {
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.FloatLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.FloatLiteral) ajExpr;
        FloatLiteral castedJDT = new FloatLiteral(castedAJ.source(), castedAJ.sourceStart, castedAJ.sourceEnd);
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue) {
        // ECLIPSE 3.7.1 --- must use reflection since constructors have changed
        // ORIG
        //            IntLiteralMinValue castedJDT = new IntLiteralMinValue();
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue) ajExpr;
        IntLiteral castedJDT = null;
        try {
            castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTIntLiteralMinValue(castedAJ);
        } catch (Exception e) {
        }
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral) {
        // ECLIPSE 3.7.1 --- must use reflection since constructors have changed
        // ORIG
        //            IntLiteralMinValue castedJDT = new IntLiteralMinValue();
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral) ajExpr;
        IntLiteral castedJDT = null;
        try {
            castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTIntLiteral(castedAJ);
        } catch (Exception e) {
        }
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral) {
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral) ajExpr;
        FalseLiteral castedJDT = null;
        try {
            castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTFalseLiteral(castedAJ);
        } catch (Exception e) {
        }
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullLiteral) {
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullLiteral) ajExpr;
        NullLiteral castedJDT = null;
        try {
            castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTNullLiteral(castedAJ);
        } catch (Exception e) {
        }
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral) {
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral) ajExpr;
        TrueLiteral castedJDT = null;
        try {
            castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTTrueLiteral(castedAJ);
        } catch (Exception e) {
        }
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue) {
        // ECLIPSE 3.7.1 --- must use reflection since constructors have changed
        // ORIG
        //            IntLiteralMinValue castedJDT = new IntLiteralMinValue();
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue) ajExpr;
        LongLiteral castedJDT = null;
        try {
            castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTLongLiteralMinValue(castedAJ);
        } catch (Exception e) {
        }
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteral) {
        // ECLIPSE 3.7.1 --- must use reflection since constructors have changed
        // ORIG
        //            IntLiteralMinValue castedJDT = new IntLiteralMinValue();
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteral) ajExpr;
        LongLiteral castedJDT = null;
        try {
            castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTLongLiteral(castedAJ);
        } catch (Exception e) {
        }
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral) {
        // note that here we capture both StringLiteral and ExtendedStringLiteral
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral) ajExpr;
        // can we get away with no line number?
        StringLiteral castedJDT = new StringLiteral(castedAJ.source(), castedAJ.sourceStart, castedAJ.sourceEnd,
                0);
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer) {
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer) ajExpr;
        ArrayInitializer castedJDT = new ArrayInitializer();
        if (castedAJ.expressions != null) {
            castedJDT.expressions = new Expression[castedAJ.expressions.length];
            for (int i = 0; i < castedJDT.expressions.length; i++) {
                castedJDT.expressions[i] = convertToJDTExpression(castedAJ.expressions[i]);
            }
        }
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression) {
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression) ajExpr;
        ArrayAllocationExpression castedJDT = new ArrayAllocationExpression();
        castedJDT.type = convertToJDTTypeReference(castedAJ.type);
        if (castedAJ.dimensions != null) {
            castedJDT.dimensions = new Expression[castedAJ.dimensions.length];
            for (int i = 0; i < castedJDT.dimensions.length; i++) {
                castedJDT.dimensions[i] = convertToJDTExpression(castedAJ.dimensions[i]);
            }
        }
        castedJDT.initializer = (ArrayInitializer) convertToJDTExpression(castedAJ.initializer);
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldReference) {
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldReference castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldReference) ajExpr;
        FieldReference castedJDT = new FieldReference(castedAJ.token,
                toPos(castedAJ.sourceStart, castedAJ.sourceEnd));
        castedJDT.nameSourcePosition = castedAJ.nameSourcePosition;
        castedJDT.receiver = convertToJDTExpression(castedAJ.receiver);
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayReference) {
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayReference castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayReference) ajExpr;
        ArrayReference castedJDT = new ArrayReference(convertToJDTExpression(castedAJ.receiver),
                convertToJDTExpression(castedAJ.position));
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference) {
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference) ajExpr;
        QualifiedNameReference castedJDT = new QualifiedNameReference(castedAJ.tokens, castedAJ.sourcePositions,
                castedAJ.sourceStart, castedAJ.sourceEnd);
        castedJDT.indexOfFirstFieldBinding = castedAJ.indexOfFirstFieldBinding;
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleNameReference) {
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleNameReference castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleNameReference) ajExpr;
        SingleNameReference castedJDT = new SingleNameReference(castedAJ.token,
                toPos(castedAJ.sourceStart, castedAJ.sourceEnd));
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) {
        jdtExpr = convertToJDTTypeReference(
                (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) ajExpr);
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess) {
        org.aspectj.org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess) ajExpr;
        ClassLiteralAccess castedJDT = new ClassLiteralAccess(castedAJ.sourceEnd,
                convertToJDTTypeReference(castedAJ.type));
        jdtExpr = castedJDT;
    } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation) {
        jdtExpr = convertToJDTAnnotation((org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation) ajExpr);
    }

    if (jdtExpr != null) {
        // now fill in other fields
        jdtExpr.bits = ajExpr.bits;
        jdtExpr.implicitConversion = ajExpr.implicitConversion;
        jdtExpr.sourceStart = ajExpr.sourceStart;
        jdtExpr.sourceEnd = ajExpr.sourceEnd;
        jdtExpr.statementEnd = ajExpr.statementEnd;
    }
    return jdtExpr;
}

From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java

License:Open Source License

protected void consumePrimaryNoNewArrayArrayType() {
    // PrimaryNoNewArray ::= Name Dims '.' 'class'
    this.intPtr--; // remove the class start position

    pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
    pushOnGenericsLengthStack(0);/*from ww  w .j  a  va 2 s.  com*/

    pushOnExpressionStack(new ClassLiteralAccess(this.intStack[this.intPtr--],
            getTypeReference(this.intStack[this.intPtr--])));
}

From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java

License:Open Source License

protected void consumePrimaryNoNewArrayName() {
    // PrimaryNoNewArray ::= Name '.' 'class'
    this.intPtr--; // remove the class start position

    // handle type arguments
    pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
    pushOnGenericsLengthStack(0);/*w  ww. j  ava 2s.  co m*/
    TypeReference typeReference = getTypeReference(0);

    pushOnExpressionStack(new ClassLiteralAccess(this.intStack[this.intPtr--], typeReference));
}

From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java

License:Open Source License

protected void consumePrimaryNoNewArrayPrimitiveArrayType() {
    // PrimaryNoNewArray ::= PrimitiveType Dims '.' 'class'
    this.intPtr--; // remove the class start position
    pushOnExpressionStack(new ClassLiteralAccess(this.intStack[this.intPtr--],
            getTypeReference(this.intStack[this.intPtr--])));
}

From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java

License:Open Source License

protected void consumePrimaryNoNewArrayPrimitiveType() {
    // PrimaryNoNewArray ::= PrimitiveType '.' 'class'
    this.intPtr--; // remove the class start position
    pushOnExpressionStack(new ClassLiteralAccess(this.intStack[this.intPtr--], getTypeReference(0)));
}

From source file:org.nabucco.framework.mda.model.java.ast.produce.JavaAstModelProducer.java

License:Open Source License

/**
 * Creates a class literal access <code>name.class</code>.
 * /*from  w ww. j av a2  s  .c o  m*/
 * @param name
 *            name of the reference
 * 
 * @return the class literal access
 * 
 * @throws JavaModelException
 */
public ClassLiteralAccess createClassLiteralAccess(String name) throws JavaModelException {
    return new ClassLiteralAccess(0, createTypeReference(name, false));
}

From source file:org.nabucco.framework.mda.model.java.ast.produce.JavaAstModelProducer.java

License:Open Source License

/**
 * Creates a class literal access <code>typeReference.class</code>.
 * //from  w w  w  . ja  va2 s .co  m
 * @param name
 *            the type reference
 * 
 * @return the class literal access
 * 
 * @throws JavaModelException
 */
public ClassLiteralAccess createClassLiteralAccess(TypeReference typeReference) throws JavaModelException {
    return new ClassLiteralAccess(0, typeReference);
}

From source file:org.nabucco.framework.mda.template.java.extract.statement.JavaAstStatementExtractorVisitor.java

License:Open Source License

@Override
public boolean visit(ClassLiteralAccess classLiteral, BlockScope scope) {

    TypeReference typeReference = copy(classLiteral.type);

    ClassLiteralAccess literalCopy = new ClassLiteralAccess(classLiteral.sourceEnd, typeReference);

    this.statement = literalCopy;

    return false;
}