public ITransformation VisitNode(ClassDeclarationSyntax node)
        {
            var parameters = new List <ITransformation>();

            parameters.AddRange(this.CreateModifiersList(node.Modifiers));
            parameters.Add(new StringTransformation(node.Identifier.Text, Range.ForToken(node.Identifier)));

            if (node.BaseList != null)
            {
                parameters.AddRange(this.CreateBasesList(node.BaseList));
            }

            return(new ChildTransformations(
                       new ITransformation[]
            {
                new CommandTransformation(
                    CommandNames.ClassStart,
                    Range.ForToken(node.Keyword),
                    parameters.ToArray()
                    ),
                this.Router.RecurseIntoNodes(node.Members, node),
                new CommandTransformation(CommandNames.ClassEnd, Range.AfterNode(node))
            },
                       Range.ForNode(node)
                       ));
        }
Example #2
0
 public ITransformation VisitNode(NamespaceDeclarationSyntax node)
 => new ChildTransformations(
     new ITransformation[]
 {
     new CommandTransformation(
         CommandNames.FileStart,
         Range.ForNode(node.Name),
         this.CreateParametersForName(node.Name)
         ),
     this.Router.RecurseIntoNodes(node.Members, node),
     new CommandTransformation(CommandNames.FileEnd, Range.AfterNode(node))
 },
     Range.ForNode(node)
     );
Example #3
0
        private ITransformation[] CreateParametersForName(NameSyntax name)
        {
            var rawParameters = name.ToString().Split('.');
            var parameters    = new List <ITransformation>();
            var startIndex    = 0;

            foreach (var rawParameter in rawParameters)
            {
                parameters.Add(new StringTransformation(rawParameter, new Range(startIndex, rawParameter.Length)));
                startIndex += rawParameter.Length + 1;
            }

            parameters.Add(new StringTransformation(this.FileName, Range.AfterNode(name)));

            return(parameters.ToArray());
        }
Example #4
0
 public ITransformation VisitNode(WhileStatementSyntax node)
 {
     return(new ChildTransformations(
                new ITransformation[]
     {
         new CommandTransformation(
             CommandNames.WhileStart,
             Range.ForNode(node.Condition),
             this.Router.RecurseIntoNode(node.Condition)
             ),
         this.Router.RecurseIntoNode(node.Statement),
         new CommandTransformation(
             CommandNames.WhileEnd,
             Range.AfterNode(node)
             )
     },
                Range.ForNode(node)
                ));
 }
        public ITransformation VisitNode(IfStatementSyntax node)
        {
            var transformations = new List <ITransformation>();

            if (node.Else != null)
            {
                transformations.Add(this.Router.RecurseIntoNode(node.Else));
            }

            transformations.Add(new CommandTransformation(CommandNames.IfEnd, Range.AfterNode(node)));

            return(new ChildTransformations(
                       new ITransformation[]
            {
                new CommandTransformation(
                    CommandNames.IfStart,
                    Range.ForNode(node.Condition),
                    this.Router.RecurseIntoNode(node.Condition)),
                this.Router.RecurseIntoNode(node.Statement),
            },
                       Range.ForNode(node)
                       ));
        }