public IEnumerable <ClassInfo> Parse(string code) { if (code == null) { throw new ArgumentNullException(); } var reader = new SourceCodeReader(code); var classList = new List <ClassInfo>(); var classParser = new ClassParser(string.Empty, Modifier.Package); while (!reader.IsEndOfLines) { if (TryParsePackage(reader, out var package)) { classParser = new ClassParser(package, Modifier.Package); continue; } if (classParser.TryParse(reader, out var classInfo)) { classList.Add(classInfo); continue; } reader.TryRead(out var _); } return(classList); }
public IEnumerable <ClassInfo> Parse(string code) { if (code == null) { throw new ArgumentNullException(); } var reader = new SourceCodeReader(code); var classList = new List <ClassInfo>(); var classParser = new ClassParser(string.Empty, Modifier.Internal); var prevNS = new Dictionary <int, string>(); while (!reader.IsEndOfLines) { if (TryParseNameSpace(reader, out var nameSpace, out var depth)) { // Already existed parent namespace, Add it before a nameSpace if (prevNS.ContainsKey(depth - 1)) { nameSpace = prevNS[depth - 1] + "." + nameSpace; } prevNS[depth] = nameSpace; classParser = new ClassParser(nameSpace, Modifier.Internal); continue; } if (classParser.TryParse(reader, out var classInfo)) { classList.Add(classInfo); continue; } reader.TryRead(out var _); } return(classList); }