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
19 import doc
::vim_autocomplete
21 redef class ToolContext
22 # Modules to analyze, other modules will only get a shallow processing.
23 var mmodules_to_check
= new HashSet[MModule]
24 redef fun phase_process_npropdef
(phase
, npropdef
)
26 var pd
= npropdef
.mpropdef
28 # Do not analyze the property bodies outside specified modules
29 if pd
!= null and not mmodules_to_check
.has
(pd
.mclassdef
.mmodule
) then return
34 # Create a tool context to handle options and paths
35 var toolcontext
= new ToolContext
36 toolcontext
.tooldescription
= "Usage: nitpick [OPTION]... <file.nit>...\nCollect potential style and code issues."
38 # We do not add other options, so process them now!
39 toolcontext
.process_options
(args
)
41 # Do not stop phases on errors
42 toolcontext
.keep_going
= true
45 var arguments
= toolcontext
.option_context
.rest
47 # We need a model to collect stuffs
49 # A model builder to parse files
50 var modelbuilder
= new ModelBuilder(model
, toolcontext
)
52 # Here we load and process all modules passed on the command line
53 var mmodules
= modelbuilder
.parse_full
(arguments
)
54 toolcontext
.mmodules_to_check
.add_all mmodules
56 modelbuilder
.run_phases
57 toolcontext
.run_global_phases
(mmodules
)