Search in sources :

Example 96 with IndexedRegion

use of org.eclipse.wst.sse.core.internal.provisional.IndexedRegion in project webtools.sourceediting by eclipse.

the class StructuredSelectNextCSSActionDelegate method getCursorIndexedRegion.

protected IndexedRegion getCursorIndexedRegion(IDocument document, ITextSelection textSelection) {
    int offset = textSelection.getOffset() + textSelection.getLength() - 1;
    if (offset < 0)
        offset = 0;
    IndexedRegion indexedRegion = null;
    indexedRegion = getIndexedRegion(document, offset);
    return indexedRegion;
}
Also used : IndexedRegion(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)

Example 97 with IndexedRegion

use of org.eclipse.wst.sse.core.internal.provisional.IndexedRegion in project webtools.sourceediting by eclipse.

the class StructuredSelectEnclosingHandler method getNewSelectionRegion.

protected Region getNewSelectionRegion(IndexedRegion indexedRegion, ITextSelection textSelection) {
    Region newRegion = null;
    if (indexedRegion instanceof ICSSNode) {
        ICSSNode cursorNode = (ICSSNode) indexedRegion;
        Region cursorNodeRegion = new Region(indexedRegion.getStartOffset(), indexedRegion.getEndOffset() - indexedRegion.getStartOffset());
        int currentOffset = textSelection.getOffset();
        int currentEndOffset = currentOffset + textSelection.getLength();
        if (cursorNodeRegion.getOffset() >= currentOffset && cursorNodeRegion.getOffset() <= currentEndOffset && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= currentOffset && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= currentEndOffset) {
            ICSSNode newNode = cursorNode.getParentNode();
            if (newNode instanceof CSSStyleDeclaration) {
                newNode = newNode.getParentNode();
            }
            if (newNode instanceof IndexedRegion) {
                IndexedRegion newIndexedRegion = (IndexedRegion) newNode;
                newRegion = new Region(newIndexedRegion.getStartOffset(), newIndexedRegion.getEndOffset() - newIndexedRegion.getStartOffset());
            }
        } else
            newRegion = cursorNodeRegion;
    }
    return newRegion;
}
Also used : Region(org.eclipse.jface.text.Region) IndexedRegion(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion) ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode) CSSStyleDeclaration(org.w3c.dom.css.CSSStyleDeclaration) IndexedRegion(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)

Example 98 with IndexedRegion

use of org.eclipse.wst.sse.core.internal.provisional.IndexedRegion in project webtools.sourceediting by eclipse.

the class StructuredSelectEnclosingHandler method getCursorIndexedRegion.

protected IndexedRegion getCursorIndexedRegion(IDocument document, ITextSelection textSelection) {
    IndexedRegion indexedRegion = null;
    indexedRegion = getIndexedRegion(document, textSelection.getOffset());
    return indexedRegion;
}
Also used : IndexedRegion(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)

Example 99 with IndexedRegion

use of org.eclipse.wst.sse.core.internal.provisional.IndexedRegion in project webtools.sourceediting by eclipse.

the class StructuredSelectPreviousHandler method getNewSelectionRegion.

protected Region getNewSelectionRegion(IndexedRegion indexedRegion, ITextSelection textSelection) {
    Region newRegion = null;
    if (indexedRegion instanceof ICSSNode) {
        ICSSNode cursorNode = (ICSSNode) indexedRegion;
        Region cursorNodeRegion = new Region(indexedRegion.getStartOffset(), indexedRegion.getEndOffset() - indexedRegion.getStartOffset());
        int currentOffset = textSelection.getOffset();
        int currentEndOffset = currentOffset + textSelection.getLength();
        if (cursorNodeRegion.getOffset() >= currentOffset && cursorNodeRegion.getOffset() <= currentEndOffset && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= currentOffset && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= currentEndOffset) {
            ICSSNode newNode = cursorNode.getPreviousSibling();
            if (newNode == null) {
                newNode = cursorNode.getParentNode();
                if (newNode instanceof IndexedRegion) {
                    IndexedRegion newIndexedRegion = (IndexedRegion) newNode;
                    newRegion = new Region(newIndexedRegion.getStartOffset(), newIndexedRegion.getEndOffset() - newIndexedRegion.getStartOffset());
                }
            } else {
                if (newNode instanceof IndexedRegion) {
                    IndexedRegion newIndexedRegion = (IndexedRegion) newNode;
                    newRegion = new Region(newIndexedRegion.getStartOffset(), currentEndOffset - newIndexedRegion.getStartOffset());
                }
            }
        } else
            newRegion = cursorNodeRegion;
    }
    return newRegion;
}
Also used : Region(org.eclipse.jface.text.Region) IndexedRegion(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion) ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode) IndexedRegion(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)

Example 100 with IndexedRegion

use of org.eclipse.wst.sse.core.internal.provisional.IndexedRegion in project webtools.sourceediting by eclipse.

the class StructuredSelectPreviousHandler method getCursorIndexedRegion.

protected IndexedRegion getCursorIndexedRegion(IDocument document, ITextSelection textSelection) {
    IndexedRegion indexedRegion = null;
    indexedRegion = getIndexedRegion(document, textSelection.getOffset());
    return indexedRegion;
}
Also used : IndexedRegion(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)

Aggregations

IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)148 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)33 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)32 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)31 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)27 Node (org.w3c.dom.Node)27 Region (org.eclipse.jface.text.Region)21 ICSSNode (org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)21 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)21 CSSCleanupStrategy (org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy)20 RegionIterator (org.eclipse.wst.css.core.internal.util.RegionIterator)17 ArrayList (java.util.ArrayList)11 List (java.util.List)11 ITextSelection (org.eclipse.jface.text.ITextSelection)11 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)10 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)8 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)8 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)8 Preferences (org.eclipse.core.runtime.Preferences)7 IDocument (org.eclipse.jface.text.IDocument)7