Skip to content

Commit

Permalink
refactor: getClassProvider + reuse Local
Browse files Browse the repository at this point in the history
  • Loading branch information
swissiety committed Oct 25, 2024
1 parent 09e0855 commit a7bb4f8
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Optional<JavaSootClassSource> getClassSource(
@Nonnull ClassType classType, @Nonnull View view) {
JavaClassType klassType = (JavaClassType) classType;

ClassProvider classProvider = new AsmJavaClassProvider(view);
ClassProvider classProvider = getClassProvider(view);
Path filepath =
theFileSystem.getPath(
klassType.getFullyQualifiedName().replace('.', '/')
Expand Down Expand Up @@ -143,7 +143,7 @@ protected Stream<JavaSootClassSource> getClassSourcesInternal(
@Nonnull IdentifierFactory identifierFactory,
@Nonnull View view) {

ClassProvider classProvider = new AsmJavaClassProvider(view);
ClassProvider classProvider = getClassProvider(view);

String moduleInfoFilename =
JavaModuleIdentifierFactory.MODULE_INFO_FILE
Expand All @@ -156,12 +156,15 @@ protected Stream<JavaSootClassSource> getClassSourcesInternal(
List<JavaSootClassSource> javaSootClassSources =
paths
.filter(
filePath ->
!Files.isDirectory(filePath)
&& filePath
.toString()
.endsWith(classProvider.getHandledFileType().getExtensionWithDot())
&& !filePath.toString().endsWith(moduleInfoFilename))
filePath -> {
if (!Files.isDirectory(filePath)) {
String pathStr = filePath.toString();
return pathStr.endsWith(
classProvider.getHandledFileType().getExtensionWithDot())
&& !pathStr.endsWith(moduleInfoFilename);
}
return false;
})
.<SootClassSource>flatMap(
p ->
StreamUtils.optionalToStream(
Expand All @@ -174,6 +177,10 @@ protected Stream<JavaSootClassSource> getClassSourcesInternal(
}
}

protected ClassProvider getClassProvider(@Nonnull View view) {
return new AsmJavaClassProvider(view);
}

@Override
public @Nonnull Collection<JavaSootClassSource> getClassSources(@Nonnull View view) {

Expand Down

0 comments on commit a7bb4f8

Please sign in to comment.