public override object VisitCompilation_unit([NotNull] CSharpParser.Compilation_unitContext context) { var usingDirs = context?.using_directive(); if (usingDirs != null) { foreach (var usingDir in usingDirs) { var usingInner = usingDir.using_directive_inner().GetText(); if (_usingSet.Contains(usingInner)) { _usingSet.Remove(usingInner); } } } VisitChildren(context); if (_usingSet.Count > 0) { var usingStopIndex = _cSharpParserService.GetUsingStopIndex(context); var usingDirectivesStr = _cSharpParserService.GenerateUsingDirectives( _usingSet.ToList(), usingStopIndex.Equals(context.Start)); IsModified = true; Rewriter.InsertAfter(usingStopIndex, usingDirectivesStr); } if (!_hasBreadcrumbNamespace) { var namespaceStopIndex = _cSharpParserService.GetNamespaceStopIndex(context); var breadcrumbNamespaceDeclaration = _breadcrumbCommandParserService.GenerateBreadcrumbNamespaceDeclaration( _breadcrumbNamespace, _breadcrumbDeclaration); IsModified = true; Rewriter.InsertAfter(namespaceStopIndex, breadcrumbNamespaceDeclaration); } return(null); }