I have some ANTLR/C# classes capable of parsing a T-SQL stored procedure, walking its dependencies and identifying the required permissions to execute said stored procedure.
I now need to analyse a couple of relatively large C# .NET projects to identify what stored procedures are called.
It is not enough to just locate ALL stored procedure calls, I need to work from a given method and identify stored procedure calls from that.
We can assume that stored procedures are the only means of invoking SQL.
I suppose ANTLR would assist again, but I am uncertain about a few things
- Is ANTLR the only approach to walking the chain of method calls?
- If I use ANTLR where do I find the 'best' C# .g4 grammar files?
- How would I walk from a method call in one unit to its declaration in another - this is the point on which I am most unsure at the moment
To simplify the problem let us suppose that all stored procedure calls take the form
new SqlCommand()
{
Connection = GetConnection(),
CommandText = "dbo.SomeProcName",
CommandType = CommandType.StoredProcedure
};
for my purposes that is almost true.
My Principal concern is 3. above