Skip to content
Permalink
Browse files
Remove trailing whitepsace.
  • Loading branch information
garydgregory committed Feb 15, 2021
1 parent 3709e58 commit 4006b2c36ccd5aac05f844f4b86895370afa36af
Showing 54 changed files with 401 additions and 401 deletions.
@@ -22,7 +22,7 @@

/**
* Wrapping an Eclipse compiler problem
*
*
* @author tcurdt
*/
public final class EclipseCompilationProblem implements CompilationProblem {
@@ -309,7 +309,7 @@ private boolean isPackage( final String pClazzName ) {
is.close();
} catch (final IOException ie) {
log.error("could not close input stream", ie);
}
}
return false;
}

@@ -24,7 +24,7 @@

/**
* Native Eclipse compiler settings
*
*
* @author tcurdt
*/
public final class EclipseJavaCompilerSettings extends JavaCompilerSettings {
@@ -37,15 +37,15 @@ public EclipseJavaCompilerSettings() {
defaultEclipseSettings.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.IGNORE);
defaultEclipseSettings.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
}

public EclipseJavaCompilerSettings( final JavaCompilerSettings pSettings ) {
super(pSettings);

if (pSettings instanceof EclipseJavaCompilerSettings) {
defaultEclipseSettings.putAll(((EclipseJavaCompilerSettings)pSettings).toNativeSettings());
}
}

public EclipseJavaCompilerSettings( final Map<String, String> pMap ) {
defaultEclipseSettings.putAll(pMap);
}
@@ -61,17 +61,17 @@ public EclipseJavaCompilerSettings( final Map<String, String> pMap ) {
put("1.6", CompilerOptions.VERSION_1_6);
put("1.7", CompilerOptions.VERSION_1_7);
}};

private String toNativeVersion( final String pVersion ) {
final String nativeVersion = nativeVersions.get(pVersion);

if (nativeVersion == null) {
throw new RuntimeException("unknown version " + pVersion);
}

return nativeVersion;
}

