Skip to content

Commit

Permalink
Add boolean to ExpectedTypes when in conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelistria committed Dec 17, 2024
1 parent 7ca73a2 commit 71b24df
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ private static enum TypeFilter {
SUPERTYPE, SUBTYPE;
}

private static final Set<StructuralPropertyDescriptor> CONDITION_LOCATIONS = Set.of(
IfStatement.EXPRESSION_PROPERTY,
WhileStatement.EXPRESSION_PROPERTY,
DoStatement.EXPRESSION_PROPERTY,
ForStatement.EXPRESSION_PROPERTY,
ConditionalExpression.EXPRESSION_PROPERTY
);

private final int offset;
private Collection<TypeFilter> expectedTypesFilters = Set.of(TypeFilter.SUPERTYPE, TypeFilter.SUBTYPE);
private final Collection<ITypeBinding> expectedTypes = new LinkedHashSet<>();
Expand Down Expand Up @@ -75,6 +83,10 @@ private void computeExpectedTypes(){
this.expectedTypes.add(cast.getType().resolveBinding());
return;
}
if (parent2.getLocationInParent() != null && CONDITION_LOCATIONS.contains(parent2.getLocationInParent())) {
this.expectedTypes.add(parent2.getAST().resolveWellKnownType(PrimitiveType.BOOLEAN.toString()));
return;
}
parent2 = parent2.getParent();
}
ASTNode parent = parent2;
Expand Down

0 comments on commit 71b24df

Please sign in to comment.