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

Question - Are coordinated multi file refactorings possible with AutoRefactor? #327

Open
cal101 opened this issue Mar 30, 2018 · 4 comments
Labels

Comments

@cal101
Copy link
Collaborator

cal101 commented Mar 30, 2018

Standard eclipse refactorings like "renameMethod" require coordinated changes to multiple files.

I want to write some refactorings requiring coordinated changes, too.
As a proof of concept I tried to write a naive AutoRefactor refactoring rule for removing some interface method and it's implementations and usages.
That did not work because as far as I can see AutoRefactor requires each CompilationUnit to be compilable on it's own and as soon as some dependency is already refactored (e.g. method removed)
the compile fails.

I got the impression that eclipse uses something called "virtual workspaces" for this but I may have misunderstood that. I did not find much information on that.

Does the AutoRefactor "rule framework" support such a use case?
If not do you consider that? Any concrete plans?
Any links to information on doing coordinated refactorings?
I tried to look at the rename refactoring but have problems navigating and accessing the "ltk" bundles from my oxygen autorefactor workspace.

I use eclipse only for AutoRefactor stuff and so my knowledge is sparse:
How do I find what bundle versions to require for lets say oxygen 3?
I peeked at the oxygen 3 installation for bundle versions and just added them to the manifest. Visible now.

@cal101
Copy link
Collaborator Author

cal101 commented Apr 1, 2018

Answering my own question:

Yes, it is possible to do coordinated refactorings using the AutoRefactor framework.
By accident some test code triggered the failing recompiles.
I was able to

  • remove methods from interfaces and classes,
  • remove parameters and arguments for those
  • remove variable declarations, costructor parameters and if statements
  • replace if statements with it's else statement based on matching of the condition of the if statement
    all in one single run.

@Fabrice-TIERCELIN
@JnRouvignac
BTW: Some time ago changes were done to auto refactor that I understood used ast pattern matching for implementation of refactorings. I tried to find some autorefactor code that uses ast pattern matching but could not find it. I am back playing with ast patterns and would like to compare ideas. Any hints?

@JnRouvignac
Copy link
Owner

Does the AutoRefactor "rule framework" support such a use case?

I have never written such refactorings yet, but in theory you can do it. Be careful with multi threading if you have more than one autorefactor job running.

@JnRouvignac
Copy link
Owner

JnRouvignac commented Jul 3, 2018

used ast pattern matching for implementation of refactorings

It depends what you mean by that.
AutoRefactor is an expert system matching patterns of code before applying refactorings. So it is doing pattern matching.

However maybe you mean something like this?

@cal101
Copy link
Collaborator Author

cal101 commented Jul 4, 2018

Yes i meant something like the clang ast matcher and wrote it since opening this ticket.
The matcher code in the script dsl example I wrote in the configuration question ticket is real.

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

3 participants