Skip to content

Commit 0e89a04

Browse files
committed
Optimize ControlCompletionContributor
1 parent 1c1e2e2 commit 0e89a04

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/main/kotlin/org/nette/helpers/completion/ControlCompletionContributor.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ class ControlCompletionContributor : CompletionContributor() {
2727
result: CompletionResultSet
2828
) {
2929
val stringLiteral = parameters.originalPosition?.parent as? StringLiteralExpression ?: return
30-
val prefix = if (result.prefixMatcher.prefix.contains("-")) {
31-
result.prefixMatcher.prefix.take(result.prefixMatcher.prefix.lastIndexOf("-") + 1)
32-
} else {
33-
""
34-
}
35-
3630
var target: PsiElement? = null
3731

3832
// Case 1: $this['...'] array access
@@ -53,6 +47,10 @@ class ControlCompletionContributor : CompletionContributor() {
5347
val classes = target?.resolvePhpClasses()?.filter { it.isComponent() } ?: return
5448
if (classes.isEmpty()) return
5549

50+
val prefix = result.prefixMatcher.prefix.let { prefix ->
51+
if (prefix.contains("-")) prefix.take(prefix.lastIndexOf("-") + 1) else ""
52+
}
53+
5654
val seen = HashSet<String>()
5755
for (phpClass in target.resolvePhpClasses().filter { it.isComponent() } ) {
5856
for (method in phpClass.getControls()) {

0 commit comments

Comments
 (0)