Skip to content

Commit

Permalink
replace deprecated "PhpIndex::getAllSubclasses"
Browse files Browse the repository at this point in the history
  • Loading branch information
Haehnchen committed Apr 3, 2024
1 parent 1649f60 commit 831a746
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import de.espend.idea.php.annotation.util.PhpElementsUtil;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Collection;

/**
* @author Daniel Espendiller <daniel@espendiller.net>
*/
Expand Down Expand Up @@ -41,9 +44,13 @@ public DoctrineRepositoryReference(StringLiteralExpression psiElement) {
@NotNull
@Override
public Object @NotNull [] getVariants() {
Collection<PhpClass> phpClasses = new ArrayList<>();
PhpIndex.getInstance(getElement().getProject()).processAllSubclasses("\\Doctrine\\Common\\Persistence\\ObjectRepository", phpClass -> {
phpClasses.add(phpClass);
return true;
});

return PhpIndex.getInstance(getElement().getProject())
.getAllSubclasses("\\Doctrine\\Common\\Persistence\\ObjectRepository")
return phpClasses
.stream()
.map(phpClass -> LookupElementBuilder.create(phpClass.getPresentableFQN()).withIcon(PhpIcons.CLASS))
.toArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,15 @@ public static String trimBlackSlashes(@NotNull String namespaceName) {
}

public static void visitCustomTypes(@NotNull Project project, @NotNull ColumnTypeVisitor visitor) {

Set<String> found = new HashSet<>();

for (PhpClass phpClass : PhpIndex.getInstance(project).getAllSubclasses("\\Doctrine\\DBAL\\Types\\Type")) {
Collection<PhpClass> phpClasses = new ArrayList<>();
PhpIndex.getInstance(project).processAllSubclasses("\\Doctrine\\DBAL\\Types\\Type", phpClass -> {
phpClasses.add(phpClass);
return true;
});

for (PhpClass phpClass : phpClasses) {
String name = PhpElementsUtil.getMethodReturnAsString(phpClass, "getName");
if(name != null) {
found.add(name);
Expand Down

0 comments on commit 831a746

Please sign in to comment.