Skip to content
This repository has been archived by the owner on Mar 12, 2022. It is now read-only.

Handle "multiple class definitions" by preferring definitions from _ide_helper.php #245

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
22 changes: 22 additions & 0 deletions src/main/java/de/espend/idea/laravel/ReferenceResolver2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package de.espend.idea.laravel;

import com.jetbrains.php.lang.psi.elements.PhpNamedElement;
import com.jetbrains.php.lang.psi.elements.PhpReference;
import com.jetbrains.php.lang.psi.resolve.PhpReferenceResolver2;

import java.util.Collection;
import java.util.Collections;

@SuppressWarnings("UnstableApiUsage")
public class ReferenceResolver2 implements PhpReferenceResolver2 {
@Override
public Collection<? extends PhpNamedElement> resolve(PhpReference phpReference, Collection<? extends PhpNamedElement> candidates) {
if (candidates.size()>1) {
for (PhpNamedElement element : candidates) {
if (element.getContainingFile().getVirtualFile().getName().equals("_ide_helper.php"))
return Collections.singleton(element);
}
}
return candidates;
}
}
1 change: 1 addition & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<extensions defaultExtensionNs="com.jetbrains.php">
<typeProvider3 implementation="de.espend.idea.laravel.blade.BladeInjectTypeProvider"/>
<typeProvider3 implementation="de.espend.idea.laravel.dic.DicTypeProvider"/>
<referenceResolver2 implementation="de.espend.idea.laravel.ReferenceResolver2"/>
</extensions>

<extensions defaultExtensionNs="com.intellij">
Expand Down