This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 152778 - [cc] Type inference on method calls
Summary: [cc] Type inference on method calls
Status: NEW
Alias: None
Product: groovy
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker with 4 votes (vote)
Assignee: Martin Janicek
: 149715 152779 153701 225731 (view as bug list)
Depends on:
Reported: 2008-11-08 15:28 UTC by Lukas Jungmann
Modified: 2013-06-26 13:20 UTC (History)
1 user (show)

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Jungmann 2008-11-08 15:28:07 UTC
ie in this case:

new File(".").listFiles().s|

CC does not offer "sort()"
Comment 1 Petr Hejl 2008-11-08 15:37:17 UTC
I think the code completion does not work (suggesting only methods for Object) on method calls in general. So this
"new SomeObject().|" should work, while "new SomeObject().someMethod().|" does not work at all so far (afaik).

So perhaps we should make this issue P1 enhancement. I think we will need some kind of type inference in order to
determine (guess) return type of the method.
Comment 2 Petr Hejl 2008-11-08 15:41:00 UTC
Actually I didn't want to argue about the category/severity. My point was that this is missing functionality.
Comment 3 Lukas Jungmann 2008-11-08 16:04:39 UTC
...pretty important to have tracked at least (and implemented - in this case sooner is better I think)

It's quite annoying to think about that I have to be using one statement per typed variable per line instead of just
typing more statements at once to be able to use CC.

compare what I have to type:
 Process p = (command + "").execute()

to what I want to type:
 (command + "").execute().waitForOrKill(5000)

(or later maybe:
 def p = (command + "").execute()
Comment 4 Lukas Jungmann 2008-11-08 16:09:58 UTC
not sort example, but one gets an idea :-) Is issue 152779 dup or subset of this then?
Comment 5 Petr Hejl 2008-11-08 16:16:17 UTC
Could be. Depends just on scope of type inference task we will define. In general it is a subset, but I would rather
keep it tracked separate and establish some groups like 1) method calls, 2) operators 3)...

Actually there should a very very simple type inference for cases like:

def x = new Date() // the x is java.lang.Object in fact
x.| // here Date cc should be offered despite the java.lang.Object type of variable
Comment 6 Petr Hejl 2008-11-18 16:26:05 UTC
We can try to support basic scenario even for 7.0.
Comment 7 Petr Hejl 2008-11-18 16:26:49 UTC
*** Issue 149715 has been marked as a duplicate of this issue. ***
Comment 8 Martin Janicek 2012-03-03 15:06:22 UTC
Would be nice to have this as soon as possible, but not sure if there will be enough of time to do so for 7.2 --> Changing TM to Next
Comment 9 Martin Janicek 2012-12-05 10:27:50 UTC
*** Bug 152779 has been marked as a duplicate of this bug. ***
Comment 10 Martin Janicek 2012-12-05 10:29:05 UTC
*** Bug 153701 has been marked as a duplicate of this bug. ***
Comment 11 Martin Janicek 2012-12-05 10:29:23 UTC
From the issue 152779:

("" + "").| should offer same methods as: "".|

From the issue 153701:

since /regex/ (as well as ~"regex") is only a shortcut for an instance of java.util.regex.Pattern editor should be able to recognize it and offer Pattern methods in code completion (at least for cases like "/regex/.|")
Comment 12 Martin Janicek 2013-06-26 13:20:15 UTC
*** Bug 225731 has been marked as a duplicate of this bug. ***
Comment 13 Martin Janicek 2013-06-26 13:20:53 UTC
First part of the issue done in: web-main #2553ab6b0c22

The code completion works on method chain but only in cases when the "base"
variable is directly declared (statically typed). I need to spend more time on
this to get it working also for dynamic variables.