Package org.eclipse.xtext.xbase.typesystem.computation

This package contains the primary hooks for the actual type computation in Xbase as well as their respective base implementations.

See: Description

Package org.eclipse.xtext.xbase.typesystem.computation Description

This package contains the primary hooks for the actual type computation in Xbase as well as their respective base implementations. Sensible entry points to explore are the these interfaces.
  1. ITypeComputer - The primary SPI. Clients implement this interface in order to compute types or expressions. This is pretty much the only interface that is expected to be implemented by clients. It is highly recommend to inherit from the default implementation.
  2. ITypeComputationState - The state is passed around during the computation process. It allows to define expectations for child expressions and trigger their type inference. Other aspects are validation, querying for the current expected type and adding elements to the scope.
  3. ITypeExpectation - One of the currently expected types. This can be evaluated in order to compute a type which depends on the current context, e.g. a string with one character may be a Character, char or string.
  4. ITypeComputationResult - The (possibly intermediate) result of a type computation for an expression. It offers a means to query for the expected type which is the one that was finally picked from all expectations for that expression.
Useful utilities that can be used or specialized are:
  1. SynonymTypesProvider - Registers automatic conversions of existing types to others that do not depend on the current context. By default these include conversions from iterables to arrays and vice versa as well as boxing and unboxing semantics for primitives. Synonyms are not considered to be retrieved for demand conversions, e.g. function type conversion.
  2. NumberLiterals - Type computation for XNumberLiteral, e.g. which sort of concrete syntax may yield a BigDecimal or BigInteger.
  3. ClosureTypeComputer - The type computation of lambda expressions is implemented in this utility.
APIs that are considered primarily to be consumed but not specialized or implemented include
  1. Linking candidates - These implement the Java'ish logic for feature linking in combination with extension method semantics, precedences and the like.
  2. ITypeAssigner - The type assigner allows to bulk-assign local variables that are defined on the same level. Good use cases include parameters of lambdas or methods.
  3. ClosureTypeComputer - The type computation of lambda expressions is implemented in this utility.
Author:
Sebastian Zarnekow - Initial contribution and API