コード例 #1
0
ファイル: IfcFixture.cs プロジェクト: ghord/SharpExpress
        public void Ifc_SemanticModel_ShouldCreateSymbolTable(string path)
        {
            var parser = new ExpressParser();

            using (var stream = File.Open(path, FileMode.Open, FileAccess.Read))
            {
                var result = parser.Parse(stream);

                Assert.IsTrue(result.Success);

                var builder     = new SymbolTableBuilder(result.Schemas);
                var symbolTable = builder.Build();

                var declarations = new DeclarationSyntaxWalker();
                foreach (var schema in result.Schemas)
                {
                    schema.Accept(declarations);
                }

                foreach (var declaration in declarations.Declarations)
                {
                    if (declaration is LocalRuleDeclaration)
                    {
                        continue;
                    }

                    var symbolInfo = symbolTable.GetSymbolInfo(declaration);

                    Assert.IsNotNull(symbolInfo,
                                     $"Missing ISymbolInfo for {declaration.Name}({declaration.Kind})");

                    ValidateSymbolInfo(symbolInfo);
                }
            }
        }
コード例 #2
0
ファイル: HelpfulExtensions.cs プロジェクト: rdavisau/tbc
        public static List <string> GetContainedTypes(this SyntaxTree syntaxTree)
        {
            var walker  = new DeclarationSyntaxWalker <TypeDeclarationSyntax>();
            var classes = walker.Visit(syntaxTree).Select(c => c.Identifier.ToString()).ToList();

            return(classes);
        }