@@ -58,7 +58,7 @@ public class ClangCompletionProvider extends LanguageAwareCompletionProvider {
58
58
public ClangCompletionProvider (Editor e , DefaultCompletionProvider cp ) {
59
59
super (cp );
60
60
editor = e ;
61
- // setParameterizedCompletionParams('(', ", ", ')');
61
+ cp . setParameterizedCompletionParams ('(' , ", " , ')' );
62
62
}
63
63
64
64
@ Override
@@ -98,21 +98,23 @@ protected List<Completion> getCompletionsImpl(JTextComponent textarea) {
98
98
allCc = mapper .readValue (out , ArduinoCompletionsList .class );
99
99
for (ArduinoCompletion cc : allCc ) {
100
100
101
- if (cc .type .equals ("Macro" )) {
102
- // for now skip macro
103
- continue ;
104
- }
105
-
106
- if (cc .type .equals ("Function" )) {
101
+ if (cc .type .equals ("Function" ) || cc .type .equals ("Macro" )) {
107
102
List <Parameter > params = new ArrayList <>();
108
103
int i =0 ;
104
+ String fancyParameters = "(" ;
109
105
for (CompletionChunk chunk : cc .completion .chunks ) {
110
106
if (chunk .placeholder != null ) {
111
107
ArduinoParameter p = cc .parameters .get (i );
112
108
params .add (new Parameter (p .type , p .name ));
109
+ fancyParameters += (p .name .equals ("" ) ? p .type : p .name ) + ", " ;
113
110
i ++;
114
111
}
115
112
}
113
+ int lastComma = fancyParameters .lastIndexOf ("," );
114
+ if (lastComma > 0 ) {
115
+ fancyParameters = fancyParameters .substring (0 , lastComma );
116
+ }
117
+ fancyParameters += ")" ;
116
118
117
119
if (!cc .getCompletion ().getTypedText ().startsWith (getAlreadyEnteredText (textarea ))) {
118
120
continue ;
@@ -122,19 +124,22 @@ protected List<Completion> getCompletionsImpl(JTextComponent textarea) {
122
124
cc .getCompletion ().getTypedText (),
123
125
cc .getCompletion ().getResultType ());
124
126
compl .setParams (params );
127
+ compl .setShortDescription (fancyParameters + " : " + cc .getCompletion ().getResultType ());
125
128
res .add (compl );
126
129
continue ;
127
130
}
128
131
129
132
String returnType = "" ;
130
133
String typedText = null ;
131
134
String template = "" ;
135
+ String fancyParameters = "(" ;
136
+
132
137
for (CompletionChunk chunk : cc .completion .chunks ) {
133
138
if (chunk .t != null ) {
134
139
template += chunk .t ;
135
140
}
136
141
if (chunk .res != null ) {
137
- returnType = " - " + chunk .res ;
142
+ returnType = chunk .res ;
138
143
}
139
144
if (chunk .typedtext != null ) {
140
145
template += chunk .typedtext ;
@@ -143,16 +148,22 @@ protected List<Completion> getCompletionsImpl(JTextComponent textarea) {
143
148
if (chunk .placeholder != null ) {
144
149
String [] spl = chunk .placeholder .split (" " );
145
150
template += "${" + spl [spl .length - 1 ] + "}" ;
151
+ fancyParameters += spl [spl .length - 1 ] + ", " ;
146
152
}
147
153
if (chunk .info != null ) {
148
154
//System.out.println("INFO: "+chunk.info);
149
155
}
150
156
}
151
157
template += "${cursor}" ;
158
+ int lastComma = fancyParameters .lastIndexOf ("," );
159
+ if (lastComma > 0 ) {
160
+ fancyParameters = fancyParameters .substring (0 , lastComma );
161
+ }
162
+ fancyParameters += ")" ;
152
163
//System.out.println("TEMPLATE: " + template);
153
164
if (typedText .startsWith (getAlreadyEnteredText (textarea ))) {
154
- res . add ( new TemplateCompletion (this , typedText , typedText + returnType ,
155
- template ) );
165
+ TemplateCompletion compl = new TemplateCompletion (this , typedText , fancyParameters + " : " + returnType , template );
166
+ res . add ( compl );
156
167
}
157
168
}
158
169
return res ;
0 commit comments