Remove EmptyBlockState
- Turns out you can't put an empty block except in code
This commit is contained in:
@@ -351,29 +351,3 @@ def test_warning_directive() -> None:
|
||||
data = parse_string(content, cleandoc=True)
|
||||
|
||||
assert data == ParsedData()
|
||||
|
||||
|
||||
def test_empty_block() -> None:
|
||||
"""
|
||||
Ensure the simple visitor doesn't break with an empty block
|
||||
"""
|
||||
content = """
|
||||
{
|
||||
class X {};
|
||||
}
|
||||
"""
|
||||
data = parse_string(content, cleandoc=True)
|
||||
|
||||
assert data == ParsedData(
|
||||
namespace=NamespaceScope(
|
||||
classes=[
|
||||
ClassScope(
|
||||
class_decl=ClassDecl(
|
||||
typename=PQName(
|
||||
segments=[NameSpecifier(name="X")], classkey="class"
|
||||
)
|
||||
)
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
@@ -10,7 +10,6 @@ from cxxheaderparser.simple import (
|
||||
NamespaceScope,
|
||||
ParsedData,
|
||||
SClassBlockState,
|
||||
SEmptyBlockState,
|
||||
SExternBlockState,
|
||||
SNamespaceBlockState,
|
||||
SimpleCxxVisitor,
|
||||
@@ -148,53 +147,6 @@ def test_skip_class() -> None:
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# ensure empty block is skipped
|
||||
#
|
||||
|
||||
|
||||
class SkipEmptyBlock(SimpleCxxVisitor):
|
||||
def on_empty_block_start(self, state: SEmptyBlockState) -> typing.Optional[bool]:
|
||||
return False
|
||||
|
||||
|
||||
def test_skip_empty_block() -> None:
|
||||
content = """
|
||||
void fn1();
|
||||
|
||||
{
|
||||
void fn2();
|
||||
}
|
||||
|
||||
void fn3();
|
||||
"""
|
||||
v = SkipEmptyBlock()
|
||||
parser = CxxParser("<str>", inspect.cleandoc(content), v)
|
||||
parser.parse()
|
||||
data = v.data
|
||||
|
||||
assert data == ParsedData(
|
||||
namespace=NamespaceScope(
|
||||
functions=[
|
||||
Function(
|
||||
return_type=Type(
|
||||
typename=PQName(segments=[FundamentalSpecifier(name="void")])
|
||||
),
|
||||
name=PQName(segments=[NameSpecifier(name="fn1")]),
|
||||
parameters=[],
|
||||
),
|
||||
Function(
|
||||
return_type=Type(
|
||||
typename=PQName(segments=[FundamentalSpecifier(name="void")])
|
||||
),
|
||||
name=PQName(segments=[NameSpecifier(name="fn3")]),
|
||||
parameters=[],
|
||||
),
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# ensure namespace 'skip' is skipped
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user