Exemple #1
0
        private void NodeAction(TSqlFragment node)
        {
            List<ISkimmer<SqlFileContext>> skimmersList;

            if (node == null) { return; }

            if (this.typeToSkimmersMap.TryGetValue(node.GetType(), out skimmersList))
            {
                foreach (ISqlSkimmer skimmer in skimmersList)
                {
                    this.context.Fragment = node;
                    try
                    {
                        skimmer.Analyze(this.context);
                    }
                    catch (Exception ex)
                    {
                        RuntimeErrors |= AnalyzeCommand.LogUnhandledRuleExceptionAnalyzingTarget(
                            this.disabledSkimmers,
                            this.context,
                            skimmer,
                            ex);
                    }
                }
            }
        }
Exemple #2
0
        private void NodeAction(TSqlFragment node)
        {
            List <ISkimmer <SqlFileContext> > skimmersList;

            if (node == null)
            {
                return;
            }

            if (this.typeToSkimmersMap.TryGetValue(node.GetType(), out skimmersList))
            {
                foreach (ISqlSkimmer skimmer in skimmersList)
                {
                    this.context.Fragment = node;
                    try
                    {
                        skimmer.Analyze(this.context);
                    }
                    catch (Exception ex)
                    {
                        RuntimeErrors |= AnalyzeCommand.LogUnhandledRuleExceptionAnalyzingTarget(
                            this.disabledSkimmers,
                            this.context,
                            skimmer,
                            ex);
                    }
                }
            }
        }
Exemple #3
0
        public static string DebugNodeStr(TSqlFragment node, bool ignoreWhiteSpace = true)
        {
            List <TSqlParserToken> tokens = SelectTokens(node, false);
            string text2 = string.Join("", tokens.Where(x => !ignoreWhiteSpace || x.TokenType != TSqlTokenType.WhiteSpace)
                                       .Select(x => "{" + "[" + x.TokenType + "]" + x.Text + "}").ToArray());

            return(node.GetType() + ": '" + string.Join("", tokens.Select(x => x.Text).ToArray()) + "'\r\n(" + text2 + ")");
        }
Exemple #4
0
        public override void Visit(TSqlFragment node)
        {
            base.Visit(node);

            var fragmentType      = node.GetType();
            var isFragmentPresent = SpecificConfiguration.AffectedFragmentTypes.Any(aX => aX.IsAssignableFrom(fragmentType));

            if (isFragmentPresent)
            {
                AddFinding(node, $"{SpecificConfiguration.ViolationMessage} ({fragmentType.Name})");
            }
        }
        private ISyntaxNode VisitNode(TSqlFragment node, TSqlFragment parent, string sourceProperty, ISyntaxNode result)
        {
            ISyntaxTreeVisitor visitor;

            if (Visitors.TryGetValue(node.GetType(), out visitor))
            {
                // TODO: visitor.BeforeVisitAction(); // set visiting context
                return(visitor.Visit(node, parent, sourceProperty, result));
                // TODO: visitor.AfterVisitAction(); // clear or restore context
            }
            return(result);
        }
        private void VisitChildren(TSqlFragment parent, TreeNodeViewModel result)
        {
            Type type = parent.GetType();

            // visit children which resides in properties
            foreach (PropertyInfo property in type.GetProperties())
            {
                // ignore indexed properties
                if (property.GetIndexParameters().Length > 0) // property is an indexer
                {
                    // indexer property name is "Item" and it has parameters
                    continue;
                }

                // get type of property
                Type propertyType = property.PropertyType;
                bool isList       = (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(IList <>));
                if (isList)
                {
                    propertyType = propertyType.GetGenericArguments()[0];
                }

                // continue if child is not TSqlFragment
                if (!propertyType.IsSubclassOf(typeof(TSqlFragment)))
                {
                    continue;
                }

                // check if property is null
                object child = property.GetValue(parent);
                if (child == null)
                {
                    continue;
                }

                // visit property or collection
                if (isList)
                {
                    IList list = (IList)child;
                    for (int i = 0; i < list.Count; i++)
                    {
                        object item = list[i];
                        VisitRecursively((TSqlFragment)item, result);
                    }
                }
                else
                {
                    VisitRecursively((TSqlFragment)child, result);
                }
            }
        }
        private void VisitChildren(TSqlFragment parent, ISyntaxNode result)
        {
            Type type = parent.GetType();

            IList <PropertyInfo> properties = GetProperties(type); // considering order priority defined by type visitor

            foreach (PropertyInfo property in properties)
            {
                if (property.GetIndexParameters().Length > 0) // property is an indexer
                {
                    // indexer property name is "Item" with parameters
                    continue;
                }

                Type propertyType = property.PropertyType;
                bool isList       = (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(IList <>));

                if (isList)
                {
                    propertyType = propertyType.GetGenericArguments()[0];
                }
                if (!propertyType.IsSubclassOf(typeof(TSqlFragment)))
                {
                    continue;
                }

                object child = property.GetValue(parent);
                if (child == null)
                {
                    continue;
                }

                if (isList)
                {
                    IList list = (IList)child;
                    for (int i = 0; i < list.Count; i++)
                    {
                        object item = list[i];
                        VisitRecursively((TSqlFragment)item, parent, property.Name, result);
                    }
                }
                else
                {
                    VisitRecursively((TSqlFragment)child, parent, property.Name, result);
                }
            }
        }
        /// <summary>
        /// Converts a tsql object into a fragment
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="parseErrors"></param>
        /// <returns></returns>
        public static TSqlFragment GetFragment(this TSqlObject obj, out IList <ParseError> parseErrors)
        {
            var          tsqlParser = new TSql140Parser(true);
            TSqlFragment fragment   = null;

            using (StringReader stringReader = new StringReader(obj.GetScript()))
            {
                fragment = tsqlParser.Parse(stringReader, out parseErrors);

                //so even after parsing, some scripts are coming back as tsql script, lets try to get the root object
                if (fragment.GetType() == typeof(TSqlScript))
                {
                    fragment = ((TSqlScript)fragment).Batches.FirstOrDefault()?.Statements.FirstOrDefault();
                }
            }
            return(fragment);
        }
        /// <summary>
        /// Transforms syntax node into tree view node
        /// </summary>
        /// <param name="node">Syntax node to transform</param>
        /// <param name="result">Result of transformation</param>
        /// <returns></returns>
        private TreeNodeViewModel VisitNode(TSqlFragment node, TreeNodeViewModel result)
        {
            Type type = node.GetType();
            TreeNodeViewModel child = new TreeNodeViewModel()
            {
                NodeText = type.Name
            };
            PropertyInfo property = type.GetProperty("Value");

            if (property != null)
            {
                object value = property.GetValue(node);
                child.NodeText += " = " + (value == null ? string.Empty : value.ToString());
            }
            result.TreeNodes.Add(child);
            return(child);
        }
