Exemplo n.º 1
0
        /// <summary>
        ///   Normalizes the <paramref name="declaration" />.
        /// </summary>
        public override SyntaxNode VisitIndexerDeclaration(IndexerDeclarationSyntax declaration)
        {
            // Nothing to do here for properties without expression bodies
            if (declaration.ExpressionBody == null)
            {
                return(declaration);
            }

            // Nothing to do here for indexers not defined in fault effects or for indexers that are no overrides of some port
            var propertySymbol = declaration.GetPropertySymbol(SemanticModel);

            if (!propertySymbol.ContainingType.IsFaultEffect(SemanticModel) || !propertySymbol.IsOverride)
            {
                return(declaration);
            }

            var originalDeclaration = declaration;
            var statements          = AsStatementBody(propertySymbol.GetMethod, declaration.ExpressionBody.Expression);

            var getter       = SyntaxFactory.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration, statements);
            var accessorList = SyntaxFactory.AccessorList(SyntaxFactory.SingletonList(getter));

            declaration = declaration.WithAccessorList(accessorList);

            declaration = declaration.WithExpressionBody(null).WithSemicolonToken(default(SyntaxToken));
            return(declaration.EnsureLineCount(originalDeclaration));
        }