Package com.github.javaparser
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ParserConfiguration.LanguageLevel
-
Constructor Summary
Constructors Constructor Description ParserConfiguration()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Charset
getCharacterEncoding()
ParserConfiguration.LanguageLevel
getLanguageLevel()
List<Supplier<Processor>>
getProcessors()
Optional<SymbolResolver>
getSymbolResolver()
Retrieve the SymbolResolver to be used while parsing, if any.int
getTabSize()
boolean
isAttributeComments()
boolean
isDetectOriginalLineSeparator()
boolean
isDoNotAssignCommentsPrecedingEmptyLines()
boolean
isIgnoreAnnotationsWhenAttributingComments()
boolean
isLexicalPreservationEnabled()
boolean
isPreprocessUnicodeEscapes()
boolean
isStoreTokens()
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.ParserConfiguration
setCharacterEncoding(Charset characterEncoding)
The character encoding used for reading input from files and streams.ParserConfiguration
setDetectOriginalLineSeparator(boolean detectOriginalLineSeparator)
ParserConfiguration
setDoNotAssignCommentsPrecedingEmptyLines(boolean doNotAssignCommentsPrecedingEmptyLines)
ParserConfiguration
setIgnoreAnnotationsWhenAttributingComments(boolean ignoreAnnotationsWhenAttributingComments)
ParserConfiguration
setLanguageLevel(ParserConfiguration.LanguageLevel languageLevel)
ParserConfiguration
setLexicalPreservationEnabled(boolean lexicalPreservationEnabled)
Disabled by default.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.ParserConfiguration
setStoreTokens(boolean storeTokens)
ParserConfiguration
setSymbolResolver(SymbolResolver symbolResolver)
Set the SymbolResolver to be injected while parsing.ParserConfiguration
setTabSize(int tabSize)
When a TAB character is encountered during parsing, the column position will be increased by this value.
-
-
-
Method Detail
-
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.
-
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.
-
-