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 @@ -8,8 +8,8 @@
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiWhiteSpace;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.ThreeState;
import com.jetbrains.php.lang.parser.PhpElementTypes;
import com.jetbrains.php.lang.psi.PhpFile;
import com.jetbrains.php.lang.psi.PhpPsiUtil;
import com.jetbrains.php.lang.psi.elements.*;
Expand Down Expand Up @@ -72,7 +72,7 @@ public static class PhpAttributeAutoPopupHandler extends TypedHandlerDelegate {
}

// Check if we're before a method, class, or field
if (getMethod(element) == null && getPhpClass(element) == null && getField(element) == null) {
if (getMethod(element) == null && getField(element) == null && getPhpClass(element) == null) {
return Result.CONTINUE;
}

Expand Down Expand Up @@ -113,10 +113,21 @@ public static class PhpAttributeAutoPopupHandler extends TypedHandlerDelegate {
public static @Nullable PhpClass getPhpClass(@NotNull PsiElement element) {
if (element.getParent() instanceof PhpClass phpClass) {
return phpClass;
} else if (PhpPsiUtil.getNextSiblingIgnoreWhitespace(element, true) instanceof PhpClass phpClass) {
}

// with use statement given
PsiElement nextSiblingIgnoreWhitespace = PhpPsiUtil.getNextSiblingIgnoreWhitespace(element, true);
if (nextSiblingIgnoreWhitespace instanceof PhpClass phpClass) {
return phpClass;
}

// no use statements
if (nextSiblingIgnoreWhitespace != null && nextSiblingIgnoreWhitespace.getNode().getElementType() == PhpElementTypes.NON_LAZY_GROUP_STATEMENT) {
if (nextSiblingIgnoreWhitespace.getFirstChild() instanceof PhpClass phpClass) {
return phpClass;
}
}

return null;
}

Expand Down