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

[core] Add Rewrite Events #871

Closed
wants to merge 2 commits into from

Conversation

MatiasComercio
Copy link
Contributor

Depends on #858 ==> Start review from commit 41c3684

PR Description
Implements: #693: Generate & identify events over AST nodes

List of changes

  • Add main classes to support Rewrite Events
  • Update AbstractNode to record rewrite events over children nodes
  • Add test cases for implemented functionality
  • Fix test cases
    • It would be nice to disable the haveChildrenChanged property in xpath. This would allow to leave test cases as they were, but I actually don't know how to achieve this. So, for the moment, I've added this new field to the test cases.

- Update Node interface
  - Add insert method to insert new children in certain indexes
  - Add replace method to replace current children with new ones in certain indexes
  - Rename removeChildAtIndex method to remove with an index parameter
    - Fix test cases to match the new convention
- Implement insert & replace methods in AbstractNode
- Add test cases for the new features
- Leave some TODOs related to the autofix flow
  - NodeEvents will be implemented soon; that's why these TODOs were left in the code
- Add main classes to support Rewrite Events
- Update AbstractNode to record rewrite events over children nodes
- Add test cases for implemented functionality
- Fix test cases
  - It would be nice to disable the `haveChildrenChanged` property in xpath.
    This would allow to leave test cases as they were, but I actually don't know
    how to achieve this. So, for the momment,
    I've added this new field to the test cases
@@ -32,7 +32,7 @@ public void testAttributeAxisIterator() {
Attribute attribute = it.next();
atts.put(attribute.getName(), attribute);
}
Assert.assertEquals(7, atts.size());
Assert.assertEquals(8, atts.size());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be nice to disable the haveChildrenChanged property in xpath.

@@ -28,6 +28,7 @@ public void testCopyXmlToClipboard() {
String xml = Designer.getXmlTreeCode(compilationUnit);
assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<dummyNode BeginColumn=\"1\" BeginLine=\"1\" EndColumn=\"0\" EndLine=\"0\" FindBoundary=\"false\"\n"
+ " Image=\"Foo\"\n" + " SingleLine=\"false\"/>", xml);
+ " Image=\"Foo\"\n" + " SingleLine=\"false\"\n"
+ " haveChildrenChanged=\"false\"/>", xml);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be nice to disable the haveChildrenChanged property in xpath.

@MatiasComercio MatiasComercio changed the title Add Rewrite Events [core] Add Rewrite Events Jan 22, 2018
* </p>
* <p>
* Rewrite events occurring on the same index are merged straight away, so at all moment only one rewrite event
* is hold for a given index. This helps to understand exactly what kind of change has the node suffer,
Copy link
Contributor

Choose a reason for hiding this comment

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

Change suffer to suffered

Copy link
Member

Choose a reason for hiding this comment

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

I'd add that "hold" should be "held"

@oowekyala oowekyala added the in:autofixes Affects the autofixes framework label Jan 23, 2018
@jsotuyod jsotuyod self-assigned this Jan 28, 2018
@jsotuyod
Copy link
Member

Thanks for yet another PR. I've briefly reviewed this changeset, but I have two problems with it.

  1. this PR includes plenty of code already present in [core] Add insert & replace child nodes #858, making it harder to read / audit
  2. I fail to see the purpose of all these new objects in the autofix feature. Why do we need intermediate objects to get to the Document operations we actually want? As far as I understand, we want autofixes to produce 2 things: to modify the AST for other rules to work on the updated version (covered in [core] Add insert & replace child nodes #858), and to reflect those modifications on the Document to write those changes to disk. I don't see how these fit into any of those two.

@jsotuyod jsotuyod added the is:WIP For PRs that are not fully ready, or issues that are actively being tackled label Jan 28, 2018
@MatiasComercio
Copy link
Contributor Author

We are closing this as it has been deprecated in favor of a new autofixes approach. See #693.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in:autofixes Affects the autofixes framework is:WIP For PRs that are not fully ready, or issues that are actively being tackled
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants