Search in sources :

Example 1 with ParameterInfo

use of org.eclipse.che.ide.api.editor.signature.ParameterInfo in project che by eclipse.

the class SignatureHelpView method renderDocumentation.

private void renderDocumentation(Element element, SignatureInfo signatureInfo, Optional<Integer> activeParameter) {
    if (signatureInfo.getDocumentation().isPresent()) {
        elemental.html.DivElement documentation = Elements.createDivElement(resources.css().documentation());
        documentation.setTextContent(signatureInfo.getDocumentation().get());
        element.appendChild(documentation);
    }
    if (signatureInfo.getParameters().isPresent() && activeParameter.isPresent() && signatureInfo.getParameters().get().size() > activeParameter.get()) {
        ParameterInfo parameterInfo = signatureInfo.getParameters().get().get(activeParameter.get());
        if (parameterInfo.getDocumentation().isPresent()) {
            elemental.html.DivElement parameter = Elements.createDivElement(resources.css().documentationParameter());
            SpanElement label = Elements.createSpanElement(resources.css().documentationParameter());
            label.setTextContent(parameterInfo.getLabel());
            SpanElement documentation = Elements.createSpanElement(resources.css().documentation());
            documentation.setTextContent(parameterInfo.getDocumentation().get());
            parameter.appendChild(label);
            parameter.appendChild(documentation);
            element.appendChild(parameter);
        }
    }
}
Also used : SpanElement(elemental.html.SpanElement) ParameterInfo(org.eclipse.che.ide.api.editor.signature.ParameterInfo)

Example 2 with ParameterInfo

use of org.eclipse.che.ide.api.editor.signature.ParameterInfo in project che by eclipse.

the class SignatureHelpView method renderParameters.

private void renderParameters(Element parent, SignatureInfo signatureInfo, Optional<Integer> activeParameter) {
    int end = signatureInfo.getLabel().length();
    int idx;
    Element element;
    for (int i = signatureInfo.getParameters().get().size() - 1; i >= 0; i--) {
        ParameterInfo parameterInfo = signatureInfo.getParameters().get().get(i);
        idx = signatureInfo.getLabel().lastIndexOf(parameterInfo.getLabel(), end);
        int signatureLabelOffset = 0;
        int signatureLabelEnd = 0;
        if (idx >= 0) {
            signatureLabelOffset = idx;
            signatureLabelEnd = idx + parameterInfo.getLabel().length();
        }
        element = Elements.createSpanElement();
        element.setTextContent(signatureInfo.getLabel().substring(signatureLabelEnd, end));
        parent.insertBefore(element, parent.getFirstElementChild());
        element = Elements.createSpanElement(resources.css().parameter());
        if (activeParameter.isPresent() && i == activeParameter.get()) {
            Elements.addClassName(resources.css().active(), element);
        }
        element.setTextContent(signatureInfo.getLabel().substring(signatureLabelOffset, signatureLabelEnd));
        parent.insertBefore(element, parent.getFirstElementChild());
        end = signatureLabelOffset;
    }
    element = Elements.createSpanElement();
    element.setTextContent(signatureInfo.getLabel().substring(0, end));
    parent.insertBefore(element, parent.getFirstElementChild());
}
Also used : Element(elemental.dom.Element) SpanElement(elemental.html.SpanElement) ParameterInfo(org.eclipse.che.ide.api.editor.signature.ParameterInfo)

Aggregations

SpanElement (elemental.html.SpanElement)2 ParameterInfo (org.eclipse.che.ide.api.editor.signature.ParameterInfo)2 Element (elemental.dom.Element)1