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
SourcePositions are incorrect in some cases #1953
Comments
I think it is mostly due to |
I tried to fix some of the issues, I have now only 10 tests that do not succeed. @GlobalAnnotation
public @Deprecated final @TypeAnnotation Void m() {
} Because getModifierSourceStart and getModifierSourceEnd mean nothing in this case, because there is the annotation between them. Should we move the position of the modifiers in CtExtendedModifier? |
Can we change the convention to MAX_VALUE?
|
We can do so. Would it be backward compatible?
|
Source position section of modifiers already contains annotations in other cases ... and I am OK with that personally. Only the name of this section is confusing. Otherwise it is OK. The types behaves same. E.g this one:
And many thanks Thomas for fixing that! I have to learn to create more issues ... and not to do it on my own.... looks like we are not only 3 on github ;-)) |
I made all the test pass. I put in @GlobalAnnotation
public @Deprecated final @TypeAnnotation Void m() {
} |
You cannot avoid mixing of modifiers and annotations, so may be the solution is simply to document that source fragment of modifiers contains |
The issue is that for the moment, it doesn't not include all the modifiers |
Can I debug it somewhere? Which test, which branch? |
Sorry I meant annotations. But currently with this code the modifier final is not inluded in the interval. @GlobalAnnotation
public @Deprecated final Void m() {
} |
Thanks for explanation. I understand. |
Do you mean that you would prefer to include all the annotations in the interval? Even in this case |
yes exactly. Even in that case. It already behaves like this. It fits to needs of #1927 |
I have checked the code and I was wrong. I have found the PositionBuilder code which tries to search for place where annotations ends and modifiers start. So Spoon actually tries to separated annotations and modifiers (of type and method) into different source fragments. So my sentences in the comments above: "It already behaves like this." are wrong. But I still think that we cannot separate annotations and modifiers, because they can be mixed in arbitrary order, so the only reliable solution is to have them in one one shared "modifiers" source interval. May be we can rename |
I think it is the same with comments :/ |
yes and no. Comments are special. They behaves like a whitespace in source code. Note:
|
can we close this issue (the title is not really focused)? |
ok, I agree to close it. There are still probably some Source position problems, but it makes sense to create individual issues for them. I will do so in next days after checking the state of sniper mode and related failing tests |
In the PR #1950 I added check for consistency of source position start/end offsets:
It is needed for sniper mode (source code refactored by spoon has minimum differences comparing to origin source code).
But this SourcePosition consistency check causes that many tests fail now.
The text was updated successfully, but these errors were encountered: