Class CompilableSource

java.lang.Object
org.ek9lang.compiler.CompilableSource
All Implemented Interfaces:
Serializable, Source, TokenConsumptionListener

public final class CompilableSource extends Object implements Source, Serializable, TokenConsumptionListener
Holds a reference to the name of the file being compiled a checksum of the file and the date time last modified. This is used to detect changes in source that needs to have a new parse tree generated.
But also note it can be created with just an inputStream so the in memory ek9 source can also be supplied and parsed.
See Also:
  • Constructor Details

    • CompilableSource

      public CompilableSource(String filename)
      Create compilable source for a specific filename.
    • CompilableSource

      public CompilableSource(String filename, InputStream inputStream)
      Create a compilable source with a name, but provide the inputStream. This is useful for internal supplied sources.
  • Method Details

    • tokenConsumed

      public void tokenConsumed(org.antlr.v4.runtime.Token token)
      Informed when a token have been consumed out of the Lexer.
      Specified by:
      tokenConsumed in interface TokenConsumptionListener
    • nearestToken

      public TokenResult nearestToken(int line, int characterPosition)
      Get the nearest source token on a particular line and character position.
    • getCompilationUnitContext

      public EK9Parser.CompilationUnitContext getCompilationUnitContext()
      Provide access to the main compilation context. This is only valid if a prepareToParse and parse has been run.
    • hasNotBeenSuccessfullyParsed

      public boolean hasNotBeenSuccessfullyParsed()
    • isDev

      public boolean isDev()
      Specified by:
      isDev in interface Source
    • setDev

      public CompilableSource setDev(boolean dev)
    • isLib

      public boolean isLib()
      Specified by:
      isLib in interface Source
    • getPackageModuleName

      public String getPackageModuleName()
    • setLib

      public void setLib(String packageModuleName, boolean lib)
      Set this compilable source as a library.
    • isModified

      public boolean isModified()
      Checks if the file content have changed from when first calculated.
      Returns:
      true if modified, false if modified time and checksum are the same.
    • resetDetails

      public void resetDetails()
      Just updates the last modified and the check sum to current values.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getSourceAsStringForDebugging

      public String getSourceAsStringForDebugging()
      Used in debugging built-in sources.
    • prepareToParse

      public CompilableSource prepareToParse()
      Sets up the compilable source to be parsed.
    • prepareToParse

      public CompilableSource prepareToParse(InputStream inputStream)
      Prepare to parse but with a provided input stream of what to parse.
    • completeParsing

      public CompilableSource completeParsing()
    • parse

      Actually parse the source code.
    • getErrorListener

      public ErrorListener getErrorListener()
      Access the error listener, only check after parsing.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getFileName

      public String getFileName()
      Specified by:
      getFileName in interface Source
    • getGeneralIdentifier

      public String getGeneralIdentifier()