コード例 #1
0
ファイル: MemberMapper.cs プロジェクト: wangchengqun/janett
        private Expression GetMapExpression(string mapKey)
        {
            string  program = "namespace Test { public class A { public void Method() { result = " + mapKey + "; } }}";
            IParser parser  = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(program));

            parser.ParseMethodBodies = true;
            parser.Parse();

            CompilationUnit cu = parser.CompilationUnit;

            ParentVisitor parentVisitor = new ParentVisitor();

            parentVisitor.VisitCompilationUnit(cu, null);

            TypeReferenceCorrector typeReferenceCorrector = new TypeReferenceCorrector();

            typeReferenceCorrector.VisitCompilationUnit(cu, null);

            MappingIdentifierMarker mappingIdentifierMarker = new MappingIdentifierMarker();

            mappingIdentifierMarker.MarkIdentifiers(cu);

            NamespaceDeclaration ns  = (NamespaceDeclaration)cu.Children[0];
            TypeDeclaration      ty  = (TypeDeclaration)ns.Children[0];
            MethodDeclaration    md  = (MethodDeclaration)ty.Children[0];
            ExpressionStatement  st  = (ExpressionStatement)md.Body.Children[0];
            AssignmentExpression ase = (AssignmentExpression)st.Expression;

            return(ase);
        }
コード例 #2
0
 public void SetUp()
 {
     substitution = new Substitution();
     marker       = new MappingIdentifierMarker();
 }
コード例 #3
0
        private Expression GetMapExpression(string mapKey)
        {
            string program = "namespace Test { public class A { public void Method() { result = " + mapKey + "; } }}";
            IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(program));
            parser.ParseMethodBodies = true;
            parser.Parse();

            CompilationUnit cu = parser.CompilationUnit;

            ParentVisitor parentVisitor = new ParentVisitor();
            parentVisitor.VisitCompilationUnit(cu, null);

            TypeReferenceCorrector typeReferenceCorrector = new TypeReferenceCorrector();
            typeReferenceCorrector.VisitCompilationUnit(cu, null);

            MappingIdentifierMarker mappingIdentifierMarker = new MappingIdentifierMarker();
            mappingIdentifierMarker.MarkIdentifiers(cu);

            NamespaceDeclaration ns = (NamespaceDeclaration) cu.Children[0];
            TypeDeclaration ty = (TypeDeclaration) ns.Children[0];
            MethodDeclaration md = (MethodDeclaration) ty.Children[0];
            ExpressionStatement st = (ExpressionStatement) md.Body.Children[0];
            AssignmentExpression ase = (AssignmentExpression) st.Expression;
            return ase;
        }
コード例 #4
0
 public void SetUp()
 {
     substitution = new Substitution();
     marker = new MappingIdentifierMarker();
 }