Пример #1
0
        public override bool TryFix(ConstructFixer fixer, SyntaxTree syntaxTree, IDocument document, TextLocation location, ref int newOffset)
        {
            var stmt = syntaxTree.GetNodeAt <UncheckedExpression>(location);

            if (stmt != null && stmt.Parent is ExpressionStatement)
            {
                var insertionOffset = document.GetOffset(stmt.EndLocation);
                document.Insert(insertionOffset, fixer.GenerateBody(stmt, fixer.Options.StatementBraceStyle, false, ref newOffset));
                return(true);
            }
            return(false);
        }
Пример #2
0
        public override bool TryFix(ConstructFixer fixer, SyntaxTree syntaxTree, IDocument document, TextLocation location, ref int newOffset)
        {
            var stmt = syntaxTree.GetNodeAt <LockStatement>(location);

            if (stmt != null)
            {
                if (!stmt.LParToken.IsNull && stmt.RParToken.IsNull)
                {
                    var lastNode = GetLastNonErrorChild(stmt);
                    if (lastNode == null)
                    {
                        return(false);
                    }

                    var insertionOffset = document.GetOffset(lastNode.EndLocation);
                    document.Insert(insertionOffset, fixer.GenerateBody(stmt, fixer.Options.StatementBraceStyle, true, ref newOffset));
                    return(true);
                }
            }
            return(false);
        }
Пример #3
0
        public override bool TryFix(ConstructFixer fixer, SyntaxTree syntaxTree, IDocument document, TextLocation location, ref int newOffset)
        {
            var typeDeclaration = syntaxTree.GetNodeAt <TypeDeclaration>(location);

            if (typeDeclaration != null)
            {
                if (typeDeclaration.LBraceToken.IsNull && typeDeclaration.RBraceToken.IsNull)
                {
                    if (typeDeclaration.Members.Any())
                    {
                        return(false);
                    }
                    var lastNode = GetLastNonErrorChild(typeDeclaration);
                    if (lastNode == null)
                    {
                        return(false);
                    }
                    var insertionOffset = document.GetOffset(lastNode.EndLocation);
                    document.Insert(insertionOffset, fixer.GenerateBody(typeDeclaration, fixer.Options.ClassBraceStyle, false, ref newOffset));
                    return(true);
                }
            }
            return(false);
        }