1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # A program that collect potential style and code issues
20 redef class ToolContext
21 # Modules to analyze, other modules will only get a shallow processing.
22 var mmodules_to_check
= new HashSet[MModule]
23 redef fun phase_process_npropdef
(phase
, npropdef
)
25 var pd
= npropdef
.mpropdef
27 # Do not analyze the property bodies outside specified modules
28 if pd
!= null and not mmodules_to_check
.has
(pd
.mclassdef
.mmodule
) then return
33 # Create a tool context to handle options and paths
34 var toolcontext
= new ToolContext
35 toolcontext
.tooldescription
= "Usage: nitpick [OPTION]... <file.nit>...\nCollect potential style and code issues."
37 # We do not add other options, so process them now!
38 toolcontext
.process_options
(args
)
41 var arguments
= toolcontext
.option_context
.rest
43 # We need a model to collect stuffs
45 # A model builder to parse files
46 var modelbuilder
= new ModelBuilder(model
, toolcontext
)
48 # Here we load an process all modules passed on the command line
49 var mmodules
= modelbuilder
.parse
(arguments
)
50 toolcontext
.mmodules_to_check
.add_all mmodules
52 modelbuilder
.run_phases