mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-26 20:54:22 +01:00
autocomplete: improved rendering of completions
This commit is contained in:
parent
3d6af521db
commit
93d013d1f4
@ -175,26 +175,25 @@ public class ClangCompletionProvider extends LanguageAwareCompletionProvider {
|
||||
}
|
||||
if (chunk.typedtext != null) {
|
||||
template += chunk.typedtext;
|
||||
shortDesc += chunk.typedtext;
|
||||
typedText = chunk.typedtext;
|
||||
}
|
||||
if (chunk.placeholder != null) {
|
||||
String[] spl = chunk.placeholder.split(" ");
|
||||
template += "${" + spl[spl.length - 1] + "}";
|
||||
shortDesc += spl[spl.length - 1] + ", ";
|
||||
shortDesc += spl[spl.length - 1];
|
||||
}
|
||||
if (chunk.info != null) {
|
||||
// System.out.println("INFO: "+chunk.info);
|
||||
}
|
||||
}
|
||||
template += "${cursor}";
|
||||
int lastComma = shortDesc.lastIndexOf(",");
|
||||
if (lastComma > 0) {
|
||||
shortDesc = shortDesc.substring(0, lastComma);
|
||||
}
|
||||
shortDesc += ")";
|
||||
System.out.println("TEMPLATE: " + template);
|
||||
return new TemplateCompletion(this, typedText,
|
||||
shortDesc + " : " + returnType, template);
|
||||
System.out.println("SHORT: " + shortDesc);
|
||||
if (!returnType.isEmpty()) {
|
||||
shortDesc += " : " + returnType;
|
||||
}
|
||||
return new TemplateCompletion(this, typedText, shortDesc, template);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,21 +120,25 @@ public class CompletionsRenderer extends DefaultListCellRenderer {
|
||||
//
|
||||
// } else
|
||||
if (value instanceof ShorthandCompletion) {
|
||||
text = ((ShorthandCompletion) value).getShortDescription();
|
||||
ShorthandCompletion v = (ShorthandCompletion) value;
|
||||
text = v.getShortDescription();
|
||||
tokenType = CompletionType.TEMPLATE;
|
||||
} else if (value instanceof FunctionCompletion) {
|
||||
text = font(((FunctionCompletion) value).getInputText(), LIGHT_BLUE)
|
||||
+ font(((FunctionCompletion) value).getShortDescription(), GRAY);
|
||||
FunctionCompletion v = (FunctionCompletion) value;
|
||||
text = font(v.getInputText(), LIGHT_BLUE) + " "
|
||||
+ font(v.getShortDescription(), GRAY);
|
||||
tokenType = CompletionType.FUNCTION;
|
||||
} else if (value instanceof BasicCompletion) {
|
||||
text = ((BasicCompletion) value).getInputText();
|
||||
if (((BasicCompletion) value).getShortDescription() != null) {
|
||||
text = ((BasicCompletion) value).getShortDescription();
|
||||
BasicCompletion v = (BasicCompletion) value;
|
||||
if (v.getShortDescription() != null) {
|
||||
text = v.getShortDescription();
|
||||
} else {
|
||||
text = v.getInputText();
|
||||
}
|
||||
} else if (value instanceof TemplateCompletion) {
|
||||
TemplateCompletion template = (TemplateCompletion) value;
|
||||
text = font(template.getInputText(), LIGHT_BLUE)
|
||||
+ font(template.getDefinitionString(), GRAY);
|
||||
TemplateCompletion v = (TemplateCompletion) value;
|
||||
text = font(v.getInputText(), LIGHT_BLUE) + " "
|
||||
+ font(v.getDefinitionString(), GRAY);
|
||||
}
|
||||
|
||||
if (text == null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user