Exemple #10
0
        private void TransformToBinaryLiteral(ColumnReferenceExpression node, TSqlFragment parent, string sourceProperty, TSqlFragment expression)
        {
            PropertyInfo property = parent.GetType().GetProperty(sourceProperty);
            bool         isList   = (property.PropertyType.IsGenericType &&
                                     property.PropertyType.GetGenericTypeDefinition() == typeof(IList <>));

            if (isList)
            {
                IList list  = (IList)property.GetValue(parent);
                int   index = list.IndexOf(node);
                list[index] = expression;
            }
            else
            {
                property.SetValue(parent, expression);
            }
        }
Exemple #11
0
        private void Transform(TSqlFragment parent, string sourceProperty, FunctionCall functionCall, int typeCode)
        {
            string        HexTypeCode   = $"0x{typeCode.ToString("X").PadLeft(8, '0')}";
            BinaryLiteral binaryLiteral = new BinaryLiteral()
            {
                Value = HexTypeCode
            };

            PropertyInfo pi     = parent.GetType().GetProperty(sourceProperty);
            bool         isList = (pi.PropertyType.IsGenericType && pi.PropertyType.GetGenericTypeDefinition() == typeof(IList <>));

            if (isList)
            {
                IList list  = (IList)pi.GetValue(parent);
                int   index = list.IndexOf(functionCall);
                list[index] = binaryLiteral;
            }
            else
            {
                pi.SetValue(parent, binaryLiteral);
            }
        }
        public StatementList GetStatementList(TSqlFragment fragment)
        {
            var fragmentTypeName = fragment.GetType().Name;
            var statementList    = new StatementList();

            switch (fragmentTypeName.ToLower())
            {
            case "createprocedurestatement":
                return((fragment as CreateProcedureStatement)?.StatementList);

            case "createviewstatement":
                statementList.Statements.Add((fragment as CreateViewStatement)?.SelectStatement);
                return(statementList);

            case "createfunctionstatement":
                var func = (fragment as CreateFunctionStatement);
                if (func == null)
                {
                    return(null);
                }

                var returnType = func.ReturnType as SelectFunctionReturnType;
                //this is an ITVF, and does not have a statement list, it has one statement in the return block...
                if (func.StatementList == null && returnType != null)
                {
                    statementList.Statements.Add(returnType.SelectStatement);
                    return(statementList);
                }

                return(func.StatementList);

            case "createtriggerstatement":
                return((fragment as CreateTriggerStatement)?.StatementList);

            default:
                //throw new ApplicationException("Unable to determine statement list for fragment type: " + fragmentTypeName);
                return(null);
            }
        }
