Class: Solargraph::TypeChecker::Rules

Inherits:
Object
  • Object
show all
Defined in:
lib/solargraph/type_checker/rules.rb

Constant Summary collapse

LEVELS =
{
  normal: 0,
  typed: 1,
  strict: 2,
  strong: 3
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(level) ⇒ Rules

Returns a new instance of Rules.

Parameters:

  • level (Symbol)


18
19
20
21
22
23
24
25
26
# File 'lib/solargraph/type_checker/rules.rb', line 18

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

#levelSymbol (readonly)

Returns:

  • (Symbol)


12
13
14
# File 'lib/solargraph/type_checker/rules.rb', line 12

def level
  @level
end

#rankInteger (readonly)

Returns:

  • (Integer)


15
16
17
# File 'lib/solargraph/type_checker/rules.rb', line 15

def rank
  @rank
end

Instance Method Details

#ignore_all_undefined?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/solargraph/type_checker/rules.rb', line 28

def ignore_all_undefined?
  rank < LEVELS[:strict]
end

#must_tag_or_infer?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/solargraph/type_checker/rules.rb', line 44

def must_tag_or_infer?
  rank > LEVELS[:typed]
end

#require_type_tags?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/solargraph/type_checker/rules.rb', line 40

def require_type_tags?
  rank >= LEVELS[:strong]
end

#validate_calls?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/solargraph/type_checker/rules.rb', line 36

def validate_calls?
  rank >= LEVELS[:strict]
end

#validate_consts?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/solargraph/type_checker/rules.rb', line 32

def validate_consts?
  rank >= LEVELS[:strict]
end

#validate_tags?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/solargraph/type_checker/rules.rb', line 48

def validate_tags?
  rank > LEVELS[:normal]
end