Skip to content

Commit

Permalink
Identify async methods in symgraph import
Browse files Browse the repository at this point in the history
  • Loading branch information
johnfairh committed Jun 28, 2021
1 parent bff2de6 commit fc732a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/jazzy/sourcekitten.rb
Expand Up @@ -591,9 +591,11 @@ def self.make_source_declarations(docs, parent = nil, mark = SourceMark.new)
inherited_types = doc['key.inheritedtypes'] || []
declaration.inherited_types =
inherited_types.map { |type| type['key.name'] }.compact
if xml_declaration = doc['key.fully_annotated_decl']
declaration.async = swift_async?(xml_declaration)
end
declaration.async =
doc['key.async'] ||
if xml_declaration = doc['key.fully_annotated_decl']
swift_async?(xml_declaration)
end

next unless make_doc_info(doc, declaration)
declaration.children = make_substructure(doc, declaration)
Expand Down
8 changes: 8 additions & 0 deletions lib/jazzy/symbol_graph/sym_node.rb
Expand Up @@ -23,6 +23,7 @@ def children_to_sourcekit

# A SymNode is a node of the reconstructed syntax tree holding a symbol.
# It can turn itself into SourceKit and helps decode extensions.
# rubocop:disable Metrics/ClassLength
class SymNode < BaseNode
attr_accessor :symbol
attr_writer :override
Expand Down Expand Up @@ -111,6 +112,11 @@ def inherits_clause
" : #{superclass_name}"
end

# approximately...
def async?
symbol.declaration =~ /async[^\)]*$/
end

def full_declaration
symbol.availability
.append(symbol.declaration + inherits_clause + where_clause)
Expand All @@ -129,6 +135,7 @@ def to_sourcekit
'key.accessibility' => symbol.acl,
'key.parsed_decl' => declaration,
'key.annotated_decl' => xml_declaration,
'key.async' => async?,
}
if docs = symbol.doc_comments
hash['key.doc.comment'] = docs
Expand Down Expand Up @@ -158,5 +165,6 @@ def <=>(other)
symbol <=> other.symbol
end
end
# rubocop:enable Metrics/ClassLength
end
end

0 comments on commit fc732a5

Please sign in to comment.