Skip to content

Simplify if expressions #158

@CatarinaGamboa

Description

@CatarinaGamboa

It would be great if the expression simplification also simplified if expressions when possible:

  • true ? a : ba
  • false ? a : bb
  • a ? b : bb

Example

@ExternalRefinementsFor("java.awt.dnd.DropTarget")
@StateSet({"noListener", "listenerSet"})
@StateSet({"notActive", "active"})
public interface DropTargetRefinements {
    @StateRefinement(to="act ? listenerSet(this) && active(this) : listenerSet(this) && notActive(this)")
    public void DropTarget(Component c, int ops, DropTargetListener dtl, boolean act);

    @StateRefinement(from="active(this)")
    public void dragEnter(DropTargetDragEvent dtde);
}

Test

void test(){
    DropTarget dt = new DropTarget(null, 42, null, false);
    dt.dragEnter(null);
}

Result

false ? listenerSet(#dt_221) && active(#dt_221) : listenerSet(#dt_221) && notActive(#dt_221)

Which could be simplified to:
 listenerSet(#dt_221) && notActive(#dt_221)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestsimplificationRelated to the simplification of expressions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions