Skip to content

Commit

Permalink
Changed JDT parser and opptions to Java 17.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRivis committed Dec 20, 2022
1 parent 974a53a commit 613f937
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dxworks/jafax",
"version": "0.3.1",
"version": "0.5.0",
"description": "Java Fact Extractor (JaFaX) is a code analysis tool used to find irregularities with Java based software projects",
"keywords": [
"jafax",
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<properties>
<main.class>org.vladg.jafax.MainKt</main.class>
<kotlin.version>1.4.32</kotlin.version>
<kotlin.version>1.6.21</kotlin.version>
<final.jar.name>jafax</final.jar.name>
<serialization.version>1.1.0</serialization.version>
</properties>
Expand All @@ -19,7 +19,7 @@
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.22.0</version>
<version>3.29.0</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
Expand Down
2 changes: 2 additions & 0 deletions releaseNotes/v0.5.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* upgraded jdt version
* now parsing with Java 17 options
12 changes: 5 additions & 7 deletions src/main/java/org/vladg/jafax/ast/ASTCreator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import org.eclipse.jdt.core.JavaCore
import org.eclipse.jdt.core.dom.AST
import org.eclipse.jdt.core.dom.ASTParser
import org.vladg.jafax.utils.extensions.logger
import org.vladg.jafax.utils.extensions.stream
import kotlin.streams.toList

class ASTCreator {

Expand All @@ -17,12 +15,12 @@ class ASTCreator {

fun createAst(javaFiles: Array<String>, jarFiles: Array<String>) {
logger.info("Creating the AST Request...")
val parser = ASTParser.newParser(AST.JLS14)
val parser = ASTParser.newParser(AST.JLS17)
parser.setResolveBindings(true)
parser.setKind(ASTParser.K_COMPILATION_UNIT)
setParserOptions(parser)
parser.setEnvironment(jarFiles, emptyArray(), emptyArray(), true)
val encodings = javaFiles.stream()
val encodings = javaFiles
.map { "UTF-8" }
.toList()
.toTypedArray()
Expand All @@ -31,9 +29,9 @@ class ASTCreator {

private fun setParserOptions(parser: ASTParser) {
val options = JavaCore.getOptions()
options[JavaCore.COMPILER_COMPLIANCE] = JavaCore.VERSION_1_8
options[JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM] = JavaCore.VERSION_1_8
options[JavaCore.COMPILER_SOURCE] = JavaCore.VERSION_1_8
options[JavaCore.COMPILER_COMPLIANCE] = JavaCore.VERSION_17
options[JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM] = JavaCore.VERSION_17
options[JavaCore.COMPILER_SOURCE] = JavaCore.VERSION_17
parser.setCompilerOptions(options)
}

Expand Down

0 comments on commit 613f937

Please sign in to comment.