Temporary variable not removed when assignment deleted

Issue #403 resolved
Matthias Schoettle created an issue

Given an AssignmentStatement like String x = ..., when deleting the assignment, the temporary variable is not deleted as well (as is done with message assignments or when changing the assignTo of the assignment statement).

However, this should only be done if it is not used anywhere else.

Comments (13)

  1. Matthias Schoettle reporter

    This also needs to be performed when deleting the operand it is contained in.

    When deleting a message with nested behaviour, it should be removed automatically, since it is the initialMessage which contains the property.

  2. Matthias Schoettle reporter

    The following needs to be supported as well I think:

    String x = ...;
    String x = somethingElse;
    

    When the first statement is deleted, x should not be deleted. Right now, it is only checked whether it is referenced in messages (of their assignTo).

  3. Matthias Schoettle reporter

    References #403: Adds special handling for assignment statements.

    Adds a check when deleting an AssignmentStatement to make sure the temporary property (if necessary) is deleted.

    Updates the condition to determine whether a temporary property needs to be removed. Considers other assignment statement's assignTo references as well. The temporary property can only be deleted if it is only referenced by this one assignment statement.

    → <<cset 180331268b4f>>

  4. Matthias Schoettle reporter

    Adds tests with test data for the FragmentsController.

    Adds dependency to JUnit to the controller project and a tests source folder.

    References #403 (tests).

    → <<cset 22b2fbe5fcee>>

  5. Matthias Schoettle reporter

    Temporarily disables Checkstyle for tests.

    In the future, it might be desirably to create specific rules (more relaxed) for test cases.

    References #403 (tests).

    → <<cset 091adebe1d94>>

  6. Matthias Schoettle reporter

    References #403: Improves structure of tests.

    Adds abstract test class which handles the initialization (set up before class), test setup and tear down.

    Also, the indices for fragments in the test classes are extracted to constants, in order to easier manage them when the test model changes.

    Added two self messages to nested behaviour for additional test cases.

    → <<cset bd99c7ca622e>>

  7. Matthias Schoettle reporter

    References #403: Fixes temporary property removal check when removing messages.

    • Moves removal of temporary property to MessageViewController.
    • Updates check to ensure that temporary property is at most used once in order to safely remove it.

    → <<cset 11dcaba4f44a>>

  8. Matthias Schoettle reporter

    References #403: Adds test case to check whether temporary properties are properly deleted.

    Ensures that deletion is performed also for assigning a property several times, but deleting all of the statements.

    → <<cset 181cf5b66ad2>>

  9. Matthias Schoettle reporter

    References #403: Improves removal of unused temporary properties to consider all affected fragments.

    If the only fragments/messages assigning to the temporary property are ones being deleted or updated (the assignTo is replaced), it can be safely deleted.

    → <<cset 3505986ba7f1>>

  10. Log in to comment