Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renaming a field may of a @Value may break code #512

Closed
rijnb opened this issue Jul 30, 2018 · 1 comment
Closed

Renaming a field may of a @Value may break code #512

rijnb opened this issue Jul 30, 2018 · 1 comment
Labels

Comments

@rijnb
Copy link

rijnb commented Jul 30, 2018

Renaming a field of a @value class may break code

Renaming a field of a @value class may refactor code using the field via a getter to incorrect code.
This happens if the field is accessed in a class, not via 'this' and it's using the getter, "o.getId()" for a field 'id' -- this may change to "this.getIdRenamed()" when id is renamed.

Version information

  • IDEA Version: 2018.1 and 2018.2
  • JDK Version: 1.8.0_162
  • OS Type & Version: MacOSX 10.13.6
  • Lombok Plugin Version: 0.19-LATEST
  • Lombok Dependency Version: 1.18.0

Steps to reproduce

Point at "Tile tile" and rename 'tile' to 'xyz'.
The line 'o.getTile()' will be replaced incorrectly with 'this.getXyz()'

package com.tomtom.speedtools.geometry;

import com.google.common.collect.ComparisonChain;
import lombok.NonNull;
import lombok.Value;

class Test {
    class Tile {
        int id;

        int getId() {
            return id;
        }
    }

    @Value              // <-- This needs to be Lombok supplied
    private static class TileIdFormatAndBaseLevel implements Comparable<TileIdFormatAndBaseLevel> {
        @NonNull
        Tile tile;      // <-- If you rename this 'tile' to 'xyz', the o.getTile() below becomes this.getXYZ()

        @Override
        public int compareTo(@NonNull final TileIdFormatAndBaseLevel o) {
            return ComparisonChain.start()
                    .compare(o.getTile().getId(), tile.getId())
                    .result();
        }
    }
}

@mplushnikov
Copy link
Owner

Can you verify with current new version (0.20.) of plugin? It contains some improvements for "Find Usages" already..

mplushnikov added a commit that referenced this issue Oct 24, 2018
mplushnikov added a commit that referenced this issue Oct 24, 2018
* added example for issue #512

* fix removing of field annotations during delombok

* cleanup code

* added to changelog #530

* added support for ImplicitResourceCloser extension point for @cleanup #287

* master is now for: up from 2018.1 IntelliJ builds
@rijnb rijnb closed this as completed Dec 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants