Search in sources :

Example 36 with ITextRegionContainer

use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer in project webtools.sourceediting by eclipse.

the class ScannerUnitTests method testVBLinContent.

public void testVBLinContent() {
    String text = "#{out.foo}";
    IStructuredDocumentRegionList nodes = setUpJSP(text);
    boolean sizeCheck = checkSimpleRegionCounts(nodes, new int[] { 1 });
    assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
    sizeCheck = checkSimpleRegionCount(((ITextRegionContainer) nodes.item(0).getRegions().get(0)), 3);
    assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
    boolean typeCheck = checkSimpleRegionTypes(nodes.item(0).getRegions(), new String[] { DOMRegionContext.XML_CONTENT });
    assertTrue("region context type check", typeCheck);
    typeCheck = checkSimpleRegionTypes(((ITextRegionContainer) nodes.item(0).getRegions().get(0)).getRegions(), new String[] { DOMJSPRegionContexts.JSP_VBL_OPEN, DOMJSPRegionContexts.JSP_VBL_CONTENT, DOMJSPRegionContexts.JSP_VBL_CLOSE });
    assertTrue("region context type check", typeCheck);
    verifyLengths(0, nodes.item(0), text);
}
Also used : IStructuredDocumentRegionList(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList) ITextRegionContainer(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)

Example 37 with ITextRegionContainer

use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer in project webtools.sourceediting by eclipse.

the class ScannerUnitTests method verifyEmbeddedContainerParentage.

/**
 * @param nodes
 */
private void verifyEmbeddedContainerParentage(IStructuredDocumentRegionList nodes) {
    for (int i = 0; i < nodes.getLength(); i++) {
        IStructuredDocumentRegion r = nodes.item(i);
        ITextRegionList list = r.getRegions();
        for (int j = 0; j < list.size(); j++) {
            ITextRegion region = list.get(j);
            if (region instanceof ITextRegionContainer) {
                assertNotNull("parent is null for " + region, ((ITextRegionContainer) region).getParent());
            }
        }
    }
}
Also used : ITextRegionList(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList) IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion) ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) ITextRegionContainer(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)

Example 38 with ITextRegionContainer

use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer in project webtools.sourceediting by eclipse.

the class ScannerUnitTests method testELinContent.

public void testELinContent() {
    String text = "${out.foo}";
    IStructuredDocumentRegionList nodes = setUpJSP(text);
    boolean sizeCheck = checkSimpleRegionCounts(nodes, new int[] { 1 });
    assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
    sizeCheck = checkSimpleRegionCount(((ITextRegionContainer) nodes.item(0).getRegions().get(0)), 3);
    assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
    boolean typeCheck = checkSimpleRegionTypes(nodes.item(0).getRegions(), new String[] { DOMRegionContext.XML_CONTENT });
    assertTrue("region context type check", typeCheck);
    typeCheck = checkSimpleRegionTypes(((ITextRegionContainer) nodes.item(0).getRegions().get(0)).getRegions(), new String[] { DOMJSPRegionContexts.JSP_EL_OPEN, DOMJSPRegionContexts.JSP_EL_CONTENT, DOMJSPRegionContexts.JSP_EL_CLOSE });
    assertTrue("region context type check", typeCheck);
    verifyLengths(0, nodes.item(0), text);
}
Also used : IStructuredDocumentRegionList(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList) ITextRegionContainer(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)

Example 39 with ITextRegionContainer

use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer in project webtools.sourceediting by eclipse.

the class ScannerUnitTests method testJSPGreaterThanInAttValue.

public void testJSPGreaterThanInAttValue() {
    IStructuredDocumentRegionList nodes = setUpJSP("<a type=\">next\"/>");
    boolean sizeCheck = checkSimpleRegionCounts(nodes, new int[] { 6 });
    assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
    assertTrue("region is not somple", !(nodes.item(0).getRegions().get(4) instanceof ITextRegionContainer));
    boolean typeCheck = checkSimpleRegionTypes(nodes.item(0).getRegions(), new String[] { DOMRegionContext.XML_TAG_OPEN, DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS, DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE, DOMRegionContext.XML_EMPTY_TAG_CLOSE });
    assertTrue("region context type check", typeCheck);
    verifyModelLength();
}
Also used : IStructuredDocumentRegionList(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList) ITextRegionContainer(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)

Example 40 with ITextRegionContainer

use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer in project webtools.sourceediting by eclipse.

the class JSPELContentAssistProcessor method computeCompletionProposals.

public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentPosition) {
    // get results from JSP completion processor
    fJspCompletionProcessor = getJspCompletionProcessor();
    ICompletionProposal[] results = fJspCompletionProcessor.computeCompletionProposals(viewer, documentPosition);
    fErrorMessage = fJspCompletionProcessor.getErrorMessage();
    if (results.length == 0 && (fErrorMessage == null || fErrorMessage.length() == 0)) {
        fErrorMessage = UNKNOWN_CONTEXT;
    }
    IStructuredDocumentRegion flat = ContentAssistUtils.getStructuredDocumentRegion(viewer, documentPosition);
    if (flat != null) {
        ITextRegion cursorRegion = flat.getRegionAtCharacterOffset(documentPosition);
        if (DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE == cursorRegion.getType()) {
            ITextRegionContainer container = (ITextRegionContainer) cursorRegion;
            cursorRegion = container.getRegionAtCharacterOffset(documentPosition);
            if (cursorRegion.getType() == DOMJSPRegionContexts.JSP_EL_CONTENT) {
                String elText = container.getText(cursorRegion).trim();
                String prefix = getPrefix(documentPosition - container.getStartOffset(cursorRegion) - 1, elText);
                if (null != prefix) {
                    List proposals = getFunctionProposals(prefix, (StructuredTextViewer) viewer, documentPosition);
                    results = new ICompletionProposal[proposals.size()];
                    proposals.toArray(results);
                }
            }
        }
    }
    return results;
}
Also used : IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion) ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) ITextRegionContainer(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ITextRegionContainer (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)52 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)39 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)26 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)25 IStructuredDocumentRegionList (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList)11 Iterator (java.util.Iterator)10 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)10 List (java.util.List)8 ArrayList (java.util.ArrayList)7 CustomCompletionProposal (org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal)6 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)4 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)3 ITextViewer (org.eclipse.jface.text.ITextViewer)3 Image (org.eclipse.swt.graphics.Image)3 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)3 ITextRegionCollection (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection)3 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)3 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)3 CMNode (org.eclipse.wst.xml.core.internal.contentmodel.CMNode)3 NamedNodeMap (org.w3c.dom.NamedNodeMap)3