Skip to content

Commit

Permalink
Prevent NPEs in previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosame committed Oct 17, 2023
1 parent d01cf66 commit ca972f8
Showing 1 changed file with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1138,22 +1138,25 @@ public boolean supports(SelectorList selectors) {
}

private boolean supports(Selector selector) {
switch (selector.getSelectorType()) {
case CHILD:
case DESCENDANT:
case DIRECT_ADJACENT:
case SUBSEQUENT_SIBLING:
CombinatorSelector combSel = (CombinatorSelector) selector;
return supports(combSel.getSelector()) && supports(combSel.getSecondSelector());
case CONDITIONAL:
ConditionalSelector condSel = (ConditionalSelector) selector;
return supports(condSel.getSimpleSelector())
&& supports(condSel.getCondition());
case COLUMN_COMBINATOR:
return false;
default:
return true;
if (selector != null) {
switch (selector.getSelectorType()) {
case CHILD:
case DESCENDANT:
case DIRECT_ADJACENT:
case SUBSEQUENT_SIBLING:
CombinatorSelector combSel = (CombinatorSelector) selector;
return supports(combSel.getSelector())
&& supports(combSel.getSecondSelector());
case CONDITIONAL:
ConditionalSelector condSel = (ConditionalSelector) selector;
return supports(condSel.getSimpleSelector())
&& supports(condSel.getCondition());
case COLUMN_COMBINATOR:
return false;
default:
}
}
return true;
}

private boolean supports(Condition condition) {
Expand All @@ -1164,7 +1167,8 @@ private boolean supports(Condition condition) {
&& supports(combCond.getSecondCondition());
case SELECTOR_ARGUMENT:
ArgumentCondition argCond = (ArgumentCondition) condition;
return supports(argCond.getSelectors());
SelectorList selist = argCond.getSelectors();
return selist == null || supports(selist);
default:
return true;
}
Expand Down

0 comments on commit ca972f8

Please sign in to comment.