Class ParserConfiguration

java.lang.Object
com.github.javaparser.ParserConfiguration

public class ParserConfiguration extends Object
The configuration that is used by the parser. Note that this can be changed even when reusing the same JavaParser instance. It will pick up the changes.
  • Constructor Details

    • ParserConfiguration

      public ParserConfiguration()
  • Method Details

    • isAttributeComments

      public boolean isAttributeComments()
    • setAttributeComments

      public ParserConfiguration setAttributeComments(boolean attributeComments)
      Whether to run CommentsInserter, which will put the comments that were found in the source code into the comment and javadoc fields of the nodes it thinks they refer to.
    • isDoNotAssignCommentsPrecedingEmptyLines

      public boolean isDoNotAssignCommentsPrecedingEmptyLines()
    • setDoNotAssignCommentsPrecedingEmptyLines

      public ParserConfiguration setDoNotAssignCommentsPrecedingEmptyLines(boolean doNotAssignCommentsPrecedingEmptyLines)
    • isIgnoreAnnotationsWhenAttributingComments

      public boolean isIgnoreAnnotationsWhenAttributingComments()
    • setIgnoreAnnotationsWhenAttributingComments

      public ParserConfiguration setIgnoreAnnotationsWhenAttributingComments(boolean ignoreAnnotationsWhenAttributingComments)
    • setStoreTokens

      public ParserConfiguration setStoreTokens(boolean storeTokens)
    • isStoreTokens

      public boolean isStoreTokens()
    • getTabSize

      public int getTabSize()
    • setTabSize

      public ParserConfiguration setTabSize(int tabSize)
      When a TAB character is encountered during parsing, the column position will be increased by this value. By default it is 1.
    • setLexicalPreservationEnabled

      public ParserConfiguration setLexicalPreservationEnabled(boolean lexicalPreservationEnabled)
      Disabled by default. When this is enabled, LexicalPreservingPrinter.print can be used to reproduce the original formatting of the file.
    • isLexicalPreservationEnabled

      public boolean isLexicalPreservationEnabled()
    • getSymbolResolver

      public Optional<SymbolResolver> getSymbolResolver()
      Retrieve the SymbolResolver to be used while parsing, if any.
    • setSymbolResolver

      public ParserConfiguration setSymbolResolver(SymbolResolver symbolResolver)
      Set the SymbolResolver to be injected while parsing.
    • getPreProcessors

      public List<Providers.PreProcessor> getPreProcessors()
    • getPostProcessors

      public List<ParseResult.PostProcessor> getPostProcessors()
    • setLanguageLevel

      public ParserConfiguration setLanguageLevel(ParserConfiguration.LanguageLevel languageLevel)
    • getLanguageLevel

      public ParserConfiguration.LanguageLevel getLanguageLevel()
    • setPreprocessUnicodeEscapes

      public ParserConfiguration setPreprocessUnicodeEscapes(boolean preprocessUnicodeEscapes)
      When set to true, unicode escape handling is done by preprocessing the whole input, meaning that all unicode escapes are turned into unicode characters before parsing. That means the AST will never contain literal unicode escapes. However, positions in the AST will point to the original input, which is exactly the same as without this option. Without this option enabled, the unicode escapes will not be processed and are transfered intact to the AST.
    • isPreprocessUnicodeEscapes

      public boolean isPreprocessUnicodeEscapes()
    • setDetectOriginalLineSeparator

      public ParserConfiguration setDetectOriginalLineSeparator(boolean detectOriginalLineSeparator)
    • isDetectOriginalLineSeparator

      public boolean isDetectOriginalLineSeparator()
    • getCharacterEncoding

      public Charset getCharacterEncoding()
    • setCharacterEncoding

      public ParserConfiguration setCharacterEncoding(Charset characterEncoding)
      The character encoding used for reading input from files and streams. By default UTF8 is used.