Skip to content

Instantly share code, notes, and snippets.

@mzaks
Last active October 11, 2015 10:05
Show Gist options
  • Select an option

  • Save mzaks/3bd4b1d436eee9b54f27 to your computer and use it in GitHub Desktop.

Select an option

Save mzaks/3bd4b1d436eee9b54f27 to your computer and use it in GitHub Desktop.
Find all used Components in document
Console.WriteLine ("File : " + doc.FileName);
SyntaxTree ast = doc.ParsedDocument.GetAst<SyntaxTree> ();
HashSet<string> typeNames = new HashSet<string> ();
var astResolver = new CSharpAstResolver (doc.Compilation, ast, (CSharpUnresolvedFile)doc.ParsedDocument.ParsedFile);
foreach (var identifier in ast.Descendants.OfType<MemberReferenceExpression> ()) {
var targetString = identifier.Target.ToString ();
// FIXME: Game specific
if(targetString == "CoreGameMatcher" || targetString == "MetaGameMatcher" || targetString == "UIMatcher"){
AddType (identifier, typeNames, componentTypes);
}
var rr = astResolver.Resolve (identifier.Target);
if (rr == null) {
// Not an invocation resolve result - could be a UnknownMemberResolveResult instead
continue;
}
var type = rr.Type;
if (type.FullName == "Entitas.Entity" || type.FullName == "Entitas.Pool"){
AddType (identifier, typeNames, componentTypes);
}
}
foreach (var name in typeNames) {
Console.WriteLine ("Component used : " + name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment