Class SourceCodeProcessor


  • public class SourceCodeProcessor
    extends java.lang.Object
    Utitlity class that allows to add a TreePathScanner into the compilation process to extract information from the abstract syntax tree.
    Author:
    Andi Hotz, (c) Sahits GmbH, 2018 Created on Apr 07, 2018
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getSourcePath​(java.lang.Class<?> clazz)
      Calculate the the source path of the java file based on the class file.
      boolean processSourceFile​(java.lang.Class<?> clazz, com.sun.source.util.TreePathScanner scanner)
      Process the class with the supplied scanner.
      boolean processSourceFile​(java.lang.String path, javax.annotation.processing.AbstractProcessor processor)
      Process a java source file with the processor.
      private java.lang.String toSourceFilePath​(java.lang.Class<?> clazz)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SourceCodeProcessor

        public SourceCodeProcessor()
    • Method Detail

      • processSourceFile

        public boolean processSourceFile​(java.lang.String path,
                                         javax.annotation.processing.AbstractProcessor processor)
        Process a java source file with the processor.
        Parameters:
        path - of the java source file
        processor - to be used
        Returns:
        true when the processing failed
      • processSourceFile

        public boolean processSourceFile​(java.lang.Class<?> clazz,
                                         com.sun.source.util.TreePathScanner scanner)
        Process the class with the supplied scanner.
        Parameters:
        clazz - class to be processed.
        scanner - used for the processing
        Returns:
        true if the processing failed.
      • getSourcePath

        public java.lang.String getSourcePath​(java.lang.Class<?> clazz)
        Calculate the the source path of the java file based on the class file.
        Parameters:
        clazz - for which to calculate the path of the source file
        Returns:
        path to the java source file or null, if the file does not exist or an error occurred.
      • toSourceFilePath

        private java.lang.String toSourceFilePath​(java.lang.Class<?> clazz)