예제 #1
0
        public override void ExplicitVisit(SchemaObjectName node)
        {
            if (node.Identifiers.Count() < 1 || node.Identifiers.Count() > 2)
            {
                return;
            }

            var names = Array.ConvertAll((SqlDbType[])Enum.GetValues(typeof(SqlDbType)),
                                         type => type.ToString().ToUpper());

            var id1 = node.Identifiers[0].Value;

            if (names.Contains(id1))
            {
                return;
            }

            var id2 = node.Identifiers.Count() == 2 ? node.Identifiers[1]?.Value : null;

            if (id1 != "dbo" && id2 == null)
            {
                id2 = id1;
                id1 = "dbo";
            }

            var startLocation       = node.StartOffset;
            var endLocation         = node.StartOffset + node.FragmentLength;
            var ids                 = node.Identifiers;
            var collapsedIdentifier = ids.Aggregate(string.Empty,
                                                    (s, identifier) => s + identifier.Value + ".").TrimEnd('.');

            var idPosition = new SqlIdPosition
            {
                Schema        = id1,
                TableName     = id2,
                StartPosition = startLocation,
                EndPosition   = endLocation
            };

            IdPositions.Add(idPosition);
            Console.WriteLine($"[Found Id] {collapsedIdentifier} ({startLocation}, {endLocation})");
        }
예제 #2
0
        public override void ExplicitVisit(MultiPartIdentifierCallTarget callTarget)
        {
            var ids = callTarget.MultiPartIdentifier.Identifiers.Select(x => x.Value);

            if (!ids.Contains("dbo"))
            {
                return;
            }

            var startLocation = callTarget.StartOffset;
            var endLocation   = callTarget.StartOffset + callTarget.FragmentLength;
            var target        = ids.ToArray()[0];

            var idPosition = new SqlIdPosition
            {
                Schema        = target,
                TableName     = null,
                StartPosition = startLocation,
                EndPosition   = endLocation
            };

            IdPositions.Add(idPosition);
            Console.WriteLine($"[Found CallTgt] {target} ({startLocation}, {endLocation})");
        }