Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/arduino/Arduino.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@arduino.cc>2017-10-17 14:45:39 +0300
committerMartino Facchin <m.facchin@arduino.cc>2020-04-07 15:09:06 +0300
commit93d013d1f4cd6d5da4e0e830a2803dffa452592c (patch)
treecb9e388aee26346a57fd5f4d4bdd9e8b35ca0fd7
parent3d6af521db9861191368b377909ccb864579a337 (diff)
autocomplete: improved rendering of completions
-rw-r--r--app/src/cc/arduino/autocomplete/ClangCompletionProvider.java15
-rw-r--r--app/src/cc/arduino/autocomplete/CompletionsRenderer.java22
2 files changed, 20 insertions, 17 deletions
diff --git a/app/src/cc/arduino/autocomplete/ClangCompletionProvider.java b/app/src/cc/arduino/autocomplete/ClangCompletionProvider.java
index 5ee4464bc..7ebe9fe52 100644
--- a/app/src/cc/arduino/autocomplete/ClangCompletionProvider.java
+++ b/app/src/cc/arduino/autocomplete/ClangCompletionProvider.java
@@ -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);
}
}
}
diff --git a/app/src/cc/arduino/autocomplete/CompletionsRenderer.java b/app/src/cc/arduino/autocomplete/CompletionsRenderer.java
index 3d915c35d..d7a1a3917 100644
--- a/app/src/cc/arduino/autocomplete/CompletionsRenderer.java
+++ b/app/src/cc/arduino/autocomplete/CompletionsRenderer.java
@@ -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) {