Class: Solargraph::TypeChecker
- Inherits:
-
Object
- Object
- Solargraph::TypeChecker
show all
- Includes:
- ParserGem::NodeMethods, Checks
- Defined in:
- lib/solargraph/type_checker.rb,
lib/solargraph/type_checker/rules.rb,
lib/solargraph/type_checker/checks.rb,
lib/solargraph/type_checker/problem.rb,
lib/solargraph/type_checker/param_def.rb
Overview
A static analysis tool for validating data types.
Defined Under Namespace
Modules: Checks
Classes: ParamDef, Problem, Rules
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Checks
all_types_match?, any_types_match?, duck_types_match?, either_way?, fuzz, types_match?
Constructor Details
#initialize(filename, api_map: nil, level: :normal) ⇒ TypeChecker
Returns a new instance of TypeChecker.
27
28
29
30
31
32
33
34
|
# File 'lib/solargraph/type_checker.rb', line 27
def initialize filename, api_map: nil, level: :normal
@filename = filename
@api_map = api_map || Solargraph::ApiMap.load(File.dirname(filename))
@rules = Rules.new(level)
@marked_ranges = []
end
|
Instance Attribute Details
22
23
24
|
# File 'lib/solargraph/type_checker.rb', line 22
def api_map
@api_map
end
|
#filename ⇒ String
16
17
18
|
# File 'lib/solargraph/type_checker.rb', line 16
def filename
@filename
end
|
19
20
21
|
# File 'lib/solargraph/type_checker.rb', line 19
def rules
@rules
end
|
Class Method Details
.load(filename, level = :normal) ⇒ self
62
63
64
65
66
67
|
# File 'lib/solargraph/type_checker.rb', line 62
def load filename, level = :normal
source = Solargraph::Source.load(filename)
api_map = Solargraph::ApiMap.new
api_map.map(source)
new(filename, api_map: api_map, level: level)
end
|
.load_string(code, filename = nil, level = :normal) ⇒ self
73
74
75
76
77
78
|
# File 'lib/solargraph/type_checker.rb', line 73
def load_string code, filename = nil, level = :normal
source = Solargraph::Source.load_string(code, filename)
api_map = Solargraph::ApiMap.new
api_map.map(source)
new(filename, api_map: api_map, level: level)
end
|
Instance Method Details
#problems ⇒ Array<Problem>
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/solargraph/type_checker.rb', line 47
def problems
@problems ||= begin
all = method_tag_problems
.concat(variable_type_tag_problems)
.concat(const_problems)
.concat(call_problems)
unignored = without_ignored(all)
unignored.concat(unneeded_sgignore_problems)
end
end
|
42
43
44
|
# File 'lib/solargraph/type_checker.rb', line 42
def source
@source_map.source
end
|
37
38
39
|
# File 'lib/solargraph/type_checker.rb', line 37
def source_map
@source_map ||= api_map.source_map(filename)
end
|