Skip to content

Commit

Permalink
Merge branch 'feature/issue-8-projectroot'
Browse files Browse the repository at this point in the history
* feature/issue-8-projectroot:
  update version to 1.2.0
  issue #8 : Also support patterns relative to project dir
  • Loading branch information
markiewb committed Jun 10, 2014
2 parents d6bf46e + 7a71369 commit c014c23
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>de.markiewb.netbeans.plugins</groupId>
<artifactId>open-file-at-cursor-plugin</artifactId>
<version>1.1.2</version>
<version>1.2.0</version>
<packaging>nbm</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,21 @@ private Set<FileObject> 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);
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/NewMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit c014c23

Please sign in to comment.