-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #171 - Fix additional case when the module directory contains h…
…yphen.
- Loading branch information
Showing
5 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright 2013-2014 Grzegorz Ligas <[email protected]> and other contributors | ||
* Copyright 2013-2016 Grzegorz Ligas <[email protected]> and other contributors | ||
* (see the CONTRIBUTORS file). | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
@@ -97,7 +97,7 @@ public boolean value(PsiFile psiFile) { | |
if (virtualFile == null) return false; | ||
String canonicalPath = virtualFile.getCanonicalPath(); | ||
if (canonicalPath == null) return false; | ||
return canonicalPath.replaceAll("-[\\d\\.\\w-]+/", "/").endsWith(name); | ||
return canonicalPath.endsWith(name); | ||
} | ||
}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright 2013-2014 Grzegorz Ligas <[email protected]> and other contributors | ||
* Copyright 2013-2016 Grzegorz Ligas <[email protected]> and other contributors | ||
* (see the CONTRIBUTORS file). | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
@@ -86,6 +86,26 @@ public void testModuleReferenceToFileWhenTwoFilesWithTheSameNameAndDifferentDire | |
assertFalse("sub".equals(((XQueryFile) resolvedReference).getContainingDirectory().getName())); | ||
} | ||
|
||
public void testModuleReferenceToFileInDirectoryWithHyphen() { | ||
myFixture.configureByFiles("ModuleReferenceWithHyphen.xq", "sub-dir/ModuleReferenceWithHyphen_ReferencedModule.xq"); | ||
|
||
PsiElement resolvedReference = getTargetOfReferenceAtCaret(myFixture, XQueryModuleImportPath.class); | ||
|
||
assertChildOf(resolvedReference, XQueryFile.class); | ||
assertEquals("ModuleReferenceWithHyphen_ReferencedModule.xq", ((XQueryFile) resolvedReference).getName()); | ||
assertTrue("sub-dir".equals(((XQueryFile) resolvedReference).getContainingDirectory().getName())); | ||
} | ||
|
||
public void testModuleReferenceToFileInDirectoryWithHyphenInSameDirectory() { | ||
myFixture.configureByFiles("sub-dir/ModuleReferenceWithHyphenInSameDirectory.xq", "sub-dir/ModuleReferenceWithHyphen_ReferencedModule.xq"); | ||
|
||
PsiElement resolvedReference = getTargetOfReferenceAtCaret(myFixture, XQueryModuleImportPath.class); | ||
|
||
assertChildOf(resolvedReference, XQueryFile.class); | ||
assertEquals("ModuleReferenceWithHyphen_ReferencedModule.xq", ((XQueryFile) resolvedReference).getName()); | ||
assertTrue("sub-dir".equals(((XQueryFile) resolvedReference).getContainingDirectory().getName())); | ||
} | ||
|
||
public void testModuleReferenceWithRelativePath() { | ||
myFixture.configureByFiles("sub/ModuleReference_InSubDir.xq", "ModuleReference.xq"); | ||
|
||
|
3 changes: 3 additions & 0 deletions
3
...testFunctional/testData/org/intellij/xquery/reference/module/ModuleReferenceWithHyphen.xq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import module namespace library = "http://module2.namespace" at "<caret>sub-dir/ModuleReferenceWithHyphen_ReferencedModule.xq"; | ||
|
||
$library:accessible |
3 changes: 3 additions & 0 deletions
3
.../org/intellij/xquery/reference/module/sub-dir/ModuleReferenceWithHyphenInSameDirectory.xq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import module namespace library = "http://module2.namespace" at "<caret>sub-dir/ModuleReferenceWithHyphen_ReferencedModule.xq"; | ||
|
||
$library:accessible |
Empty file.