Skip to content

Commit 41b2053

Browse files
committed
fix ConcurrentModificationException signature filter #66 and migrate to PhpTypeProvider3 #58
1 parent 6d9e246 commit 41b2053

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

META-INF/plugin.xml

+4-3
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@
9494
TODO: Add provider
9595
<depends optional="true">de.espend.idea.php.annotation</depends>
9696
-->
97-
<extensions defaultExtensionNs="com.intellij">
98-
</extensions>
97+
98+
<extensions defaultExtensionNs="com.jetbrains.php">
99+
<typeProvider3 implementation="de.espend.idea.php.toolbox.type.PhpToolboxTypeProvider"/>
100+
</extensions>
99101

100102
<extensions defaultExtensionNs="com.intellij">
101103

@@ -104,7 +106,6 @@
104106
groupId="language"
105107
id="PhpToolbox.ApplicationForm"/>
106108

107-
<php.typeProvider2 implementation="de.espend.idea.php.toolbox.type.PhpToolboxTypeProvider"/>
108109
<gotoDeclarationHandler implementation="de.espend.idea.php.toolbox.navigation.PhpToolboxGotoDeclarationHandler"/>
109110
<completion.contributor language="any" implementationClass="de.espend.idea.php.toolbox.completion.ToolboxCompletionContributor"/>
110111
<completion.contributor language="JSON" implementationClass="de.espend.idea.php.toolbox.completion.ToolboxJsonCompletionContributor"/>

src/de/espend/idea/php/toolbox/type/PhpToolboxTypeProvider.java

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
package de.espend.idea.php.toolbox.type;
22

33
import com.intellij.openapi.application.ApplicationManager;
4-
import com.intellij.openapi.project.DumbService;
54
import com.intellij.openapi.project.Project;
65
import com.intellij.psi.PsiElement;
76
import com.intellij.util.containers.ContainerUtil;
87
import com.jetbrains.php.PhpIndex;
98
import com.jetbrains.php.lang.psi.elements.*;
10-
import com.jetbrains.php.lang.psi.resolve.types.PhpTypeProvider2;
9+
import com.jetbrains.php.lang.psi.resolve.types.PhpType;
10+
import com.jetbrains.php.lang.psi.resolve.types.PhpTypeProvider3;
1111
import de.espend.idea.php.toolbox.PhpToolboxApplicationService;
1212
import de.espend.idea.php.toolbox.dict.json.JsonRawLookupElement;
1313
import de.espend.idea.php.toolbox.dict.json.JsonRegistrar;
1414
import de.espend.idea.php.toolbox.dict.json.JsonSignature;
1515
import de.espend.idea.php.toolbox.extension.PhpToolboxProviderInterface;
1616
import de.espend.idea.php.toolbox.matcher.php.container.ContainerConditions;
17+
import de.espend.idea.php.toolbox.symfony.Symfony2InterfacesUtil;
1718
import de.espend.idea.php.toolbox.type.utils.PhpTypeProviderUtil;
1819
import de.espend.idea.php.toolbox.utils.ExtensionProviderUtil;
19-
import de.espend.idea.php.toolbox.symfony.Symfony2InterfacesUtil;
2020
import org.apache.commons.lang.StringUtils;
2121
import org.jetbrains.annotations.NotNull;
2222
import org.jetbrains.annotations.Nullable;
@@ -26,7 +26,7 @@
2626
/**
2727
* @author Daniel Espendiller <daniel@espendiller.net>
2828
*/
29-
public class PhpToolboxTypeProvider implements PhpTypeProvider2 {
29+
public class PhpToolboxTypeProvider implements PhpTypeProvider3 {
3030

3131
final static char TRIM_KEY = '\u0195';
3232

@@ -37,12 +37,7 @@ public char getKey() {
3737

3838
@Nullable
3939
@Override
40-
public String getType(PsiElement e) {
41-
42-
if (DumbService.getInstance(e.getProject()).isDumb()) {
43-
return null;
44-
}
45-
40+
public PhpType getType(PsiElement e) {
4641
if(!(e instanceof FunctionReference)) {
4742
return null;
4843
}
@@ -56,7 +51,7 @@ public String getType(PsiElement e) {
5651
Set<String> methods = new HashSet<>();
5752
Set<String> functions = new HashSet<>();
5853
for (JsonRegistrar type : types) {
59-
for (JsonSignature signature: ContainerUtil.filter(type.getSignatures(), ContainerConditions.RETURN_TYPE_TYPE)) {
54+
for (JsonSignature signature: ContainerUtil.filter(new ArrayList<>(type.getSignatures()), ContainerConditions.RETURN_TYPE_TYPE)) {
6055
if(signature.getFunction() != null && StringUtils.isNotBlank(signature.getFunction())) {
6156
functions.add(signature.getFunction());
6257
}
@@ -71,22 +66,28 @@ public String getType(PsiElement e) {
7166
// Foo::app('bar')
7267
if(e instanceof MethodReference) {
7368
if(methods.contains(((FunctionReference) e).getName())) {
74-
return PhpTypeProviderUtil.getReferenceSignature((FunctionReference) e, TRIM_KEY);
69+
String referenceSignature = PhpTypeProviderUtil.getReferenceSignature((FunctionReference) e, TRIM_KEY);
70+
if(referenceSignature != null) {
71+
return new PhpType().add("#" + this.getKey() + referenceSignature);
72+
}
7573
}
7674

7775
return null;
7876
}
7977

8078
// foo('bar')
8179
if(functions.contains(((FunctionReference) e).getName())) {
82-
return PhpTypeProviderUtil.getReferenceSignature((FunctionReference) e, TRIM_KEY);
80+
String referenceSignature = PhpTypeProviderUtil.getReferenceSignature((FunctionReference) e, TRIM_KEY);
81+
if(referenceSignature != null) {
82+
return new PhpType().add("#" + this.getKey() + referenceSignature);
83+
}
8384
}
8485

8586
return null;
8687
}
8788

8889
@Override
89-
public Collection<? extends PhpNamedElement> getBySignature(String expression, Project project) {
90+
public Collection<? extends PhpNamedElement> getBySignature(String expression, Set<String> visited, int depth, Project project) {
9091

9192
// get back our original call
9293
// since phpstorm 7.1.2 we need to validate this

0 commit comments

Comments
 (0)