Skip to content

Commit bd6ff88

Browse files
authored
Merge pull request #90 from cedricziel/trailing-slashes
Allow resolving resource paths with trailing slashes
2 parents cc9d312 + 3f2006f commit bd6ff88

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/main/java/com/cedricziel/idea/typo3/codeInsight/navigation/PathResourceGotoDeclarationHandler.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ public PsiElement[] getGotoDeclarationTargets(@Nullable PsiElement sourceElement
2020

2121
if (sourceElement != null) {
2222
String identifier = sourceElement.getText();
23+
24+
if (ResourcePathIndex.projectContainsResourceDirectory(sourceElement.getProject(), identifier)) {
25+
return emptyPsiElementArray();
26+
}
27+
2328
return ResourcePathIndex.findElementsForKey(sourceElement.getProject(), identifier);
2429
}
2530

src/main/java/com/cedricziel/idea/typo3/index/ResourcePathIndex.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.intellij.util.io.EnumeratorStringDescriptor;
1010
import com.intellij.util.io.KeyDescriptor;
1111
import gnu.trove.THashMap;
12+
import org.apache.commons.lang.StringUtils;
1213
import org.jetbrains.annotations.NotNull;
1314
import org.jetbrains.annotations.Nullable;
1415

@@ -29,7 +30,23 @@ public static boolean projectContainsResourceFile(@NotNull Project project, @Not
2930
}
3031

3132
public static boolean projectContainsResourceDirectory(@NotNull Project project, @NotNull String resourceId) {
32-
return false;
33+
Set<String> keys = new HashSet<>();
34+
keys.add(StringUtils.strip(resourceId, "/"));
35+
36+
Set<VirtualFile> matches = new HashSet<>();
37+
38+
FileBasedIndex.getInstance().getFilesWithKey(ResourcePathIndex.KEY, keys, file -> {
39+
if (file.isDirectory()) {
40+
41+
matches.add(file);
42+
43+
return false;
44+
}
45+
46+
return true;
47+
}, GlobalSearchScope.allScope(project));
48+
49+
return matches.size() > 0;
3350
}
3451

3552
public static PsiElement[] findElementsForKey(@NotNull Project project, @NotNull String identifier) {

0 commit comments

Comments
 (0)