Exemple #1
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);
        }
Exemple #2
0
 public void SetUp()
 {
     substitution = new Substitution();
     marker       = new MappingIdentifierMarker();
 }
        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;
        }
 public void SetUp()
 {
     substitution = new Substitution();
     marker = new MappingIdentifierMarker();
 }