Exemple #13
0
        private void VisitReferenceTypeColumn(ColumnReferenceExpression node, TSqlFragment parent, string sourceProperty, Identifier identifier, Property property)
        {
            if (property.Fields.Count == 1) // Т.Ссылка (не составной тип)
            {
                string hexTypeCode = $"0x{property.PropertyTypes[0].ToString("X").PadLeft(8, '0')}";
                identifier.Value = property.Fields[0].Name;
                ParenthesisExpression expression = new ParenthesisExpression()
                {
                    Expression = new ScriptDom.BinaryExpression()
                    {
                        BinaryExpressionType = BinaryExpressionType.Add,
                        FirstExpression      = new BinaryLiteral()
                        {
                            Value = hexTypeCode
                        },
                        SecondExpression = node
                    }
                };
                PropertyInfo pi     = parent.GetType().GetProperty(sourceProperty);
                bool         isList = (pi.PropertyType.IsGenericType && pi.PropertyType.GetGenericTypeDefinition() == typeof(IList <>));
                if (isList)
                {
                    IList list  = (IList)pi.GetValue(parent);
                    int   index = list.IndexOf(node);
                    list[index] = expression;
                }
                else
                {
                    pi.SetValue(parent, expression);
                }
            }
            else // Т.Владелец (составной тип)
            {
                Field typeCode  = property.Fields.Where(f => f.Purpose == FieldPurpose.TypeCode).FirstOrDefault();
                Field reference = property.Fields.Where(f => f.Purpose == FieldPurpose.Object).FirstOrDefault();
                identifier.Value = reference.Name;

                MultiPartIdentifier mpi = new MultiPartIdentifier();
                foreach (var id in node.MultiPartIdentifier.Identifiers)
                {
                    mpi.Identifiers.Add(new Identifier()
                    {
                        Value = id.Value
                    });
                }
                mpi.Identifiers[mpi.Count - 1].Value = typeCode.Name;
                ParenthesisExpression expression = new ParenthesisExpression()
                {
                    Expression = new ScriptDom.BinaryExpression()
                    {
                        BinaryExpressionType = BinaryExpressionType.Add,
                        FirstExpression      = new ColumnReferenceExpression()
                        {
                            ColumnType          = ColumnType.Regular,
                            MultiPartIdentifier = mpi
                        },
                        SecondExpression = node
                    }
                };

                PropertyInfo pi     = parent.GetType().GetProperty(sourceProperty);
                bool         isList = (pi.PropertyType.IsGenericType && pi.PropertyType.GetGenericTypeDefinition() == typeof(IList <>));
                if (isList)
                {
                    IList list  = (IList)pi.GetValue(parent);
                    int   index = list.IndexOf(node);
                    list[index] = expression;
                }
                else
                {
                    pi.SetValue(parent, expression);
                }
            }
        }
        public Node parse(TSqlFragment tsqlnode, Node parent_node = null, string parent_key_name = null)
        {
            Node node = new Node();

            node.class_name = tsqlnode.GetType().Name;

            if (tsqlnode.FirstTokenIndex >= 0)
            {
                StringBuilder sb = new StringBuilder();
                for (var i = tsqlnode.FirstTokenIndex; i <= tsqlnode.LastTokenIndex; i++)
                {
                    sb.Append(tsqlnode.ScriptTokenStream[i].Text);
                }
                node.token = sb.ToString();
            }

            if (parent_node != null)
            {
                parent_node.setListDic(parent_key_name, node);
            }

            foreach (var prop in tsqlnode.GetType().GetProperties())
            {
                if ((new List <string> {
                    "ScriptTokenStream", "StartOffset", "FragmentLength", "StartLine", "StartColumn", "FirstTokenIndex", "LastTokenIndex"
                })
                    .Contains(prop.Name))
                {
                    //NOP
                }
                else if (prop.PropertyType.IsEnum == true & prop.PropertyType.Namespace == "Microsoft.SqlServer.TransactSql.ScriptDom")
                {
                    node.setDic(prop.Name, prop.GetValue(tsqlnode).ToString());
                }
                else
                {
                    System.Reflection.ParameterInfo[] param_infos = prop.GetIndexParameters();
                    var index_length = prop.GetIndexParameters().Length;
                    if (index_length > 0)
                    {
                        //index parameter
                    }
                    else
                    {
                        var prop_value = prop.GetValue(tsqlnode);
                        if (prop_value == null)
                        {
                            //NOP
                        }
                        else
                        {
                            var prop_value_type = prop_value.GetType();
                            if (prop_value_type.IsGenericType)
                            {
                                if (typeof(List <>).IsAssignableFrom(prop_value.GetType().GetGenericTypeDefinition()))
                                {
                                    IEnumerable <object> list = (IEnumerable <object>)prop_value;

                                    foreach (var v in list)
                                    {
                                        if (v.GetType().IsSubclassOf(typeof(TSqlFragment)))
                                        {
                                            parse((TSqlFragment)v, node, prop.Name);
                                        }
                                    }
                                }
                                else
                                {
                                    Console.Error.WriteLine($"not support!\t{prop.Name}\t{prop_value_type.Name}\t{prop_value}");
                                }
                            }
                            else if (prop_value_type.IsSubclassOf(typeof(TSqlFragment)))
                            {
                                parse((TSqlFragment)prop_value, node, prop.Name);
                            }
                            else
                            {
                                node.setDic(prop.Name, prop.GetValue(tsqlnode).ToString());
                            }
                        }
                    }
                }
            }
            return(node);
        }
        private void EmitFragment(int indent, TSqlFragment fragment)
        {
            var t = fragment.GetType();
            Func <PropertyInfo, bool> __9__0 = null;

            while (t != null && t != typeof(TSqlFragment))
            {
                var properties = TypeDescriptor.GetProperties(t);
                IEnumerable <PropertyInfo> arg_50_0 = t.GetProperties();
                Func <PropertyInfo, bool>  arg_50_1;
                if ((arg_50_1 = __9__0) == null)
                {
                    arg_50_1 = (__9__0 = ((PropertyInfo e) => e.DeclaringType == t && e.GetIndexParameters().Length == 0));
                }
                foreach (var current in arg_50_0.Where(arg_50_1))
                {
                    var propertyDescriptor = properties[current.Name];
                    var value      = current.GetValue(fragment);
                    var enumerable = value as IEnumerable <TSqlFragment>;
                    var flag       = value == null;
                    if (flag)
                    {
                        this.EmitLine(indent + 1, current, null, false);
                    }
                    else
                    {
                        var flag2 = enumerable != null;
                        if (flag2)
                        {
                            var array = enumerable.ToArray <TSqlFragment>();
                            this.EmitLine(indent + 1, current, (array.Length == 0) ? null : string.Format(" ({0}[])", value.GetType().GetGenericArguments()[0].Name), false);
                            this.EmitFragmentList(indent + 1, current, array);
                        }
                        else
                        {
                            var flag3 = value is Literal;
                            if (flag3)
                            {
                                var literal = (Literal)value;
                                this.EmitLine(indent + 1, current, string.Format(" ({0})  '{1}'", value.GetType().Name, literal.Value), false);
                            }
                            else
                            {
                                var flag4 = value is Identifier;
                                if (flag4)
                                {
                                    var identifier = (Identifier)value;
                                    this.EmitLine(indent + 1, current, string.Format(" ({0})  '{1}'", value.GetType().Name, identifier.Value), false);
                                }
                                else
                                {
                                    var flag5 = value is IdentifierOrValueExpression;
                                    if (flag5)
                                    {
                                        var identifierOrValueExpression = (IdentifierOrValueExpression)value;
                                        this.EmitLine(indent + 1, current, string.Format(" ({0})  '{1}'", value.GetType().Name, identifierOrValueExpression.Value), false);
                                    }
                                    else
                                    {
                                        var flag6 = value is ColumnReferenceExpression;
                                        if (flag6)
                                        {
                                            var    columnReferenceExpression = (ColumnReferenceExpression)value;
                                            var    arg_255_1 = indent + 1;
                                            var    arg_255_2 = current;
                                            var    arg_24F_0 = " ({0})  {1}";
                                            object arg_24F_1 = value.GetType().Name;
                                            var    arg_24A_0 = ".";
                                            IEnumerable <Identifier> arg_245_0 = columnReferenceExpression.MultiPartIdentifier.Identifiers;
                                            var arg_245_1 = (new Func <Identifier, string>(id => "[" + id.Value + "]"));
                                            this.EmitLine(arg_255_1, arg_255_2,
                                                          string.Format(arg_24F_0, arg_24F_1, string.Join(arg_24A_0, arg_245_0.Select(arg_245_1))), false);
                                        }
                                        else
                                        {
                                            var flag7 = value is SchemaObjectName;
                                            if (flag7)
                                            {
                                                var    schemaObjectName            = (SchemaObjectName)value;
                                                var    arg_2CD_1                   = indent + 1;
                                                var    arg_2CD_2                   = current;
                                                var    arg_2C7_0                   = " ({0})  {1}";
                                                object arg_2C7_1                   = value.GetType().Name;
                                                var    arg_2C2_0                   = ".";
                                                IEnumerable <Identifier> arg_2BD_0 = schemaObjectName.Identifiers;
                                                var arg_2BD_1 = (new Func <Identifier, string>(id => "[" + id.Value + "]"));
                                                this.EmitLine(arg_2CD_1, arg_2CD_2, string.Format(arg_2C7_0, arg_2C7_1, string.Join(arg_2C2_0, arg_2BD_0.Select(arg_2BD_1))), false);
                                            }
                                            else
                                            {
                                                var flag8 = typeof(TSqlFragment).IsAssignableFrom(current.PropertyType);
                                                if (flag8)
                                                {
                                                    this.EmitLine(indent + 1, current, " (" + value.GetType().Name + ")", false);
                                                    this.EmitFragment(indent + 1, (TSqlFragment)value);
                                                }
                                                else
                                                {
                                                    try
                                                    {
                                                        this.EmitLine(indent + 1, current, value, Convert.ToInt64(value).Equals(0L));
                                                    }
                                                    catch
                                                    {
                                                        this.EmitLine(indent + 1, current, value, value.Equals(0));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                t = t.BaseType;
            }
        }
 public static string WhatIsThis(this TSqlFragment fragment)
 {
     return(fragment.GetType().Name + " # " + fragment.AsText());
 }
 public string GetFragmentTypeName(TSqlFragment fragment)
 {
     return fragment.GetType().Name;
 }
		private void EmitFragment(int indent, TSqlFragment fragment)
		{
			var t = fragment.GetType();
			Func<PropertyInfo, bool> __9__0 = null;
			while (t != null && t != typeof(TSqlFragment))
			{
				var properties = TypeDescriptor.GetProperties(t);
				IEnumerable<PropertyInfo> arg_50_0 = t.GetProperties();
				Func<PropertyInfo, bool> arg_50_1;
				if ((arg_50_1 = __9__0) == null)
				{
					arg_50_1 = (__9__0 = ((PropertyInfo e) => e.DeclaringType == t && e.GetIndexParameters().Length == 0));
				}
				foreach (var current in arg_50_0.Where(arg_50_1))
				{
					var propertyDescriptor = properties[current.Name];
					var value = current.GetValue(fragment);
					var enumerable = value as IEnumerable<TSqlFragment>;
					var flag = value == null;
					if (flag)
					{
						this.EmitLine(indent + 1, current, null, false);
					}
					else
					{
						var flag2 = enumerable != null;
						if (flag2)
						{
							var array = enumerable.ToArray<TSqlFragment>();
							this.EmitLine(indent + 1, current, (array.Length == 0) ? null : string.Format(" ({0}[])", value.GetType().GetGenericArguments()[0].Name), false);
							this.EmitFragmentList(indent + 1, current, array);
						}
						else
						{
							var flag3 = value is Literal;
							if (flag3)
							{
								var literal = (Literal)value;
								this.EmitLine(indent + 1, current, string.Format(" ({0})  '{1}'", value.GetType().Name, literal.Value), false);
							}
							else
							{
								var flag4 = value is Identifier;
								if (flag4)
								{
									var identifier = (Identifier)value;
									this.EmitLine(indent + 1, current, string.Format(" ({0})  '{1}'", value.GetType().Name, identifier.Value), false);
								}
								else
								{
									var flag5 = value is IdentifierOrValueExpression;
									if (flag5)
									{
										var identifierOrValueExpression = (IdentifierOrValueExpression)value;
										this.EmitLine(indent + 1, current, string.Format(" ({0})  '{1}'", value.GetType().Name, identifierOrValueExpression.Value), false);
									}
									else
									{
										var flag6 = value is ColumnReferenceExpression;
										if (flag6)
										{
											var columnReferenceExpression = (ColumnReferenceExpression) value;
											var arg_255_1 = indent + 1;
											var arg_255_2 = current;
											var arg_24F_0 = " ({0})  {1}";
											object arg_24F_1 = value.GetType().Name;
											var arg_24A_0 = ".";
											IEnumerable<Identifier> arg_245_0 = columnReferenceExpression.MultiPartIdentifier.Identifiers;
											var arg_245_1 = (new Func<Identifier, string>(id => "[" + id.Value + "]"));
											this.EmitLine(arg_255_1, arg_255_2,
												string.Format(arg_24F_0, arg_24F_1, string.Join(arg_24A_0, arg_245_0.Select(arg_245_1))), false);
										}
										else
										{
											var flag7 = value is SchemaObjectName;
											if (flag7)
											{
												var schemaObjectName = (SchemaObjectName)value;
												var arg_2CD_1 = indent + 1;
												var arg_2CD_2 = current;
												var arg_2C7_0 = " ({0})  {1}";
												object arg_2C7_1 = value.GetType().Name;
												var arg_2C2_0 = ".";
												IEnumerable<Identifier> arg_2BD_0 = schemaObjectName.Identifiers;
												var arg_2BD_1 = ( new Func<Identifier, string>(id => "[" + id.Value + "]"));
												this.EmitLine(arg_2CD_1, arg_2CD_2, string.Format(arg_2C7_0, arg_2C7_1, string.Join(arg_2C2_0, arg_2BD_0.Select(arg_2BD_1))), false);
											}
											else
											{
												var flag8 = typeof(TSqlFragment).IsAssignableFrom(current.PropertyType);
												if (flag8)
												{
													this.EmitLine(indent + 1, current, " (" + value.GetType().Name + ")", false);
													this.EmitFragment(indent + 1, (TSqlFragment)value);
												}
												else
												{
													try
													{
														this.EmitLine(indent + 1, current, value, Convert.ToInt64(value).Equals(0L));
													}
													catch
													{
														this.EmitLine(indent + 1, current, value, value.Equals(0));
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
				t = t.BaseType;
			}
		}
Exemple #19
0
            public override void Visit(TSqlFragment node)
            {
                Action <TSqlFragment> action = outer.Lookup(node.GetType());

                action(node);
            }
        public override void Visit(TSqlFragment node)
        {
            fragmentIndex++;
            if (DumpEnabled)
            {
                Console.WriteLine(fragmentIndex + " " + prefix + node.GetType().Name + "  " + node.AsText());
            }
            if ((node is TSqlScript) ||
                (node is TSqlBatch) ||
                (node is BeginEndBlockStatement) || // CREATE PROCEDURE
                (node is StatementList) ||
                (node is DeclareVariableStatement) || // skip
                (node is DeclareVariableElement) || // skip
                (node is Identifier) || // skip
                (node is SqlDataTypeReference) || // NVARCHAR(MAX)
                (node is SchemaObjectName) || // NVARCHAR
                (node is MaxLiteral) || // MAX
                (node is DeclareTableVariableStatement) || // DECLARE @table TABLE(
                (node is DeclareTableVariableBody) || // @table TABLE(cmdbflowname...
                (node is TableDefinition) || // cmdbflowname NVARCHAR(...
                (node is ColumnDefinition) || // cmdbflowname NVARCHAR(255) NOT NULL
                (node is IntegerLiteral) || // 255
                (node is NullableConstraintDefinition) // NOT NULL

                || (node is InsertStatement) ||
                (node is InsertSpecification) ||
                (node is VariableTableReference) ||
                (node is SelectInsertSource) || // SELECT S.id, [root].
                (node is QuerySpecification) ||
                (node is ColumnReferenceExpression) ||
                (node is MultiPartIdentifier) ||
                (node is FromClause) ||
                (node is QualifiedJoin) ||
                (node is NamedTableReference) || // [dbo].[hlspcmdbflow] AS [root]
                (node is BooleanComparisonExpression) // S.id = [root].[cmdbflowname]

                || (node is VariableReference) ||
                (node is IfStatement) ||
                (node is TryCatchStatement) ||
                (node is SelectElement)

                || (node is ExistsPredicate) || // (SELECT * FROM
                (node is ScalarSubquery) || // (SELECT * FROM @table WHERE cmdbflowid IS NULL OR cmdbflowatt
                (node is WhereClause) || // WHERE cmdbflowid IS NULL OR cmdbflowattri
                (node is BooleanBinaryExpression) || // cmdbflowid IS NULL OR cmdbflowattributeid IS N
                (node is BooleanIsNullExpression) // cmdbflowid IS NULL O

                || (node is SelectStatement) || // SELECT TOP 1 @cmdb
                (node is TopRowFilter) || // TOP 1
                (node is SetVariableStatement) || // SET @error_text = CONCAT(N'C
                (node is FunctionCall) || // CONCAT(N'CmdbFlowAttrib
                (node is StringLiteral) || // N'CmdbFlowAtt
                (node is CastCall) || //CAST(@cmdbflowattributeid AS NVARCHAR(50))
                (node is ThrowStatement) || // THROW 50000, @error_text, 1;
                (node is IdentifierOrValueExpression) || // AttributeDefId
                (node is GroupByClause) || // GROUP BY [a].[attributeid]
                (node is ExpressionGroupingSpecification) // [a].[attributeid]

                //|| (node is ColumnReferenceExpression)
                //|| (node is MultiPartIdentifier)
                //|| (node is Identifier)
                //|| (node is IntegerLiteral)
                //|| (node is BooleanIsNullExpression)
                //|| (node is StringLiteral)

                || (node is ValuesInsertSource) || //=> VALUES(@parentid, @domain, @href, @rel, @title)
                (node is RowValue) || //  (@parentid, @domain, @href, @rel, @title)
                (node is ReturnStatement) || //  RETURN @@ROWCOUNT
                (node is GlobalVariableExpression) || //  @@ROWCOUNT
                (node is DeleteStatement) || //  DELETE [dbo].[hlcmhypermedialinks] WHE
                (node is DeleteSpecification) || //  DELETE [dbo].[hlcmhypermedialinks]
                (node is UpdateStatement) || //  UPDATE [dbo].[hlcmhypermedialinks]
                (node is UpdateSpecification) || //  UPDATE [dbo].[hlcmhypermedialinks]
                (node is AssignmentSetClause) || //  title = @title
                (node is PredicateSetStatement) || //  SET NOCOUNT ON;
                (node is UniqueConstraintDefinition) || //  PRIMARY KEY ([actionid])
                (node is ColumnWithSortOrder) || //  [actionid]
                (node is SchemaObjectFunctionTableReference) || //  [dbo].[hlsyssec_query_agentobjectmsk](@age
                (node is IIfCall) || //  IIF(@objecttype = 7, 789, @objecttype + 783)
                (node is BinaryExpression) || //  @objecttype + 783
                (node is ParenthesisExpression) || //  (@accessmask & 133)
                (node is TableHint) || //  NOLOCK
                (node is BooleanParenthesisExpression) || //  (@isportalsupporter = 1 OR @reservedbyme
                (node is SimpleCaseExpression) || //  CASE [actionid] WHEN 5
                (node is SimpleWhenClause) || //  WHEN 5 /
                (node is OrderByClause) || //  ORDER BY [cs].[creationtime]
                (node is ExpressionWithSortOrder) || //  [cs].[creationtime]
                (node is OffsetClause) || //  OFFSET     @skip ROWS
                (node is UnqualifiedJoin) || //  [dbo].[hlsyssuassociation] AS [ac]
                (node is UserDataTypeReference) || //  SYSNAME
                (node is RaiseErrorStatement) || //  RAISERROR (@errortext, 16, 2)
                (node is MergeStatement) || //  MERGE [dbo].[hlspcmdbflow] AS T
                (node is MergeSpecification) || //  MERGE [dbo].[hlspcmdbflow] AS T
                (node is QueryDerivedTable) || //  (SELECT @processrootid AS cmdbflowid,
                (node is MergeActionClause) || //  INSERT (cmdbflowid, cmdbflowname, deploytime)
                (node is InsertMergeAction) || //  INSERT (cmdbflowid, cmdbflowname, deploytime)
                (node is UpdateMergeAction) || //  UPDATE SET T.deploytime = GETUTCDATE()
                (node is WithCtesAndXmlNamespaces) || //  WITH PartialTarget AS
                (node is CommonTableExpression) || //  PartialTarget AS
                (node is DeleteMergeAction) || //  DELETE
                (node is ExecuteStatement) || //  EXEC [dbo].[hlsp_persistattributes_bool]
                (node is ExecuteSpecification) || //  EXEC [dbo].[hlsp_persistattributes_bool] @
                (node is ExecutableProcedureReference) || //  [dbo].[hlsp_persistattributes_bool] @
                (node is ExecuteParameter) || //  @spinstanceid = @spinstanceid
                (node is ProcedureReferenceName) || //  [dbo].[hlsp_persistattributes_bool]
                (node is ProcedureReference) || //  [dbo].[hlsp_persistattributes_bool]
                (node is BooleanNotExpression) || //  NOT ISNULL(S.[attributevalue],N'') = N''
                (node is OutputClause) || //  OUTPUT INSERTED.[actioncontextid]
                (node is NextValueForExpression) || //  NEXT VALUE FOR [dbo].[SEQ_h
                (node is PrintStatement) || //  PRINT(N'do nothing');
                (node is SetRowCountStatement) || //  SET ROWCOUNT 0
                (node is XmlDataTypeReference) || //  XML
                (node is XmlForClause) || //  PATH(N'person'), ELEMENTS
                (node is XmlForClauseOption) || //  PATH(N'person')
                (node is BinaryQueryExpression) || //  SELECT CAST(N'A' AS SYSNAME) producer
                (node is ConvertCall) || //  CONVERT(NVARCHAR(100), DATEDIFF(m
                (node is ParameterlessCall) || //  CURRENT_TIMESTAMP
                (node is OutputIntoClause) || //  OUTPUT ISNULL(INSERTED.id, DELETED.ID) INTO
                (node is MultiPartIdentifierCallTarget) || //  trs
                (node is VariableMethodCallTableReference) || //  @translationmodel.nodes(N'declare default element nam
                (node is OverClause) || //  OVER(PARTITION BY tv.tthc, ttlcid ORDER BY LEN(ttvalu
                (node is SetCommandStatement) || //  SET DEADLOCK_PRIORITY LOW;
                (node is GeneralSetCommand) || //  LOW
                (node is IdentifierLiteral) || //  LOW
                (node is InPredicate) || //  requestid IN (SELECT id FROM @mailstoprocess)
                (node is WhileStatement) || //  WHILE @rowcount > 0
                (node is UnaryExpression) || //  -@retentiondays
                (node is BeginTransactionStatement) || //  BEGIN TRANSACTION;
                (node is ExecuteInsertSource) || //  EXEC
                (node is ExecutableStringList) || // N''hlsys_searchdata_targetsvc'' AND[ce].[state] = ''CO''
                (node is BeginDialogStatement) || //  BEGIN DIALOG CONVERSATION @ch
                (node is OnOffDialogOption) || //  OFF
                (node is SendStatement) || //  SEND ON CONVERSATION @ch MESSAG
                (node is CommitTransactionStatement) || //  COMMIT;
                (node is RollbackTransactionStatement) || //  ROLLBACK TRANSACTION
                (node is NullLiteral) || //  NULL
                (node is WaitForStatement) || //  WAITFOR(
                (node is ReceiveStatement) || //  RECEIVE TOP (1) @ch = co
                (node is InlineDerivedTable) || //  (VALUES (@objectdefid, 10, GETUTCDATE(), @a
                (node is EndConversationStatement) || //  @initiatorconversationhandle
                (node is BinaryLiteral) || //  0xC0400081
                (node is SearchedCaseExpression) || //  CASE WHEN @isapproved = 1 THEN 2
                (node is SearchedWhenClause) || //  WHEN @isapproved = 1 THEN 2
                (node is CoalesceExpression) || //  COALESCE(tib_fromtime,tia_totime,0)
                (node is BooleanTernaryExpression) || //  rd.dayno_wrk BETWEEN (@dfd1_dayno_wrk+1
                (node is BreakStatement) || //  BREAK
                (node is ExpressionCallTarget) || //  s.v.query (N'Name')
                (node is LikePredicate) || //  regkeyvaluedata LIKE(N'dword:%')
                (node is DefaultConstraintDefinition) || //  DEFAULT(0)
                (node is CheckConstraintDefinition) || //  CHECK([configurationid]=1)
                (node is AlterSequenceStatement) || //  ALTER SEQUENCE [dbo].[SEQ_hlsysdailycounter] R
                (node is ScalarExpressionSequenceOption) || //  RESTART WITH 1
                (node is SetTransactionIsolationLevelStatement) || //  SET TRANSACTION ISOLATION LEVEL
                (node is SetIdentityInsertStatement) || //  SET IDENTITY_INSERT [dbo].[hlsysde
                (node is NullIfExpression) || //  NULLIF(@objectid, 0)
                (node is XmlNamespaces) || //  N'http://tempuri.org/hlsys.xsd' AS pd)
                (node is XmlNamespacesAliasElement) || //  N'http://tempuri.org/hlsys.xsd' AS pd
                (node is AlterTableConstraintModificationStatement) || //  ALTER TABLE [dbo].[hlspatt
                (node is DbccStatement) || //  DBCC CHECKIDENT (N'dbo.hlsysattrpathodedef', RESEED, 1);
                (node is DbccNamedLiteral) || //  N'dbo.hlsysattrpathodedef'
                (node is XmlNamespacesDefaultElement) || //  DEFAULT N'pd'
                (node is DefaultLiteral) || //  DEFAULT
                (node is QueryParenthesisExpression) || // hltm_getnotificationagentids (SELECT a3.objectida, a3.objectdefida
                (node is FullTextPredicate) || // CONTAINS()
                (node is FullTextTableReference) || // CONTAINS()
                (node is SelectFunctionReturnType) || //  SELECT dv.[defaultattrpathid]
                (node is LeftFunctionCall) || //  LEFT([cd].[description], 100)
                (node is HavingClause) || //  HAVING MIN([fullfillment].[state]) < 2 AND MAX([fullfillment].[state]) >= 2
                (node is TryCastCall) || //  TRY_CAST(settingvalue AS INT)
                (node is CheckpointStatement) //  CHECKPOINT;
                )
            {
                if (node is SelectInsertSource)
                {
                }
                // ok
            }
            else
            {
                //throw new NotImplementedException("Node type:" + node.GetType().Name);
                throw new NotImplementedException("|| (node is " + node.GetType().Name + ") //  " + node.AsText());
            }
            base.Visit(node);
        }