Skip to content

Commit 655e0e9

Browse files
authored
Handle braces in ctor list (#65)
1 parent c4ffcc6 commit 655e0e9

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

nsiqcppstyle_checker.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,27 @@ def ConstructContextInfo(lexer):
12401240
# continue
12411241
impl = lexer.HasBody()
12421242
if impl:
1243-
contextStart = lexer.GetNextTokenInType("LBRACE")
1243+
while True:
1244+
# handle ctor list initializers
1245+
contextStart = lexer.GetNextTokenInType("LBRACE")
1246+
if t.type != "ID" or prevName is None:
1247+
break
1248+
if curContext is not None and curContext.type in ["CLASS_BLOCK", "STRUCT_BLOCK"]:
1249+
# we are in a class
1250+
if t.value != curContext.name or fullName[0] == "~":
1251+
break # not a ctor
1252+
elif "::" in fullName:
1253+
# checking for a ctor outside a class
1254+
names = fullName.split("::")
1255+
if len(names) == 1 or names[-1] != names[0]:
1256+
break
1257+
else:
1258+
# just a normal scope, no need to iterate
1259+
break
1260+
bracePrevToken = lexer.PeekPrevTokenSkipWhiteSpaceAndComment()
1261+
if bracePrevToken.type in ["RPAREN", "RBRACE", "COMMA"]:
1262+
# we reached the end of initializer list
1263+
break
12441264
contextEnd = lexer.GetNextMatchingToken(contextStart)
12451265
if contextEnd is not None:
12461266
contextPrediction = Context("FUNCTION_BLOCK", fullName, True, contextStart, contextEnd)

0 commit comments

Comments
 (0)