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

Clean up duplicate classes migrated into jdt.core.manipulation #1923

Merged
merged 5 commits into from
Oct 25, 2021

Conversation

rgrunber
Copy link
Contributor

@rgrunber rgrunber commented Oct 25, 2021

@testforstephen , I think you migrated a lot of these in org.eclipse.jdt.ui to org.eclipse.jdt.core.manipulation.

Let me know if we can go ahead with this cleanup.
Note : As mentioned in #1911 (comment), I adjusted 5 test asertions upon updating the target platform.

To quicky find possible candidates :

cd ~/git/eclipse.jdt.ui/org.eclipse.jdt.core.manipulation
for f in `find -name "*.java" -printf "%f\n"`; do find ~/git/eclipse.jdt.ls -name ${f}; done;

To compare the differences, I used something like :

for f in CodeScopeBuilder.java DimensionRewrite.java JdtASTMatcher.java LocalVariableIndex.java ModifierRewrite.java ReplaceRewrite.java StatementRewrite.java TypeAnnotationRewrite.java TypeBindingVisitor.java VariableDeclarationRewrite.java;
  do diff -uwB `find git/eclipse.jdt.ls -name $f` "`find git/eclipse.jdt.ui -name $f`"
done

@fbricon
Copy link
Contributor

fbricon commented Oct 25, 2021

That's the kind of PR I like ;-)

Copy link
Contributor

@testforstephen testforstephen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

- org.eclipse.jdt.internal.corext.dom was moved from jdt.ui to
  jdt.core.manipulation

Signed-off-by: Roland Grunberg <[email protected]>
- org.eclipse.jdt.internal.corext.dom.fragments was moved from jdt.ui to
  jdt.core.manipulation

Signed-off-by: Roland Grunberg <[email protected]>
- Remove some classes from
  o.e.jdt.ls.internal.corext.refactoring.{changes,delegates,nls,rename,util}
  and use original classes.

Signed-off-by: Roland Grunberg <[email protected]>
- Remove some classes from
  o.e.jdt.ls.internal.corext.refactoring.{tagging,base,code,reorg} and
  use original classes.

Signed-off-by: Roland Grunberg <[email protected]>
- Remove some classes from various subpackages of corext and use
  original classes

Signed-off-by: Roland Grunberg <[email protected]>
@rgrunber rgrunber changed the title Cleanup duplicate classes Clean up duplicate classes migrated into jdt.core.manipulation Oct 25, 2021
@rgrunber rgrunber merged commit e9a2af5 into eclipse-jdtls:master Oct 25, 2021
@rgrunber rgrunber deleted the cleanup-duplicate-classes branch October 25, 2021 17:30
@rgrunber rgrunber added the debt label Oct 25, 2021
@rgrunber rgrunber added this to the Early November milestone Oct 25, 2021
@@ -49,9 +49,9 @@
import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels;
import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.dom.IASTSharedValues;
import org.eclipse.jdt.internal.corext.refactoring.nls.changes.CreateFileChange;
Copy link
Contributor Author

@rgrunber rgrunber Dec 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This small mistake introduced a regression. Thanks to @fbricon for catching this. Currently creating compilation units (classes/interfaces/enums) from unresolved symbols fails to create the file. You can see the missing

"options": {
"overwrite": false,
"ignoreIfExists": true
},
"kind": "create"

when comparing the data.

When I planned this refactoring, I wanted to use CreateFileChange from org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/nls/changes/CreateFileChange.java and remove our copy. However, I noticed a key difference. Our copy opened up getPath() whereas it's restricted in the upstream version.

-   protected IPath getPath() {
+   public IPath getPath() {
        return fPath;
    }

Rather than wait for upstream to adopt it, I decided to just undo the change and continue using our copy of CreateFileChange. I must have left this import in, and because it resolves, I never saw any indication of a problem.

The result is that we use org.eclipse.jdt.internal.corext.refactoring.nls.changes.CreateFileChange when creating the file change, but our ChangeUtil code does an instance of check on our org.eclipse.jdt.ls.core.internal.corext.refactoring.nls.changes.CreateFileChange so we fail to correctly recognize this case.

Just changing this line fixes things, so I'll post a change, and hopefully there's a way to test this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants