Search in sources :

Example 1 with ICSSSelector

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector in project webtools.sourceediting by eclipse.

the class CSSSelectorListImpl method getString.

/**
 * @return java.lang.String
 */
public String getString() {
    if (fCachedString == null) {
        StringBuffer buf = new StringBuffer();
        boolean bFirst = true;
        // groups is list of comma-separated selectors
        Iterator i = getSelectors().iterator();
        while (i.hasNext()) {
            if (!bFirst) {
                // $NON-NLS-1$
                buf.append(", ");
            }
            ICSSSelector item = (ICSSSelector) i.next();
            buf.append(item.getString());
            bFirst = false;
        }
        fCachedString = buf.toString();
    }
    return fCachedString;
}
Also used : Iterator(java.util.Iterator) ICSSSelector(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector)

Example 2 with ICSSSelector

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector in project webtools.sourceediting by eclipse.

the class CSSClassTraverser method addClassNames.

/**
 */
private void addClassNames(ICSSStyleRule rule) {
    ICSSSelectorList selectorList = rule.getSelectors();
    Iterator iSelector = selectorList.getIterator();
    while (iSelector.hasNext()) {
        ICSSSelector selector = (ICSSSelector) iSelector.next();
        Iterator iItem = selector.getIterator();
        while (iItem.hasNext()) {
            ICSSSelectorItem item = (ICSSSelectorItem) iItem.next();
            if (item.getItemType() == ICSSSelectorItem.SIMPLE) {
                ICSSSimpleSelector sel = (ICSSSimpleSelector) item;
                int nClasses = sel.getNumOfClasses();
                for (int iClass = 0; iClass < nClasses; iClass++) {
                    String className = sel.getClass(iClass);
                    if (!fClassNames.contains(className))
                        fClassNames.add(className);
                }
            }
        }
    }
}
Also used : ICSSSelectorList(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList) Iterator(java.util.Iterator) ICSSSelector(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector) ICSSSimpleSelector(org.eclipse.wst.css.core.internal.provisional.document.ICSSSimpleSelector) ICSSSelectorItem(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem)

Example 3 with ICSSSelector

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector in project webtools.sourceediting by eclipse.

the class SelectorValidator method getOnlyOneSimpleSelector.

private ICSSSimpleSelector getOnlyOneSimpleSelector() {
    parse();
    if (fSelectorList != null && fSelectorList.getLength() == 1) {
        ICSSSelector selector = fSelectorList.getSelector(0);
        int nItem = selector.getLength();
        if (nItem == 1) {
            ICSSSelectorItem item = selector.getItem(0);
            if (item instanceof ICSSSimpleSelector) {
                return (ICSSSimpleSelector) item;
            }
        }
    }
    return null;
}
Also used : ICSSSelector(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector) ICSSSimpleSelector(org.eclipse.wst.css.core.internal.provisional.document.ICSSSimpleSelector) ICSSSelectorItem(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem)

Example 4 with ICSSSelector

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector in project webtools.sourceediting by eclipse.

the class SelectorsCollector method addSelectorToAvoid.

/**
 */
public void addSelectorToAvoid(ICSSStyleRule rule) {
    ICSSSelectorList list = rule.getSelectors();
    Iterator it = list.getIterator();
    while (it.hasNext()) {
        ICSSSelector sel = (ICSSSelector) it.next();
        addSelectorToAvoid(sel);
    }
}
Also used : ICSSSelectorList(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList) Iterator(java.util.Iterator) ICSSSelector(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector)

Example 5 with ICSSSelector

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector in project webtools.sourceediting by eclipse.

the class CSSSelectorTest method testSelector14.

public void testSelector14() {
    ICSSSelectorList list = createSelectorList("DIV P *[href]");
    checkSelectorList(list, "DIV P *[href]", 1, 0);
    ICSSSelector selector;
    ICSSSelectorItem item;
    selector = list.getSelector(0);
    checkSelector(selector, "DIV P *[href]", 5, 102, 0);
    item = selector.getItem(0);
    checkSimpleSelector(item, "DIV", false, 0, 0, 0, 0);
    item = selector.getItem(1);
    checkSelectorCombinator(item, " ", ICSSSelectorCombinator.DESCENDANT);
    item = selector.getItem(2);
    checkSimpleSelector(item, "P", false, 0, 0, 0, 0);
    item = selector.getItem(3);
    checkSelectorCombinator(item, " ", ICSSSelectorCombinator.DESCENDANT);
    item = selector.getItem(4);
    checkSimpleSelector(item, "*", true, 1, 0, 0, 0);
    checkSimpleSelectorAttributes(item, new String[] { "href" });
}
Also used : ICSSSelectorList(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList) ICSSSelector(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector) ICSSSelectorItem(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem)

Aggregations

ICSSSelector (org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector)52 ICSSSelectorList (org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList)48 ICSSSelectorItem (org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem)42 Iterator (java.util.Iterator)7 ICSSStyleRule (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule)3 ImportedCollector (org.eclipse.wst.css.core.internal.util.ImportedCollector)3 SelectorsCollector (org.eclipse.wst.css.core.internal.util.SelectorsCollector)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ICSSNode (org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)2 ICSSSimpleSelector (org.eclipse.wst.css.core.internal.provisional.document.ICSSSimpleSelector)2 ICSSStyleSheet (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet)2 Vector (java.util.Vector)1 CSSTextParser (org.eclipse.wst.css.core.internal.parserz.CSSTextParser)1 CSSTextToken (org.eclipse.wst.css.core.internal.parserz.CSSTextToken)1 ICSSImportRule (org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule)1 ICSSValue (org.eclipse.wst.css.core.internal.provisional.document.ICSSValue)1 ImportRuleCollector (org.eclipse.wst.css.core.internal.util.ImportRuleCollector)1