aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2014-01-18 20:23:34 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2014-01-18 20:23:34 +0100
commit08868a2076f827958f1f3b89f084abbc32c3f423 (patch)
tree3854af3f83be718895ba10e300af4352305eb6b5
parent3a7c19f786cb793f40136d80be755ea43f85e852 (diff)
downloadlombok-08868a2076f827958f1f3b89f084abbc32c3f423.tar.gz
lombok-08868a2076f827958f1f3b89f084abbc32c3f423.tar.bz2
lombok-08868a2076f827958f1f3b89f084abbc32c3f423.zip
[configuration] The 'getAbsoluteFileLocation()' addition to EclipseAST did not work in ECJ; now it does.
-rw-r--r--src/core/lombok/eclipse/EclipseAST.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/core/lombok/eclipse/EclipseAST.java b/src/core/lombok/eclipse/EclipseAST.java
index 2e11d5e1..45551d1c 100644
--- a/src/core/lombok/eclipse/EclipseAST.java
+++ b/src/core/lombok/eclipse/EclipseAST.java
@@ -21,6 +21,7 @@
*/
package lombok.eclipse;
+import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URI;
@@ -67,8 +68,25 @@ public class EclipseAST extends AST<EclipseAST, EclipseNode, ASTNode> {
clearChanged();
}
+ private static volatile boolean skipEclipseWorkspaceBasedFileResolver = false;
public URI getAbsoluteFileLocation() {
- return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(getFileName())).getLocationURI();
+ if (!skipEclipseWorkspaceBasedFileResolver) {
+ try {
+ return EclipseWorkspaceBasedFileResolver.resolve(getFileName());
+ } catch (NoClassDefFoundError e) {
+ skipEclipseWorkspaceBasedFileResolver = true;
+ }
+ }
+
+ // Our fancy workspace based source file to absolute disk location algorithm only works in a fully fledged eclipse.
+ // This fallback works when using 'ecj', which has a much simpler project/path system. For example, no 'linked' resources.
+ return new File(getFileName()).getAbsoluteFile().toURI();
+ }
+
+ private static class EclipseWorkspaceBasedFileResolver {
+ public static URI resolve(String path) {
+ return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path)).getLocationURI();
+ }
}
private static String packageDeclaration(CompilationUnitDeclaration cud) {