From 08868a2076f827958f1f3b89f084abbc32c3f423 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Sat, 18 Jan 2014 20:23:34 +0100 Subject: [configuration] The 'getAbsoluteFileLocation()' addition to EclipseAST did not work in ECJ; now it does. --- src/core/lombok/eclipse/EclipseAST.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/core/lombok/eclipse') 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 { 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) { -- cgit