-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c12ea9
commit ce3141f
Showing
10 changed files
with
376 additions
and
457 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
memory-javac/src/main/java/frege/memoryjavac/CompilationInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package frege.memoryjavac; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.eclipse.jdt.core.compiler.CategorizedProblem; | ||
import org.eclipse.jdt.internal.compiler.CompilationResult; | ||
|
||
public class CompilationInfo { | ||
|
||
private final List<CompilationResult> results; | ||
private final Map<String, byte[]> classes; | ||
private final ClassLoader classLoader; | ||
|
||
public CompilationInfo(final List<CompilationResult> results, | ||
final Map<String, byte[]> classes, | ||
final ClassLoader classLoader) { | ||
this.results = Collections.unmodifiableList(results); | ||
this.classes = Collections.unmodifiableMap(classes); | ||
this.classLoader = classLoader; | ||
} | ||
|
||
public boolean isSuccess() { | ||
for (final CompilationResult res : results) { | ||
if (res.getProblems() != null) { | ||
for (final CategorizedProblem problem : res.getProblems()) { | ||
if (problem.isError()) { | ||
return false; | ||
} | ||
} | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
public String errorsAsString() { | ||
final StringBuilder msgBuilder = new StringBuilder(); | ||
for (final CompilationResult res : results) { | ||
if (res.getProblems() != null) { | ||
for (final CategorizedProblem problem : res.getProblems()) { | ||
if (problem.isError()) { | ||
msgBuilder.append(problem.getMessage()); | ||
msgBuilder.append("\n"); | ||
} | ||
} | ||
} | ||
} | ||
return msgBuilder.toString(); | ||
} | ||
|
||
public ClassLoader classLoader() { | ||
return classLoader; | ||
} | ||
|
||
public Map<String, byte[]> classes() { | ||
return classes; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.