Search in sources :

Example 1 with Parameter

use of org.fife.ui.autocomplete.ParameterizedCompletion.Parameter in project omegaide by omegaui.

the class ParameterizedCompletionContext method possiblyUpdateParamCopies.

private void possiblyUpdateParamCopies(Document doc) {
    int index = getCurrentParameterIndex();
    // FunctionCompletions add an extra param at end of inserted text
    if (index > -1 && index < pc.getParamCount()) {
        // Typing in an "end parameter" => stop parameter assistance.
        Parameter param = pc.getParam(index);
        if (param.isEndParam()) {
            deactivate();
            return;
        }
        // Get the current value of the current parameter.
        List<Highlight> paramHighlights = getParameterHighlights();
        Highlight h = paramHighlights.get(index);
        // param offsets are offset (!) by 1
        int start = h.getStartOffset() + 1;
        int len = h.getEndOffset() - start;
        String replacement = null;
        try {
            replacement = doc.getText(start, len);
        } catch (BadLocationException ble) {
            // Never happens
            ble.printStackTrace();
        }
        // value of this parameter.
        for (ParamCopyInfo pci : paramCopyInfos) {
            if (pci.paramName.equals(param.getName())) {
                pci.h = replaceHighlightedText(doc, pci.h, replacement);
            }
        }
    } else {
        // Probably the "end parameter" for FunctionCompletions.
        deactivate();
    }
}
Also used : Highlight(javax.swing.text.Highlighter.Highlight) Parameter(org.fife.ui.autocomplete.ParameterizedCompletion.Parameter) Point(java.awt.Point) BadLocationException(javax.swing.text.BadLocationException)

Example 2 with Parameter

use of org.fife.ui.autocomplete.ParameterizedCompletion.Parameter in project omegaide by omegaui.

the class MarkupTagCompletion method addAttributes.

/**
 * Adds HTML describing the attributes of this tag to a buffer.
 *
 * @param sb The buffer to append to.
 */
protected void addAttributes(StringBuilder sb) {
    // TODO: Localize me.
    int attrCount = getAttributeCount();
    if (attrCount > 0) {
        sb.append("<b>Attributes:</b><br>");
        sb.append("<center><table width='90%'><tr><td>");
        for (int i = 0; i < attrCount; i++) {
            Parameter attr = getAttribute(i);
            sb.append("&nbsp;&nbsp;&nbsp;<b>");
            sb.append(attr.getName() != null ? attr.getName() : attr.getType());
            sb.append("</b>&nbsp;");
            String desc = attr.getDescription();
            if (desc != null) {
                sb.append(desc);
            }
            sb.append("<br>");
        }
        sb.append("</td></tr></table></center><br><br>");
    }
}
Also used : Parameter(org.fife.ui.autocomplete.ParameterizedCompletion.Parameter)

Example 3 with Parameter

use of org.fife.ui.autocomplete.ParameterizedCompletion.Parameter in project lara-framework by specs-feup.

the class EditorConfigurer method addPrintlnCompletion.

static void addPrintlnCompletion(DefaultCompletionProvider provider) {
    FunctionCompletion printlnCompletion = new FunctionCompletion(provider, "println", "void");
    List<Parameter> params = new ArrayList<>();
    Parameter messageParam = new Parameter(null, "message", true);
    messageParam.setDescription("The message to print");
    params.add(messageParam);
    printlnCompletion.setParams(params);
    printlnCompletion.setShortDescription("Print a message");
    printlnCompletion.setSummary("Print a message");
    provider.addCompletion(printlnCompletion);
}
Also used : FunctionCompletion(org.fife.ui.autocomplete.FunctionCompletion) ArrayList(java.util.ArrayList) Parameter(org.fife.ui.autocomplete.ParameterizedCompletion.Parameter)

Aggregations

Parameter (org.fife.ui.autocomplete.ParameterizedCompletion.Parameter)3 Point (java.awt.Point)1 ArrayList (java.util.ArrayList)1 BadLocationException (javax.swing.text.BadLocationException)1 Highlight (javax.swing.text.Highlighter.Highlight)1 FunctionCompletion (org.fife.ui.autocomplete.FunctionCompletion)1