public override void VisitNamespaceDeclaration(NamespaceDeclarationSyntax node)
        {
            MainDeclaration.Instance.RoslynWatch.Start();
            INamespaceSymbol namescpaceSymbol = MainDeclaration.Instance.Model.GetDeclaredSymbol(node);

            MainDeclaration.Instance.RoslynWatch.Stop();

            INamespaceSymbol actualNamespaceFromMergedNamespace = GetActualNamespaceFromMergedNamespace(namescpaceSymbol, node);

            Package limNode = SymbolBuilder.BuildDispatch <Package, INamespaceSymbol>(actualNamespaceFromMergedNamespace);

            MainDeclaration.Instance.LimOrigin.addCompIdCsharpIdLimIdToMap(MainDeclaration.Instance.Component.Id, _map[node], limNode.Id);

            node.CreateCommentNode(actualNamespaceFromMergedNamespace);
            node.CreateCommentForCU();

            base.VisitNamespaceDeclaration(node);

            if (MainDeclaration.Instance.NamespaceStack.Peek() > 0 && MainDeclaration.Instance.UsesStack.Count > 0)
            {
                Package package = (Package)MainDeclaration.Instance.LimFactory.getRef(
                    MainDeclaration.Instance.NamespaceStack.Peek()
                    );
                Commons.Common.AddUses(package);
                MainDeclaration.Instance.UsesStack.Pop();
            }

            limNode.SetCLOC(node);
            var location = node.GetLocation();

            location.CalculateFileLevelCommentLines();
            location.CalculateFileLevelNumberOfBranches();
        }
Ejemplo n.º 2
0
            public override void VisitNamespaceDeclaration(NamespaceDeclarationSyntax node)
            {
                base.VisitNamespaceDeclaration(node);
                ++this.namespaceDeclarationCount;

                if (this.namespaceDeclarationCount > 1)
                {
                    var diagnostic = Diagnostic.Create(
                        Rule,
                        node.GetLocation());
                    this.context.ReportDiagnostic(diagnostic);
                }
            }
Ejemplo n.º 3
0
        public static void Analyze(SyntaxNodeAnalysisContext context, NamespaceDeclarationSyntax declaration)
        {
            if (!declaration.Members.Any())
            {
                SyntaxToken openBrace  = declaration.OpenBraceToken;
                SyntaxToken closeBrace = declaration.CloseBraceToken;

                if (!openBrace.IsMissing &&
                    !closeBrace.IsMissing &&
                    openBrace.TrailingTrivia.All(f => f.IsWhitespaceOrEndOfLineTrivia()) &&
                    closeBrace.LeadingTrivia.All(f => f.IsWhitespaceOrEndOfLineTrivia()))
                {
                    context.ReportDiagnostic(
                        DiagnosticDescriptors.RemoveEmptyNamespaceDeclaration,
                        declaration.GetLocation());
                }
            }
        }
Ejemplo n.º 4
0
 public override void VisitNamespaceDeclaration(NamespaceDeclarationSyntax node)
 {
     AddEntry("", node.GetLocation());
     base.VisitNamespaceDeclaration(node);
 }