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;
}
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);
}
}
}
}
}
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;
}
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);
}
}
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" });
}
Aggregations