コード例 #1
0
 internal static IEnumerable <UsingDirectiveSyntax> Handler(CompilationUnitSyntax root, HashSet <string> noUseUsings)
 {
     DefaultUsing.Remove(noUseUsings);
     return(from usingDeclaration in root.Usings
            where noUseUsings.Contains(usingDeclaration.Name.ToFullString())
            select usingDeclaration);
 }
コード例 #2
0
        public static IEnumerable <UsingDirectiveSyntax> Handler(Diagnostic diagnostic)
        {
            var root   = diagnostic.Location.SourceTree.GetRoot();
            var usings = GetUnableUsing(diagnostic, root.ToFullString());
            var sets   = new HashSet <string>(usings);

            DefaultUsing.Remove(sets);
            return(from usingDeclaration in root.DescendantNodes()
                   .OfType <UsingDirectiveSyntax>()
                   where sets.Contains(usingDeclaration.Name.ToFullString())
                   select usingDeclaration);
        }
コード例 #3
0
        public static IEnumerable <UsingDirectiveSyntax> Handler(CompilationUnitSyntax root, Diagnostic diagnostic)
        {
            var needToRemove = GetUnableUsing(diagnostic);
            var nodes        = from usingDeclaration in root.Usings
                               where usingDeclaration.Name.ToFullString().StartsWith(needToRemove)
                               select usingDeclaration;

            if (nodes != null)
            {
                DefaultUsing.Remove(nodes.Select(item => item.Name.ToFullString()));
            }
            return(nodes);
        }
コード例 #4
0
        public static void RemoveUsingAndNodesFromStartName(this Diagnostic diagnostic, CompilationUnitSyntax root, HashSet <SyntaxNode> removeCollection)
        {
            var usingNode = GetTypeSyntaxNode <UsingDirectiveSyntax>(diagnostic, root);

            if (usingNode != null)
            {
                var usingNodes = (from usingDeclaration in root.Usings
                                  where usingDeclaration.Name.ToString().StartsWith(usingNode.Name.ToString())
                                  select usingDeclaration).ToList();

                removeCollection.UnionWith(usingNodes);
                DefaultUsing.Remove(usingNodes.Select(item => item.Name.ToString()));
            }
        }
コード例 #5
0
        public static IEnumerable <UsingDirectiveSyntax> Handler(Diagnostic diagnostic)
        {
            var needToRemove = GetUnableUsing(diagnostic);
            var nodes        = from usingDeclaration in diagnostic.Location.SourceTree.GetRoot()
                               .DescendantNodes()
                               .OfType <UsingDirectiveSyntax>()
                               where usingDeclaration.Name.ToFullString().StartsWith(needToRemove)
                               select usingDeclaration;

            if (nodes != null)
            {
                DefaultUsing.Remove(nodes.Select(item => item.Name.ToFullString()));
            }
            return(nodes);
        }
コード例 #6
0
 public static void RemoveUsingAndNode(this UsingDirectiveSyntax usingDirectiveSyntax, HashSet <SyntaxNode> removeCollection)
 {
     removeCollection.Add(usingDirectiveSyntax);
     DefaultUsing.Remove(usingDirectiveSyntax.Name.ToString());
 }