public override void Visit(TSqlScript node)
        {
            var typesToUpcase = Constants.TSqlKeywords.Concat(Constants.TSqlDataTypes).ToArray();

            for (var index = 0; index < node.ScriptTokenStream?.Count; index++)
            {
                var token = node.ScriptTokenStream[index];
                if (!typesToUpcase.Contains(token.Text, StringComparer.CurrentCultureIgnoreCase))
                {
                    continue;
                }

                if (IsUpperCase(token.Text))
                {
                    continue;
                }

                var dynamicSQLAdjustment = AdjustColumnForDymamicSQL(token);

                // get a count of all tabs on the line that occur prior to the last token in this node
                var tabsOnLine = ColumnNumberCalculator.CountTabsBeforeToken(token.Line, index, node.ScriptTokenStream);
                var column     = ColumnNumberCalculator.GetColumnNumberBeforeToken(tabsOnLine, token);

                errorCallback(RULE_NAME, RULE_TEXT, token.Line, column + dynamicSQLAdjustment);
            }
        }
Exemplo n.º 2
0
        public override void Visit(TSqlStatement node)
        {
            if (TypesToSkip.Contains(node.GetType()) || EndsWithSemicolon(node))
            {
                return;
            }

            var lastToken  = node.ScriptTokenStream[node.LastTokenIndex];
            var tabsOnLine = ColumnNumberCalculator.CountTabsBeforeToken(lastToken.Line, node.LastTokenIndex, node.ScriptTokenStream);
            var column     = ColumnNumberCalculator.GetColumnNumberAfterToken(tabsOnLine, lastToken);

            ErrorCallback(RULE_NAME, RULE_TEXT, lastToken.Line, column);
        }
Exemplo n.º 3
0
        public override void Visit(TSqlStatement node)
        {
            if (Array.IndexOf(typesToSkip, node.GetType()) > -1 ||
                EndsWithSemicolon(node) ||
                waitForStatements.Contains(node))
            {
                return;
            }

            var dynamicSqlColumnOffset = node.StartLine == DynamicSqlStartLine
                ? DynamicSqlStartColumn
                : 0;

            var lastToken  = node.ScriptTokenStream[node.LastTokenIndex];
            var tabsOnLine = ColumnNumberCalculator.CountTabsBeforeToken(lastToken.Line, node.LastTokenIndex, node.ScriptTokenStream);
            var column     = ColumnNumberCalculator.GetColumnNumberAfterToken(tabsOnLine, lastToken);

            errorCallback(RULE_NAME, RULE_TEXT, lastToken.Line, column + dynamicSqlColumnOffset);
        }
        public override void Visit(TSqlScript node)
        {
            for (var index = 0; index < node.ScriptTokenStream.Count; index++)
            {
                var token = node.ScriptTokenStream[index];
                if (!Constants.TSqlKeywords.Contains(token.Text, StringComparer.CurrentCultureIgnoreCase))
                {
                    continue;
                }

                if (IsUpperCase(token.Text))
                {
                    continue;
                }

                // get a count of all tabs on the line that occur prior to the last token in this node
                var tabsOnLine = ColumnNumberCalculator.CountTabsBeforeToken(token.Line, index, node.ScriptTokenStream);
                var column     = ColumnNumberCalculator.GetColumnNumberBeforeToken(tabsOnLine, token);

                ErrorCallback(RULE_NAME, RULE_TEXT, token.Line, column);
            }
        }
Exemplo n.º 5
0
        public override void Visit(TableReference node)
        {
            void ChildCallback(TSqlFragment childNode)
            {
                var tabsOnLine = ColumnNumberCalculator.CountTabsBeforeToken(childNode.StartLine, childNode.LastTokenIndex, childNode.ScriptTokenStream);
                var column     = ColumnNumberCalculator.GetColumnNumberBeforeToken(tabsOnLine, childNode.ScriptTokenStream[childNode.FirstTokenIndex]);

                ErrorCallback(RULE_NAME, RULE_TEXT, childNode.StartLine, column);
            }

            var childTableJoinVisitor = new ChildTableJoinVisitor();

            node.AcceptChildren(childTableJoinVisitor);

            if (!childTableJoinVisitor.TableJoined)
            {
                return;
            }

            var childTableAliasVisitor = new ChildTableAliasVisitor(ChildCallback, CteNames);

            node.AcceptChildren(childTableAliasVisitor);
        }