lib/java: fix and improve documentation

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
lib/java: intro `JavaObject::is_java_null`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
lib/java: use Java's `toString` to implement Nit's `to_s`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
model-clients: use `is_root_init` instead of `.name == "init"`

Signed-off-by: Jean Privat <jean@pryen.org>
model: `new` factories are named "new", not init.

It means that in `new X`, first the method name `new` is searched,
then the method named `init` as a fallback.

Signed-off-by: Jean Privat <jean@pryen.org>
model: `new` factories have a return type.

The default is the definition class, so it remove a special case for
such methods.

Signed-off-by: Jean Privat <jean@pryen.org>
typing: ANew distinguish the type of the class and the returned type

Signed-off-by: Jean Privat <jean@pryen.org>
typing: allow `new` on interface and abstract classes that have a `new`-factory

Signed-off-by: Jean Privat <jean@pryen.org>
typing: `new`-fatories are like top-level methods

Signed-off-by: Jean Privat <jean@pryen.org>
neo: Fix linking between `MProperty` and `MPropDef`.

At loading, `neo.nit` linked each `MPropDef` two times to its
`MProperty`.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
model: better implementation of the two `intro` methods

MClass and MProperty have a `intro` method the get the introducing
definition.
The initial implementation was to return the first known definition, that
make sense for a model constructed from a source-code where introductions
are read before refinements and redefinitions.

However, for a better robustness of the model that allows to load the
model form a serialized form or allows a model partially loaded, the
first-read definition is not necessary the intro.

This new implementation uses a different approach: the introduction is
the definition in the introducing compound (module for classes and
classdefs for properties). The introducing compound is known since the
construction, thus this new implementation is trivial and does not change
the API.

Signed-off-by: Jean Privat <jean@pryen.org>
neo: Remove `is_intro`.

`is_intro` is computed by the model and is ignored anyway.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
typing: ANew accepts only `init` on concrete class

Signed-off-by: Jean Privat <jean@pryen.org>
tests: add base_new.nit

Signed-off-by: Jean Privat <jean@pryen.org>
tests: update some tests because buggy `new` are let untyped

Signed-off-by: Jean Privat <jean@pryen.org>
Merge: model: better implementation of the two `intro` methods

MClass and MProperty have a `intro` method to get the introducing
definition.
The initial implementation was to return the first known definition, that
make sense for a model constructed from a source-code where introductions
are read before refinements and redefinitions.

However, for a better robustness of the model that allows to load the
model form a serialized form or allows a model partially loaded, the
first-read definition is not necessary the intro.

This new implementation uses a different approach: the introduction is
the definition in the introducing compound (module for classes and
classdefs for properties). The introducing compound is known since the
construction, thus this new implementation is trivial and does not change
the API.

Rewrite-of: #841

Pull-Request: #843
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Merge: neo: Fix definition lists

Fix the code that load relationships between a property or a class and its definitions.

Pull-Request: #841
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>
Merge: New constructors with the `new` keyword

`new` constructors where introduced with the FFI and generalized latter for intern methods.
This PR make them also legal with used-defined code in Nit.

~~~
abstract class Person
   var age: Int
   new(age: Int) do
      if i < 18 then
         return new Adult(age)
      else
         return new Child(age)
      end
end
~~~

A `new` constructor is specified like a static method.
By default it returns the type of self, but this can be changed by the user.

This PR starts by generalizing the `new` constructors. Thus a lot of specific code in engine is removed.
Then additional rules are added to control the usage of user-defined `new` constructors.

The original code was great enough to accepts these new kind of method without heavy modification.

Pull-Request: #840
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
lib: add Text::justify

Signed-off-by: Jean Privat <jean@pryen.org>
opportunity: Corrected typo in welcome message

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>