Jean Privat [Mon, 26 Aug 2019 21:05:20 +0000 (17:05 -0400)]
parser: regenerate with comments in line annotations
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Mon, 26 Aug 2019 21:04:57 +0000 (17:04 -0400)]
grammar: enable full comments in line annotations (is ... end)
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 23 Aug 2019 13:25:28 +0000 (09:25 -0400)]
Merge: Proposal for lambda expression syntax
This extends the Nit syntax with lambdas expressions.
Lambdas are basically anonymous functions, so just accept functions without a name as expressions.
~~~nit
var x = fun(i: Int): Int do
return i + 1
end
# or on a single line
var x = fun(i: Int): Int do return i + 1 end
~~~
`fun`, `do` and `end` are mandatory, the rest is optional
~~~nit
var x = fun do end
~~~
The main weirdness is the mandatory `end` that makes the following invalid
~~~nit
# invalid:
var x = (fun(i: Int): Int do return i + 1) # missing `end`, unexpected `)`
~~~
There is no semantic yet, nor implementation, this might come in some future PR
Pull-Request: #2758
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Fri, 23 Aug 2019 13:25:26 +0000 (09:25 -0400)]
Merge: Wrapper of ICU's UTF-16 encoded strings and conversion
### `u16_string` module
This module is meant to ease the use of complex string operations provided by the ICU library. The module provides a wrapper for ICU's string structure : `UChar *` as well as conversion fucntions to/from `String` and `CString`
### Remarks
- In order to convert a `String` to a `U16String`, the string must be converted to a `CString` first. Since `CString`'s are null temrinated, `U16String`'s also have to be null terminated and cannot have embedded termination characters.
- I am having some issues with DocUnits blocs thus there are no tests in the comments at the moment.
- I added an other `new` operator to the `CString` class which only returns a `null` string
Pull-Request: #2773
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 23 Aug 2019 13:25:22 +0000 (09:25 -0400)]
Merge: Adding a Windows build test
In parallel, a new Gitlab Runner tagged "windows" was added. This new test only builds the project.
Pull-Request: #2776
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 23 Aug 2019 13:25:19 +0000 (09:25 -0400)]
Merge: Abstract_text: Add a method to get string representation of float in scientific notation
Add a method `to_se` to get the string representation of float in scientific notation.
```
123.45.to_se == "1.2345e+02"
0.001234.to_se == "1.234e-03"
10860460000.0.to_se == "1.086046e+10"
```
The to_se method have a precision between 1 to 6 max decimal. The precision is adapted in function of the number.
Add a `to_precision_size_with_format` and `to_precision_fill_with_format` method to get the representation in a specific given format
Pull-Request: #2785
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>
Florian Deljarry [Sun, 18 Aug 2019 20:24:47 +0000 (16:24 -0400)]
abstract_text: Refactorisation of the to_s method
Split the code of the `to_s` for use this in the `to_sci`. Now all conversion method uses the `to_precision_size_with_format` and `to_precision_fill_with_format`
Signed-off-by: Florian Deljarry <deljarry.florian@gmail.com>
Florian Deljarry [Sun, 18 Aug 2019 20:17:01 +0000 (16:17 -0400)]
abstract_text: Add the `to_sci` to get the string representation of a float in scientific notation
Signed-off-by: Florian Deljarry <deljarry.florian@gmail.com>
Ana Daouda [Tue, 20 Aug 2019 16:04:01 +0000 (12:04 -0400)]
.gitlab-ci.yml: adding a Windows build test
Signed-off-by: Ana Daouda <anadaouda@gmail.com>
Ana Daouda [Fri, 16 Aug 2019 20:17:03 +0000 (16:17 -0400)]
lib/core/text: Wrapper of ICU's UTF-16 encoded strings and conversion
Signed-off-by: Ana Daouda <anadaouda@gmail.com>
Jean Privat [Mon, 19 Aug 2019 18:43:08 +0000 (14:43 -0400)]
Merge: mongodb: Fixed failing test for `aggregate` method.
The test assumed the query would return in some order when it is not.
Added a "$sort" stage to the pipeline to avoid miss index asserts.
This PR fixed gitlab-ci test pipeline.
Signed-off-by: Louis-Vincent Boudreault <lv.boudreault95@gmail.com>
Pull-Request: #2783
Jean Privat [Mon, 19 Aug 2019 18:43:04 +0000 (14:43 -0400)]
Merge: compiler: Refactored `AbstractRuntimeFunction`
Removed duplicate code across all the compiler and made
`AbstractRuntimeFunction` implement Template Design pattern.
This allows for better code reuse and easier customization.
Removed the notion of "virtual function" and unified it with the concept
of thunk function. A thunk is an intermediary function between a caller
and a callee whose purpose is to compute thing before or after the
callee gets invoke. Currently, the only usages of thunks are to do conversions (casting)
before calling the actual callee. Thunks can be created by inheriting
`abstract_compiler::ThunkFunction` which provides a default
implementation. Furthermore, this class simplify the old code of
`SeparateRuntimeFunction` by replacing `if` with actual polymorphism.
Finally, thunks will be used to implement callref mechanics.
Signed-off-by: Louis-Vincent Boudreault <lv.boudreault95@gmail.com>
Pull-Request: #2782
Jean Privat [Mon, 8 Jul 2019 19:08:57 +0000 (15:08 -0400)]
tests: update error message of test_parser_args7.res
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 4 Jul 2019 19:36:10 +0000 (15:36 -0400)]
tests: add syntax_lambda to check various forms
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 4 Jul 2019 19:35:00 +0000 (15:35 -0400)]
parser: regenerate with lambda
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 4 Jul 2019 19:34:29 +0000 (15:34 -0400)]
syntax: add lambda construction with the fun keyword
Signed-off-by: Jean Privat <jean@pryen.org>
Louis-Vincent Boudreault [Fri, 16 Aug 2019 13:56:36 +0000 (09:56 -0400)]
mongodb: Fixed failing test for `aggregate` method.
The test assumed the query would return in some order when it is not.
Added a "$sort" stage to the pipeline to avoid miss index asserts.
Signed-off-by: Louis-Vincent Boudreault <lv.boudreault95@gmail.com>
Louis-Vincent Boudreault [Thu, 15 Aug 2019 19:22:24 +0000 (15:22 -0400)]
compiler: Refactor `AbstractRuntimeFunction`
Removed duplicate code across all the compiler and made
`AbstractRuntimeFunction` implement Template Design pattern.
This allow for better code reuse and easier to customization.
Removed the notion of "virtual function" and unified it with the concept
of thunk function. A thunk is an intermediary function between a caller
and a callee whose purpose is to compute thing before or after the
callee gets invoke. Currently, the only usages of thunks is to do conversion (casting)
before calling the actual callee. Thunks can be created by inheriting
`abstract_compiler::ThunkFunction` which provides a default
implementation. Furthermore, this class simplify the old code of
`SeparateRuntimeFunction` by replacing `if` with actual polymorphism.
Finally, thunks will be used to implement callref mechanics.
Signed-off-by: Louis-Vincent Boudreault <lv.boudreault95@gmail.com>
Jean Privat [Wed, 14 Aug 2019 15:23:30 +0000 (11:23 -0400)]
Merge: abstract_compiler: Replace the use of `n_float` by the `value`
## Added methods
Add a little improvement of the abstract_compiler to generate a Float value by the usage of the `value` and not the `n_float`.
Add the float conversion in exponential hexadecimal notation.
```
assert 12.345.to_hexa_exponential_notation == "0x1.8b0a3d70a3d71p+3"
assert 12.345.to_hexa_exponential_notation.to_f == 12.345
```
## Future work
Take into account the scientific notation for the display.
Pull-Request: #2778
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Wed, 14 Aug 2019 15:22:30 +0000 (11:22 -0400)]
Merge: MModule: new method `add_mclassdef` to avoid incoherent cache state.
Currently, the constructor of `MClassDef` would directly add itself in the `MModule`, like so:
`mmodule.mclassdefs.add(self)`. However, this could out of date `MModule:flatten_mclass_hierarchy`.
If we want better support for model manipulation after all the semantic phases, we need more logic when adding a new `MClassDef` in the hierarchy.
Moreover, this allows better protection since `MClassDef` no longer needs to know `mmodule.mclassdefs`.
Signed-off-by: Louis-Vincent Boudreault <lv.boudreault95@gmail.com>
Pull-Request: #2777
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Wed, 14 Aug 2019 15:22:26 +0000 (11:22 -0400)]
Merge: Callref syntax
Note: I forgot to independently PR the syntax for callrefs (used by #2774), so here it is.
Introduce the `&` syntax to capture and reference calls.
This is used to provide a simple *function pointer* construction that will be used later to implement full lambdas. However, this is not expected to be used by lambda programmers :)
```nit
var ref = &recv.foo
```
Currently, the syntax is analogous to a simple call (recv.foo) with a prefix `&`.
On chains, only the last call is captured (`.` have a higer precedence than `&`)
```nit
var r = &foo.bar.baz
# is equivalent with
var x = foo.bar
var r = &x.baz
```
Since the syntax is analogous to a call (except the &), there is always a receiver (including the implicit self or sys) and arguments are accepted by the parser.
```nit
var r = &foo
# is equivalent with
var r = &self.foo
```
There is no clear syntax proposal to avoid the capture of a receiver since a receiver is statically expected to resolve the method name.
Pull-Request: #2775
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Wed, 14 Aug 2019 15:22:21 +0000 (11:22 -0400)]
Merge: fix nitcc assert failure and nitcc continuous integration
Since #2573, some nitcc tests failed on a self-check (because the trim function did not correctly remove tags on trimmed nodes).
The bug was benign and easily fixable, but the subversion of the expectation was that the script kind of forgot about correctly reporting the error (an error message was printed but a success error code was returned). So the whole CI job was a success as failed tests where unreported.
Reported-by: Florian Deljarry <deljarry.florian@gmail.com>
Pull-Request: #2772
Florian Deljarry [Mon, 12 Aug 2019 20:15:24 +0000 (16:15 -0400)]
text/abstract_text: Adds the float conversion in exponential hexadecimal notation
Signed-off-by: Florian Deljarry <deljarry.florian@gmail.com>
Jean Privat [Tue, 9 Jul 2019 15:11:03 +0000 (11:11 -0400)]
tests: add syntax_callref.nit
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 9 Jul 2019 15:11:18 +0000 (11:11 -0400)]
typing: stub to handle callrefs
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 9 Jul 2019 15:10:23 +0000 (11:10 -0400)]
scope: refuse `&x` where x is a local variable
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 9 Jul 2019 15:09:49 +0000 (11:09 -0400)]
parser: regenerate with callrefs
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 9 Jul 2019 15:09:29 +0000 (11:09 -0400)]
syntax: add call reference (funref+recv capture) `&x.foo`
Signed-off-by: Jean Privat <jean@pryen.org>
Florian Deljarry [Mon, 12 Aug 2019 20:22:11 +0000 (16:22 -0400)]
abstract_compiler: Replace the use of `n_float` by the `value`
Signed-off-by: Florian Deljarry <deljarry.florian@gmail.com>
Louis-Vincent Boudreault [Mon, 12 Aug 2019 13:42:55 +0000 (09:42 -0400)]
MModule: new method `add_mclassdef` to avoid incoherent cache state.
Signed-off-by: Louis-Vincent Boudreault <lv.boudreault95@gmail.com>
Jean Privat [Fri, 19 Jul 2019 00:59:11 +0000 (20:59 -0400)]
CI: nitunit_some skips contrib since some code might be generated
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 18 Jul 2019 18:39:57 +0000 (14:39 -0400)]
Merge: Safe call operator
A long time ago, there was a proposal to have a safe call operator in Nit #1274 `x?.foo` that executes the call if `x` is not null and returns null otherwise (instead of aborting).
This was refused because at the time, the syntax `x?.foo` was considered weird and not POLA.
Moreover, what was proposed was a more general version of the concept that could be used everywhere, not only as a receiver that made the semantic quite complex and even less POLA.
Nowadays, most languages have adopted it https://en.wikipedia.org/wiki/Safe_navigation_operator so the syntax and behavior is not as weird as before.
This operator is nice in the context of Nit with nullable types since if avoids to use chained `if x != null then x.foo` and plays nicely with the type system.
Currently, only explicit dotted calls are handled; e.g. `x?.foo`, I'm not sure if something should be done with other call constructions like `x + y` or `x[y]`.
Pull-Request: #2761
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Thu, 18 Jul 2019 18:08:18 +0000 (14:08 -0400)]
nitcc: tests script return non-zero on failure (print is not enough)
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 18 Jul 2019 18:06:52 +0000 (14:06 -0400)]
nitcc: trim also remove tags on bad states
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Mon, 15 Jul 2019 15:08:16 +0000 (11:08 -0400)]
Merge: ci: generate metrics output in an artifact file
Results for nitmetrics should be easily available.
Pull-Request: #2771
Jean Privat [Mon, 15 Jul 2019 15:08:12 +0000 (11:08 -0400)]
Merge: fix ci nitunit some
When there is no change in watched nit files, the job `nitunit_some` failed.
Pull-Request: #2770
Jean Privat [Mon, 15 Jul 2019 15:08:09 +0000 (11:08 -0400)]
Merge: Introduce `test_frontend`
Sometimes we need to test things related to a model and it's not easy to do this with NitUnit since creating
a model by hand is tedious.
With the `TestModel` abstract suite it's easier:
```nit
module my_test is test
import test_frontend
class MyTest
super TestModel
test
redef var test_src = "path/to/files"
fun my_test is test do
assert test_model.mmodules.length == 1
end
end
```
Pull-Request: #2769
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Mon, 15 Jul 2019 15:08:04 +0000 (11:08 -0400)]
Merge: doc: Rename `synopsys` into `synopsis`
Typo found in a lot of places ported since the very first `nitdoc` version I think.
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Pull-Request: #2768
Jean Privat [Mon, 15 Jul 2019 15:08:00 +0000 (11:08 -0400)]
Merge: metrics: ReadmeMetrics uses markdown2
Some leftovers introducing the new markdown parser.
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Pull-Request: #2767
Jean Privat [Mon, 15 Jul 2019 15:07:57 +0000 (11:07 -0400)]
Merge: Update basic requirements and document them
Since #2615 we broke the initial build according to the documentation since nitpm (picnit) requires libcurl.
To minimize the number of doc to update I just moved `nitpm` to the "more" set of tools and documented their requirements.
I also added a CI job to avoid future failures (note: I'm not sure how to adapt it on other docker-less platforms).
Pull-Request: #2766
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Mon, 15 Jul 2019 15:07:28 +0000 (11:07 -0400)]
Merge: Move back manual to the main repo
The manual is slowly bit rotting in the wiki (the disclaimer in http://nitlanguage.org/manual/ and the link to the very old issue #761 is not a nice thing to have).
The idea is to move back the documentation in the main repository so that PR that enhance the language should also update the manual.
We could add checks to ensure that new AST element or annotations implies some update in the manual.
It is what is currently done with the manpages of the tools, and they are quite complete and up to date.
Pull-Request: #2762
Jean Privat [Mon, 15 Jul 2019 15:07:24 +0000 (11:07 -0400)]
Merge: Clean old projects from `contrib`
This PR removes 3 old projects from `contrib` that are no more used nor interesting:
* `neo_doxygen`
* `refund`
* `wiringPi`
222 files and 25k LOC less :D
Pull-Request: #2764
Jean Privat [Mon, 15 Jul 2019 15:07:20 +0000 (11:07 -0400)]
Merge: github: Summer cleaning
Some cleaning to the `github` lib.
Most interesting changes:
* kill `github_curl` and migrate clients (`github_merge`, `github_search_for_jni`)
* clean deserialization process heuristics for something more robust and readable (but a bit slower)
* array pagination
* kill `GithubEntity`
* remove ISO date methods
* mock testing for `github::wallet`
* `wallet` uses a `Logger`
This PR can be read commit by commit.
Pull-Request: #2765
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Mon, 15 Jul 2019 15:05:18 +0000 (11:05 -0400)]
ci: generate metrics output in an artifact file
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Mon, 15 Jul 2019 13:57:59 +0000 (09:57 -0400)]
tests: error_syntax errors on `? now
Signed-off-by: Jean Privat <jean@pryen.org>
Alexandre Terrasa [Sun, 14 Jul 2019 18:42:00 +0000 (14:42 -0400)]
indexing: Use `test_frontend`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Sun, 14 Jul 2019 18:41:38 +0000 (14:41 -0400)]
doc: Commands tests use `test_frontend`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Sun, 14 Jul 2019 18:01:30 +0000 (14:01 -0400)]
frontend: Introduce `test_frontend` to easily test model related code
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Sun, 14 Jul 2019 16:55:45 +0000 (12:55 -0400)]
doc: Rename `synopsys` into `synopsis`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Sun, 14 Jul 2019 15:37:52 +0000 (11:37 -0400)]
metrics: ReadmeMetrics uses markdown2
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Fri, 12 Jul 2019 19:53:19 +0000 (15:53 -0400)]
Merge: ci: basic bench with old branch
This adds a job where a basic execution is compared against origin/master is order to catch important time or space regressions. Because the test machine is shared with many jobs, the results are not that reliable and some additional checks by the integrator might be required.
However, the script can help developers to do a basic check to document their PR.
Pull-Request: #2739
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Jean Privat [Fri, 12 Jul 2019 19:53:15 +0000 (15:53 -0400)]
Merge: typing: get_method refactoring
Split the get_method to three different entry points. These new entry points make it possible to adapt the treatment to the actual context. This avoids creating callsites manually and in the same time do the verification if the researched method exist (display an error if not exist)
Signed-off-by: Florian Deljarry <deljarry.florian@gmail.com>
Pull-Request: #2760
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 12 Jul 2019 19:53:10 +0000 (15:53 -0400)]
Merge: nitc: fix --keep-going in the compiler broken by
539ca148d
Also add tests to avoid that again
Pull-Request: #2763
Jean Privat [Wed, 10 Jul 2019 14:59:09 +0000 (10:59 -0400)]
ci: compile the manual
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 12 Jul 2019 18:00:41 +0000 (14:00 -0400)]
ci: do not error when nothing with nitunit_some
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 12 Jul 2019 19:11:57 +0000 (15:11 -0400)]
ci: tests that requirements for tools are still OK
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 12 Jul 2019 19:09:34 +0000 (15:09 -0400)]
README: update the state of requirements
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 12 Jul 2019 18:23:12 +0000 (14:23 -0400)]
tools: move nitpm to more_tools since it requires libcurl
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 10 Jul 2019 14:58:57 +0000 (10:58 -0400)]
doc/manual: put back the manual in the main repository
Currently it bit rot in the wiki :(
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 10 Jul 2019 20:13:11 +0000 (16:13 -0400)]
nitc: fix --keep-going in the compiler broken by
539ca148d
Signed-off-by: Jean Privat <jean@pryen.org>
Florian Deljarry [Tue, 9 Jul 2019 20:21:41 +0000 (16:21 -0400)]
typing: get_method refactoring
Split the get_method to three different entry points. These new entry points make it possible to adapt the treatment to the actual context.
Signed-off-by: Florian Deljarry <deljarry.florian@gmail.com>
Jean Privat [Wed, 10 Jul 2019 14:06:22 +0000 (10:06 -0400)]
tests: add base_safe.nit for safe calls
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 10 Jul 2019 13:59:27 +0000 (09:59 -0400)]
typing and engines: handle safe calls `x?.foo`
Signed-off-by: Jean Privat <jean@pryen.org>
Alexandre Terrasa [Thu, 11 Jul 2019 02:35:40 +0000 (22:35 -0400)]
github: Remove old logging
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 11 Jul 2019 02:35:19 +0000 (22:35 -0400)]
github: Clean `get_contributor_stats`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 9 Jul 2019 03:15:31 +0000 (23:15 -0400)]
github: Kill `github_curl`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 9 Jul 2019 03:14:48 +0000 (23:14 -0400)]
github_search_for_jni: Migrate to new Github API
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 9 Jul 2019 03:14:27 +0000 (23:14 -0400)]
github_merge: Migrate to new Github API
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Thu, 11 Jul 2019 12:31:53 +0000 (08:31 -0400)]
ci: clean ccache stats to see the real effect of ccaching
Signed-off-by: Jean Privat <jean@pryen.org>
Alexandre Terrasa [Thu, 11 Jul 2019 01:05:13 +0000 (21:05 -0400)]
github: Introduce `get_pull_comments`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 11 Jul 2019 00:59:12 +0000 (20:59 -0400)]
github: Rename `ReviewComment` in `PullComment`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 11 Jul 2019 00:57:08 +0000 (20:57 -0400)]
github: Rename `get_review_comment` in `get_pull_comment`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 11 Jul 2019 00:42:13 +0000 (20:42 -0400)]
github: Introduce `get_commit_status`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 11 Jul 2019 01:08:55 +0000 (21:08 -0400)]
github: Repo::default_branch can actually be null...
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 9 Jul 2019 00:57:24 +0000 (20:57 -0400)]
github: GithubWallet uses logger
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 9 Jul 2019 00:44:53 +0000 (20:44 -0400)]
github: GithubWallet uses optional attributes
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 9 Jul 2019 00:44:28 +0000 (20:44 -0400)]
github: Add mock testing for GithubWallet
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 11 Jul 2019 01:24:37 +0000 (21:24 -0400)]
github: Clean GithubAPI deserialization
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Fri, 21 Jun 2019 03:12:30 +0000 (23:12 -0400)]
gihtub: Remove ISODate
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Fri, 21 Jun 2019 03:08:12 +0000 (23:08 -0400)]
github: Remove GithubEntity
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Fri, 21 Jun 2019 02:56:22 +0000 (22:56 -0400)]
github: Decouple API from responses instances
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Fri, 21 Jun 2019 02:27:06 +0000 (22:27 -0400)]
github: Remove method `GithubAPI::get_branch_commits`
Let clients handle that.
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 11 Jul 2019 01:21:34 +0000 (21:21 -0400)]
github: `search_issues` returns a SearchResults
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 11 Jul 2019 01:20:16 +0000 (21:20 -0400)]
github: Remove `get_repo_last_issue`
This was a terrible hack...
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Fri, 21 Jun 2019 02:25:16 +0000 (22:25 -0400)]
github: Refactorize array requests
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Fri, 21 Jun 2019 00:33:20 +0000 (20:33 -0400)]
github: Rename `GithubAPI::load_` methods in `get_`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Fri, 21 Jun 2019 00:44:38 +0000 (20:44 -0400)]
github: Move deserialization process to `get`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Fri, 21 Jun 2019 01:22:17 +0000 (21:22 -0400)]
github: Decouple GithubAPI from `GithubCurl`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 11 Jul 2019 00:06:26 +0000 (20:06 -0400)]
contrib: Kill `wiringPi`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 11 Jul 2019 00:05:50 +0000 (20:05 -0400)]
contrib: Kill `refund`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 11 Jul 2019 00:05:08 +0000 (20:05 -0400)]
contrib: Kill `neo_doxygen`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Sat, 23 Feb 2019 03:13:05 +0000 (22:13 -0500)]
ci: basic bench with old branch
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 10 Jul 2019 13:56:38 +0000 (09:56 -0400)]
interpreter: add `Instance::is_null` to simplify code
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 10 Jul 2019 13:56:01 +0000 (09:56 -0400)]
parser: regenerate with safe call `x?.foo`
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 10 Jul 2019 13:54:14 +0000 (09:54 -0400)]
syntax: add safe call syntax `x?.foo`
Signed-off-by: Jean Privat <jean@pryen.org>
Alexandre Terrasa [Wed, 19 Jun 2019 03:22:32 +0000 (23:22 -0400)]
github: API use new constructors
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Wed, 3 Jul 2019 18:50:57 +0000 (14:50 -0400)]
Merge: nitrpg: Move `nitrpg` to its own repository
`nitrpg` is broken since a long time. I think https:/api.github.com actually changed twice since it broke. I don't plan on killing it yet but I moved it to its own repository until I worked again on it (or never).
See https://github.com/Morriar/nitrpg.
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Pull-Request: #2755
Jean Privat [Wed, 3 Jul 2019 18:50:53 +0000 (14:50 -0400)]
Merge: Mock Github API tests
This PR adds a mock to GithubAPI so we can avoid sending requests to the API on CI.
For each API call we save the actual Github response body from the API and reuse it during the tests.
The attribute `update_responses_cache` can be set to `true` so the cache files are updated from the API when `nitunit` is called.
Pull-Request: #2753
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 3 Jul 2019 18:50:48 +0000 (14:50 -0400)]
Merge: Follow the INI specification
This version follows more closely the INI specification (https://en.wikipedia.org/wiki/INI_file) and adds some improvements to the API.
Spec changes:
* Allow `#` and `;` for comments
* No more sections nesting as by the spec (which actually change nothing see below)
API changes:
* Renaming `ConfigTree` -> `IniFile` (as it's no more a "tree")
* No more coupling with a file path, use utility methods `load_string`, `load_file`, `write_to` instead
* Ability to iterate keys, values, sections and section content
* Ability to create `IniSection` by hand
* `IniFile` and `IniSection` implements `Map[String, nullable String]`
The biggest change is that sub-sections are now flattened.
Before, with the following ini:
~~~ini
[section1]
key1=value1
[section1.section2]
key2=value2
~~~
You would get this hierarchy:
~~~
section1
| key1=value1
`- section2
`- key2=value2
~~~
Now you get:
~~~
section1
`- key1=value1
section1.section2
`- key2=value2
~~~
Two independent (unnested) sections, one called `section1` and the other called `section1.section2`.
This actually change nothing if the client was using the `[]` operator with the `.` notation as:
~~~
ini["section1.section2.key2"] # still returns `value2`
~~~
Documentation and specification from the README:
# `ini` - Read and write INI configuration files
[INI files](https://en.wikipedia.org/wiki/INI_file) are simple text files with
a basic structure composed of sections, properties and values used to store
configuration parameters.
Here's an example from the `package.ini` of this package:
~~~nit
import ini
var package_ini = """
[package]
name=ini
desc=Read and write INI configuration files.
[upstream]
git=https://github.com/nitlang/nit.git
git.directory=lib/ini/
"""
~~~
## Basic usage
`IniFile` is used to parse INI strings and access their content:
~~~nit
var ini = new IniFile.from_string(package_ini)
assert ini["package.name"] == "ini"
assert ini["upstream.git.directory"] == "lib/ini/"
assert ini["unknown.unknown"] == null
~~~
`IniFile` can also load INI configuration from a file:
~~~nit
package_ini.write_to_file("my_package.ini")
ini = new IniFile.from_file("my_package.ini")
assert ini["package.name"] == "ini"
assert ini["upstream.git.directory"] == "lib/ini/"
"my_package.ini".to_path.delete
~~~
INI content can be added or edited through the `IniFile` API then written to
a stream or a file.
~~~nit
ini["package.name"] = "new name"
ini["upstream.git.directory"] = "/dev/null"
ini["section.key"] = "value"
var stream = new StringWriter
ini.write_to(stream)
assert stream.to_s == """
[package]
name=new name
desc=Read and write INI configuration files.
[upstream]
git=https://github.com/nitlang/nit.git
git.directory=/dev/null
[section]
key=value
"""
~~~
## INI content
### Properties
Properties are the basic element of the INI format.
Every property correspond to a *key* associated to a *value* thanks to the equal (`=`) sign.
~~~nit
ini = new IniFile.from_string("""
key1=value1
key2=value2
""")
assert ini["key1"] == "value1"
assert ini["key2"] == "value2"
assert ini.length == 2
~~~
Accessing an unknown property returns `null`:
~~~nit
assert ini["unknown"] == null
~~~
Properties can be iterated over:
~~~nit
var i = 1
for key, value in ini do
assert key == "key{i}"
assert value == "value{i}"
i += 1
end
~~~
Property keys cannot contain the character `=`.
Values can contain any character.
Spaces are trimmed.
~~~nit
ini = new IniFile.from_string("""
prop=erty1=value1
property2 = value2
property3=value3 ; with semicolon
""")
assert ini[";property1"] == null
assert ini["prop=erty1"] == null
assert ini["prop"] == "erty1=value1"
assert ini["property2"] == "value2"
assert ini[" property2 "] == "value2"
assert ini["property3"] == "value3 ; with semicolon"
~~~
Both keys and values are case sensitive.
~~~nit
ini = new IniFile.from_string("""
Property1=value1
property2=Value2
""")
assert ini["property1"] == null
assert ini["Property1"] == "value1"
assert ini["property2"] != "value2"
assert ini["property2"] == "Value2"
~~~
### Sections
Properties may be grouped into arbitrary sections.
The section name appears on a line by itself between square brackets (`[` and `]`).
All keys after the section declaration are associated with that section.
The is no explicit "end of section" delimiter; sections end at the next section
declaration or the end of the file.
Sections cannot be nested.
~~~nit
var content = """
key1=value1
key2=value2
[section1]
key1=value3
key2=value4
[section2]
key1=value5
"""
ini = new IniFile.from_string(content)
assert ini["key1"] == "value1"
assert ini["unknown"] == null
assert ini["section1.key1"] == "value3"
assert ini["section1.unknown"] == null
assert ini["section2.key1"] == "value5"
~~~
Sections can be iterated over:
~~~nit
i = 1
for section in ini.sections do
assert section.name == "section{i}"
assert section["key1"].has_prefix("value")
i += 1
end
~~~
When iterating over a file properties, only properties at root are returned.
`flatten` can be used to iterate over all properties including the one from
sections.
~~~nit
assert ini.join(", ", ": ") == "key1: value1, key2: value2"
assert ini.flatten.join(", ", ": ") ==
"key1: value1, key2: value2, section1.key1: value3, section1.key2: value4, section2.key1: value5"
i = 0
for key, value in ini do
i += 1
assert key == "key{i}" and value == "value{i}"
end
assert i == 2
~~~
Sections name may contain any character including brackets (`[` and `]`).
Spaces are trimmed.
~~~nit
ini = new IniFile.from_string("""
[[section1]]
key=value1
[ section 2 ]
key=value2
[section1.section3]
key=value3
""")
assert ini.sections.length == 3
assert ini["[section1].key"] == "value1"
assert ini["section 2.key"] == "value2"
assert ini["section1.section3.key"] == "value3"
assert ini.sections.last.name == "section1.section3"
~~~
The dot `.` notation is used to create new sections with `[]=`.
Unknown sections will be created on the fly.
~~~nit
ini = new IniFile
ini["key"] = "value1"
ini["section1.key"] = "value2"
ini["section2.key"] = "value3"
stream = new StringWriter
ini.write_to(stream)
assert stream.to_s == """
key=value1
[section1]
key=value2
[section2]
key=value3
"""
~~~
Sections can also be created manually:
~~~nit
ini = new IniFile
ini["key"] = "value1"
var section = new IniSection("section1")
section["key"] = "value2"
ini.sections.add section
stream = new StringWriter
ini.write_to(stream)
assert stream.to_s == """
key=value1
[section1]
key=value2
"""
~~~
### Comments
Comments are indicated by semicolon (`;`) or a number sign (`#`) at the begining
of the line. Commented lines are ignored as well as empty lines.
~~~nit
ini = new IniFile.from_string("""
; This is a comment.
; property1=value1
# This is another comment.
# property2=value2
""")
assert ini.is_empty
~~~
### Unicode support
INI files support Unicode:
~~~nit
ini = new IniFile.from_string("""
property❤=héhé
""")
assert ini["property❤"] == "héhé"
~~~
Pull-Request: #2752
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 3 Jul 2019 18:50:43 +0000 (14:50 -0400)]
Merge: Introduce `Logger`, a simple yet powerful logging system
# A simple logger for Nit
## Basic Usage
Create a new `Logger` with a severity level threshold set to `warn_level`:
~~~nit
var logger = new Logger(warn_level)
~~~
Messages with a severity equal or higher than `warn_level` will be displayed:
~~~nit
logger.error "Displays an error."
logger.warn "Displays a warning."
~~~
Messages with a lower severity are silenced:
~~~nit
logger.info "Displays nothing."
~~~
`FileLogger` can be used to output the messages into a file:
~~~nit
var log_file = "my.log"
logger = new FileLogger(warn_level, log_file, append = false)
logger.error("An error")
logger.info("Some info")
logger.close
assert log_file.to_path.read_all == "An error\n"
log_file.to_path.delete
~~~
## Severity levels
Each message is associated with a level that indicate its severity.
Only messages with a severity equal to or higher than the logger `level`
threshold will be displayed.
Severity levels from the most severe to the least severe:
* `unknown_level`: An unknown message that should always be outputted.
* `fatal_level`: An unhandleable error that results in a program crash.
* `error_level`: A handleable error condition.
* `warn_level`: A warning.
* `info_level`: Generic (useful) information about system operation.
* `debug_level`: Low-level information for developpers.
## Formatting messages
You can create custom formatters by implementing the `Formatter` interface.
~~~nit
class MyFormatter
super Formatter
redef fun format(level, message) do
if level < warn_level then return message
return "!!!{message}!!!"
end
end
~~~
See `DefaultFormatter` for a more advanced implementation example.
Each Logger can be given a default formatter used to format the every messages
before outputting them:
~~~nit
var formatter = new MyFormatter
var stderr = new StringWriter
var logger = new Logger(warn_level, stderr, formatter)
logger.warn("This is a warning.")
assert stderr.to_s.trim.split("\n").last == "!!!This is a warning.!!!"
~~~
Optionally, a `Formatter` can be given to replace the `default_formatter`
used by default:
~~~nit
# Create a formatter with no default decorator
logger = new Logger(warn_level, stderr, null)
# Display a message without any formatter
logger.warn("This is a warning.")
assert stderr.to_s.trim.split("\n").last == "This is a warning."
# Display a message with a custom formatter
logger.warn("This is a warning.", formatter)
assert stderr.to_s.trim.split("\n").last == "!!!This is a warning.!!!"
~~~
Pull-Request: #2751
Reviewed-by: Jean Privat <jean@pryen.org>