mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[incrParse] Fix parsing of nodes covering no source text
This commit is contained in:
@@ -18,7 +18,7 @@ class Node(object):
|
||||
|
||||
def __init__(self, name, description=None, kind=None, traits=None,
|
||||
children=None, element=None, element_name=None,
|
||||
element_choices=None):
|
||||
element_choices=None, omit_when_empty=False):
|
||||
self.syntax_kind = name
|
||||
self.swift_syntax_kind = lowercase_first_word(name)
|
||||
self.name = kind_to_type(self.syntax_kind)
|
||||
@@ -36,6 +36,7 @@ class Node(object):
|
||||
error("unknown base kind '%s' for node '%s'" %
|
||||
(self.base_kind, self.syntax_kind))
|
||||
|
||||
self.omit_when_empty = omit_when_empty
|
||||
self.collection_element = element or ""
|
||||
# If there's a preferred name for the collection element that differs
|
||||
# from its supertype, use that.
|
||||
@@ -74,3 +75,10 @@ class Node(object):
|
||||
return not self.is_base() and \
|
||||
not self.is_unknown() and \
|
||||
not self.is_syntax_collection()
|
||||
|
||||
def shall_be_omitted_when_empty(self):
|
||||
"""
|
||||
Returns 'True' if this node shall not be created while parsing if it
|
||||
has no children.
|
||||
"""
|
||||
return self.omit_when_empty
|
||||
|
||||
Reference in New Issue
Block a user