Package org.codehaus.backport175.compiler.parser

Examples of org.codehaus.backport175.compiler.parser.AnnotationValidationException


    public void insertClassAnnotation(final RawAnnotation annotation) {
        if (m_reader == null) {
            throw new IllegalStateException("annotation enhancer is not initialized");
        }
        if (hasClassAnnotation(annotation)) {
            throw new CompilerException(
                    "duplicate class annotation " + annotation,
                    SourceLocation.render(annotation)
            );
        }
        m_classAnnotations.add(annotation);
View Full Code Here


        if (m_reader == null) {
            throw new IllegalStateException("annotation enhancer is not initialized");
        }
        FieldAnnotationInfo info = new FieldAnnotationInfo(field, annotation);
        if (hasFieldAnnotation(info)) {
            throw new CompilerException(
                    "duplicate field annotation " + annotation,
                    SourceLocation.render(annotation)
            );
        }
        m_fieldAnnotations.add(new FieldAnnotationInfo(field, annotation));
View Full Code Here

        if (m_reader == null) {
            throw new IllegalStateException("annotation enhancer is not initialized");
        }
        MethodAnnotationInfo info = new MethodAnnotationInfo(constructor, annotation);
        if (hasConstructorAnnotation(info)) {
            throw new CompilerException(
                    "duplicate constructor annotation " + annotation,
                    SourceLocation.render(annotation)
            );
        }
        m_constructorAnnotations.add(new MethodAnnotationInfo(constructor, annotation));
View Full Code Here

        File file = new File(filename);
        File parentFile = file.getParentFile();
        if (!parentFile.exists()) {
            // directory does not exist create all directories in the filename
            if (!parentFile.mkdirs()) {
                throw new CompilerException(
                        "could not create dir structure needed to write file " + filename + " to disk"
                );
            }
        }
        FileOutputStream os = null;
        try {
            os = new FileOutputStream(filename);
            os.write(writer.toByteArray());
        } catch (IOException e) {
            throw new CompilerException("could not write compiled class file to disk [" + filename + "]", e);
        } finally {
            try {
                os.close();
            } catch (IOException e) {
                throw new CompilerException("could not close file output stream for [" + filename + "]", e);
            }
        }
    }
View Full Code Here

        /**
         * Helper to stdout
         */
        public void dump() {
            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

            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

TOP

Related Classes of org.codehaus.backport175.compiler.parser.AnnotationValidationException

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.