Map<String, String> toNativeSettings() {
final Map<String, String> map = new HashMap<String, String>(defaultEclipseSettings);

@@ -83,7 +83,7 @@ Map<String, String> toNativeSettings() {

return map;
}

@Override
public String toString() {
return toNativeSettings().toString();
@@ -26,7 +26,7 @@

/**
* Groovy version of a CompilationProblem
*
*
* @author tcurdt
*/
public final class GroovyCompilationProblem implements CompilationProblem {
@@ -42,18 +42,18 @@

/**
* Groovy implementation of the JavaCompiler interface
*
*
* @author tcurdt
*/
public final class GroovyJavaCompiler extends AbstractJavaCompiler {

private final Log log = LogFactory.getLog(GroovyJavaCompiler.class);
private final GroovyJavaCompilerSettings defaultSettings;

public GroovyJavaCompiler() {
defaultSettings = new GroovyJavaCompilerSettings(new CompilerConfiguration());
}

public CompilationResult compile(
final String[] pResourceNames,
final ResourceReader pReader,
@@ -78,13 +78,13 @@ public CompilationResult compile(
);
unit.addSource(source[i]);
}

final Collection<CompilationProblem> problems = new ArrayList<CompilationProblem>();

try {
log.debug("compiling");
unit.compile(Phases.CLASS_GENERATION);

@SuppressWarnings("unchecked") // Groovy library is not yet generic
final List<GroovyClass> classes = unit.getClasses();
for (final GroovyClass clazz : classes) {
@@ -97,7 +97,7 @@ public CompilationResult compile(
final Collection<WarningMessage> warnings = col.getWarnings();
if (warnings != null) {
for (final WarningMessage warning : warnings) {
final CompilationProblem problem = new GroovyCompilationProblem(warning);
final CompilationProblem problem = new GroovyCompilationProblem(warning);
if (problemHandler != null) {
problemHandler.handle(problem);
}
@@ -109,7 +109,7 @@ public CompilationResult compile(
final Collection<Message> errors = col.getErrors();
if (errors != null) {
for (final Message message : errors) {
final CompilationProblem problem = new GroovyCompilationProblem(message);
final CompilationProblem problem = new GroovyCompilationProblem(message);
if (problemHandler != null) {
problemHandler.handle(problem);
}
@@ -21,7 +21,7 @@

/**
* Native configuration for the Groovy compiler
*
*
* @author tcurdt
*/
public final class GroovyJavaCompilerSettings extends JavaCompilerSettings {
@@ -18,7 +18,7 @@
package org.apache.commons.jci2.compilers;

/**
*
*
* @author tcurdt
*/
public final class GroovyJavaCompilerTestCase extends AbstractCompilerTestCase {
@@ -23,7 +23,7 @@

/**
* Janino version of a CompilationProblem
*
*
* @author tcurdt
*/
public final class JaninoCompilationProblem implements CompilationProblem {
@@ -55,21 +55,21 @@ public final class JaninoJavaCompiler extends AbstractJavaCompiler {
public JaninoJavaCompiler() {
this(new JaninoJavaCompilerSettings());
}

public JaninoJavaCompiler( final JaninoJavaCompilerSettings pSettings ) {
defaultSettings = pSettings;
}

private final static class JciResource implements Resource {

private final String name;
private final byte[] bytes;

public JciResource( final String pName, final byte[] pBytes ) {
name = pName;
bytes = pBytes;
}

public String getFileName() {
return name;
}
@@ -98,48 +98,48 @@ public void close() throws IOException {
super.close();

final byte[] bytes = toByteArray();

store.write(name, bytes);
}
}

public CompilationResult compile( final String[] pSourceNames, final ResourceReader pResourceReader, final ResourceStore pStore, final ClassLoader pClassLoader, final JavaCompilerSettings pSettings ) {

final Collection<CompilationProblem> problems = new ArrayList<CompilationProblem>();

final StringPattern[] pattern = StringPattern.PATTERNS_NONE;

final Compiler compiler = new Compiler(
new ResourceFinder() {
@Override
public Resource findResource( final String pSourceName ) {
final byte[] bytes = pResourceReader.getBytes(pSourceName);

if (bytes == null) {
log.debug("failed to find source " + pSourceName);
return null;
}

log.debug("reading " + pSourceName + " (" + bytes.length + ")");

return new JciResource(pSourceName, bytes);
}
}
},
new ClassLoaderIClassLoader(pClassLoader),
new ResourceFinder() {
@Override
public Resource findResource( final String pResourceName ) {
final byte[] bytes = pStore.read(pResourceName);

if (bytes == null) {
log.debug("failed to find " + pResourceName);
return null;
}

log.debug("reading " + pResourceName + " (" + bytes.length + ")");

return new JciResource(pResourceName, bytes);
}
}
},
new ResourceCreator() {
public OutputStream createResource( final String pResourceName ) throws IOException {
@@ -151,7 +151,7 @@ public boolean deleteResource( final String pResourceName ) {

pStore.remove(pResourceName);
return true;
}
}
},
pSettings.getSourceEncoding(),
false,
@@ -165,11 +165,11 @@ public void handleWarning( final String pHandle, final String pMessage, final Lo
problemHandler.handle(problem);
}
problems.add(problem);
}
})
}
})
);


compiler.setCompileErrorHandler(new ErrorHandler() {
public void handleError( final String pMessage, final Location pLocation ) throws CompileException {
final CompilationProblem problem = new JaninoCompilationProblem(pLocation.getFileName(), pLocation, pMessage, true);
@@ -179,23 +179,23 @@ public void handleError( final String pMessage, final Location pLocation ) throw
problems.add(problem);
}
});


final Resource[] resources = new Resource[pSourceNames.length];
for (int i = 0; i < pSourceNames.length; i++) {
log.debug("compiling " + pSourceNames[i]);
final byte[] source = pResourceReader.getBytes(pSourceNames[i]);
resources[i] = new JciResource(pSourceNames[i], source);
}

try {
compiler.compile(resources);
} catch ( final LocatedException e ) {
problems.add(new JaninoCompilationProblem(e));
} catch ( final IOException e ) {
// low level problems reading or writing bytes
log.error("this error should have been cought before", e);
}
}
final CompilationProblem[] result = new CompilationProblem[problems.size()];
problems.toArray(result);
return new CompilationResult(result);
@@ -204,5 +204,5 @@ public void handleError( final String pMessage, final Location pLocation ) throw
public JavaCompilerSettings createDefaultSettings() {
return new JaninoJavaCompilerSettings(defaultSettings);
}

}
@@ -21,11 +21,11 @@ public final class JaninoJavaCompilerSettings extends JavaCompilerSettings {
// TODO: implement the native janino compiler settings

public JaninoJavaCompilerSettings() {

}

public JaninoJavaCompilerSettings( final JaninoJavaCompilerSettings pSettings ) {
super(pSettings);
super(pSettings);
}

}
@@ -18,7 +18,7 @@
package org.apache.commons.jci2.compilers;

/**
*
*
* @author tcurdt
*/
public final class JaninoJavaCompilerTestCase extends AbstractCompilerTestCase {
@@ -48,7 +48,7 @@
public final class Jsr199JavaCompiler extends AbstractJavaCompiler {

private final Log log = LogFactory.getLog(Jsr199JavaCompiler.class);

private class CompilationUnit extends SimpleJavaFileObject {
final private ResourceReader reader;
final private String name;
@@ -170,7 +170,7 @@ public boolean hasLocation(final JavaFileManager.Location location) {
return false;
}
public String inferBinaryName(final JavaFileManager.Location location, final JavaFileObject file) {
final String s = file.getName().replaceFirst(".java", ".class");
final String s = file.getName().replaceFirst(".java", ".class");
log.debug("inferBinaryName " + file.getName() + " -> " + s);
return s;
}
@@ -20,7 +20,7 @@
import org.apache.commons.jci2.problems.CompilationProblem;

/**
*
*
* @author tcurdt
*/
public final class RhinoCompilationProblem implements CompilationProblem {

0 comments on commit 4006b2c

Please sign in to comment.