Skip to content

Commit bcd892c

Browse files
authored
Merge branch 'main' into new_module_tweaker
2 parents 914242a + 11663f9 commit bcd892c

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

SymbolGenerator/Commands/MainCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public ValueTask ExecuteAsync(IConsole console)
114114
// Extract annotations from variables
115115
foreach (var variable in variables)
116116
{
117-
if (variable.RawComment is null || variable.Location is null || !willBeParsed.Contains(variable.Location.File))
117+
if (variable.RawComment is null || variable.Location is null)
118118
continue;
119119
RawAnnotation[] anns = CommentParser.ParseAnnotations(variable, variable.RawComment, variable.Location).ToArray();
120120
annotations.AddRange(anns);

SymbolGenerator/Parsing/ASTVisitor.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,11 @@ private bool ShouldProcessFile(string? file)
223223
return file.StartsWith(InputDirectory, StringComparison.Ordinal) && StrictHeaders.Contains(file);
224224
}
225225

226-
private (List<CXCursor> methods, List<CXCursor> vars, List<CXCursor> bases) CollectClassMembers(CXCursor cursor)
226+
private (List<CXCursor> methods, List<CXCursor> vars, List<CXCursor> classes, List<CXCursor> bases) CollectClassMembers(CXCursor cursor)
227227
{
228228
var methods = new List<CXCursor>();
229229
var vars = new List<CXCursor>();
230+
var classes = new List<CXCursor>();
230231
var bases = new List<CXCursor>();
231232

232233
unsafe
@@ -249,12 +250,16 @@ private bool ShouldProcessFile(string? file)
249250
case CXCursorKind.CXCursor_CXXBaseSpecifier:
250251
bases.Add(c);
251252
break;
253+
case CXCursorKind.CXCursor_ClassDecl:
254+
case CXCursorKind.CXCursor_StructDecl:
255+
classes.Add(c);
256+
break;
252257
}
253258
return CXChildVisitResult.CXChildVisit_Continue;
254259
}, new CXClientData(nint.Zero));
255260
}
256261

257-
return (methods, vars, bases);
262+
return (methods, vars, classes, bases);
258263
}
259264

260265
public ASTClass[] GetClasses()
@@ -415,7 +420,7 @@ public ASTVariable[] GetVariables()
415420
CursorLocation? location = GetLocation(cursor);
416421

417422
// Collect members
418-
var (methodsCursors, variableCursors, baseCursors) = CollectClassMembers(cursor);
423+
var (methodsCursors, variableCursors, classesCursors, baseCursors) = CollectClassMembers(cursor);
419424

420425
// Find base classes
421426
List<ASTBaseSpecifier> baseClasses = [.. baseCursors
@@ -424,7 +429,7 @@ public ASTVariable[] GetVariables()
424429
bool isVirtualBase = c.IsVirtualBase;
425430
CXType type = c.Type;
426431
CXCursor decl = type.Declaration;
427-
ASTClass? classInfo = VisitClass(decl, decl.SemanticParent, decl.Usr.ToString()).rawClass;
432+
ASTClass? classInfo = VisitClass(decl, decl.SemanticParent, GetUsr(decl)).rawClass;
428433
return classInfo is not null ? new ASTBaseSpecifier()
429434
{
430435
Class = classInfo,
@@ -435,12 +440,17 @@ public ASTVariable[] GetVariables()
435440

436441
// Find methods
437442
List<ASTMethod> methods = [.. methodsCursors
438-
.Select(c => VisitMethod(c, cursor, c.Usr.ToString()).method
443+
.Select(c => VisitMethod(c, cursor, GetUsr(c)).method
439444
).Where(t => t is not null)!];
440445

441446
// Find variables
442447
List<ASTVariable> variables = [.. variableCursors
443-
.Select(c => VisitVariable(c, cursor, c.Usr.ToString()).variable
448+
.Select(c => VisitVariable(c, cursor, GetUsr(c)).variable
449+
).Where(t => t is not null)!];
450+
451+
// Find nested classes
452+
List<ASTClass> nestedClasses = [.. classesCursors
453+
.Select(c => VisitClass(c, cursor, GetUsr(c)).rawClass
444454
).Where(t => t is not null)!];
445455

446456
ASTClass rawClass = new()
@@ -474,7 +484,7 @@ public ASTVariable[] GetVariables()
474484
if (overriden.Length > 0)
475485
{
476486
var first = overriden[0];
477-
var (_, overrideOfMethod) = VisitMethod(first, first.SemanticParent, first.Usr.ToString());
487+
var (_, overrideOfMethod) = VisitMethod(first, first.SemanticParent, GetUsr(first));
478488
overrideOf = overrideOfMethod;
479489
}
480490
}

0 commit comments

Comments
 (0)