Class: Solargraph::TypeChecker::Rules
- Inherits:
-
Object
- Object
- Solargraph::TypeChecker::Rules
- Defined in:
- lib/solargraph/type_checker/rules.rb
Overview
Definitions of type checking rules to be performed at various levels
Constant Summary collapse
- LEVELS =
{ normal: 0, typed: 1, strict: 2, strong: 3 }.freeze
Instance Attribute Summary collapse
- #level ⇒ Symbol readonly
- #rank ⇒ Integer readonly
Instance Method Summary collapse
- #ignore_all_undefined? ⇒ Boolean
-
#initialize(level) ⇒ Rules
constructor
A new instance of Rules.
- #must_tag_or_infer? ⇒ Boolean
- #require_type_tags? ⇒ Boolean
- #validate_calls? ⇒ Boolean
- #validate_consts? ⇒ Boolean
- #validate_tags? ⇒ Boolean
Constructor Details
#initialize(level) ⇒ Rules
Returns a new instance of Rules.
22 23 24 25 26 27 28 29 30 |
# File 'lib/solargraph/type_checker/rules.rb', line 22 def initialize level @rank = if LEVELS.key?(level) LEVELS[level] else Solargraph.logger.warn "Unrecognized TypeChecker level #{level}, assuming normal" 0 end @level = LEVELS[LEVELS.values.index(@rank)] end |
Instance Attribute Details
#level ⇒ Symbol (readonly)
16 17 18 |
# File 'lib/solargraph/type_checker/rules.rb', line 16 def level @level end |
#rank ⇒ Integer (readonly)
19 20 21 |
# File 'lib/solargraph/type_checker/rules.rb', line 19 def rank @rank end |
Instance Method Details
#ignore_all_undefined? ⇒ Boolean
32 33 34 |
# File 'lib/solargraph/type_checker/rules.rb', line 32 def ignore_all_undefined? rank < LEVELS[:strict] end |
#must_tag_or_infer? ⇒ Boolean
48 49 50 |
# File 'lib/solargraph/type_checker/rules.rb', line 48 def must_tag_or_infer? rank > LEVELS[:typed] end |
#require_type_tags? ⇒ Boolean
44 45 46 |
# File 'lib/solargraph/type_checker/rules.rb', line 44 def rank >= LEVELS[:strong] end |
#validate_calls? ⇒ Boolean
40 41 42 |
# File 'lib/solargraph/type_checker/rules.rb', line 40 def validate_calls? rank >= LEVELS[:strict] end |
#validate_consts? ⇒ Boolean
36 37 38 |
# File 'lib/solargraph/type_checker/rules.rb', line 36 def validate_consts? rank >= LEVELS[:strict] end |
#validate_tags? ⇒ Boolean
52 53 54 |
# File 'lib/solargraph/type_checker/rules.rb', line 52 def rank > LEVELS[:normal] end |