Beispiel #1
0
        private void VisitHelper(ProcedureStatementBody node)
        {
            WasVisited  = true;
            SqlFragment = node;
            TSqlStatement statement;

            if (node.StatementList.Statements.Any())
            {
                var predicate = node.StatementList.Statements[0] as PredicateSetStatement;
                if (predicate != null)
                {
                    HasNocountOn = predicate.Options == SetOptions.NoCount && predicate.IsOn;
                    _approximateBodyStartTokenIndex = predicate.LastTokenIndex;
                }
            }

            statement = node.StatementList.Statements.FirstOrDefault(s => (s as SetTransactionIsolationLevelStatement) != null);
            if (statement != null)
            {
                var tran = statement as SetTransactionIsolationLevelStatement;
                HasTransactionIsolationLevel = tran.Level == IsolationLevel.ReadUncommitted;
            }

            for (int i = _approximateBodyStartTokenIndex; i < node.LastTokenIndex; i++)
            {
                TSqlParserToken token = node.ScriptTokenStream[i];
                if (token.TokenType == TSqlTokenType.SingleLineComment)
                {
                    HasComments = true;
                    break;
                }
            }
        }
Beispiel #2
0
        private void VisitHelper(ProcedureStatementBody node)
        {
            WasVisited = true;
              SqlFragment = node;
              TSqlStatement statement;
              if (node.StatementList.Statements.Any())
              {
            var predicate = node.StatementList.Statements[0] as PredicateSetStatement;
            if (predicate != null)
            {
              HasNocountOn = predicate.Options == SetOptions.NoCount && predicate.IsOn;
              _approximateBodyStartTokenIndex = predicate.LastTokenIndex;
            }
              }

              statement = node.StatementList.Statements.FirstOrDefault(s => (s as SetTransactionIsolationLevelStatement) != null);
              if (statement != null)
              {
            var tran = statement as SetTransactionIsolationLevelStatement;
            HasTransactionIsolationLevel = tran.Level == IsolationLevel.ReadUncommitted;
              }

              for (int i = _approximateBodyStartTokenIndex; i < node.LastTokenIndex; i++)
              {
            TSqlParserToken token = node.ScriptTokenStream[i];
            if (token.TokenType == TSqlTokenType.SingleLineComment)
            {
              HasComments = true;
              break;
            }
              }
        }
Beispiel #3
0
 private static Procedure BuildProc(ProcedureStatementBody procExpr) =>
 new Procedure
 {
     Name = new[]
     {
         procExpr.ProcedureReference.Name.DatabaseIdentifier?.Value,
         procExpr.ProcedureReference.Name.SchemaIdentifier?.Value,
         procExpr.ProcedureReference.Name.BaseIdentifier?.Value
     }.Where(x => x != null).ToArray(),
     Parameters = procExpr.Parameters.ToDictionary(
         x => x.VariableName.Value,
         x => TranslateType(x.DataType)),
     Statements = procExpr.StatementList
 };
        public void HandleProcedure(ProcedureStatementBody node)
        {
            var outerPreviousScope = this.currentScopeRef.Current;
            var dbScope            = this.currentScopeRef.Current.GetRoot();
            var declarationScope   = dbScope.CreateChildDeclarationScope("procedure", dbScope.ScopeNameResolverContext);

            this.currentScopeRef.Push(declarationScope);
            var procedureScope = dbScope.CreateChildScope("procedure", dbScope.ScopeNameResolverContext);

            this.currentScopeRef.Push(declarationScope);

            this.ExplicitVisit((ProcedureStatementBody)node);

            this.currentScopeRef.Pop();
            this.currentScopeRef.Pop();
            System.Diagnostics.Debug.Assert(ReferenceEquals(outerPreviousScope, this.currentScopeRef.Current), "previous must be restored.");
        }
        public void ProcessProcedureStatementBody(ProcedureStatementBody StatementBody)
        {
            _smells.AssignmentList.Clear();

            TestProcedureReference(StatementBody.ProcedureReference);
            ParameterList = StatementBody.Parameters;

            NoCountSet = false;
            if (StatementBody.StatementList != null)
            {
                foreach (TSqlFragment Fragment in StatementBody.StatementList.Statements)
                {
                    _smells.ProcessTsqlFragment(Fragment);
                }
                if (!NoCountSet) _smells.SendFeedBack(30, StatementBody.ProcedureReference);
            }
            ParameterList = null;
        }
Beispiel #6
0
        public void ProcessProcedureStatementBody(ProcedureStatementBody StatementBody)
        {
            _smells.AssignmentList.Clear();

            TestProcedureReference(StatementBody.ProcedureReference);
            ParameterList = StatementBody.Parameters;

            NoCountSet = false;
            if (StatementBody.StatementList != null)
            {
                foreach (TSqlFragment Fragment in StatementBody.StatementList.Statements)
                {
                    _smells.ProcessTsqlFragment(Fragment);
                }
                if (!NoCountSet)
                {
                    _smells.SendFeedBack(30, StatementBody.ProcedureReference);
                }
            }
            ParameterList = null;
        }
 public override void ExplicitVisit(ProcedureStatementBody fragment)
 {
     _fragments.Add(fragment);
 }
 public sealed override void ExplicitVisit(ProcedureStatementBody node)
 {
     base.ExplicitVisit(node);
 }
Beispiel #9
0
 public override void ExplicitVisit(ProcedureStatementBody node) { this.action(node); }