public override SyntaxNode VisitIdentifierName(IdentifierNameSyntax node)
        {
            CheckCastContex(node);
            CheckParenthesizeContex(node);

            var newNode = SyntaxFactoryExtensions.DataCodeVirtualAccess();

            string      name        = node.Identifier.Text;
            string      typeText    = "";
            bool        found       = false;
            VirtualData virtualData = null;

            foreach (var data in _virtualizationContext.data)
            {
                if (data.Name.Equals(name))
                {
                    typeText    = data.Type;
                    found       = true;
                    virtualData = data;
                    break;
                }
            }
            if (!found)
            {
                return(node);
            }

            newNode = newNode.WithAdditionalAnnotations(virtualData.Annotations);

            var newExpression = newNode;

            if (CastEnabled)
            {
                newExpression = SyntaxFactory.CastExpression(SyntaxFactory.IdentifierName
                                                             (
                                                                 @"" + typeText
                                                             ),
                                                             newNode
                                                             );
            }
            if (ParenthesizeEnabled)
            {
                newExpression = SyntaxFactory.ParenthesizedExpression(newExpression);
            }

            newExpression = newExpression.WithLeadingTrivia(node.GetLeadingTrivia())
                            .WithTrailingTrivia(node.GetTrailingTrivia())
            ;

            return(newExpression);
        }
        public override SyntaxNode VisitPrefixUnaryExpression(PrefixUnaryExpressionSyntax node)
        {
            if (node.Kind() != SyntaxKind.UnaryMinusExpression)
            {
                return(base.VisitPrefixUnaryExpression(node));
            }
            var expression = node.Operand;

            if (expression.Kind() != SyntaxKind.NumericLiteralExpression)
            {
                return(base.VisitPrefixUnaryExpression(node));
            }

            CheckCastContex(node);

            string      value    = node.ToString();
            bool        found    = false;
            VirtualData constant = null;

            foreach (var data in _virtualizationContext.data)
            {
                if (value.Equals(data.Name))
                {
                    found    = true;
                    constant = data;
                    break;
                }
            }
            if (!found)
            {
                int              index          = _virtualizationContext.DataIndex;
                string           name           = value;
                SyntaxAnnotation indexMarker    = new SyntaxAnnotation("index", index + "");
                SyntaxAnnotation nameMarker     = new SyntaxAnnotation("name", name);
                SyntaxAnnotation constantMarker = new SyntaxAnnotation("type", "constant");
                SyntaxAnnotation codeMarker     = new SyntaxAnnotation("code", "undefined");
                SyntaxAnnotation uniqueMarker   = new SyntaxAnnotation("unique", "" + VirtualizationContext.UniqueId);

                constant       = new VirtualData();
                constant.Index = index;
                constant.Name  = name;
                var typeInfo = _virtualizationContext.semanticModel.GetTypeInfo(node);
                var info     = typeInfo.Type.ToString();
                constant.Type         = info;
                constant.Node         = node;
                constant.DefaultValue = node;
                constant.Annotations.Add(indexMarker);
                constant.Annotations.Add(nameMarker);
                constant.Annotations.Add(constantMarker);
                constant.Annotations.Add(codeMarker);
                constant.Annotations.Add(uniqueMarker);
                _virtualizationContext.data.Add(constant);
            }

            //            constants.Add(node);



            ExpressionSyntax newNode = SyntaxFactoryExtensions.DataCodeVirtualAccess();

            newNode = newNode.WithAdditionalAnnotations(constant.Annotations);
            ExpressionSyntax newExpression;

            if (CastEnabled)
            {
                newExpression = SyntaxFactory.CastExpression(SyntaxFactory.IdentifierName
                                                             (
                                                                 @"" + constant.Type
                                                             ),
                                                             newNode
                                                             );
            }
            else
            {
                newExpression = newNode;
            }

            //TODO: add annotations + comments
            newExpression = newExpression.WithLeadingTrivia(node.GetLeadingTrivia())
                            .WithTrailingTrivia(node.GetTrailingTrivia())
            ;

            return(newExpression);
        }
        public override SyntaxNode VisitLiteralExpression(LiteralExpressionSyntax node)
        {
            var kind = node.Kind();

            if ((kind != SyntaxKind.NumericLiteralExpression) &&
                (kind != SyntaxKind.StringLiteralExpression) &&
                (kind != SyntaxKind.FalseLiteralExpression) &&
                (kind != SyntaxKind.TrueLiteralExpression) &&
                (kind != SyntaxKind.CharacterLiteralExpression)
                )
            {
                return(node);
            }

            CheckCastContex(node);

            string      value        = node.ToString();
            bool        found        = false;
            VirtualData constant     = null;
            string      requiredType = GetRequiredType(node); //in the case of return statements

            if (requiredType.Equals("void"))
            {
                requiredType = ""; // return statement was added as a refactoring "hack"
            }
            var typeInfo     = _virtualizationContext.semanticModel.GetTypeInfo(node);
            var declaredType = typeInfo.Type.ToString();

            foreach (var data in _virtualizationContext.data)
            {
                if (value.Equals(data.Name))
                {
                    if (requiredType.Equals("") && declaredType.Equals(data.Type))
                    {
                        found        = true;
                        constant     = data;
                        requiredType = declaredType;
                        break;
                    }
                    if (requiredType.Equals(data.Type))
                    {
                        found    = true;
                        constant = data;
                        break;
                    }
                }
            }
            if (!found)
            {
                if (requiredType.Equals(""))
                {
                    requiredType = declaredType;
                }

                int              index           = _virtualizationContext.DataIndex;
                string           name            = value;
                SyntaxAnnotation dataIndexMarker = new SyntaxAnnotation("index", index + "");
                SyntaxAnnotation nameMarker      = new SyntaxAnnotation("name", name);
                SyntaxAnnotation constantMarker  = new SyntaxAnnotation("type", "constant");
                SyntaxAnnotation codeIndexMarker = new SyntaxAnnotation("code", "undefined");
                SyntaxAnnotation uniqueMarker    = new SyntaxAnnotation("unique", "" + VirtualizationContext.UniqueId);

                constant       = new VirtualData();
                constant.Index = index;
                constant.Name  = name;
                var info = requiredType;

                constant.Type         = info;
                constant.Node         = node;
                constant.DefaultValue = node;
                constant.Annotations.Add(dataIndexMarker);
                constant.Annotations.Add(nameMarker);
                constant.Annotations.Add(constantMarker);
                constant.Annotations.Add(codeIndexMarker);
                constant.Annotations.Add(uniqueMarker);
                _virtualizationContext.data.Add(constant);
            }



            ExpressionSyntax newNode = SyntaxFactoryExtensions.DataCodeVirtualAccess();

            newNode = newNode.WithAdditionalAnnotations(constant.Annotations);
            ExpressionSyntax newExpression;

            if (CastEnabled)
            {
                newExpression = SyntaxFactory.CastExpression(SyntaxFactory.IdentifierName
                                                             (
                                                                 @"" + constant.Type
                                                             ),
                                                             newNode
                                                             );
            }
            else
            {
                newExpression = newNode;
            }

            //TODO: add annotations + comments
            newExpression = newExpression.WithLeadingTrivia(node.GetLeadingTrivia())
                            .WithTrailingTrivia(node.GetTrailingTrivia())
            ;

            return(newExpression);
        }