aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-12-23 03:31:09 +0100
committerReinier Zwitserloot <reinier@tipit.to>2009-12-23 03:31:09 +0100
commitf57e23bebb4c50a6a74014a245f14dba6aa24923 (patch)
tree420841b87e437d9e9e02827c2e8379bac56d9e04 /src
parentdf1e578432e4de894e4a2769aaf7566be584d05b (diff)
downloadlombok-f57e23bebb4c50a6a74014a245f14dba6aa24923.tar.gz
lombok-f57e23bebb4c50a6a74014a245f14dba6aa24923.tar.bz2
lombok-f57e23bebb4c50a6a74014a245f14dba6aa24923.zip
Abstracted out stuff that only works in a full eclipse and not in ECJ.
Diffstat (limited to 'src')
-rw-r--r--src/core/lombok/eclipse/Eclipse.java42
1 files changed, 30 insertions, 12 deletions
diff --git a/src/core/lombok/eclipse/Eclipse.java b/src/core/lombok/eclipse/Eclipse.java
index 3adaf417..019b37fd 100644
--- a/src/core/lombok/eclipse/Eclipse.java
+++ b/src/core/lombok/eclipse/Eclipse.java
@@ -30,7 +30,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import lombok.Lombok;
import lombok.core.AnnotationValues;
import lombok.core.TypeLibrary;
import lombok.core.TypeResolver;
@@ -105,18 +104,36 @@ public class Eclipse {
* Generates an error in the Eclipse error log. Note that most people never look at it!
*/
public static void error(CompilationUnitDeclaration cud, String message, String bundleName, Throwable error) {
- Bundle bundle = Platform.getBundle(bundleName);
- if (bundle == null) {
- System.err.printf("Can't find bundle %s while trying to report error:\n%s\n", bundleName, message);
- return;
+ try {
+ new EclipseWorkspaceLogger().error(message, bundleName, error);
+ } catch (NoClassDefFoundError e) { //standalone ecj does not jave Platform, ILog, IStatus, and friends.
+ new TerminalLogger().error(message, bundleName, error);
}
-
- ILog log = Platform.getLog(bundle);
-
- log.log(new Status(IStatus.ERROR, bundleName, message, error));
if (cud != null) EclipseAST.addProblemToCompilationResult(cud, false, message + " - See error log.", 0, 0);
}
+ private static class TerminalLogger {
+ @SuppressWarnings("unused") //to match signature of EclipseWorkspaceLogger.
+ void error(String message, String bundleName, Throwable error) {
+ System.err.println(message);
+ error.printStackTrace();
+ }
+ }
+
+ private static class EclipseWorkspaceLogger {
+ void error(String message, String bundleName, Throwable error) {
+ Bundle bundle = Platform.getBundle(bundleName);
+ if (bundle == null) {
+ System.err.printf("Can't find bundle %s while trying to report error:\n%s\n", bundleName, message);
+ return;
+ }
+
+ ILog log = Platform.getLog(bundle);
+
+ log.log(new Status(IStatus.ERROR, bundleName, message, error));
+ }
+ }
+
/**
* For 'speed' reasons, Eclipse works a lot with char arrays. I have my doubts this was a fruitful exercise,
* but we need to deal with it. This turns [[java][lang][String]] into "java.lang.String".
@@ -454,7 +471,7 @@ public class Eclipse {
try {
generatedByField = ASTNode.class.getDeclaredField("$generatedBy");
} catch (Throwable t) {
- throw Lombok.sneakyThrow(t);
+ //ignore - no $generatedBy exists when running in ecj.
}
}
@@ -462,7 +479,8 @@ public class Eclipse {
try {
return (ASTNode) generatedByField.get(node);
} catch (Exception t) {
- throw Lombok.sneakyThrow(t);
+ //ignore - no $generatedBy exists when running in ecj.
+ return null;
}
}
@@ -474,7 +492,7 @@ public class Eclipse {
try {
generatedByField.set(node, source);
} catch (Exception t) {
- throw Lombok.sneakyThrow(t);
+ //ignore - no $generatedBy exists when running in ecj.
}
return node;