Skip to content

Commit 9ce3627

Browse files
committed
Autocomplete renderTypes
1 parent a565e46 commit 9ce3627

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

src/main/java/com/cedricziel/idea/typo3/tca/codeInsight/TCACompletionContributor.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package com.cedricziel.idea.typo3.tca.codeInsight;
22

33
import com.cedricziel.idea.typo3.psi.PhpElementsUtil;
4+
import com.cedricziel.idea.typo3.util.TCAUtil;
45
import com.cedricziel.idea.typo3.util.TableUtil;
56
import com.intellij.codeInsight.completion.*;
7+
import com.intellij.codeInsight.lookup.LookupElement;
68
import com.intellij.psi.PsiElement;
79
import com.intellij.util.ProcessingContext;
810
import org.jetbrains.annotations.NotNull;
911

12+
import static com.cedricziel.idea.typo3.psi.PhpElementsUtil.extractArrayIndexFromValue;
1013
import static com.cedricziel.idea.typo3.util.TCAUtil.arrayIndexIsTCATableNameField;
1114

1215
public class TCACompletionContributor extends CompletionContributor {
@@ -28,5 +31,32 @@ protected void addCompletions(@NotNull CompletionParameters parameters, Processi
2831
}
2932
}
3033
);
34+
35+
/*
36+
* Complete 'renderType' fields in TCA
37+
*/
38+
extend(
39+
CompletionType.BASIC,
40+
PhpElementsUtil.isStringArrayValue(),
41+
new CompletionProvider<CompletionParameters>() {
42+
@Override
43+
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
44+
PsiElement element = parameters.getPosition();
45+
46+
String arrayIndex = extractArrayIndexFromValue(element);
47+
if ("renderType".equals(arrayIndex)) {
48+
for(String name: TCAUtil.getAvailableRenderTypes(element)) {
49+
result.addElement(new LookupElement() {
50+
@NotNull
51+
@Override
52+
public String getLookupString() {
53+
return name;
54+
}
55+
});
56+
}
57+
}
58+
}
59+
}
60+
);
3161
}
3262
}

src/main/resources/META-INF/plugin.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@
6868
<li>line marker to allow quick navigation to the route definition</li>
6969
</ul>
7070
71+
<h3>TCA</h3>
72+
<ul>
73+
<li>completion for built-in TCA render types</li>
74+
</ul>
75+
7176
<h3>Code inspections</h3>
7277
7378
<br/>
@@ -102,6 +107,11 @@ It is a great inspiration for possible solutions and parts of the code.</p>
102107
]]></description>
103108

104109
<change-notes><![CDATA[
110+
<h2>0.2.10</h2>
111+
<ul>
112+
<li>Autocompletion for TCA renderTypes</li>
113+
</ul>
114+
105115
<h2>0.2.9</h2>
106116
<ul>
107117
<li>Add MissingTableInspection</li>

0 commit comments

Comments
 (0)