Package org.codehaus.backport175.compiler

Examples of org.codehaus.backport175.compiler.CompilerException


            String rawValueString = rawAnnotationString.substring(annotationName.length());
            rawValueString = rawValueString.trim();
            char first = rawValueString.charAt(0);
            if (first == '(') {
                if (!rawValueString.endsWith(")")) {
                    throw new CompilerException("annotation not well-formed, needs to end with a closing parenthesis ["
                            + rawAnnotationString + "]",
                            SourceLocation.render(annotationClass, tag, enclosingClassName, enclosingClassFileName)
                    );
                }
                return new RawAnnotation(annotationClass, rawValueString.substring(1, rawValueString.length()-1), tag.getLineNumber(), enclosingClassName, enclosingClassFileName);
            } else if (first == '"') {
                if (!rawValueString.endsWith("\"")) {
                    throw new CompilerException("annotation not well-formed, needs to end with a closing \" ["
                            + rawAnnotationString + "]",
                            SourceLocation.render(annotationClass, tag, enclosingClassName, enclosingClassFileName)
                    );
                }
                return new RawAnnotation(annotationClass, rawValueString, tag.getLineNumber(), enclosingClassName, enclosingClassFileName);
View Full Code Here


            for (Iterator iterator = compilerExceptions.iterator(); iterator.hasNext();) {
                CompilerException compilerException = (CompilerException) iterator.next();
                System.out.println("ERROR: "+ compilerException.toString());
            }
            for (Iterator iterator = acceptedLocations.iterator(); iterator.hasNext();) {
                SourceLocation sourceLocation = (SourceLocation) iterator.next();
                System.out.println("OK: " + sourceLocation.toString());
            }
        }
View Full Code Here

            }
            destDirToUse = classpath[0];
        }

        // set up the parser sources
        final JavaDocParser javaDocParser = new JavaDocParser();
        try {
            // add classloader
            javaDocParser.addClassLoaderToSearchPath(compilationLoader);

            // add src dirs
            StringBuffer logDirs = new StringBuffer("parsing source dirs:");
            for (int i = 0; i < srcDirs.length; i++) {
                logDirs.append("\n\t" + srcDirs[i]);
            }
            messageHandler.info(logDirs.toString());
            javaDocParser.addSourceTrees(srcDirs);

            // add src files
            logDirs = new StringBuffer();
            for (int i = 0; i < srcFiles.length; i++) {
                logDirs.append("\n\t" + srcFiles[i]);
                javaDocParser.addSource(srcFiles[i]);
            }
            if (srcFiles.length > 0) {
                messageHandler.info(logDirs.toString());
            }
View Full Code Here

     * @param clazz
     */
    private void handleClassAnnotations(final AnnotationEnhancer enhancer, final JavaClass clazz) {
        DocletTag[] tags = clazz.getTags();
        for (int i = 0; i < tags.length; i++) {
            RawAnnotation rawAnnotation = getRawAnnotation(
                    tags[i], enhancer.getClassName(), enhancer.getClassFileName()
            );
            if (rawAnnotation == null) {
                continue;
            }
            enhancer.insertClassAnnotation(rawAnnotation);
            logInfo(
                    "\tprocessing class annotation [" + rawAnnotation.getName() + " @ "
                    + clazz.getFullyQualifiedName() + ']'
            );
        }
    }
View Full Code Here

     * @param method
     */
    private void handleMethodAnnotations(final AnnotationEnhancer enhancer, final JavaMethod method) {
        DocletTag[] tags = method.getTags();
        for (int i = 0; i < tags.length; i++) {
            RawAnnotation rawAnnotation = getRawAnnotation(
                    tags[i], enhancer.getClassName(), enhancer.getClassFileName()
            );
            if (rawAnnotation == null) {
                continue;
            }
            enhancer.insertMethodAnnotation(method, rawAnnotation);
            logInfo(
                    "\tprocessing method annotation [" + rawAnnotation.getName() + " @ "
                    + method.getParentClass().getName() + '.' +
                    method.getName()
                    + ']'
            );
        }
View Full Code Here

     * @param constructor
     */
    private void handleConstructorAnnotations(final AnnotationEnhancer enhancer, final JavaMethod constructor) {
        DocletTag[] tags = constructor.getTags();
        for (int i = 0; i < tags.length; i++) {
            RawAnnotation rawAnnotation = getRawAnnotation(
                    tags[i], enhancer.getClassName(), enhancer.getClassFileName()
            );
            if (rawAnnotation == null) {
                continue;
            }
            enhancer.insertConstructorAnnotation(constructor, rawAnnotation);
            logInfo(
                    "\tprocessing constructor annotation [" + rawAnnotation.getName() + " @ "
                    + constructor.getParentClass().getName() + '.' +
                    constructor.getName()
                    + ']'
            );
        }
View Full Code Here

     * @param field
     */
    private void handleFieldAnnotations(final AnnotationEnhancer enhancer, final JavaField field) {
        DocletTag[] tags = field.getTags();
        for (int i = 0; i < tags.length; i++) {
            RawAnnotation rawAnnotation = getRawAnnotation(
                    tags[i], enhancer.getClassName(), enhancer.getClassFileName()
            );
            if (rawAnnotation == null) {
                continue;
            }
            enhancer.insertFieldAnnotation(field, rawAnnotation);
            logInfo("\tprocessing field annotation [" + rawAnnotation.getName() + " @ " + field.getName() + ']');
        }
    }
View Full Code Here

        public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
            // handles runtime retention to expose 1.4 annotations under 1.5
            boolean hasRetention = false;
            for (Iterator iterator = m_classAnnotations.iterator(); iterator.hasNext();) {
                RawAnnotation rawAnnotation = (RawAnnotation) iterator.next();
                if (rawAnnotation.getName().equals("java.lang.annotation.Retention")) {
                    hasRetention = true;
                    break;
                }
            }
            if (hasRetention) {
View Full Code Here

            return methodVisitor;
        }

        public void visitEnd() {
            for (Iterator it = m_classAnnotations.iterator(); it.hasNext();) {
                final RawAnnotation rawAnnotation = (RawAnnotation)it.next();
                final Class annIntf = rawAnnotation.getAnnotationClass();
                final AnnotationVisitor bytecodeMunger = visitAnnotation(
                        Type.getDescriptor(annIntf),
                        true
                );
                AnnotationParser.parse(bytecodeMunger, annIntf, rawAnnotation);
View Full Code Here

        if (m_reader == null) {
            throw new IllegalStateException("annotation enhancer is not initialized");
        }
        MethodAnnotationInfo info = new MethodAnnotationInfo(method, annotation);
        if (hasMethodAnnotation(info)) {
            throw new ParseException(
                    "duplicate method annotation " + annotation,
                    SourceLocation.render(annotation)
            );
        }
        m_methodAnnotations.add(new MethodAnnotationInfo(method, annotation));
View Full Code Here

TOP

Related Classes of org.codehaus.backport175.compiler.CompilerException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.