`source.exclude` is used in very specific cases to prevent some .nit file of directory to belong to a package.
This means two things:
* when the loader is scanning/loading a full package or group, and finds an excluded group or module, then the excluded entity will be not included in the package (and not scanned/loaded)
* when the loader is explicitly requested to load an excluded entity, then it will be detached from the parent package. The excluded modules will be considered as standalone modules.
Pull-Request: #2160
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
tags=educ,web,cli
maintainer=Alexis Laferrière <alexis.laf@xymus.net>
license=Apache-2.0
+[source]
+exclude=src/parser/parser_abs.nit
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/pep8analysis/
git=https://github.com/nitlang/nit.git
var mgrouppath = path.join_path("..").simplify_path
var mgroup = identify_group(mgrouppath)
+ if mgroup != null then
+ var mpackage = mgroup.mpackage
+ if not mpackage.accept(path) then
+ mgroup = null
+ toolcontext.info("module `{path}` excluded from package `{mpackage}`", 2)
+ end
+ end
if mgroup == null then
# singleton package
var loc = new Location.opaque_file(path)
if not stopper.file_exists then
# Recursively get the parent group
parent = identify_group(parentpath)
+ if parent != null then do
+ var mpackage = parent.mpackage
+ if not mpackage.accept(dirpath) then
+ toolcontext.info("directory `{dirpath}` excluded from package `{mpackage}`", 2)
+ parent = null
+ end
+ end
if parent == null then
# Parent is not a group, thus we are not a group either
mgroups[rdp] = null
#
# Some packages, like stand-alone packages or virtual packages have no `ini` file associated.
var ini: nullable ConfigTree = null
+
+ # Array of relative source paths excluded according to the `source.exclude` key of the `ini`
+ var excludes: nullable Array[String] is lazy do
+ var ini = self.ini
+ if ini == null then return null
+ var exclude = ini["source.exclude"]
+ if exclude == null then return null
+ var excludes = exclude.split(":")
+ return excludes
+ end
+
+ # Does the source inclusion/inclusion rules of the package `ini` accept such path?
+ fun accept(filepath: String): Bool
+ do
+ var excludes = self.excludes
+ if excludes != null then
+ var relpath = root.filepath.relpath(filepath)
+ if excludes.has(relpath) then return false
+ end
+ return true
+ end
end
redef class MGroup
var name = qid.n_id.text
var qname = qid.full_name
+ if bad_class_names[mmodule].has(qname) then
+ error(qid, "Error: class `{qname}` not found in module `{mmodule}`.")
+ return
+ end
+ bad_class_names[mmodule].add(qname)
+
var all_classes = model.get_mclasses_by_name(name)
var hints = new Array[String]
error(qid, "Error: class `{qname}` not found in module `{mmodule}`.")
end
+ # List of already reported bad class names.
+ # Used to not perform and repeat hints again and again.
+ private var bad_class_names = new MultiHashMap[MModule, String]
+
# Return the static type associated to the node `ntype`.
# `mmodule` and `mclassdef` is the context where the call is made (used to understand formal types)
# In case of problem, an error is displayed on `ntype` and null is returned.
tags=devel,cli
maintainer=Jean Privat <jean@pryen.org>
license=Apache-2.0
+[source]
+exclude=parser/parser_abs.nit:parser/.parser-nofact.nit
[upstream]
browse=https://github.com/nitlang/nit/tree/master/src
git=https://github.com/nitlang/nit.git
-s base_simple3.nit project1
-M base_simple3.nit base_simple_import.nit
-td project1/module3.nit
+test_prog --no-color
+test_prog/game/excluded.nit test_prog/game/excluded_dir/more.nit -t --no-color
--no-color -W test_advice_repeated_types.nit
--no-color base_simple3.nit; echo $?
--no-color error_mod_unk.nit; echo $?
+--no-color test_prog
+Empty README for group `excluded` (readme-warning)
+Errors: 0. Warnings: 1.
+MGroupPage excluded
+ # excluded.section
+ ## excluded.intro
+ ## excluded.concerns
+ ## excluded.concern
+ ## excluded.concern
+ ## excluded-.concern
+ ### excluded-.definition
+ #### excluded-.intros_redefs
+ ##### list.group
+ ###### excluded-.intros
+ ###### excluded-.redefs
+
+MModulePage excluded
+ # excluded.section
+ ## excluded-.intro
+ ## excluded-.importation
+ ### excluded-.graph
+ ### list.group
+ #### excluded-.imports
+ #### excluded-.clients
+
OverviewPage Overview
# home.article
## packages.section
+ ### excluded.definition
### test_prog.definition
+ReadmePage excluded
+
ReadmePage test_prog
# mdarticle-0
#### test_prog__rpg__rpg.imports
#### test_prog__rpg__rpg.clients
-Generated 96 pages
+Generated 99 pages
list:
- MPropertyPage: 58 (60.41%)
- MClassPage: 20 (20.83%)
- MModulePage: 8 (8.33%)
- MGroupPage: 4 (4.16%)
- ReadmePage: 4 (4.16%)
- SearchPage: 1 (1.04%)
- OverviewPage: 1 (1.04%)
-Found 182 mentities
+ MPropertyPage: 58 (58.58%)
+ MClassPage: 20 (20.20%)
+ MModulePage: 9 (9.09%)
+ ReadmePage: 5 (5.05%)
+ MGroupPage: 5 (5.05%)
+ SearchPage: 1 (1.01%)
+ OverviewPage: 1 (1.01%)
+Found 185 mentities
list:
- MMethodDef: 68 (37.36%)
- MMethod: 57 (31.31%)
- MClassDef: 22 (12.08%)
- MClass: 20 (10.98%)
- MModule: 8 (4.39%)
- MGroup: 4 (2.19%)
+ MMethodDef: 68 (36.75%)
+ MMethod: 57 (30.81%)
+ MClassDef: 22 (11.89%)
+ MClass: 20 (10.81%)
+ MModule: 9 (4.86%)
+ MGroup: 5 (2.70%)
+ MPackage: 2 (1.08%)
MVirtualTypeDef: 1 (0.54%)
MVirtualTypeProp: 1 (0.54%)
- MPackage: 1 (0.54%)
quicksearch-list.js
--- /dev/null
+test_prog: Test program for model tools. (test_prog)
+|--game: Gaming group (test_prog/game)
+| `--\e[1mgame\e[m: A game abstraction for RPG. (test_prog/game/game.nit)
+|--platform: Fictive Crappy Platform. (test_prog/platform)
+| `--\e[1mplatform\e[m: Declares base types allowed on the platform. (test_prog/platform/platform.nit)
+|--rpg: Role Playing Game group (test_prog/rpg)
+| |--\e[1mcareers\e[m: Careers of the game. (test_prog/rpg/careers.nit)
+| |--\e[1mcharacter\e[m: Characters are playable entity in the world. (test_prog/rpg/character.nit)
+| |--\e[1mcombat\e[m: COmbat interactions between characters. (test_prog/rpg/combat.nit)
+| |--\e[1mraces\e[m: Races of the game. (test_prog/rpg/races.nit)
+| `--\e[1mrpg\e[m: A worlg RPG abstraction. (test_prog/rpg/rpg.nit)
+`--\e[1mtest_prog\e[m: A test program with a fake model to check model tools. (test_prog/test_prog.nit)
--- /dev/null
+\e[1mexcluded\e[m (test_prog/game/excluded.nit)
+\e[1mmore\e[m (test_prog/game/excluded_dir/more.nit)
# mpackages:
-test_prog
+excluded test_prog
------------------------------------
-test_prog
+excluded test_prog
# mmodules:
-careers character combat game platform races rpg test_prog
+careers character combat excluded game platform races rpg test_prog
------------------------------------
-careers character combat game platform races rpg test_prog
+careers character combat excluded game platform races rpg test_prog
# mclasses:
Alcoholic Bool Career Character Combatable Dwarf Elf Float Game Human Int List Magician Object Race Starter String Sys Warrior Weapon
|--test_prog/README.md
|--test_prog/game
| |--test_prog/game/README.md
+| |--test_prog/game/excluded.nit
+| |--test_prog/game/excluded_dir
+| | `--test_prog/game/excluded_dir/more.nit
| `--test_prog/game/game.nit
|--test_prog/package.ini
|--test_prog/platform
--- /dev/null
+This is not a valid Nit program
--- /dev/null
+This is not a valid Nit program
maintainer=John Doe <jdoe@example.com> (http://www.example.com/~jdoe), Spider-Man
more_contributors=Riri <riri@example.com>, Fifi (http://www.example.com/~fifi), Loulou
license=Apache-2.0
+[source]
+exclude=game/excluded.nit:game/excluded_dir
[upstream]
browse=https://github.com/nitlang/nit/tree/master/tests/test_prog
git=https://github.com/nitlang/nit.git