RubyTypeInference
Contents |
This page describes current state and future plan with regard to Type Inference in the NetBeans Ruby IDE. Search for Issues tokens for planned, currently unimplemented features.
Implemented in NetBeans 7.0
TODO: describe limitations
Implemented in NetBeans 6.5
Very basic Type Inference:
TODO: describe limitations
Individual Type Inference Features
Literals
TODO: describe current support and issues
Constructor
TODO: describe current support and issues
Variables
TODO: describe current support and issues
Constants
Built-in constants
Type awareness for built-in constants, like ARGV, RUBY_VERSION, ENV, TOPLEVEL_BINDING, ...
Non-local constant:
Local constant:
TODO: describe current support and issues
Issues:
- Issue 154600: Pre-generated stubs contains misleading values and thus misleading types are inferred for constants in Standard Ruby Library
Core Methods
Real Type Inference of classes/modules from Ruby Standard Library cannot be done by static code analysis of Ruby code, since they are written in native code, e.g. C or Java (Note: what about Rubinius?). Current approach utilized in NetBeans uses RDoc-based "Type Inference" which parses RDoc of such methods which often looks like:
class Module
# mod.ancestors -> array
#
#
# Returns a list of modules included in <i>mod</i> (including
# <i>mod</i> itself).
#
....
....
#
def ancestors
# This is just a stub for a builtin Ruby method.
# See the top of this file for more info.
end
end
from which we will parse Array return type. But not all methods contain such chunks of RDoc. There are more ways to handle them TODO.
In the future we might harness other approach, e.g. the one described in Static Type Inference for Ruby paper.
Methods
Methods chaining
greeting in example below is correctly inferred as the String type and code completion offers appropriate methods on the second line.
TODO:
- infer types of expression in broken AST, like
100.between?(0, 100).|
- describe more of the current support and issues
Conditionals
TODO: describe current support and issues





