-
Notifications
You must be signed in to change notification settings - Fork 193
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
Poor experience with code assist #288
Comments
Thanks for the issue submission. I tried this case out quickly and found a different result.
1) When I have "import static org.junit.Assert.*" or extend GroovyTestCase and ask for content assist on "assertNu", I get two choices. One completion for "assertNull(Object)" and one for "assertNull(String, Object)". If I choose the first, I get "assertNull(object)" in my editor source. "object" has a box around it like it is where the focus is, but the caret is actually after the closing paren. If I Shift-Tab, I can get focus on the argument and type-over it.
NOTE: The same scenario in Java results in "assertNull();" with the caret placed inside the parens. So I would like to correct the caret position for method completions.
2) If I go to Preferences > Groovy and check "Try to guess the most likely parameters to use for method invocations" -- which seems to echo Preferences > Java > Editor > Content Assist's "Fill method arguments and show guessed arguments" -- I get "assertNull(local)" and a little box with a choice of local variables, method parameters and instance fields. Selecting from this list replaces the parameter and then the caret is after the closing paren.
Are you seeing any behaviors like these? Can you say what Eclipse you are running and any pertinent editor preferences you may have set that are changing the behavior of content assist?
|
Hi Eric. Yes, I have both suggestions, "assertNull(Object)" and "assertNull(String, Object)", and I choose the first one, just like you. I had "Try to guess the most likely..." checked and what I get is "assertNull(", not "assertNull(local)". I don't know why I get a different result from yours... I'm using Eclipse Neon.3 (build M20170301-0400), Groovy-Eclipse feature 2.9.2.xx-201705040351-e46 and Groovy Compiler 2.4 2.9.2.xx-201705040351-e46 If I uncheck that checkbox, instead, I get exactly what you describe in point 1). In any case, as you realised already, having the caret after the closing bracket is quite uncomfortable. Please note that unchecking "Do not use parens..." or checking "Use named arguments..." seems not to make any difference in this context (perhaps it's not clear to me what those options should do). |
Thanks for the update. I'm trying to carve off a little time today to see if I can make a step in the right direction.
|
Can you try again with the latest snapshot? The focus and selection should have moved to the first argument. Not sure about the incomplete replacement issue, but am have found all the relevant code and can add some logging if it is still happening. |
I'm trying on another Eclipse installation with Greclipse 2.9.2.xx-201705070120-e46.
or:
|
I'm very perplexed. Today I installed Greclipse 2.9.2.xx-201705080332-e46 at work, the system I used when I opened this issue, and, if the checkbox "Guess the most likely parameters for method calls" is checked, then the case Both systems have a Eclipse Neon.3, at home I have a Linux Mint 17.3 (based on Ubuntu 14.04), here at work I have Windows 10. Here at work I may have some more plugins installed and probably different code formatting options, but I'm not sure what could cause this difference. Do you have any suspect? |
Ok, I was able to find the steps to reproduce my issue!! If I start Eclipse at work on a brand new workspace, all works as expected. When I apply the preferences file I'm going to attach, I reproduce the issue with the incomplete completion I mentioned. I hope you'll be able to reproduce now. |
I think I understand why you are seeing some odd behaviors like all the out-of-bounds exceptions. While editing and invoking content assist, the working copy in the editor is not always in sync with the compilation unit (the thing that is parsed and compiled to produce the AST and whatnot). I am using the latter to check things like fully-qualified names (completion on Okay this probably sounds lame, but if you save the editor buffer before content assisting the reconciler will have a chance to sync up the working copy and the compilation unit. This may be a workaround for some of the oddities you experience while editing. (You should be able to tell that things are out of sync if the syntax highlighting looks funky.) Longer term, I need to find all the places used by content assist that read from the compilation unit and try to get from the working copy instead. NOTE: The reconciler runs in the background to sync up the working copy and the compilation unit while you type. But there is a delay of a couple seconds that can be noticed while typing and content assisting quickly. |
Yes, I confirm that, apart from the odd behaviour observed once I import the attached preferences, I get a lot of out-of-bounds exceptions and I often experience empty content assists until I save the editor and/or wait some time and then invoke code assist again. This fragility of the Groovy content assist brings a very bad user experience, because it makes the whole thing seem like "crappy" indeed. It's not very elegant, especially because it would trigger the Eclipse UI freeze monitor, but I personally would prefer a lot if I had to wait a bit for suggestions to show up, but then the list of suggested options were consistent without the need to cycle through proposals multiple times and/or save the editor before retrying. If you get to fix this, I think the whole user experience of Greclipse would be extremely improved! |
Is the dark theme plug-in required to recreate? If so, should this be a bug for them? I get the expected completions even after importing your preferences. |
I don't know. It would be strange if this problem were directly related to the Dark Theme. I will try to narrow down which is the actual preference that causes this. Maybe I will also understand if it's some other plugin fault. Meanwhile, did you try to reproduce with that theme installed? |
I tried to copy my Eclipse installation, remove the Darkest Dark Theme plugin, I still reproduce. So I'll try to narrow it down. |
I found the actual cause of the incomplete completion. I'll open a new issue for this. Do you prefer to keep this open for the content assist from compilation unit vs working copy or do you prefer to create a separate issue for it? |
Inspired by a code snippet in the old GRECLIPSE-1797.
Consider the following code (you need JUnit 4 in the buildpath):
Place the cursor at "|" and invoke code assist. Accept assertNull as a completion. You'll get:
assertNull(
Now type "m." and expect to get "m.doSomething" suggested: you get nothing instead!
To get suggestions you absolutely need to add a closing bracket corresponding to the opened bracket of
assertNull(
invocation, which however was node added by the first completion, so you need to be in this situation:Now, invoke code assist again and acceot "m.doSomething", the result is:
In other words, the closing bracket of the surrounding invocation of "assertNull" was swallowed.
So, I think there are three problems here (let me know if you prefer me to open separate issues for one or more of them):
assertNull()
m.doSomething()
in this case). I know this might have something to do with the Groovy parser and its resilience to (temporary) syntax errors, but if Greclipse could handle this correctly it would be an GIANT improvement. (this was filed as the old GRECLIPSE-1796)The text was updated successfully, but these errors were encountered: