Пример #1
0
        private void GetDatabaseQueryVariablesInDocument(SyntaxNode root, SemanticModel semanticModel)
        {
            foreach (var node in root.DescendantNodes().OfType <VariableDeclarationSyntax>())
            {
                var varDeclarator = node.DescendantNodes().OfType <VariableDeclaratorSyntax>().First();

                if (SyntaxNodeIsDatabaseQuery(varDeclarator, semanticModel) &&
                    !_databaseQueryVariables.ContainsKey(node))
                {
                    var dbQueryVar = new DatabaseQueryVariableDeclaration <T>(node.Variables[0].Identifier.ToString(), node.GetCompilationInfo(semanticModel));
                    this.DatabaseQueryVariables.Add(dbQueryVar);
                }
            }
        }
 public void SetDatabaseQueryVariable(DatabaseQueryVariableDeclaration <T> databaseQueryVariable)
 {
     this.DatabaseQueryVariable = databaseQueryVariable;
 }
Пример #3
0
        private void AddDatabaseAccessingCall(SyntaxNode node, SemanticModel semanticModel, DatabaseQueryVariableDeclaration <T> queryVariableUsedInCall)
        {
            string queryText = node.GetText().ToString();
            HashSet <DatabaseEntityDeclaration <T> > databaseEntityDeclarationsUsedInQuery = GetDatabaseEntityTypesInQuery(node, semanticModel);
            var compilationInfo = node.GetCompilationInfo(semanticModel);


            if (!AncestorNodeForSameLineIsAlreadyFound(node))
            {
                RemoveAnyDescendantNodeAlreadyFound(node);
                var result = new DatabaseAccessingMethodCallStatement <T>(queryText, databaseEntityDeclarationsUsedInQuery, compilationInfo);

                if (queryVariableUsedInCall != null)
                {
                    result.SetDatabaseQueryVariable(queryVariableUsedInCall);
                }

                DatabaseAccessingMethodCalls.Add(result);
            }
        }