Search in sources :

Example 1 with BlockTagParser

use of org.eclipse.wst.sse.core.internal.ltk.parser.BlockTagParser in project liferay-ide by liferay.

the class AlloyJSPDocumentLoader method newEncodedDocument.

@Override
protected IEncodedDocument newEncodedDocument() {
    IEncodedDocument retval = super.newEncodedDocument();
    if (retval instanceof IStructuredDocument) {
        IStructuredDocument doc = (IStructuredDocument) retval;
        RegionParser parser = doc.getParser();
        if (parser instanceof BlockTagParser) {
            BlockTagParser blockParser = (BlockTagParser) parser;
            BlockMarker bm = new BlockMarker("aui:script", null, DOMRegionContext.BLOCK_TEXT, false);
            blockParser.addBlockMarker(bm);
        }
    }
    return retval;
}
Also used : BlockMarker(org.eclipse.wst.sse.core.internal.ltk.parser.BlockMarker) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) BlockTagParser(org.eclipse.wst.sse.core.internal.ltk.parser.BlockTagParser) IEncodedDocument(org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument) RegionParser(org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser)

Example 2 with BlockTagParser

use of org.eclipse.wst.sse.core.internal.ltk.parser.BlockTagParser in project webtools.sourceediting by eclipse.

the class StructuredDocumentReParser method checkForCrossStructuredDocumentRegionBoundryCases.

// /**
// * Currently this method is pretty specific to ?ML
// * @deprecated - not really deprecated, but plan to make
// * protected ... I'm not sure why its public or misspelled?
// */
protected StructuredDocumentEvent checkForCrossStructuredDocumentRegionBoundryCases() {
    StructuredDocumentEvent result = null;
    // StructuredDocumentRegions be rescanned
    if (result == null) {
        result = checkForCrossStructuredDocumentRegionSyntax();
    }
    // Case 2: "block tags" whose content is left unparsed
    if (result == null) {
        Object parser = fStructuredDocument.getParser();
        if (parser instanceof BlockTagParser) {
            List blockTags = ((BlockTagParser) parser).getBlockMarkers();
            result = _checkBlockNodeList(blockTags);
        }
    }
    // or! do we already do it some other more central place?
    if (result != null) {
        result.setDeletedText(fDeletedText);
    }
    return result;
}
Also used : StructuredDocumentEvent(org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent) ITextRegionList(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList) List(java.util.List) BlockTagParser(org.eclipse.wst.sse.core.internal.ltk.parser.BlockTagParser)

Example 3 with BlockTagParser

use of org.eclipse.wst.sse.core.internal.ltk.parser.BlockTagParser in project webtools.sourceediting by eclipse.

the class AbstractModelLoader method transformInstance.

/**
 * this work is done better elsewhere, but done here for this version to
 * reduce changes. especially since the need for it should go away once we
 * no longer need to re-use old document instance.
 */
