|
8 | 8 | import com.intellij.psi.PsiElement; |
9 | 9 | import com.intellij.psi.PsiFile; |
10 | 10 | import com.intellij.psi.PsiWhiteSpace; |
11 | | -import com.intellij.psi.util.PsiTreeUtil; |
12 | 11 | import com.intellij.util.ThreeState; |
| 12 | +import com.jetbrains.php.lang.parser.PhpElementTypes; |
13 | 13 | import com.jetbrains.php.lang.psi.PhpFile; |
14 | 14 | import com.jetbrains.php.lang.psi.PhpPsiUtil; |
15 | 15 | import com.jetbrains.php.lang.psi.elements.*; |
@@ -72,7 +72,7 @@ public static class PhpAttributeAutoPopupHandler extends TypedHandlerDelegate { |
72 | 72 | } |
73 | 73 |
|
74 | 74 | // Check if we're before a method, class, or field |
75 | | - if (getMethod(element) == null && getPhpClass(element) == null && getField(element) == null) { |
| 75 | + if (getMethod(element) == null && getField(element) == null && getPhpClass(element) == null) { |
76 | 76 | return Result.CONTINUE; |
77 | 77 | } |
78 | 78 |
|
@@ -113,10 +113,21 @@ public static class PhpAttributeAutoPopupHandler extends TypedHandlerDelegate { |
113 | 113 | public static @Nullable PhpClass getPhpClass(@NotNull PsiElement element) { |
114 | 114 | if (element.getParent() instanceof PhpClass phpClass) { |
115 | 115 | return phpClass; |
116 | | - } else if (PhpPsiUtil.getNextSiblingIgnoreWhitespace(element, true) instanceof PhpClass phpClass) { |
| 116 | + } |
| 117 | + |
| 118 | + // with use statement given |
| 119 | + PsiElement nextSiblingIgnoreWhitespace = PhpPsiUtil.getNextSiblingIgnoreWhitespace(element, true); |
| 120 | + if (nextSiblingIgnoreWhitespace instanceof PhpClass phpClass) { |
117 | 121 | return phpClass; |
118 | 122 | } |
119 | 123 |
|
| 124 | + // no use statements |
| 125 | + if (nextSiblingIgnoreWhitespace != null && nextSiblingIgnoreWhitespace.getNode().getElementType() == PhpElementTypes.NON_LAZY_GROUP_STATEMENT) { |
| 126 | + if (nextSiblingIgnoreWhitespace.getFirstChild() instanceof PhpClass phpClass) { |
| 127 | + return phpClass; |
| 128 | + } |
| 129 | + } |
| 130 | + |
120 | 131 | return null; |
121 | 132 | } |
122 | 133 |
|
|
0 commit comments