Search in sources :

Example 1 with CMDocumentImpl

use of org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMDocumentImpl in project webtools.sourceediting by eclipse.

the class JSPELCompletionProposalComputer method getFunctionProposals.

/**
 * <p>Get the EL function proposals, ex: ${fn:| }</p>
 * @param prefix
 * @param viewer
 * @param offset
 * @return
 */
private List getFunctionProposals(String prefix, ITextViewer viewer, int offset) {
    TLDCMDocumentManager docMgr = TaglibController.getTLDCMDocumentManager(viewer.getDocument());
    ArrayList completionList = new ArrayList();
    if (docMgr == null)
        return null;
    Iterator taglibs = docMgr.getCMDocumentTrackers(offset).iterator();
    while (taglibs.hasNext()) {
        TaglibTracker tracker = (TaglibTracker) taglibs.next();
        if (tracker.getPrefix().equals(prefix)) {
            CMDocumentImpl doc = (CMDocumentImpl) tracker.getDocument();
            List functions = doc.getFunctions();
            for (Iterator it = functions.iterator(); it.hasNext(); ) {
                TLDFunction function = (TLDFunction) it.next();
                CustomCompletionProposal proposal = new // $NON-NLS-1$
                CustomCompletionProposal(// $NON-NLS-1$
                function.getName() + "()", offset, 0, function.getName().length() + 1, null, function.getName() + " - " + function.getSignature(), null, null, // $NON-NLS-1$
                1);
                completionList.add(proposal);
            }
        }
    }
    return completionList;
}
Also used : TLDCMDocumentManager(org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager) TaglibTracker(org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) CustomCompletionProposal(org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal) ArrayList(java.util.ArrayList) List(java.util.List) TLDFunction(org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDFunction) CMDocumentImpl(org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMDocumentImpl)

Example 2 with CMDocumentImpl

use of org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMDocumentImpl in project webtools.sourceediting by eclipse.

the class JSPELContentAssistProcessor method getFunctionProposals.

protected List getFunctionProposals(String prefix, StructuredTextViewer viewer, int offset) {
    TLDCMDocumentManager docMgr = TaglibController.getTLDCMDocumentManager(viewer.getDocument());
    ArrayList completionList = new ArrayList();
    if (docMgr == null)
        return null;
    Iterator taglibs = docMgr.getCMDocumentTrackers(offset).iterator();
    while (taglibs.hasNext()) {
        TaglibTracker tracker = (TaglibTracker) taglibs.next();
        if (tracker.getPrefix().equals(prefix)) {
            CMDocumentImpl doc = (CMDocumentImpl) tracker.getDocument();
            List functions = doc.getFunctions();
            for (Iterator it = functions.iterator(); it.hasNext(); ) {
                TLDFunction function = (TLDFunction) it.next();
                CustomCompletionProposal proposal = new // $NON-NLS-1$
                CustomCompletionProposal(// $NON-NLS-1$
                function.getName() + "()", offset, 0, function.getName().length() + 1, null, function.getName() + " - " + function.getSignature(), null, null, // $NON-NLS-1$
                1);
                completionList.add(proposal);
            }
        }
    }
    return completionList;
}
Also used : TLDCMDocumentManager(org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager) TaglibTracker(org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) CustomCompletionProposal(org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal) ArrayList(java.util.ArrayList) List(java.util.List) TLDFunction(org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDFunction) CMDocumentImpl(org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMDocumentImpl)

Example 3 with CMDocumentImpl

use of org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMDocumentImpl in project webtools.sourceediting by eclipse.

the class ELGeneratorVisitor method genFunction.

/**
 * Generate a function invocation.
 *
 * @param fullFunctionName
 * @return
 */
protected String genFunction(String fullFunctionName) {
    TLDCMDocumentManager docMgr = TaglibController.getTLDCMDocumentManager(fDocument);
    int colonIndex = fullFunctionName.indexOf(':');
    String prefix = fullFunctionName.substring(0, colonIndex);
    String functionName = fullFunctionName.substring(colonIndex + 1);
    if (docMgr == null)
        return null;
    Iterator taglibs = docMgr.getCMDocumentTrackers(fCurrentNode.getStartOffset()).iterator();
    while (taglibs.hasNext()) {
        TaglibTracker tracker = (TaglibTracker) taglibs.next();
        if (tracker.getPrefix().equals(prefix)) {
            CMDocumentImpl doc = (CMDocumentImpl) tracker.getDocument();
            List functions = doc.getFunctions();
            for (Iterator it = functions.iterator(); it.hasNext(); ) {
                TLDFunction function = (TLDFunction) it.next();
                if (function.getName().equals(functionName)) {
                    String javaFuncName = getFunctionNameFromSignature(function.getSignature());
                    if (javaFuncName == null)
                        javaFuncName = functionName;
                    // $NON-NLS-1$
                    return function.getClassName() + "." + javaFuncName;
                }
            }
        }
    }
    return null;
}
Also used : TLDCMDocumentManager(org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager) TaglibTracker(org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) TLDFunction(org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDFunction) CMDocumentImpl(org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMDocumentImpl)

Aggregations

ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)3 List (java.util.List)3 CMDocumentImpl (org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMDocumentImpl)3 TLDCMDocumentManager (org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager)3 TaglibTracker (org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker)3 TLDFunction (org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDFunction)3 CustomCompletionProposal (org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal)2