Last active
October 11, 2015 10:05
-
-
Save mzaks/3bd4b1d436eee9b54f27 to your computer and use it in GitHub Desktop.
Find all used Components in document
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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