use of aQute.bnd.help.Syntax in project bnd by bndtools.
the class bnd method print.
private void print(Formatter f, Syntax sx, String indent) {
if (sx == null)
return;
f.format("%s%s\n\n", indent, sx.getLead());
if (sx.getValues() != null)
f.format("%sValues\t1:\t2%s\n", indent, sx.getValues());
if (sx.getPattern() != null)
f.format("%sPattern \t1:\t2%s\n", indent, sx.getPattern());
if (sx.getExample() != null)
f.format("%sExample \t1:\t2%s\n", indent, sx.getExample());
if (sx.getChildren() != null) {
for (Syntax child : sx.getChildren()) {
f.format("\n%s[%s]\t1:\t2", indent, child.getHeader());
print(f, child, indent + " ");
}
}
}
use of aQute.bnd.help.Syntax in project bndtools by bndtools.
the class BndCompletionProcessor method proposals.
private static ICompletionProposal[] proposals(String prefix, int offset) {
ArrayList<ICompletionProposal> results = new ArrayList<ICompletionProposal>(Syntax.HELP.size());
for (Syntax s : Syntax.HELP.values()) {
if (prefix == null || s.getHeader().startsWith(prefix)) {
IContextInformation info = new ContextInformation(s.getHeader(), s.getHeader());
String text = prefix == null ? s.getHeader() : s.getHeader().substring(prefix.length());
//$NON-NLS-1$
results.add(new CompletionProposal(text + ": ", offset, 0, text.length() + 2, null, s.getHeader(), info, s.getLead()));
}
}
Collections.sort(results, new Comparator<ICompletionProposal>() {
@Override
public int compare(ICompletionProposal p1, ICompletionProposal p2) {
return p1.getDisplayString().compareTo(p2.getDisplayString());
}
});
return results.toArray(new ICompletionProposal[0]);
}
use of aQute.bnd.help.Syntax in project bndtools by bndtools.
the class ToolTips method setupMessageAndToolTipFromSyntax.
/**
* Setup the message and the tooltip of a control. The Syntax class of bnd is used to determine these.
*
* @param control
* the control
* @param constant
* the constant, as mentioned in aQute.bnd.osgi.Constants
*/
public static void setupMessageAndToolTipFromSyntax(Control control, String constant) {
Syntax syntax = Syntax.HELP.get(constant);
if (syntax == null) {
logger.logError("No bnd syntax found for " + constant, null);
syntax = new Syntax(constant, "Description of " + constant, constant + ": Example for " + constant, null, null);
}
String values = syntax.getValues();
if (values != null) {
/* filter out macros */
values = values.replaceAll("\\$\\{[^\\}]*\\}", "");
values = values.replaceAll(",\\s*,", ",");
values = values.replaceAll("(^,|,$)", "");
}
if ((values == null) || (values.trim().length() == 0)) {
values = "";
} else {
values = "\n\nProposed Values:\n" + values.trim().replaceAll("\\s*,\\s*", ", ");
}
String examples = getStrippedExample(syntax, constant);
if (examples == null) {
examples = "";
} else {
examples = "\n\nExample:\n" + examples;
}
String tt = syntax.getLead() + values + examples;
control.setToolTipText(tt);
}
use of aQute.bnd.help.Syntax in project bnd by bndtools.
the class bnd method _syntax.
@Description("Access the internal bnd database of keywords and options")
public void _syntax(syntaxOptions opts) throws Exception {
int w = opts.width() < 80 ? 120 : opts.width();
Justif justif = new Justif(w, opts.width(), 40, 42, w - 10);
List<String> args = opts._arguments();
StringBuilder sb = new StringBuilder();
Formatter f = new Formatter(sb);
for (String s : args) {
f.format(" \n[%s]\n", s);
Syntax sx = Syntax.HELP.get(s);
if (s == null)
f.format("Unknown");
else {
print(f, sx, " ");
}
}
f.flush();
justif.wrap(sb);
err.println(sb);
}
use of aQute.bnd.help.Syntax in project bnd by bndtools.
the class Project method _help.
public String _help(String[] args) throws Exception {
if (args.length == 1)
return "Specify the option or header you want information for";
Syntax syntax = Syntax.HELP.get(args[1]);
if (syntax == null)
return "No help for " + args[1];
String what = null;
if (args.length > 2)
what = args[2];
if (what == null || what.equals("lead"))
return syntax.getLead();
if (what.equals("example"))
return syntax.getExample();
if (what.equals("pattern"))
return syntax.getPattern();
if (what.equals("values"))
return syntax.getValues();
return "Invalid type specified for help: lead, example, pattern, values";
}
Aggregations