@@ -13,32 +13,31 @@ class CPPFullIdentListener(fileName: String) : CPP14ParserBaseListener() {
13
13
14
14
override fun enterFunctionDefinition (ctx : CPP14Parser .FunctionDefinitionContext ? ) {
15
15
val method = CodeFunction ()
16
- val context = ctx!!
17
16
18
- if (context.declSpecifierSeq() != null ) {
19
- method.ReturnType = context.declSpecifierSeq() .text
17
+ ctx?.declarator()?. let {
18
+ method.Name = it .text
20
19
}
21
-
22
- val firstPtrDecl = context.declarator().pointerDeclarator() ? : return
23
- if (firstPtrDecl.noPointerDeclarator() != null ) {
24
- tryFunctionBuild(firstPtrDecl, method)
20
+ ctx?.declSpecifierSeq()?.let {
21
+ method.ReturnType = it.text
25
22
}
26
- }
27
23
28
- private fun tryFunctionBuild (firstPtrDecl : CPP14Parser .PointerDeclaratorContext , method : CodeFunction ) {
29
- val parametersAndQualifiersContext = firstPtrDecl.noPointerDeclarator().parametersAndQualifiers() ? : return
30
- method.Name = firstPtrDecl.noPointerDeclarator().noPointerDeclarator().text
24
+ val firstPtrDecl = ctx?.declarator()?.pointerDeclarator() ? : return
25
+ val noPointerDeclarator = firstPtrDecl.noPointerDeclarator() ? : return
26
+
27
+ val parameters = noPointerDeclarator.parametersAndQualifiers() ? : return
28
+
29
+ method.Name = noPointerDeclarator.noPointerDeclarator().text
31
30
32
- parametersAndQualifiersContext .parameterDeclarationClause()?.let {
31
+ parameters .parameterDeclarationClause()?.let {
33
32
method.Parameters = buildParameters(it)
34
33
}
35
34
36
35
defaultNode.Functions + = method
37
36
}
38
37
39
38
private fun buildParameters (parameterDeclaration : CPP14Parser .ParameterDeclarationClauseContext ): List <CodeProperty > {
40
- return parameterDeclaration.parameterDeclarationList()?.let {
41
- it .parameterDeclaration().map {
39
+ return parameterDeclaration.parameterDeclarationList()?.let { listContext ->
40
+ listContext .parameterDeclaration().map {
42
41
val type = it.declSpecifierSeq().declSpecifier().firstOrNull()?.typeSpecifier()?.text
43
42
val name = it.declarator()?.text
44
43
0 commit comments