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

Missing suggestion for property name completion in map-style constructor invocation code assist #331

Closed
mauromol opened this issue Sep 1, 2017 · 5 comments
Assignees

Comments

@mauromol
Copy link

mauromol commented Sep 1, 2017

This was the old GRECLIPSE-1772.

Consider the following:

package c
class MyBean {
	String foo
	void setBar(String bar) {
		foo = bar.toUpperCase()
	}
}

And:

package c
class ConstructorTest {
	static main(args) {
		MyBean b = new MyBean(f|)
	}
}

Invoke code at "|": I would expect Greclipse to suggest the "foo" property to start a map-style constructor invocation (just like it does if I remove the leading "f"). However, this is not the case.

@mauromol
Copy link
Author

Hi Eric,
I'm testing this with 2.9.2.xx-201710270212-e46, but I have some doubts on its implementation.
If I now try to reproduce with the given use case, the suggestions given when invoking code assist after "f", are (in this order):

  • bar
  • foo

So, it seems like the suggestions are not completely context sensitive. In fact, bar is suggested first, while I would expect foo as the very first candidate. Indeed, I would not expect to see bar suggestion at all, since it does not contain "f" in any form...
Also, if I choose bar, nothing gets inserted/replaced.

If I open the Groovy console, I see the following.

As soon as I invoke code assist (before suggestions are shown), the following is printed:

      Compiler : 10:13:35 D:\mypath\TestGroovy\src\main\groovy\c\ConstructorTest.groovy: 5: Apparent variable 'f' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable from a static context.
You misspelled a classname or statically imported field. Please check the spelling.
You attempted to use a method 'f' but left out brackets in a place not allowed by the grammar.
 @ line 5, column 31.
   		MyBeanOld b = new MyBeanOld(f)
                                 ^
Content assist : 10:13:35 Starting content assist for ConstructorTest.groovy
           DSL : 10:13:35 Getting DSL proposals for f
           DSL : 10:13:35 Event complete: 0ms: DSL proposals
Content assist : 10:13:35 Event complete: 69ms: Content assist for ConstructorTest.groovy

(please note here I've renamed MyBean to MyBeanOld, but the code is exactly the same)

When I choose "bar", the following gets printed to the status bar:

Groovy:Apparent variable 'f' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:

And that's truncated. No output either on the Groovy event console or on the error log.

@eric-milles
Copy link
Member

There are definitely a lot of rough edges that need smoothing in content assist. With current builds, this is what I see, Is it the same for you?

named-params

Named param proposals for map-style constructor are implemented within org.codehaus.groovy.eclipse.codeassist.processors.GroovyProposalTypeSearchRequestor.processAcceptedConstructors(Set, JDTResolver) if you want to have a look.

@eric-milles eric-milles reopened this Oct 30, 2017
@eric-milles
Copy link
Member

Okay, so I tested with a simple Pogo, like class Pogo { String foo, bar }. The check prop.getName().startsWith(context.completionExpression) limits the Property-based named argument proposals to ones starting with f in this case. However the Setter-based named params (lower loop) lacks this check. And so bar is being proposed as well.

@mauromol
Copy link
Author

Yes, the screenshot you attached shows what I see. I'll test the new build as soon as possible, thank you!

@mauromol
Copy link
Author

mauromol commented Nov 2, 2017

This works now in 2.9.2.xx-201711012114-e46. However I'm going to open a new enhancement request, because camel-case completion does not work yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants