eclipse-jdt / eclipse-jdt/eclipse.jdt.ui

Field Name Recommendation Based on Program-Specific Naming Conventions

Open
#661 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
59
Forks
127
Avg merge
22h 47m
Merged PRs (30d)
28

Description

Here we present the second heuristics to improve the name recommendation for Rename Field refactorings. Detailed explanations are provided below through examples.

The following code snippet comes from the apache/pinot (pinot-integration tests/src/test/java/com/linkedin/pinot/integration/tests/ HybridScanBasedCommandLineTestRunner.java, commit:31a6b95200cc5845706d27304fc2ed4767ec2aab). In this example, the original developers renamed the field "**multiThreaded**" to a new name "**_multiThreaded**" (Line 101) because all fields within the same class are named with common prefix **"_"** except for the original name of this field.

![image](https://github.com/eclipse-jdt/eclipse.jdt.ui/assets/77560508/b9e7adbc-f84d-4709-bfd8-df6045ad5a21)

For the given example, IntelliJ IDEA recommends “**aBoolean**” instead, that is substantially different from the one chosen by the original developers.

As a generic rule, we recommend to append the common prefix to the original name (e.g., _multiThreded for multiThreded). We also suggest to remove the prefix of the original name if other fields within the same class do not contain the prefix.

We have validated the heuristic on **8489** field renamings actually conducted by the original developers in open-source applications. In total, the heuristic recommended **239** names where **512** were exactly the same as what the original developers finally used. That is , the precision is **47%**, substantially higher than that of IntelliJ IDEA.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.