From f87b1af37b1262a5e968b36c05f63e91d1a820f2 Mon Sep 17 00:00:00 2001 From: markiewb Date: Tue, 10 Jun 2014 23:27:26 +0200 Subject: [PATCH 1/2] issue #8 : Also support patterns relative to project dir --- .../ResourceHyperlinkProvider.java | 16 +++++++++++++++- src/test/java/NewMain.java | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/markiewb/netbeans/plugins/resourcehyperlink/ResourceHyperlinkProvider.java b/src/main/java/de/markiewb/netbeans/plugins/resourcehyperlink/ResourceHyperlinkProvider.java index 0fcd322..5159384 100644 --- a/src/main/java/de/markiewb/netbeans/plugins/resourcehyperlink/ResourceHyperlinkProvider.java +++ b/src/main/java/de/markiewb/netbeans/plugins/resourcehyperlink/ResourceHyperlinkProvider.java @@ -176,7 +176,21 @@ private Set findFiles(Document doc, String path) { FileObject docFO = NbEditorUtilities.getFileObject(doc); result.addAll(getMatchingFilesFromSourceRoots(FileOwnerQuery.getOwner(docFO), path)); - //d) fallback to support absolute paths - exact match + //d) fallback to exact matches in project root + FileObject docFOX = NbEditorUtilities.getFileObject(doc); + Project owner = FileOwnerQuery.getOwner(docFOX); + if (null != owner) { + FileObject projectDirectory = owner.getProjectDirectory(); + if (null != projectDirectory) { + //exact matches + FileObject fileObject = projectDirectory.getFileObject(path); + if (fileObject != null && !fileObject.isFolder()) { + result.add(fileObject); + } + } + } + + //e) fallback to support absolute paths - exact match if (new File(path).exists() && !FileUtil.toFileObject(FileUtil.normalizeFile(new File(path))).isFolder()) { FileObject absolutePath = FileUtil.toFileObject(FileUtil.normalizeFile(new File(path))); result.add(absolutePath); diff --git a/src/test/java/NewMain.java b/src/test/java/NewMain.java index a6c9621..dff8a6c 100644 --- a/src/test/java/NewMain.java +++ b/src/test/java/NewMain.java @@ -7,6 +7,8 @@ public static void main(String[] args) { + "com/toy/anagrams/lib/WordLibrary.java"); System.out.println("filename = " + "WordLibrary.java"); System.out.println("Hyper"); + System.out.println("./src\\test\\java\\foo\\NewMain.java"); + System.out.println(".\\src\\test\\java\\foo\\NewMain.java"); System.out.println("de.markiewb.netbeans.plugins.resourcehyperlink.ResourceHyperlinkProvider"); System.out.println("de.markiewb.netbeans.plugins.resourcehyperlink.ResourceHyperlinkProvider"); System.out.println("D:\\ws\\nb-resource-hyperlink-at-cursor\\doc\\screenshot-1.0.0.png"); From 7a71369366d15b8244efc2932ab0edd8db6e6d8b Mon Sep 17 00:00:00 2001 From: markiewb Date: Tue, 10 Jun 2014 23:27:38 +0200 Subject: [PATCH 2/2] update version to 1.2.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f58cb8f..f5aa778 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ de.markiewb.netbeans.plugins open-file-at-cursor-plugin - 1.1.2 + 1.2.0 nbm