public override void EnterClassDeclaration(JavaParser.ClassDeclarationContext context) { string name = context.IDENTIFIER().GetText(); string headerText = context.GetFullText(); if (headerText.Contains("{")) { headerText = headerText.Substring( 0, headerText.IndexOf("{", StringComparison.Ordinal)); } ClassInfo newClassInfo; if (parentClass != null) { name = $"{parentClass.className.ShortName}${name}"; ClassName className = new ClassName( parentClass.className.ContainmentFile(), parentClass.className.ContainmentPackage, name); newClassInfo = new ClassInfo( className, new List <MethodInfo>(), new List <FieldInfo>(), AccessFlags.AccPrivate, new List <ClassInfo>(), new SourceCodeSnippet(headerText, SourceCodeLanguage.Java), false); parentClass.Children.Add(newClassInfo); } else { // top level class ClassName className = new ClassName( new FileName(parentFileName), new PackageName(packageFqn), name); newClassInfo = new ClassInfo( className, new List <MethodInfo>(), new List <FieldInfo>(), modifier, new List <ClassInfo>(), new SourceCodeSnippet(headerText, SourceCodeLanguage.Java), false); OuterClass = newClassInfo; } ClassBodyListener classBodyListener = new ClassBodyListener(newClassInfo); context.classBody().EnterRule(classBodyListener); }
public override void EnterClassDeclaration(JavaParser.ClassDeclarationContext context) { string name = context.IDENTIFIER().GetText(); if (outerClass != null) { string history = outerClass .FullyQualified .Substring(outerClass.FullyQualified.LastIndexOf('/') + 1); name = $"{history}${name}"; } string classPackageFqn = string.IsNullOrEmpty(packageFqn) ? name : $"{packageFqn}.{name}"; ClassName className = new ClassName($"{parentFileName}|{classPackageFqn}"); string headerText = context.GetFullText(); if (headerText.Contains("{")) { headerText = headerText.Substring( 0, headerText.IndexOf("{", StringComparison.Ordinal)); } ClassBodyListener classBodyListener = new ClassBodyListener(className, parentFileName, packageFqn); context.classBody().EnterRule(classBodyListener); ClassInfo = new ClassInfo( className, classBodyListener.MethodInfos, classBodyListener.FieldInfos, modifier, classBodyListener.InnerClasses, new SourceCodeSnippet(headerText, SourceCodeLanguage.Java), false); }