Skip to content

Commit a7a93ab

Browse files
committed
tooltip: use appropriate formatter
this formats the tooltip text according to the key e.g. for a known instruction like -buildpath it uses a formatter via BndEditModel.format() That way the tooltips look nicer and are more helpful - also: hovering: use stem to get the Syntax this allows to show helptext for keys with dots e.g. -plugin.a would still show the help text of the -plugin instruction and also point to the correct help url Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
1 parent 101c827 commit a7a93ab

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

bndtools.core/src/bndtools/editor/completion/BndHover.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.eclipse.swt.graphics.Point;
2323
import org.eclipse.swt.widgets.Shell;
2424

25+
import aQute.bnd.build.model.BndEditModel;
2526
import aQute.bnd.help.Syntax;
2627
import aQute.bnd.osgi.Processor;
2728

@@ -100,6 +101,7 @@ static String wrap(String text, int width) {
100101
}
101102

102103
public static String syntaxHoverText(String key, Processor properties) {
104+
103105
Syntax syntax = lookupSyntax(key);
104106
StringBuilder sb = new StringBuilder();
105107

@@ -118,11 +120,14 @@ public static String syntaxHoverText(String key, Processor properties) {
118120
.toString()
119121
: properties.get(key);
120122

123+
121124
if (value != null && !value.isEmpty()) {
125+
String stem = BndEditModel.getStem(key);
126+
String formatted = BndEditModel.format(stem, value);
122127
sb.append("\n")
123128
.append(key)
124129
.append("=")
125-
.append(value);
130+
.append(formatted);
126131
}
127132

128133
List<String> errors = properties.getErrors();
@@ -132,16 +137,13 @@ public static String syntaxHoverText(String key, Processor properties) {
132137
sb.append(errors);
133138
}
134139

135-
String text = sb.toString();
136-
137-
if (text.length() > 30) {
138-
text = wrap(text, 30);
139-
}
140-
return text;
140+
return sb.toString();
141141
}
142142

143143
public static Syntax lookupSyntax(String key) {
144-
Syntax syntax = Syntax.HELP.get(key);
144+
145+
String stem = BndEditModel.getStem(key);
146+
Syntax syntax = Syntax.HELP.get(stem);
145147

146148
if (syntax == null) {
147149
if (!key.startsWith("-"))

0 commit comments

Comments
 (0)