Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public class FilePathReferenceProvider extends PsiReferenceProvider {
"PMD.CognitiveComplexity",
"PMD.CyclomaticComplexity",
"PMD.NPathComplexity",
"PMD.AvoidInstantiatingObjectsInLoops"
"PMD.AvoidInstantiatingObjectsInLoops",
"PMD.AvoidDeeplyNestedIfStmts"
})
@NotNull
@Override
Expand Down Expand Up @@ -92,14 +93,13 @@ public PsiReference[] getReferencesByElement(
if (null != psiElement) {
final int currentPathIndex = currentPath.lastIndexOf('/') == -1
? 0 : currentPath.lastIndexOf('/') + 1;
final int startOffset = origValue.indexOf(filePath) + currentPathIndex;
final int endOffset = startOffset + pathPart.length();

final TextRange pathRange = new TextRange(
origValue.indexOf(filePath)
+ currentPathIndex,
origValue.indexOf(filePath)
+ currentPathIndex
+ pathPart.length()
);
if (!isProperRange(startOffset, endOffset)) {
continue;
}
final TextRange pathRange = new TextRange(startOffset, endOffset);

if (psiPathElements.containsKey(pathRange)) {
psiPathElements.get(pathRange).add(psiElement);
Expand Down Expand Up @@ -186,4 +186,8 @@ private Collection<VirtualFile> getFiles(final @NotNull PsiElement element) {
private boolean isModuleNamePresent(final @NotNull PsiElement element) {
return GetModuleNameUtil.getInstance().execute(element.getText()) != null;
}

private boolean isProperRange(final int startOffset, final int endOffset) {
return startOffset <= endOffset && startOffset >= 0;
}
}