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 117970 - Auto hint methods work incorretly
Summary: Auto hint methods work incorretly
Status: RESOLVED WONTFIX
Alias: None
Product: ruby
Classification: Unclassified
Component: Editing (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: issues@ruby
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-05 23:07 UTC by grzechg
Modified: 2013-11-26 17:14 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description grzechg 2007-10-05 23:07:24 UTC
When netBeans try show method for object the situation is clear only when we use simple object. eg.

arr = Array.new 
arr.(auto hint) <- showed method are corectly

but when we make situation more complicated eg.

arr.to_s.(auto hint) <- we don't see only string class method but every method include in ruby!!!

This make (auto hint) don'y useful in many cases.
Comment 1 Torbjorn Norbye 2007-10-08 01:21:19 UTC
Hi Grzegorz,
thank you for the report.

Unfortunately, evaluating something like arr.to_s. requires us to know the return type of methods. "Array.new" is a
special case we handle because we expect the method to return an object of type Array.

I recently added a few special cases; the ActiveRecord finders and a few others are now "known" types, which lets code
completion like this work:

   @articles = Article.find_all_by_tags(@dispatch_path, site.articles_per_page)
   @articles.|

I thought I had some support to handle to_s in the same way but it may not be working properly; I'll check that.

However, more general type inference including method calls with return types won't get done for 6.0, we're just about
to freeze. Adding that would be new feature work, so I'm marking this issue as an enhancement rather than a bug. I'll
leave it as a P1 since I agree this is a top priority for the next release. I have a lot of strategies that I plan to
employ to solve this problem, but I don't dare to put any of them into the product at this point since (a) I'm not sure
about the performance impact, and (b) we're way past feature freeze at this point with only fixing bugs and making the
product stable.
Comment 2 grzechg 2007-10-08 18:01:05 UTC
Hello

I don't know code of netbeans but I think - why don't use a ruby method .class ??
In this case we could before hint, copy line and in background check type eg.

arr = Array.new
hash = Hash.new
a = 1
b = 4.5
kuku = %r{fo+bar}
puts arr.class
puts hash.class
puts a.class
puts b.class
puts kuku.class

type = hash.to_a.to_s.class
puts type

As we could see in 2 last lines we have corertly class for statement.
When user type 

hash.to_a.

we copy it and in bacground fast check what type will be after this statement
using .class, and finally show user corret methods.
Comment 3 enebo 2013-11-26 17:14:10 UTC
I am resolving this not because it is not a nice suggestion but that nb ruby currently has no live type inference system in place to resolve that Array.to_s will in fact resolve to a string.  For a nice example of a library which can do this look at rsense.

Ultimately, it would be great to have better type inference but add it is a massive task and as a result this bug is rather open-ended (meaning it will be open for such a long time and it implies much more than just to_s not resoving type properly).  I am trying to knock down the number of bugs on this project so it is easier for people to find and work on bugs we can fix in the more near term.