@@ -58,7 +58,7 @@ public class ClangCompletionProvider extends LanguageAwareCompletionProvider {
5858 public ClangCompletionProvider (Editor e , DefaultCompletionProvider cp ) {
5959 super (cp );
6060 editor = e ;
61- // setParameterizedCompletionParams('(', ", ", ')');
61+ cp . setParameterizedCompletionParams ('(' , ", " , ')' );
6262 }
6363
6464 @ Override
@@ -98,21 +98,23 @@ protected List<Completion> getCompletionsImpl(JTextComponent textarea) {
9898 allCc = mapper .readValue (out , ArduinoCompletionsList .class );
9999 for (ArduinoCompletion cc : allCc ) {
100100
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" )) {
107102 List <Parameter > params = new ArrayList <>();
108103 int i =0 ;
104+ String fancyParameters = "(" ;
109105 for (CompletionChunk chunk : cc .completion .chunks ) {
110106 if (chunk .placeholder != null ) {
111107 ArduinoParameter p = cc .parameters .get (i );
112108 params .add (new Parameter (p .type , p .name ));
109+ fancyParameters += (p .name .equals ("" ) ? p .type : p .name ) + ", " ;
113110 i ++;
114111 }
115112 }
113+ int lastComma = fancyParameters .lastIndexOf ("," );
114+ if (lastComma > 0 ) {
115+ fancyParameters = fancyParameters .substring (0 , lastComma );
116+ }
117+ fancyParameters += ")" ;
116118
117119 if (!cc .getCompletion ().getTypedText ().startsWith (getAlreadyEnteredText (textarea ))) {
118120 continue ;
@@ -122,19 +124,22 @@ protected List<Completion> getCompletionsImpl(JTextComponent textarea) {
122124 cc .getCompletion ().getTypedText (),
123125 cc .getCompletion ().getResultType ());
124126 compl .setParams (params );
127+ compl .setShortDescription (fancyParameters + " : " + cc .getCompletion ().getResultType ());
125128 res .add (compl );
126129 continue ;
127130 }
128131
129132 String returnType = "" ;
130133 String typedText = null ;
131134 String template = "" ;
135+ String fancyParameters = "(" ;
136+
132137 for (CompletionChunk chunk : cc .completion .chunks ) {
133138 if (chunk .t != null ) {
134139 template += chunk .t ;
135140 }
136141 if (chunk .res != null ) {
137- returnType = " - " + chunk .res ;
142+ returnType = chunk .res ;
138143 }
139144 if (chunk .typedtext != null ) {
140145 template += chunk .typedtext ;
@@ -143,16 +148,22 @@ protected List<Completion> getCompletionsImpl(JTextComponent textarea) {
143148 if (chunk .placeholder != null ) {
144149 String [] spl = chunk .placeholder .split (" " );
145150 template += "${" + spl [spl .length - 1 ] + "}" ;
151+ fancyParameters += spl [spl .length - 1 ] + ", " ;
146152 }
147153 if (chunk .info != null ) {
148154 //System.out.println("INFO: "+chunk.info);
149155 }
150156 }
151157 template += "${cursor}" ;
158+ int lastComma = fancyParameters .lastIndexOf ("," );
159+ if (lastComma > 0 ) {
160+ fancyParameters = fancyParameters .substring (0 , lastComma );
161+ }
162+ fancyParameters += ")" ;
152163 //System.out.println("TEMPLATE: " + template);
153164 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 );
156167 }
157168 }
158169 return res ;
0 commit comments