nitc :: actors_injection_phase
Injects model for the classes annotated with "is actor" sonitc :: astbuilder
Instantiation and transformation of semantic nodes in the AST of expressions and statementsnitc :: i18n_phase
Basic support of internationalization through the generation of id-to-string tablesSerializable::inspect
to show more useful information
nitc :: modelbuilder
more_collections :: more_collections
Highly specific, but useful, collections-related classes.threaded
annotation
serialization :: serialization_core
Abstract services to serialize Nit objects to different formatsnitc :: serialization_model_phase
Phase generating methods (model-only) to serialize Nit objectsnitc :: toolcontext
Common command-line tool infrastructure than handle options and error messagescore :: union_find
union–find algorithm using an efficient disjoint-set data structure
# A program that collect potential style and code issues
module nitpick
import frontend
import doc::vim_autocomplete
redef class ToolContext
# Modules to analyze, other modules will only get a shallow processing.
var mmodules_to_check = new HashSet[MModule]
redef fun phase_process_npropdef(phase, npropdef)
do
var pd = npropdef.mpropdef
# Do not analyze the property bodies outside specified modules
if pd != null and not mmodules_to_check.has(pd.mclassdef.mmodule) then return
super
end
end
# Create a tool context to handle options and paths
var toolcontext = new ToolContext
toolcontext.tooldescription = "Usage: nitpick [OPTION]... <file.nit>...\nCollect potential style and code issues."
# We do not add other options, so process them now!
toolcontext.process_options(args)
# Do not stop phases on errors
toolcontext.keep_going = true
# Get arguments
var arguments = toolcontext.option_context.rest
# We need a model to collect stuffs
var model = new Model
# A model builder to parse files
var modelbuilder = new ModelBuilder(model, toolcontext)
# Here we load and process all modules passed on the command line
var mmodules = modelbuilder.parse_full(arguments)
toolcontext.mmodules_to_check.add_all mmodules
# Blacklist warnings of not explicitly required modules
for mm in model.mmodules do
if mmodules.has(mm) then continue
toolcontext.warning_blacklist[mm.location.file].add("all")
end
modelbuilder.run_phases
toolcontext.run_global_phases(mmodules)
if toolcontext.error_count > 0 then exit(1)
src/nitpick.nit:15,1--64,43