Skip to content

Commit

Permalink
Update javaparser
Browse files Browse the repository at this point in the history
  • Loading branch information
noties committed Nov 23, 2022
1 parent 0534b3c commit 1cb48e3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
13 changes: 8 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'java'
id 'application'
}

group 'ru.noties'
version '1.3.0'

apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

mainClassName = 'ru.noties.enhance.Enhance'

repositories {
jcenter()
mavenCentral()
}

dependencies {
implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'com.github.javaparser:javaparser-core:3.5.12'

// https://github.com/javaparser/javaparser
implementation 'com.github.javaparser:javaparser-core:3.24.8'

// https://github.com/google/google-java-format
implementation 'com.google.googlejavaformat:google-java-format:1.5'

implementation 'commons-cli:commons-cli:1.4'
implementation 'commons-io:commons-io:2.6'
testImplementation 'junit:junit:4.12'
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/ru/noties/enhance/EnhanceWriterImpl.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ru.noties.enhance;

import com.github.javaparser.JavaParser;
import com.github.javaparser.ParseResult;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.PackageDeclaration;
Expand Down Expand Up @@ -37,6 +38,8 @@ private interface SourceFormatter {
private final ApiInfoStore apiInfoStore;
private final ApiVersionFormatter apiVersionFormatter;

private final JavaParser javaParser = new JavaParser();

EnhanceWriterImpl(@Nonnull SourceFormat format, @Nonnull ApiInfoStore apiInfoStore, @Nonnull ApiVersionFormatter apiVersionFormatter) {
this.sourceFormatter = sourceFormatter(format);
this.apiInfoStore = apiInfoStore;
Expand Down Expand Up @@ -97,7 +100,13 @@ private String processJavaFile(@Nonnull File file) {

final CompilationUnit unit;
try {
unit = JavaParser.parse(file);
final ParseResult<CompilationUnit> result = javaParser.parse(file);
if (result.isSuccessful()) {
//noinspection OptionalGetWithoutIsPresent
unit = result.getResult().get();
} else {
throw new RuntimeException(result.toString());
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit 1cb48e3

Please sign in to comment.