diff options
Diffstat (limited to 'src/core/lombok')
-rw-r--r-- | src/core/lombok/eclipse/Eclipse.java | 71 | ||||
-rw-r--r-- | src/core/lombok/eclipse/HandlerLibrary.java | 2 |
2 files changed, 56 insertions, 17 deletions
diff --git a/src/core/lombok/eclipse/Eclipse.java b/src/core/lombok/eclipse/Eclipse.java index ddba726a..8910bb3e 100644 --- a/src/core/lombok/eclipse/Eclipse.java +++ b/src/core/lombok/eclipse/Eclipse.java @@ -1,5 +1,5 @@ /* - * Copyright © 2009 Reinier Zwitserloot and Roel Spilker. + * Copyright © 2009-2011 Reinier Zwitserloot and Roel Spilker. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -89,46 +89,85 @@ public class Eclipse { /** * Generates an error in the Eclipse error log. Note that most people never look at it! + * + * @param cud The {@code CompilationUnitDeclaration} where the error occurred. + * An error will be generated on line 0 linking to the error log entry. Can be {@code null}. + * @param message Human readable description of the problem. + * @param error The associated exception. Can be {@code null}. */ - public static void error(CompilationUnitDeclaration cud, String message) { - error(cud, message, DEFAULT_BUNDLE, null); + public static void error(CompilationUnitDeclaration cud, String message, Throwable error) { + error(cud, message, null, error); } /** * Generates an error in the Eclipse error log. Note that most people never look at it! + * + * @param cud The {@code CompilationUnitDeclaration} where the error occurred. + * An error will be generated on line 0 linking to the error log entry. Can be {@code null}. + * @param message Human readable description of the problem. + * @param bundleName Can be {@code null} to default to {@code org.eclipse.jdt.core} which is usually right. + * @param error The associated exception. Can be {@code null}. */ - public static void error(CompilationUnitDeclaration cud, String message, Throwable error) { - error(cud, message, DEFAULT_BUNDLE, error); + public static void error(CompilationUnitDeclaration cud, String message, String bundleName, Throwable error) { + if (bundleName == null) bundleName = DEFAULT_BUNDLE; + 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); + } + if (cud != null) EclipseAST.addProblemToCompilationResult(cud, false, message + " - See error log.", 0, 0); } /** - * Generates an error in the Eclipse error log. Note that most people never look at it! + * Generates a warning in the Eclipse error log. Note that most people never look at it! + * + * @param cud The {@code CompilationUnitDeclaration} where the error occurred. + * An error will be generated on line 0 linking to the error log entry. Can be {@code null}. + * @param message Human readable description of the problem. + * @param error The associated exception. Can be {@code null}. */ - public static void error(CompilationUnitDeclaration cud, String message, String bundleName) { - error(cud, message, bundleName, null); + public static void warning(String message, Throwable error) { + warning(message, null, error); } /** - * Generates an error in the Eclipse error log. Note that most people never look at it! + * Generates a warning in the Eclipse error log. Note that most people never look at it! + * + * @param message Human readable description of the problem. + * @param bundleName Can be {@code null} to default to {@code org.eclipse.jdt.core} which is usually right. + * @param error The associated exception. Can be {@code null}. */ - public static void error(CompilationUnitDeclaration cud, String message, String bundleName, Throwable error) { + public static void warning(String message, String bundleName, Throwable error) { + if (bundleName == null) bundleName = DEFAULT_BUNDLE; 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); + new EclipseWorkspaceLogger().warning(message, bundleName, error); + } catch (NoClassDefFoundError e) { //standalone ecj does not jave Platform, ILog, IStatus, and friends. + new TerminalLogger().warning(message, bundleName, error); } - if (cud != null) EclipseAST.addProblemToCompilationResult(cud, false, message + " - See error log.", 0, 0); } private static class TerminalLogger { void error(String message, String bundleName, Throwable error) { System.err.println(message); - error.printStackTrace(); + if (error != null) error.printStackTrace(); + } + + void warning(String message, String bundleName, Throwable error) { + System.err.println(message); + if (error != null) error.printStackTrace(); } } private static class EclipseWorkspaceLogger { void error(String message, String bundleName, Throwable error) { + msg(IStatus.ERROR, message, bundleName, error); + } + + void warning(String message, String bundleName, Throwable error) { + msg(IStatus.WARNING, message, bundleName, error); + } + + private void msg(int msgType, 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); @@ -137,7 +176,7 @@ public class Eclipse { ILog log = Platform.getLog(bundle); - log.log(new Status(IStatus.ERROR, bundleName, message, error)); + log.log(new Status(msgType, bundleName, message, error)); } } diff --git a/src/core/lombok/eclipse/HandlerLibrary.java b/src/core/lombok/eclipse/HandlerLibrary.java index df4681f0..ba7f891a 100644 --- a/src/core/lombok/eclipse/HandlerLibrary.java +++ b/src/core/lombok/eclipse/HandlerLibrary.java @@ -103,7 +103,7 @@ public class HandlerLibrary { SpiLoadUtil.findAnnotationClass(handler.getClass(), EclipseAnnotationHandler.class); AnnotationHandlerContainer<?> container = new AnnotationHandlerContainer(handler, annotationClass); if (lib.annotationHandlers.put(container.annotationClass.getName(), container) != null) { - Eclipse.error(null, "Duplicate handlers for annotation type: " + container.annotationClass.getName()); + Eclipse.error(null, "Duplicate handlers for annotation type: " + container.annotationClass.getName(), null); } lib.typeLibrary.addType(container.annotationClass.getName()); } catch (Throwable t) { |