@@ -31,6 +31,61 @@ function lint_file(filepath::AbstractString, root = nothing, server = SymbolServ
3131 return file
3232end
3333
34+
35+ using Pkg: develop
36+ using CodeTools: getmodule
37+
38+ export lint_module
39+ """
40+ lint_module(modul::Module)
41+ lint_module(module_name::String)
42+
43+ lint a module and get the result as a StaticLint.File
44+
45+ # Examples
46+ ```julia
47+ using Test1
48+ fileserver = lint_module(Test1)
49+ ```
50+
51+ ```julia
52+ fileserver = lint_module("./test")
53+ ```
54+ """
55+ function lint_module (path:: AbstractString )
56+ module_name, modul_path = module_name_root (path)
57+ Pkg. develop (path= modul_path)
58+ modul = CodeTools. getmodule (module_name)
59+ if isnothing (modul)
60+ module_sym = Symbol (module_name)
61+ @eval using $ module_sym # will throw error for Pkg if not available
62+ modul = CodeTools. getmodule (module_name)
63+ end
64+ return lint_module (modul)
65+ end
66+
67+ # Since the module is loaded it will give the modulefiles easily
68+ function lint_module (modul:: Module , env_path = dirname (pathof (modul)))
69+ symbolserver, symbol_extends = SymbolServer. get_symbol_server ()
70+ parentfile_path, included_files_path = modulefiles (modul)
71+
72+ root = lint_module_file (parentfile_path, nothing , symbolserver)
73+
74+ included_files_path_len = length (included_files_path)
75+ files = Vector {File} (undef, included_files_path_len)
76+ for ifile = 1 : included_files_path_len
77+ files[i] = lint_module_file (included_files_path[i], root, symbolserver)
78+ end
79+
80+ allfiles_path = prepend! (included_files_path, [parentfile_path])
81+ allfiles = prepend! (files, [root])
82+
83+ files = Dict ( file_path => file for (file_path, file) in zip (allfiles_path, allfiles))
84+ roots = Set ([root])
85+
86+ return FileServer (files, roots, symbolserver, symbol_extends)
87+ end
88+
3489export lint_module_file
3590function lint_module_file (filepath:: AbstractString , root = nothing , server = nothing )
3691
0 commit comments