private void transformInstance(IStructuredDocument oldInstance, IStructuredDocument newInstance) {
    /**
     * https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=4920
     *
     * JSP taglib support broken, correct by duplicating extended setup
     * information (BlockTagParser extension,
     * StructuredDocumentRegionParser extensions)
     */
    RegionParser oldParser = oldInstance.getParser();
    RegionParser newParser = newInstance.getParser().newInstance();
    // parser
    if (oldParser instanceof StructuredDocumentRegionParserExtension && newParser instanceof StructuredDocumentRegionParserExtension) {
        List oldHandlers = ((StructuredDocumentRegionParserExtension) oldParser).getStructuredDocumentRegionHandlers();
        for (int i = 0; i < oldHandlers.size(); i++) {
            StructuredDocumentRegionHandler handler = ((StructuredDocumentRegionHandler) oldHandlers.get(i));
            if (handler instanceof StructuredDocumentRegionHandlerExtension) {
            /**
             * Skip the transferring here, the handler will do this
             * after everything else but the source is transferred.
             */
            } else {
                ((StructuredDocumentRegionParser) oldParser).removeStructuredDocumentRegionHandler(handler);
                ((StructuredDocumentRegionParser) newParser).addStructuredDocumentRegionHandler(handler);
                handler.resetNodes();
            }
        }
    }
    // Add any global BlockMarkers to the new parser
    if (oldParser instanceof BlockTagParser && newParser instanceof BlockTagParser) {
        List oldBlockMarkers = ((BlockTagParser) oldParser).getBlockMarkers();
        for (int i = 0; i < oldBlockMarkers.size(); i++) {
            BlockMarker blockMarker = ((BlockMarker) oldBlockMarkers.get(i));
            if (blockMarker.isGlobal()) {
                ((BlockTagParser) newParser).addBlockMarker(blockMarker);
            }
        }
    }
    ((BasicStructuredDocument) oldInstance).setParser(newParser);
    ((BasicStructuredDocument) oldInstance).setReParser(newInstance.getReParser().newInstance());
    if (newInstance.getDocumentPartitioner() instanceof StructuredTextPartitioner) {
        StructuredTextPartitioner partitioner = null;
        if (oldInstance instanceof IDocumentExtension3 && newInstance instanceof IDocumentExtension3) {
            partitioner = ((StructuredTextPartitioner) ((IDocumentExtension3) newInstance).getDocumentPartitioner(IStructuredPartitioning.DEFAULT_STRUCTURED_PARTITIONING));
            if (partitioner != null) {
                partitioner = (StructuredTextPartitioner) partitioner.newInstance();
            }
            ((IDocumentExtension3) oldInstance).setDocumentPartitioner(IStructuredPartitioning.DEFAULT_STRUCTURED_PARTITIONING, partitioner);
        }
        if (partitioner == null) {
            partitioner = (StructuredTextPartitioner) ((StructuredTextPartitioner) newInstance.getDocumentPartitioner()).newInstance();
            oldInstance.setDocumentPartitioner(partitioner);
        }
        if (partitioner != null) {
            partitioner.connect(oldInstance);
        }
    }
    String existingLineDelimiter = null;
    try {
        existingLineDelimiter = newInstance.getLineDelimiter(0);
    } catch (BadLocationException e) {
        // if empty file, assume platform default
        // TODO: should be using user set preference, per content type?
        // $NON-NLS-1$
        existingLineDelimiter = System.getProperty("line.separator");
    }
    // $NON-NLS-1$);
    oldInstance.setLineDelimiter(existingLineDelimiter);
    if (newInstance.getEncodingMemento() != null) {
        oldInstance.setEncodingMemento((EncodingMemento) newInstance.getEncodingMemento().clone());
    }
    /**
     * https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=4920
     *
     * JSP taglib support broken, correct by duplicating extended setup
     * information (BlockTagParser extension,
     * StructuredDocumentRegionParser extensions)
     */
    if (oldParser instanceof StructuredDocumentRegionParserExtension && newParser instanceof StructuredDocumentRegionParserExtension) {
        List oldHandlers = ((StructuredDocumentRegionParserExtension) oldParser).getStructuredDocumentRegionHandlers();
        for (int i = 0; i < oldHandlers.size(); i++) {
            StructuredDocumentRegionHandler handler = ((StructuredDocumentRegionHandler) oldHandlers.get(i));
            if (handler instanceof StructuredDocumentRegionHandlerExtension) {
                StructuredDocumentRegionHandlerExtension handlerExtension = (StructuredDocumentRegionHandlerExtension) handler;
                handlerExtension.setStructuredDocument(oldInstance);
            }
        }
    }
    String holdString = newInstance.get();
    newInstance = null;
    oldInstance.set(holdString);
}
Also used : StructuredDocumentRegionParserExtension(org.eclipse.wst.sse.core.internal.ltk.parser.StructuredDocumentRegionParserExtension) IDocumentExtension3(org.eclipse.jface.text.IDocumentExtension3) StructuredDocumentRegionHandler(org.eclipse.wst.sse.core.internal.ltk.parser.StructuredDocumentRegionHandler) StructuredDocumentRegionParser(org.eclipse.wst.sse.core.internal.ltk.parser.StructuredDocumentRegionParser) RegionParser(org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser) StructuredDocumentRegionHandlerExtension(org.eclipse.wst.sse.core.internal.ltk.parser.StructuredDocumentRegionHandlerExtension) StructuredDocumentRegionParser(org.eclipse.wst.sse.core.internal.ltk.parser.StructuredDocumentRegionParser) StructuredTextPartitioner(org.eclipse.wst.sse.core.internal.text.rules.StructuredTextPartitioner) BasicStructuredDocument(org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument) BlockMarker(org.eclipse.wst.sse.core.internal.ltk.parser.BlockMarker) ArrayList(java.util.ArrayList) List(java.util.List) BlockTagParser(org.eclipse.wst.sse.core.internal.ltk.parser.BlockTagParser) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 4 with BlockTagParser

use of org.eclipse.wst.sse.core.internal.ltk.parser.BlockTagParser in project webtools.sourceediting by eclipse.

the class EmbeddedHTML method initializeParser.

/*
	 * @see EmbeddedContentType#initializeParser(RegionParser)
	 */
public void initializeParser(RegionParser parser) {
    if (parser instanceof BlockTagParser) {
        BlockTagParser blockTagParser = (BlockTagParser) parser;
        // $NON-NLS-1$
        addHTMLishTag(blockTagParser, "script");
        // $NON-NLS-1$
        addHTMLishTag(blockTagParser, "style");
    }
}
Also used : BlockTagParser(org.eclipse.wst.sse.core.internal.ltk.parser.BlockTagParser)

Aggregations

BlockTagParser (org.eclipse.wst.sse.core.internal.ltk.parser.BlockTagParser)4 List (java.util.List)2 BlockMarker (org.eclipse.wst.sse.core.internal.ltk.parser.BlockMarker)2 RegionParser (org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser)2 ArrayList (java.util.ArrayList)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 IDocumentExtension3 (org.eclipse.jface.text.IDocumentExtension3)1 StructuredDocumentRegionHandler (org.eclipse.wst.sse.core.internal.ltk.parser.StructuredDocumentRegionHandler)1 StructuredDocumentRegionHandlerExtension (org.eclipse.wst.sse.core.internal.ltk.parser.StructuredDocumentRegionHandlerExtension)1 StructuredDocumentRegionParser (org.eclipse.wst.sse.core.internal.ltk.parser.StructuredDocumentRegionParser)1 StructuredDocumentRegionParserExtension (org.eclipse.wst.sse.core.internal.ltk.parser.StructuredDocumentRegionParserExtension)1 IEncodedDocument (org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument)1 StructuredDocumentEvent (org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent)1 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)1 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)1 BasicStructuredDocument (org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument)1 StructuredTextPartitioner (org.eclipse.wst.sse.core.internal.text.rules.StructuredTextPartitioner)1