Class CompilationUnitFactory

java.lang.Object
spoon.reflect.factory.SubFactory
spoon.reflect.factory.CompilationUnitFactory

public class CompilationUnitFactory extends SubFactory
A factory to create some evaluation utilities on the Spoon metamodel.
  • Constructor Details

    • CompilationUnitFactory

      public CompilationUnitFactory(Factory factory)
      Creates the evaluation factory.
  • Method Details

    • getMap

      public Map<String,​CompilationUnit> getMap()
      Gets an immutable compilation unit map. If you want to add a type to be pretty-printed, use addType(CtType).
      Returns:
      a map (path -> CompilationUnit)
    • create

      public CompilationUnit create()
      Creates a compilation unit with no associated files.
    • getOrCreate

      public CompilationUnit getOrCreate(CtPackage ctPackage)
    • removeType

      public void removeType(CtType<?> type)
      remove a type from the list of types to be pretty-printed
    • addType

      public CompilationUnit addType(CtType type)
      add a new type to be pretty-printed
    • getOrCreate

      public CompilationUnit getOrCreate(CtType type)
      Returns the compilation unit corresponding to this type. Creates one on-the-fly if needed.
    • getOrCreate

      public CompilationUnit getOrCreate(CtModule module)
    • getOrCreate

      public CompilationUnit getOrCreate(String filePath)
      Creates or gets a compilation unit for a given file path.
    • removeFromCache

      public CompilationUnit removeFromCache(String filePath)
      Removes compilation unit from the cache and returns it Used by JDTSnippetCompiler to remove processed snippet from the cache
      Parameters:
      filePath -
      Returns:
      a cached compilation unit or null