Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/org.eclipse.pde.spy.css/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %name
Bundle-SymbolicName: org.eclipse.pde.spy.css;singleton:=true
Bundle-Version: 0.14.100.qualifier
Bundle-Version: 0.14.200.qualifier
Automatic-Module-Name: org.eclipse.pde.spy.css
Bundle-RequiredExecutionEnvironment: JavaSE-21
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.29.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -99,7 +100,6 @@
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.Widget;
import org.w3c.css.sac.SelectorList;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.css.CSSRule;
Expand Down Expand Up @@ -969,37 +969,39 @@ private void performCSSSearch(IProgressMonitor monitor, String text, Collection<

CSSEngine engine = getCSSEngine(root);
try {
SelectorList selectors = engine.parseSelectors(text);
var selectors = engine.parseSelectors(text);
Predicate<CSSStylableElement> matcher = el -> {
for (int i = 0; i < selectors.getLength(); i++) {
if (engine.matches(selectors.item(i), el, null)) {
return true;
}
}
return false;
};
subMonitor.split(2);
processCSSSearch(subMonitor.split(8), engine, selectors, element, null, results);
processCSSSearch(subMonitor.split(8), matcher, element, results);
} catch (Exception e) {
System.out.println(e.toString());
}
}
monitor.done();
}

private void processCSSSearch(IProgressMonitor monitor, CSSEngine engine, SelectorList selectors,
CSSStylableElement element, String pseudo, Collection<Widget> results) {
private void processCSSSearch(IProgressMonitor monitor, Predicate<CSSStylableElement> matcher,
CSSStylableElement element, Collection<Widget> results) {

if (monitor.isCanceled()) {
return;
}
NodeList children = element.getChildNodes();
SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.CssSpyPart_Searching, 5 + 5 * children.getLength());
boolean matched = false;
for (int i = 0; i < selectors.getLength(); i++) {
if (matched = engine.matches(selectors.item(i), element, pseudo)) {
break;
}
}
if (matched) {
if (matcher.test(element)) {
results.add((Widget) element.getNativeWidget());
}
subMonitor.split(5);
for (int i = 0; i < children.getLength(); i++) {
processCSSSearch(subMonitor.split(5), engine, selectors,
(CSSStylableElement) children.item(i), pseudo, results);
processCSSSearch(subMonitor.split(5), matcher,
(CSSStylableElement) children.item(i), results);
}
}

Expand Down Expand Up @@ -1196,7 +1198,7 @@ private Map<String, String> getCSSRuleSources(CSSEngine engine, CSSStylableEleme
continue;
}
try {
SelectorList selectors = engine.parseSelectors(styleRule.getSelectorText());
var selectors = engine.parseSelectors(styleRule.getSelectorText());
boolean matched = false;
for (int k = 0; k < selectors.getLength(); k++) {
if (engine.matches(selectors.item(k), element, null)) {
Expand Down
Loading