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);
}
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());
}
}
}
}
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);
}
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();
}
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;
}
Aggregations