Search in sources :

Example 1 with JSPSourceParser

use of org.eclipse.jst.jsp.core.internal.parser.JSPSourceParser in project webtools.sourceediting by eclipse.

the class StructuredTextPartitionerForJSP method isAction.

/**
 * @param sdRegion
 * @param offset
 * @return
 */
private boolean isAction(IStructuredDocumentRegion sdRegion, int offset) {
    if (!sdRegion.getType().equals(DOMRegionContext.XML_TAG_NAME))
        return false;
    /*
		 * shouldn't get a tag name region type unless a tag name region
		 * exists at [1]
		 */
    ITextRegion tagNameRegion = sdRegion.getRegions().get(1);
    String tagName = sdRegion.getText(tagNameRegion);
    RegionParser parser = fStructuredDocument.getParser();
    if (parser instanceof JSPSourceParser) {
        if (tagName.equals(fLastCheckedPrefix))
            return true;
        List fCustomActionPrefixes = ((JSPSourceParser) parser).getNestablePrefixes();
        for (int i = 0; i < fCustomActionPrefixes.size(); i++) if (tagName.startsWith(((TagMarker) fCustomActionPrefixes.get(i)).getTagName())) {
            fLastCheckedPrefix = ((TagMarker) fCustomActionPrefixes.get(i)).getTagName();
            return true;
        }
    }
    return false;
}
Also used : ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) ITextRegionList(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList) ArrayList(java.util.ArrayList) List(java.util.List) RegionParser(org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser) JSPSourceParser(org.eclipse.jst.jsp.core.internal.parser.JSPSourceParser) TagMarker(org.eclipse.wst.sse.core.internal.ltk.parser.TagMarker)

Example 2 with JSPSourceParser

use of org.eclipse.jst.jsp.core.internal.parser.JSPSourceParser in project webtools.sourceediting by eclipse.

the class ScanningTests method newParser.

public static RegionParser newParser() {
    JSPSourceParser parser = new JSPSourceParser();
    parser.addBlockMarker(new BlockMarker("foo", null, DOMRegionContext.BLOCK_TEXT, true));
    parser.addBlockMarker(new BlockMarker("globalFoo", null, DOMRegionContext.BLOCK_TEXT, true));
    // parser.addBlockMarker(new BlockMarker("jsp:text", null, XMLRegionContext.XML_CDATA_TEXT, true));
    return parser;
}
Also used : BlockMarker(org.eclipse.wst.sse.core.internal.ltk.parser.BlockMarker) JSPSourceParser(org.eclipse.jst.jsp.core.internal.parser.JSPSourceParser)

Example 3 with JSPSourceParser

use of org.eclipse.jst.jsp.core.internal.parser.JSPSourceParser in project webtools.sourceediting by eclipse.

the class UnitTests method setUpJSP.

/**
 * Set up a JSP model
 */
protected void setUpJSP() {
    IModelManager mm = StructuredModelManager.getModelManager();
    try {
        fModel = mm.createStructuredDocumentFor("dummy.jsp", (InputStream) null, null);
    } catch (IOException e) {
    // do nothing, since dummy
    }
    fModel = StructuredDocumentFactory.getNewStructuredDocumentInstance(new JSPSourceParser());
    fModel.addDocumentChangedListener(proxy);
    tree = new DOMModelImpl();
    if (tree != null) {
        fModel.addDocumentChangingListener((IStructuredDocumentListener) tree);
        tree.setStructuredDocument(fModel);
    }
}
Also used : InputStream(java.io.InputStream) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) DOMModelImpl(org.eclipse.wst.xml.core.internal.document.DOMModelImpl) IOException(java.io.IOException) JSPSourceParser(org.eclipse.jst.jsp.core.internal.parser.JSPSourceParser)

Example 4 with JSPSourceParser

use of org.eclipse.jst.jsp.core.internal.parser.JSPSourceParser in project webtools.sourceediting by eclipse.

the class DocumentFactoryForJSP method getParser.

public RegionParser getParser() {
    // remember, the Loader
    // will need to finish initialization of parser
    // based on "embedded content"
    JSPSourceParser parser = new JSPSourceParser();
    // add default nestable tag list
    addNestablePrefix(parser, JSP11Namespace.JSP_TAG_PREFIX);
    return parser;
}
Also used : JSPSourceParser(org.eclipse.jst.jsp.core.internal.parser.JSPSourceParser)

Example 5 with JSPSourceParser

use of org.eclipse.jst.jsp.core.internal.parser.JSPSourceParser in project webtools.sourceediting by eclipse.

the class JSPDocumentLoader method getParser.

public RegionParser getParser() {
    // remember, the Loader
    // will need to finish initialization of parser
    // based on "embedded content"
    JSPSourceParser parser = new JSPSourceParser();
    // add default nestable tag list
    addNestablePrefix(parser, JSP11Namespace.JSP_TAG_PREFIX);
    return parser;
}
Also used : JSPSourceParser(org.eclipse.jst.jsp.core.internal.parser.JSPSourceParser)

Aggregations

JSPSourceParser (org.eclipse.jst.jsp.core.internal.parser.JSPSourceParser)5 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BlockMarker (org.eclipse.wst.sse.core.internal.ltk.parser.BlockMarker)1 RegionParser (org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser)1 TagMarker (org.eclipse.wst.sse.core.internal.ltk.parser.TagMarker)1 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)1 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)1 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)1 DOMModelImpl (org.eclipse.wst.xml.core.internal.document.DOMModelImpl)1