Search in sources :

Example 1 with XMLSourceParser

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();
}
Also used : BlockMarker(org.eclipse.wst.sse.core.internal.ltk.parser.BlockMarker) XMLSourceParser(org.eclipse.wst.xml.core.internal.parser.XMLSourceParser)

Example 2 with XMLSourceParser

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);
}
Also used : ITextRegionList(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList) IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion) BlockMarker(org.eclipse.wst.sse.core.internal.ltk.parser.BlockMarker) ITextRegionContainer(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer) XMLSourceParser(org.eclipse.wst.xml.core.internal.parser.XMLSourceParser)

Example 3 with XMLSourceParser

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();
}
Also used : BlockMarker(org.eclipse.wst.sse.core.internal.ltk.parser.BlockMarker) XMLSourceParser(org.eclipse.wst.xml.core.internal.parser.XMLSourceParser)

Example 4 with XMLSourceParser

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;
}
Also used : BlockMarker(org.eclipse.wst.sse.core.internal.ltk.parser.BlockMarker) XMLSourceParser(org.eclipse.wst.xml.core.internal.parser.XMLSourceParser)

Example 5 with XMLSourceParser

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);
		 */
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) RegionParser(org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser) XMLSourceParser(org.eclipse.wst.xml.core.internal.parser.XMLSourceParser)

Aggregations

XMLSourceParser (org.eclipse.wst.xml.core.internal.parser.XMLSourceParser)5 BlockMarker (org.eclipse.wst.sse.core.internal.ltk.parser.BlockMarker)4 RegionParser (org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser)1 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)1 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)1 ITextRegionContainer (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)1 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)1 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)1