From 01ac8399292eeae7e5d1bd2c1009492d9df5d6d8 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Fri, 25 Mar 2022 09:20:33 +0800 Subject: [PATCH] feat(c#): config for namespace --- .../main/kotlin/chapi/ast/csharpast/CSharpFullIdentListener.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/chapi-ast-csharp/src/main/kotlin/chapi/ast/csharpast/CSharpFullIdentListener.kt b/chapi-ast-csharp/src/main/kotlin/chapi/ast/csharpast/CSharpFullIdentListener.kt index ea9ab853..e4e8766d 100644 --- a/chapi-ast-csharp/src/main/kotlin/chapi/ast/csharpast/CSharpFullIdentListener.kt +++ b/chapi-ast-csharp/src/main/kotlin/chapi/ast/csharpast/CSharpFullIdentListener.kt @@ -8,6 +8,7 @@ import chapi.infra.Stack import org.antlr.v4.runtime.ParserRuleContext class CSharpFullIdentListener(val fileName: String) : CSharpAstListener() { + private var currentNamspace: String = "" private var currentStruct: CodeDataStruct = CodeDataStruct(); private var codeContainer: CodeContainer = CodeContainer(FullName = fileName) private var currentContainer: CodeContainer = codeContainer @@ -52,6 +53,7 @@ class CSharpFullIdentListener(val fileName: String) : CSharpAstListener() { if (namespaceDeclaration != null) { if (namespaceDeclaration.qualified_identifier() != null) { val nsName = ctx.namespace_declaration().qualified_identifier().text + currentNamspace = nsName val container = CodeContainer( FullName = fileName, PackageName = nsName @@ -85,6 +87,7 @@ class CSharpFullIdentListener(val fileName: String) : CSharpAstListener() { val className = ctx!!.identifier().text val codeDataStruct = CodeDataStruct( NodeName = className, + Package = currentNamspace, Position = buildPosition(ctx) )