aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse/EclipseProjectSearcher.java
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2013-12-15 21:02:09 +0100
committerRoel Spilker <r.spilker@gmail.com>2013-12-15 21:02:09 +0100
commit930b17b85be652405bf47752d1dbf4272afbace1 (patch)
tree10d50551c069fa6dd34d5857b7bf10516717cef8 /src/core/lombok/eclipse/EclipseProjectSearcher.java
parent324022b71903ae5a9a61e9e9a3d7eb92d3d9d96c (diff)
downloadlombok-930b17b85be652405bf47752d1dbf4272afbace1.tar.gz
lombok-930b17b85be652405bf47752d1dbf4272afbace1.tar.bz2
lombok-930b17b85be652405bf47752d1dbf4272afbace1.zip
[configuration] Added the .getAbsoluteFileLocation() method to AST;
this now works properly (even with eclipse Linked Resources) in both eclipse and javac. We will now use this feature to search for and apply config files, which will apply hierarchically based on the directory of the source file.
Diffstat (limited to 'src/core/lombok/eclipse/EclipseProjectSearcher.java')
-rw-r--r--src/core/lombok/eclipse/EclipseProjectSearcher.java103
1 files changed, 0 insertions, 103 deletions
diff --git a/src/core/lombok/eclipse/EclipseProjectSearcher.java b/src/core/lombok/eclipse/EclipseProjectSearcher.java
deleted file mode 100644
index b0a0e131..00000000
--- a/src/core/lombok/eclipse/EclipseProjectSearcher.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package lombok.eclipse;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.internal.resources.Project;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.internal.core.ClasspathEntry;
-import org.eclipse.jdt.internal.core.JavaProject;
-
-public class EclipseProjectSearcher {
- private final JavaProject project;
-
- public EclipseProjectSearcher(JavaProject project) {
- this.project = project;
- }
-
- private static final String[] ENTRY_KINDS = {"", "CPE_LIBRARY", "CPE_PROJECT", "CPE_SOURCE", "CPE_VARIABLE", "CPE_CONTAINER"};
-
-
- public static JavaProject getProject(String projectName) {
- Project depProjWrapper = (Project) ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- if (depProjWrapper == null) return null;
- if (!JavaProject.hasJavaNature(depProjWrapper)) return null;
- return (JavaProject) JavaCore.create(depProjWrapper);
- }
-
- public List<String> findAllWithName(String pathSpec) throws Exception {
- List<IPath> list = new ArrayList<IPath>();
- findAllWithName0(list, new HashSet<String>(), pathSpec, project, false);
- System.out.println("-------RESULTS [" + pathSpec + "]:");
- System.out.println(list);
- System.out.println("---------------");
-
- for (IPath path : list) {
- try {
- System.out.println(path + ": " + ResourcesPlugin.getWorkspace().getRoot().getFile(path.append(pathSpec)).getLocationURI());
- } catch (Exception ignore) {
- try {
- System.out.println(path + ": " + ResourcesPlugin.getWorkspace().getRoot().getFolder(path.append(pathSpec)).getLocationURI());
- } catch (Exception e) {
- }
- }
-
- // Check if we got through (didn't double-exept out), and then check if the resulting file URI
- // actually exists.
- //
- // Then, check if 'path' itself is a jar, and if so, go root around in there.
- }
-
- System.out.println("---------------");
-
- return null;
- }
-
- private void findAllWithName0(List<IPath> list, Set<String> coveredProjectNames, String pathSpec, JavaProject proj, boolean exportedOnly) throws Exception {
- if (proj == null) return;
-// if (System.currentTimeMillis() > 0) return;
-
-
- /*
- *
- Research conclusions:
-
- * Eclipse is CRAZY.
- * Take a path, for which you don't know if it's project relative or not (nor does eclipse!!! yes, crazy), append the resource you are looking for (whether you know if its a jar or a path),
- and ask eclipse if it exists as a file. If yes, you have your answer.
- * Then, check if the path is 1 or 0 long, in that case, there is no answer.
- * Then, check if the path itself is a file and if yes, try and open it as a zip. Possibly try appending exclamationmark-resource and ask eclipse, maybe it has jar-style handling built in.
- * Cache the heck out of this because this code is called after just about every keystroke.
- * We should probably do something about duplicate detection and collapse, maybe just grab the textual content of those IPaths (they sure as hell don't contain anything useful beyond that), and
- toss em in a set.
-
- */
- if (!coveredProjectNames.add(proj.getElementName())) return;
-
- for (IClasspathEntry rawEntry : proj.getResolvedClasspath(true)) {
- ClasspathEntry entry = (ClasspathEntry) rawEntry;
- if (exportedOnly && !entry.isExported() && entry.entryKind != IClasspathEntry.CPE_SOURCE) continue;
-
- switch (entry.entryKind) {
- case IClasspathEntry.CPE_PROJECT:
- String projName = entry.path.lastSegment();
- JavaProject depProj = getProject(projName);
- findAllWithName0(list, coveredProjectNames, pathSpec, depProj, true);
- break;
- case IClasspathEntry.CPE_SOURCE:
- list.add(entry.path);
- break;
- case IClasspathEntry.CPE_LIBRARY:
- list.add(entry.path);
- break;
- default:
- System.out.println("Wot's this then? " + entry);
- }
- }
- }
-}