Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions core/src/main/java/com/webcohesion/enunciate/Enunciate.java
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@
getLogger().debug("Detected API Types: %s", new EnunciateLogger.ListWriter(includedTypes));

//gather all the java source files.
Set<URL> sourceFiles = getSourceFileURLs();
Set<URI> sourceFiles = getSourceFileURLs();
URLClassLoader apiClassLoader = new URLClassLoader(scanpath.toArray(new URL[0]));
for (String javaFile : scannedSourceFiles) {

Expand All @@ -602,7 +602,11 @@
} else {
URL resource = resources.nextElement();
if (!resources.hasMoreElements()) {
sourceFiles.add(resource);
try {
sourceFiles.add(resource.toURI());
} catch (URISyntaxException e) {
throw new EnunciateException(e);
}
} else {
StringBuilder locations = new StringBuilder("[").append(resource.toString());
while (resources.hasMoreElements()) {
Expand All @@ -616,7 +620,11 @@

if (sourceFiles.isEmpty()) {
//Java compiler needs _something_ to compile, so we'll provide an dummy class.
sourceFiles.add(Enunciate.class.getResource("/com/webcohesion/enunciate/Nothing.java"));
try {
sourceFiles.add(Enunciate.class.getResource("/com/webcohesion/enunciate/Nothing.java").toURI());
} catch (URISyntaxException e) {
throw new EnunciateException(e);
}
}

//invoke the processor.
Expand All @@ -643,8 +651,12 @@
getLogger().debug("Compiler sources: %s", new EnunciateLogger.ListWriter(sourceFiles));
List<JavaFileObject> sources = new ArrayList<>(sourceFiles.size());
String encoding = findEncoding(compilerArgs);
for (URL sourceFile : sourceFiles) {
sources.add(new URLFileObject(sourceFile, encoding));
for (URI sourceFile : sourceFiles) {
try {
sources.add(new URLFileObject(sourceFile.toURL(), encoding));
} catch (MalformedURLException e) {
throw new EnunciateException(e);
}
}

JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
Expand Down Expand Up @@ -771,14 +783,10 @@
return builder.toString();
}

protected Set<URL> getSourceFileURLs() {
Set<URL> sourceFiles = new HashSet<>(this.sourceFiles.size());
protected Set<URI> getSourceFileURLs() {
Set<URI> sourceFiles = new HashSet<>(this.sourceFiles.size());

Check warning on line 787 in core/src/main/java/com/webcohesion/enunciate/Enunciate.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename "sourceFiles" which hides the field declared at line 54.

See more on https://sonarcloud.io/project/issues?id=AutoCodeRoverSG_enunciate&issues=AZ1B8YCfgetBJX8T1kFS&open=AZ1B8YCfgetBJX8T1kFS&pullRequest=13
for (File sourceFile : this.sourceFiles) {
try {
sourceFiles.add(sourceFile.toURI().toURL());
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
sourceFiles.add(sourceFile.toURI());
}
return sourceFiles;
}
Expand Down