use of org.eclipse.wst.xml.core.internal.parser.XMLSourceParser in project webtools.sourceediting by eclipse.
the class JSPJavaCompletionProposalComputer method decodeScriptBlock.
/**
* ** TEMP WORKAROUND FOR CMVC 241882 Takes a String and blocks out
* jsp:scriptlet, jsp:expression, and jsp:declaration @param blockText
* @return
*/
private IStructuredDocumentRegion decodeScriptBlock(String blockText) {
XMLSourceParser parser = new XMLSourceParser();
// use JSP_CONTENT for region type
// $NON-NLS-1$
parser.addBlockMarker(new BlockMarker("jsp:scriptlet", null, DOMJSPRegionContexts.JSP_CONTENT, false, false));
// $NON-NLS-1$
parser.addBlockMarker(new BlockMarker("jsp:expression", null, DOMJSPRegionContexts.JSP_CONTENT, false, false));
// $NON-NLS-1$
parser.addBlockMarker(new BlockMarker("jsp:declaration", null, DOMJSPRegionContexts.JSP_CONTENT, false, false));
parser.reset(blockText);
return parser.getDocumentRegions();
}
use of org.eclipse.wst.xml.core.internal.parser.XMLSourceParser in project webtools.sourceediting by eclipse.
the class UnitTests method testDeepEmbeddedJSP3.
public void testDeepEmbeddedJSP3() {
// CMVC 245586
// this is a test to make sure ContextRegionContainer returns what we expect
setUpJSP();
String startString = "<html><head><script> <%! String testvar = \"testvar\"; %> var test = <%= testvar %> </script></head></html>";
String expectedText = "<%! String testvar = \"testvar\"; %>";
// $NON-NLS-1$
((XMLSourceParser) fModel.getParser()).addBlockMarker(new BlockMarker("script", null, DOMRegionContext.BLOCK_TEXT, false));
fModel.setText(null, startString);
fModel.getRegionList();
IStructuredDocumentRegion scriptBlockRegion = fModel.getRegionAtCharacterOffset(21);
ITextRegionList blockRegions = scriptBlockRegion.getRegions();
ITextRegionContainer jspDecl = (ITextRegionContainer) blockRegions.get(1);
String fullText = jspDecl.getFullText();
// assertTrue("ContextRegionContainer.getFullText()", fullText.equals(expectedText));
assertEquals("ContextRegionContainer.getFullText() value incorrect: ", expectedText, fullText);
}
use of org.eclipse.wst.xml.core.internal.parser.XMLSourceParser in project webtools.sourceediting by eclipse.
the class JSPContentAssistProcessor method decodeScriptBlock.
/*
* ** TEMP WORKAROUND FOR CMVC 241882 Takes a String and blocks out
* jsp:scriptlet, jsp:expression, and jsp:declaration @param blockText
* @return
*/
private IStructuredDocumentRegion decodeScriptBlock(String blockText) {
XMLSourceParser parser = new XMLSourceParser();
// use JSP_CONTENT for region type
// $NON-NLS-1$
parser.addBlockMarker(new BlockMarker("jsp:scriptlet", null, DOMJSPRegionContexts.JSP_CONTENT, false, false));
// $NON-NLS-1$
parser.addBlockMarker(new BlockMarker("jsp:expression", null, DOMJSPRegionContexts.JSP_CONTENT, false, false));
// $NON-NLS-1$
parser.addBlockMarker(new BlockMarker("jsp:declaration", null, DOMJSPRegionContexts.JSP_CONTENT, false, false));
parser.reset(blockText);
return parser.getDocumentRegions();
}
use of org.eclipse.wst.xml.core.internal.parser.XMLSourceParser in project webtools.sourceediting by eclipse.
the class ScanningTests method newXMLParser.
public static RegionParser newXMLParser() {
XMLSourceParser parser = new XMLSourceParser();
parser.addBlockMarker(new BlockMarker("Script", DOMRegionContext.BLOCK_TEXT, false));
parser.addBlockMarker(new BlockMarker("stylE", DOMRegionContext.BLOCK_TEXT, false));
return parser;
}
use of org.eclipse.wst.xml.core.internal.parser.XMLSourceParser in project webtools.sourceediting by eclipse.
the class ElementImpl method isCDATAContainer.
/**
*/
protected boolean isCDATAContainer() {
// use BlockMaker instead of CMElementDeclaration
// because <style> and <script> in XHTML is not CDATA content type
IDOMModel model = getModel();
if (model == null)
// error
return false;
IStructuredDocument structuredDocument = model.getStructuredDocument();
if (structuredDocument == null || fTagName == null)
// eror
return false;
RegionParser parser = structuredDocument.getParser();
if (parser == null || !(parser instanceof XMLSourceParser))
return false;
return (((XMLSourceParser) parser).getBlockMarker(new String(this.fTagName)) != null);
/*
* CMElementDeclaration decl = getDeclaration(); if (decl == null)
* return false; if (decl instanceof CMNodeWrapper) { decl =
* (CMElementDeclaration)((CMNodeWrapper)decl).getOriginNode(); if
* (decl == null) return false; } if (decl instanceof
* TLDElementDeclaration) { String content =
* ((TLDElementDeclaration)decl).getBodycontent(); if (content ==
* null) return false; return
* content.equals(JSP11TLDNames.CONTENT_TAGDEPENDENT); } if
* (!isGlobalTag()) return false; return (decl.getContentType() ==
* CMElementDeclaration.CDATA);
*/
}
Aggregations