Search in sources :

Example 66 with ITextRegion

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

the class CSSContentAssistContext method isTargetPosAfterOf.

/**
 */
boolean isTargetPosAfterOf(String regionType) {
    int start = ((IndexedRegion) fTargetNode).getStartOffset();
    if (start < 0 || ((IndexedRegion) fTargetNode).getEndOffset() <= 0) {
        return false;
    }
    RegionIterator iRegion = new RegionIterator(fStructuredDocument, start);
    while (iRegion.hasNext()) {
        ITextRegion region = iRegion.next();
        if (fTargetPos < iRegion.getStructuredDocumentRegion().getTextEndOffset(region)) {
            break;
        }
        if (region.getType() == regionType) {
            return true;
        }
    }
    return false;
}
Also used : ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) RegionIterator(org.eclipse.wst.css.core.internal.util.RegionIterator) IndexedRegion(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)

Example 67 with ITextRegion

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

the class CSSContentAssistContext method isSpecialDelimiterRegion.

/**
 */
private boolean isSpecialDelimiterRegion(int pos) {
    ITextRegion region = getRegionByOffset(pos);
    String type = null;
    if (region != null) {
        type = region.getType();
    }
    return (type != null) && ((type == CSSRegionContexts.CSS_LBRACE || type == CSSRegionContexts.CSS_RBRACE || type == CSSRegionContexts.CSS_DELIMITER || type == CSSRegionContexts.CSS_DECLARATION_SEPARATOR || type == CSSRegionContexts.CSS_DECLARATION_DELIMITER || type == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR || type == CSSRegionContexts.CSS_S));
}
Also used : ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)

Example 68 with ITextRegion

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

the class CSSContentAssistContext method targetHas.

/**
 */
boolean targetHas(String regionType) {
    int end = ((IndexedRegion) fTargetNode).getEndOffset();
    if (getTargetPos() < 0 || end <= 0) {
        return false;
    }
    RegionIterator iRegion = new RegionIterator(fStructuredDocument, getTargetPos());
    while (iRegion.hasNext()) {
        ITextRegion region = iRegion.next();
        if (end <= iRegion.getStructuredDocumentRegion().getStartOffset(region)) {
            break;
        }
        if (region.getType() == regionType) {
            return true;
        }
    }
    return false;
}
Also used : ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) RegionIterator(org.eclipse.wst.css.core.internal.util.RegionIterator) IndexedRegion(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)

Example 69 with ITextRegion

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

the class CSSProposalArranger method isFirstRegion.

private boolean isFirstRegion() {
    if (fContext.getCursorPos() == 0)
        return true;
    ITextRegion region = fContext.getTargetRegion();
    ITextRegion currRegion = fContext.getRegionByOffset(fContext.getCursorPos());
    String type = null;
    String crType = null;
    if (region != null) {
        type = region.getType();
    }
    if (currRegion != null) {
        crType = currRegion.getType();
    }
    if (type == null || crType == null || (crType == type))
        return true;
    else
        return false;
}
Also used : ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)

Example 70 with ITextRegion

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

the class CSSProposalGeneratorForAtmarkRule method getCandidates.

/**
 * getCandidates method comment.
 */
protected Iterator getCandidates() {
    List candidates = new ArrayList();
    ITextRegion region = fContext.getTargetRegionPrevious();
    // ITextRegion region = fContext.getSignificantTargetRegion();
    if (region != null) {
        String type = region.getType();
        if (type != CSSRegionContexts.CSS_RBRACE && type != CSSRegionContexts.CSS_DELIMITER) {
            return candidates.iterator();
        }
    }
    CSSCACandidate item;
    if ((item = getCandidateImportRule()) != null) {
        candidates.add(item);
    }
    if ((item = getCandidateCharsetRule()) != null) {
        candidates.add(item);
    }
    if ((item = getCandidateMediaRule()) != null) {
        candidates.add(item);
    }
    if ((item = getCandidatePageRule()) != null) {
        candidates.add(item);
    }
    if ((item = getCandidateFontFaceRule()) != null) {
        candidates.add(item);
    }
    return candidates.iterator();
}
Also used : ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)447 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)179 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)174 Iterator (java.util.Iterator)75 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)58 ArrayList (java.util.ArrayList)40 ITextRegionContainer (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)39 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)35 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)35 List (java.util.List)33 RegionIterator (org.eclipse.wst.css.core.internal.util.RegionIterator)31 BadLocationException (org.eclipse.jface.text.BadLocationException)30 RegionIterator (org.eclipse.wst.dtd.core.internal.text.RegionIterator)22 TextRegionListImpl (org.eclipse.wst.sse.core.internal.text.TextRegionListImpl)19 ITextRegionCollection (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection)16 Node (org.w3c.dom.Node)16 ContextRegion (org.eclipse.wst.sse.core.internal.parser.ContextRegion)15 IOException (java.io.IOException)13 IRegion (org.eclipse.jface.text.IRegion)13 StyleRange (org.eclipse.swt.custom.StyleRange)13