Search in sources :

Example 6 with ContextInformation

use of org.eclipse.jface.text.contentassist.ContextInformation in project linuxtools by eclipse.

the class STPCompletionProcessor method getGlobalKeywordCompletion.

private ICompletionProposal[] getGlobalKeywordCompletion(String prefix, int offset) {
    ArrayList<ICompletionProposal> completions = new ArrayList<>();
    int prefixLength = prefix.length();
    for (String[] keyword : GLOBAL_KEYWORDS) {
        if (keyword[0].startsWith(prefix)) {
            CompletionProposal proposal = new CompletionProposal(keyword[0].substring(prefixLength), offset, 0, keyword[0].length() - prefixLength, null, keyword[0], // $NON-NLS-1$ //$NON-NLS-2$
            new ContextInformation("contextDisplayString", "informationDisplayString"), keyword[1]);
            completions.add(proposal);
        }
    }
    return completions.toArray(new ICompletionProposal[0]);
}
Also used : STPFunctionCompletionProposal(org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.proposals.STPFunctionCompletionProposal) STPProbeCompletionProposal(org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.proposals.STPProbeCompletionProposal) STPProbevarCompletionProposal(org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.proposals.STPProbevarCompletionProposal) CompletionProposal(org.eclipse.jface.text.contentassist.CompletionProposal) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) ContextInformation(org.eclipse.jface.text.contentassist.ContextInformation) IContextInformation(org.eclipse.jface.text.contentassist.IContextInformation) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) ArrayList(java.util.ArrayList)

Example 7 with ContextInformation

use of org.eclipse.jface.text.contentassist.ContextInformation in project webtools.sourceediting by eclipse.

the class AttributeContextInformationProvider method getInfoForText.

/**
 * @param node
 */
IContextInformation[] getInfoForText(IDOMNode node) {
    Node parent = node.getParentNode();
    String contextString = node.getNodeName();
    // $NON-NLS-1$
    StringBuffer info = new StringBuffer(" ");
    if ((parent != null) && (parent.getNodeType() == Node.ELEMENT_NODE)) {
        CMElementDeclaration decl = fModelUtil.getModelQuery().getCMElementDeclaration((Element) parent);
        CMContent content = decl.getContent();
        if (content instanceof CMGroup) {
            CMGroup cmGroup = (CMGroup) content;
            CMNodeList children = cmGroup.getChildNodes();
            CMNode cmNode = null;
            for (int i = 0; i < children.getLength(); i++) {
                cmNode = children.item(i);
                contextString = cmNode.getNodeName();
                if (contextString != null) {
                    // $NON-NLS-1$ //$NON-NLS-2$
                    info.append("<" + cmNode.getNodeName() + ">");
                    if (i < children.getLength() - 1) {
                        // $NON-NLS-1$
                        info.append(" ");
                    }
                }
            }
        }
    }
    if (!info.toString().trim().equals("")) {
        return new IContextInformation[] { new ContextInformation(contextString, info.toString()) };
    } else {
        return EMPTY_CONTEXT_INFO;
    }
}
Also used : CMGroup(org.eclipse.wst.xml.core.internal.contentmodel.CMGroup) CMElementDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration) IContextInformation(org.eclipse.jface.text.contentassist.IContextInformation) ContextInformation(org.eclipse.jface.text.contentassist.ContextInformation) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) Node(org.w3c.dom.Node) CMNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode) IContextInformation(org.eclipse.jface.text.contentassist.IContextInformation) CMNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode) CMContent(org.eclipse.wst.xml.core.internal.contentmodel.CMContent) CMNodeList(org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)

Aggregations

ContextInformation (org.eclipse.jface.text.contentassist.ContextInformation)7 IContextInformation (org.eclipse.jface.text.contentassist.IContextInformation)6 CompletionProposal (org.eclipse.jface.text.contentassist.CompletionProposal)3 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)3 ArrayList (java.util.ArrayList)2 Syntax (aQute.bnd.help.Syntax)1 LinkedList (java.util.LinkedList)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 IDocument (org.eclipse.jface.text.IDocument)1 STPFunctionCompletionProposal (org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.proposals.STPFunctionCompletionProposal)1 STPProbeCompletionProposal (org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.proposals.STPProbeCompletionProposal)1 STPProbevarCompletionProposal (org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.proposals.STPProbevarCompletionProposal)1 Image (org.eclipse.swt.graphics.Image)1 CMContent (org.eclipse.wst.xml.core.internal.contentmodel.CMContent)1 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)1 CMGroup (org.eclipse.wst.xml.core.internal.contentmodel.CMGroup)1 CMNode (org.eclipse.wst.xml.core.internal.contentmodel.CMNode)1 CMNodeList (org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)1 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)1 DBPPreferenceStore (org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)1