-
Notifications
You must be signed in to change notification settings - Fork 27
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
Variable definition distorted #603
Comments
A similar issue when 2272 fixes applied on this (commit: 24d4f4b83a7d2e14f16419fbf7ce05cb019c8066)
Related to INRIA/spoon#4315. |
@khaes-kth This may be fixed by INRIA/spoon#4279. |
Great! Is it possible to add a test in Sorald that checks if it is fixed or not? |
Yes, that is possible. Let the linked PR get merged and then I will submit a PR with the test for it. Meanwhile, I can test with my local build of spoon. |
Awesome. Looking forward to it. |
Apparently, this is not so straightforward 😞. This won't be fixed by INRIA/spoon#4279. The fragment Another thing I noted is that when you pass /src/main/java/com/salesforce/mirus/KafkaMonitor.java as the source to sorald, there is no distortion produced in the field. |
Hmm. |
I found the problem. The visitor defined here is not creating the tree correctly. It somehow skips setting the sibling of |
@khaes-kth I found the root cause of the bug. Somehow, the spoon visitor, or something else, is converting Somehow, everything works in order when only |
@slarse I needed some help here because I think the auto-importer preprocessor is causing this bug. I am drawing upon this conclusion because you said something along those lines here and I feel you would have an idea. Anyway, the type of the field, which is |
@algomaster99 The auto-importer used in diffmin is not exacty the same as is used here (diffmin uses stock Spoon, sorald has the Anyway, it's pretty easy to validate your theory, just disable the auto-importer and see if it solves the problem :) To do that, remove the preprocessors that get added when creating the sniper printer here in Sorald. I forget exactly where that is but I'm sure you can find it. |
This comment has been minimized.
This comment has been minimized.
The problem is with the source position only. Consider the following two fields in KafkaMonitor.java:62-63.
We need to fix spoon's code to set the source position of this field's type. Once we're through that, I am quite confident about fixing this bug. |
Okay, so I fixed this, but I am unsure if I have done it correctly. This is the patch (in the spoon repository): diff --git a/src/main/java/spoon/support/compiler/jdt/ReferenceBuilder.java b/src/main/java/spoon/support/compiler/jdt/ReferenceBuilder.java
index e86605ae..51c4e824 100644
--- a/src/main/java/spoon/support/compiler/jdt/ReferenceBuilder.java
+++ b/src/main/java/spoon/support/compiler/jdt/ReferenceBuilder.java
@@ -154,6 +154,7 @@ public class ReferenceBuilder {
}
});
if (ref != null) {
+ ref.setPosition(accessedType.getPosition());
accessedType = ref;
}
}
Link to file in GitHub repository. The premise of this patch is the above comment - #603 (comment) Once I identified the element which doesn't have a type, I just set its position. But I don't understand some things about |
Great. Do you have also opened a PR in spoon with this patch? BTW, I think the best way to show this is actually working is to add a test in Sorald that checks it. |
I will open it by today for sure. Not sure about what exact questions I have to ask so it will take time.
I can only do that once we my patch gets merged and we start using that SNAPSHOT version of spoon. For now, I can show you the demo. I will come to your office. |
yes, agree
looking forward to it! |
I think we can skip writing the tests here in Sorald because this issue was the fault of the sniper printer and not Sorald. Therefore, the correct place of the testing this bug is spoon and it's there.
|
Fixed in INRIA/spoon@454dada. |
We accidentally closed this issue because the above is still not fixed. This is also an issue in Spoon. INRIA/spoon#4315 |
Thanks for reopening it. |
Related to INRIA/spoon#4315 |
Fixed in INRIA/spoon#4341. |
When 2142 fixes are applied on this (commit: 9eab3f69a4a9125b9bf9c9fd77949903f94a67f9), the following change is made:
The text was updated successfully, but these errors were encountered: