Skip to content

Commit 169df96

Browse files
committed
Simplify
1 parent ee670f9 commit 169df96

1 file changed

Lines changed: 48 additions & 48 deletions

File tree

‎src/main/java/org/javacs/IncrementalFileManager.java‎

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -150,57 +150,57 @@ private boolean hasUpToDateSignatures(String packageName, JavaFileObject sourceF
150150
new CheckedSignature(
151151
sourceFile.toUri(), Instant.ofEpochMilli(sourceFile.getLastModified()));
152152

153-
return upToDate.computeIfAbsent(
154-
key,
155-
newKey -> {
156-
try {
157-
JavacTask task =
158-
javac.getTask(
159-
null,
160-
classOnlyFileManager,
161-
__ -> {},
162-
ImmutableList.of(),
163-
null,
164-
ImmutableList.of(sourceFile));
165-
CompilationUnitTree tree = task.parse().iterator().next();
166-
167-
for (Tree each : tree.getTypeDecls()) {
168-
if (each instanceof ClassTree) {
169-
ClassTree sourceClass = (ClassTree) each;
170-
String qualifiedName =
171-
packageName.isEmpty()
172-
? sourceClass.getSimpleName().toString()
173-
: packageName + "." + sourceClass.getSimpleName();
174-
175-
if (!hasUpToDateSignature(qualifiedName)) {
176-
JavaFileObject classFile =
177-
super.getJavaFileForInput(
178-
StandardLocation.CLASS_PATH,
179-
qualifiedName,
180-
JavaFileObject.Kind.CLASS);
181-
182-
if (classFile != null) {
183-
LOG.warning(
184-
String.format(
185-
"%s has a different signature than %s",
186-
sourceFile.toUri(), classFile));
187-
}
188-
189-
return false;
190-
}
191-
}
192-
}
153+
return upToDate.computeIfAbsent(key, __ -> computeUpToDate(packageName, sourceFile));
154+
}
193155

194-
LOG.info(
195-
String.format(
196-
"%s appears to be out-of-date but its class files have a matching public API",
197-
sourceFile.toUri()));
156+
private boolean computeUpToDate(String packageName, JavaFileObject sourceFile) {
157+
try {
158+
JavacTask task =
159+
javac.getTask(
160+
null,
161+
classOnlyFileManager,
162+
__ -> {},
163+
ImmutableList.of(),
164+
null,
165+
ImmutableList.of(sourceFile));
166+
CompilationUnitTree tree = task.parse().iterator().next();
167+
168+
for (Tree each : tree.getTypeDecls()) {
169+
if (each instanceof ClassTree) {
170+
ClassTree sourceClass = (ClassTree) each;
171+
String qualifiedName =
172+
packageName.isEmpty()
173+
? sourceClass.getSimpleName().toString()
174+
: packageName + "." + sourceClass.getSimpleName();
175+
176+
if (!hasUpToDateSignature(qualifiedName)) {
177+
JavaFileObject classFile =
178+
super.getJavaFileForInput(
179+
StandardLocation.CLASS_PATH,
180+
qualifiedName,
181+
JavaFileObject.Kind.CLASS);
182+
183+
if (classFile != null) {
184+
LOG.warning(
185+
String.format(
186+
"%s has a different signature than %s",
187+
sourceFile.toUri(), classFile));
188+
}
198189

199-
return true;
200-
} catch (IOException e) {
201-
throw new RuntimeException(e);
190+
return false;
202191
}
203-
});
192+
}
193+
}
194+
195+
LOG.info(
196+
String.format(
197+
"%s appears to be out-of-date but its class files have a matching public API",
198+
sourceFile.toUri()));
199+
200+
return true;
201+
} catch (IOException e) {
202+
throw new RuntimeException(e);
203+
}
204204
}
205205

206206
private Optional<JavaFileObject> primaryClassFile(

0 commit comments

Comments
 (0)