@@ -207,7 +207,7 @@ public function provideCompletion(PhpDocument $doc, Position $pos): CompletionLi
207207 foreach ($ this ->index ->getDefinitionsForFqn ($ parentFqn ) as $ fqn => $ def ) {
208208 // Add the object access operator to only get members of all parents
209209 $ prefix = $ parentFqn . '-> ' ;
210- if (substr ($ fqn , 0 , strlen ($ prefix )) === $ prefix && ! $ def ->isMember ) {
210+ if (substr ($ fqn , 0 , strlen ($ prefix )) === $ prefix && $ def ->isMember ) {
211211 $ list ->items [] = CompletionItem::fromDefinition ($ def );
212212 }
213213 }
@@ -237,7 +237,7 @@ public function provideCompletion(PhpDocument $doc, Position $pos): CompletionLi
237237 foreach ($ this ->index ->getDefinitionsForFqn ($ parentFqn ) as $ fqn => $ def ) {
238238 // Append :: operator to only get static members of all parents
239239 $ prefix = strtolower ($ parentFqn . ':: ' );
240- if (substr (strtolower ($ fqn ), 0 , strlen ($ prefix )) === $ prefix && ! $ def ->isMember ) {
240+ if (substr (strtolower ($ fqn ), 0 , strlen ($ prefix )) === $ prefix && $ def ->isMember ) {
241241 $ list ->items [] = CompletionItem::fromDefinition ($ def );
242242 }
243243 }
@@ -301,25 +301,29 @@ public function provideCompletion(PhpDocument $doc, Position $pos): CompletionLi
301301 }
302302 }
303303
304- // Suggest global symbols that either
304+ // Suggest global (ie non member) symbols that either
305305 // - start with the current namespace + prefix, if the Name node is not fully qualified
306306 // - start with just the prefix, if the Name node is fully qualified
307- foreach ($ this ->index ->getGlobalDefinitions () as $ fqn => $ def ) {
307+ foreach ($ this ->index ->getDefinitions () as $ fqn => $ def ) {
308308
309309 $ fqnStartsWithPrefix = substr ($ fqn , 0 , $ prefixLen ) === $ prefix ;
310310
311311 if (
312- !$ prefix
313- || (
314- // Either not qualified, but a matching prefix with global fallback
315- ($ def ->roamed && !$ isQualified && $ fqnStartsWithPrefix )
316- // Or not in a namespace or a fully qualified name or AND matching the prefix
317- || ((!$ namespaceNode || $ isFullyQualified ) && $ fqnStartsWithPrefix )
318- // Or in a namespace, not fully qualified and matching the prefix + current namespace
312+ // Exclude methods, properties etc.
313+ !$ def ->isMember
314+ && (
315+ !$ prefix
319316 || (
320- $ namespaceNode
321- && !$ isFullyQualified
322- && substr ($ fqn , 0 , $ namespacedPrefixLen ) === $ namespacedPrefix
317+ // Either not qualified, but a matching prefix with global fallback
318+ ($ def ->roamed && !$ isQualified && $ fqnStartsWithPrefix )
319+ // Or not in a namespace or a fully qualified name or AND matching the prefix
320+ || ((!$ namespaceNode || $ isFullyQualified ) && $ fqnStartsWithPrefix )
321+ // Or in a namespace, not fully qualified and matching the prefix + current namespace
322+ || (
323+ $ namespaceNode
324+ && !$ isFullyQualified
325+ && substr ($ fqn , 0 , $ namespacedPrefixLen ) === $ namespacedPrefix
326+ )
323327 )
324328 )
325329 // Only suggest classes for `new`
0 commit comments