Skip to content

Commit 1cb48e3

Browse files
committed
Update javaparser
1 parent 0534b3c commit 1cb48e3

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

build.gradle

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
plugins {
22
id 'com.github.johnrengelman.shadow' version '7.1.2'
33
id 'java'
4+
id 'application'
45
}
56

67
group 'ru.noties'
78
version '1.3.0'
89

9-
apply plugin: 'java'
10-
apply plugin: 'application'
11-
apply plugin: 'com.github.johnrengelman.shadow'
12-
1310
sourceCompatibility = JavaVersion.VERSION_1_8
1411
targetCompatibility = JavaVersion.VERSION_1_8
1512

1613
mainClassName = 'ru.noties.enhance.Enhance'
1714

1815
repositories {
1916
jcenter()
17+
mavenCentral()
2018
}
2119

2220
dependencies {
2321
implementation 'com.google.code.findbugs:jsr305:3.0.2'
24-
implementation 'com.github.javaparser:javaparser-core:3.5.12'
22+
23+
// https://github.com/javaparser/javaparser
24+
implementation 'com.github.javaparser:javaparser-core:3.24.8'
25+
26+
// https://github.com/google/google-java-format
2527
implementation 'com.google.googlejavaformat:google-java-format:1.5'
28+
2629
implementation 'commons-cli:commons-cli:1.4'
2730
implementation 'commons-io:commons-io:2.6'
2831
testImplementation 'junit:junit:4.12'

src/main/java/ru/noties/enhance/EnhanceWriterImpl.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package ru.noties.enhance;
22

33
import com.github.javaparser.JavaParser;
4+
import com.github.javaparser.ParseResult;
45
import com.github.javaparser.ast.CompilationUnit;
56
import com.github.javaparser.ast.NodeList;
67
import com.github.javaparser.ast.PackageDeclaration;
@@ -37,6 +38,8 @@ private interface SourceFormatter {
3738
private final ApiInfoStore apiInfoStore;
3839
private final ApiVersionFormatter apiVersionFormatter;
3940

41+
private final JavaParser javaParser = new JavaParser();
42+
4043
EnhanceWriterImpl(@Nonnull SourceFormat format, @Nonnull ApiInfoStore apiInfoStore, @Nonnull ApiVersionFormatter apiVersionFormatter) {
4144
this.sourceFormatter = sourceFormatter(format);
4245
this.apiInfoStore = apiInfoStore;
@@ -97,7 +100,13 @@ private String processJavaFile(@Nonnull File file) {
97100

98101
final CompilationUnit unit;
99102
try {
100-
unit = JavaParser.parse(file);
103+
final ParseResult<CompilationUnit> result = javaParser.parse(file);
104+
if (result.isSuccessful()) {
105+
//noinspection OptionalGetWithoutIsPresent
106+
unit = result.getResult().get();
107+
} else {
108+
throw new RuntimeException(result.toString());
109+
}
101110
} catch (FileNotFoundException e) {
102111
throw new RuntimeException(e);
103112
}

0 commit comments

Comments
 (0)