Skip to content

Commit e14a903

Browse files
authored
[T3CMS] Handle StringIndexOutOfBoundsException in AbstractServiceLocatorTypeProvider (#336)
1 parent 1292d9d commit e14a903

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

.travis.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,7 @@ before_install:
2929
- java -version
3030

3131
script:
32-
- |
33-
if [[ ${SINCE_BUILD} == "193" ]]; then
34-
sed -i '25d' typo3-cms/src/main/resources/META-INF/plugin.xml
35-
cat typo3-cms/src/main/resources/META-INF/plugin.xml
36-
fi
37-
38-
- "./gradlew check"
39-
- "./gradlew buildPlugin"
32+
- "./gradlew clean build"
4033

4134
deploy:
4235
provider: releases

typo3-cms/src/main/java/com/cedricziel/idea/typo3/provider/AbstractServiceLocatorTypeProvider.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.cedricziel.idea.typo3.provider;
22

3+
import com.intellij.openapi.diagnostic.Logger;
34
import com.intellij.openapi.project.Project;
45
import com.jetbrains.php.PhpIndex;
56
import com.jetbrains.php.lang.psi.elements.PhpNamedElement;
@@ -13,6 +14,8 @@
1314

1415
abstract public class AbstractServiceLocatorTypeProvider implements PhpTypeProvider4 {
1516

17+
private static final Logger LOG = Logger.getInstance(AbstractServiceLocatorTypeProvider.class);
18+
1619
public static final char TRIM_KEY = '%';
1720

1821
@Nullable
@@ -30,16 +33,22 @@ public Collection<? extends PhpNamedElement> getBySignature(String expression, S
3033
// Get FQN from parameter string.
3134
// Example (PhpStorm 8): #K#C\Foo\Bar::get()%#K#C\Bar\Baz. -> \Bar\Baz.
3235
// Example (PhpStorm 9): #K#C\Foo\Bar::get()%#K#C\Bar\Baz.class -> \Bar\Baz.class
33-
String parameter = expression.substring(endIndex + 5);
36+
try {
37+
String parameter = expression.substring(endIndex + 5);
3438

35-
if (parameter.contains(".class")) { // for PhpStorm 9
36-
parameter = parameter.replace(".class", "");
37-
}
39+
if (parameter.contains(".class")) { // for PhpStorm 9
40+
parameter = parameter.replace(".class", "");
41+
}
3842

39-
if (parameter.contains(".")) {
40-
parameter = parameter.replace(".", "");
41-
}
43+
if (parameter.contains(".")) {
44+
parameter = parameter.replace(".", "");
45+
}
4246

43-
return PhpIndex.getInstance(project).getAnyByFQN(parameter);
47+
return PhpIndex.getInstance(project).getAnyByFQN(parameter);
48+
} catch (StringIndexOutOfBoundsException e) {
49+
LOG.warn("Unable to find PhpNamedElement by signature from \"" + expression + "\"");
50+
51+
return Collections.emptySet();
52+
}
4453
}
4554
}

0 commit comments

Comments
 (0)