-
Notifications
You must be signed in to change notification settings - Fork 401
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
Use CodeGeneration and GetterSetterUtil from o.e.jdt.core.manipulation. #821
Conversation
Ways in which some methods will be subtly different in GetterSetterUtil when the copied code is removed. The '-' (minus) is what jdt.core.manipulation is using and the '+' (plus) is what your copied code has. I could look into maintaining your current options as I think they could just be set with preferences.
|
@@ -1290,7 +1290,7 @@ public void testCompletion_getter() throws Exception { | |||
assertNotNull(resolvedItem.getTextEdit()); | |||
assertTextEdit(2, 4, 7, "/**\n" + | |||
" * @return the strField\n" + | |||
" */\n" + | |||
" */\n\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this extra line is definitely wrong. Eclipse doesn't have it. Where is it coming from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In GetterSetterUtil, getGetterStub(), and getSetterStub(), The JDT version has it and JDT-LS removed it.
if (comment != null) {
buf.append(comment);
- buf.append(lineDelim);
}
However, upon actually testing (create a field, hover over it, create getter/setters), the result is the same as before. This is why I was guessing that everything is ultimately fed to a formatter which corrects the issue. In fact, in GetterSetterCompletionProposal#updateReplacementString(..) of JDT-LS, you can see CodeFormatterUtil.format(..) called right after the stub is returned.
Thanks for trying it out. Maybe the Eclipse Generic Editor is doing something in addition. Either way, I'll look into fixing it (ie. restoring the tests as they were before) |
This is happening due to a difference between JDT UI template and JDT LS template (note the additional newline in JDT-LS). So JDT UI added the newline in the code, after the comment, and JDT-LS added it to the template. Now that we're using the JDT UI (core.manipulation) logic, we can remove the newline from the template. The fix is simple but I'll have to go through and see if this breaks any other tests. UPDATE : I had to remove the |
- With http://eclip.se/539200 complete, we can can reduce copies for classes like CodeGeneration and GetterSetterUtil. - This change brings JDT-LS back in line with JDT Core with respect to some differences that occured during copying of these classes - JDT-LS hard codes StubUtility.useIsForBooleanGetters(..) and StubUtility.useThisForFieldAccess(..) . Now the default JDT Core values will be used Signed-off-by: Roland Grunberg <[email protected]>
Thanks @rgrunber ! |
classes like CodeGeneration and GetterSetterUtil.
some differences that occured during copying of these classes
StubUtility.useThisForFieldAccess(..) . Now the default JDT Core
values will be used
setter method's comment stub. Although this required adjusting
some test cases, it doesn't seem to affect "real" usage because the
code formatter is applied to the resulting stub.
Signed-off-by: Roland Grunberg [email protected]