diff options
author | Reinier Zwitserloot <reinier@tipit.to> | 2009-06-14 23:40:10 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@tipit.to> | 2009-06-14 23:40:10 +0200 |
commit | 65cd03b6c592f825b037a6647888f4eafbaf3388 (patch) | |
tree | c4d74820829d320254581a453715f13dc297f9f6 /src/lombok/eclipse/Eclipse.java | |
parent | 012459832d32a57b3f831d362b7f225fa7587812 (diff) | |
download | lombok-65cd03b6c592f825b037a6647888f4eafbaf3388.tar.gz lombok-65cd03b6c592f825b037a6647888f4eafbaf3388.tar.bz2 lombok-65cd03b6c592f825b037a6647888f4eafbaf3388.zip |
Added support to generate errors, both on specific nodes in an AST (generified code in HandlerLibrary for unintelligible annotation param values), and more severe general errors for eclipse's error log.
Also unrolled the foreach loop on ServiceLoader, because any given .next() call can throw a ServiceLoaderError, which we now handle somewhat more nicely.
Diffstat (limited to 'src/lombok/eclipse/Eclipse.java')
-rw-r--r-- | src/lombok/eclipse/Eclipse.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/lombok/eclipse/Eclipse.java b/src/lombok/eclipse/Eclipse.java new file mode 100644 index 00000000..e1ff95cd --- /dev/null +++ b/src/lombok/eclipse/Eclipse.java @@ -0,0 +1,34 @@ +package lombok.eclipse; + +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.osgi.framework.Bundle; + +public class Eclipse { + private static final String DEFAULT_BUNDLE = "org.eclipse.jdt.core"; + public static void error(String message) { + error(message, DEFAULT_BUNDLE, null); + } + + public static void error(String message, Throwable error) { + error(message, DEFAULT_BUNDLE, error); + } + + public static void error(String message, String bundleName) { + error(message, bundleName, null); + } + + public static 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)); + } +} |