Class: Steep::Services::CompletionProvider::TypeNameItem

Inherits:
Struct
  • Object
show all
Defined in:
lib/steep/services/completion_provider.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#absolute_type_nameObject

Returns the value of attribute absolute_type_name

Returns:

  • (Object)

    the current value of absolute_type_name



104
105
106
# File 'lib/steep/services/completion_provider.rb', line 104

def absolute_type_name
  @absolute_type_name
end

#envObject

Returns the value of attribute env

Returns:

  • (Object)

    the current value of env



104
105
106
# File 'lib/steep/services/completion_provider.rb', line 104

def env
  @env
end

#rangeObject

Returns the value of attribute range

Returns:

  • (Object)

    the current value of range



104
105
106
# File 'lib/steep/services/completion_provider.rb', line 104

def range
  @range
end

#relative_type_nameObject

Returns the value of attribute relative_type_name

Returns:

  • (Object)

    the current value of relative_type_name



104
105
106
# File 'lib/steep/services/completion_provider.rb', line 104

def relative_type_name
  @relative_type_name
end

Instance Method Details

#commentsObject



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/steep/services/completion_provider.rb', line 125

def comments
  comments = [] #: Array[RBS::AST::Comment]

  case
  when absolute_type_name.interface?
    if comment = env.interface_decls.fetch(absolute_type_name).decl.comment
      comments << comment
    end
  when absolute_type_name.alias?
    if comment = env.type_alias_decls.fetch(absolute_type_name).decl.comment
      comments << comment
    end
  when absolute_type_name.class?
    case entry = env.module_class_entry(absolute_type_name)
    when RBS::Environment::ClassEntry, RBS::Environment::ModuleEntry
      entry.decls.each do |decl|
        if comment = decl.decl.comment
          comments << comment
        end
      end
    when RBS::Environment::ClassAliasEntry, RBS::Environment::ModuleAliasEntry
      if comment = entry.decl.comment
        comments << comment
      end
    else
      raise
    end
  else
    raise
  end

  comments
end

#declObject



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/steep/services/completion_provider.rb', line 105

def decl
  case
  when absolute_type_name.interface?
    env.interface_decls.fetch(absolute_type_name).decl
  when absolute_type_name.alias?
    env.type_alias_decls.fetch(absolute_type_name).decl
  when absolute_type_name.class?
    case entry = env.module_class_entry(absolute_type_name)
    when RBS::Environment::ClassEntry, RBS::Environment::ModuleEntry
      entry.primary.decl
    when RBS::Environment::ClassAliasEntry, RBS::Environment::ModuleAliasEntry
      entry.decl
    else
      raise "absolute_type_name=#{absolute_type_name}, relative_type_name=#{relative_type_name}"
    end
  else
    raise
  end
end