Interface CompilationUnit

All Superinterfaces:
Serializable
All Known Implementing Classes:
PhysicalFileObject

public interface CompilationUnit extends Serializable
Represents a compilation unit, which is a source file that can be compiled.
  • Method Details

    • toJavaFileObject

      JavaFileObject toJavaFileObject()
      Converts this compilation unit to a JavaFileObject.
      Returns:
      the JavaFileObject
    • charset

      Charset charset()
      Returns the original charset of the compilation unit.
      Returns:
      the charset of the source file
    • path

      SourcePath path()
      Returns the path including the name of the compilation unit.

      The path must not include the root. For example if the root is src/main/java and the compilation unit is src/main/java/de/firemage/autograder/core/file/CompilationUnit.java, the path must be de/firemage/autograder/core/file/CompilationUnit.java.

      Returns:
      the path of the compilation unit
      See Also:
      • SourcePath.resolve(SourcePath)
    • readString

      default String readString() throws IOException
      Returns the content of the compilation unit as a string-
      Returns:
      the content of the compilation unit, never null
      Throws:
      IOException - if the content could not be read