Beispiel #1
0
        public override bool TryFix(ConstructFixer fixer, SyntaxTree syntaxTree, IDocument document, TextLocation location, ref int newOffset)
        {
            var stmt = syntaxTree.GetNodeAt <BreakStatement>(location);

            if (stmt != null && stmt.SemicolonToken.IsNull)
            {
                // TODO !!!!
                return(true);
            }
            return(false);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public override bool TryFix(ConstructFixer fixer, SyntaxTree syntaxTree, IDocument document, TextLocation location, ref int newOffset)
        {
            var stmt = syntaxTree.GetNodeAt <ThrowStatement>(location);

            if (stmt != null && stmt.SemicolonToken.IsNull)
            {
                var insertionOffset = document.GetOffset(stmt.EndLocation);
                document.Insert(insertionOffset, ";");
                newOffset = insertionOffset + 1;
                return(true);
            }
            return(false);
        }
Beispiel #4
0
        public override bool TryFix(ConstructFixer fixer, SyntaxTree syntaxTree, IDocument document, TextLocation location, ref int newOffset)
        {
            var expressionStatement = syntaxTree.GetNodeAt <ExpressionStatement>(location);

            if (expressionStatement != null)
            {
                int offset = document.GetOffset(expressionStatement.Expression.EndLocation);
                if (expressionStatement.SemicolonToken.IsNull)
                {
                    document.Insert(offset, ";");
                    newOffset = offset + 1;
                }
                return(true);
            }
            return(false);
        }
Beispiel #5
0
        public override bool TryFix(ConstructFixer fixer, SyntaxTree syntaxTree, IDocument document, TextLocation location, ref int newOffset)
        {
            var typeDeclaration = syntaxTree.GetNodeAt <DelegateDeclaration>(location);

            if (typeDeclaration != null)
            {
                if (typeDeclaration.RParToken.IsNull)
                {
                    var lastNode = GetLastNonErrorChild(typeDeclaration);
                    if (lastNode == null)
                    {
                        return(false);
                    }
                    var insertionOffset = document.GetOffset(lastNode.EndLocation);
                    document.Insert(insertionOffset, ");\n");
                    newOffset += ");\n".Length;
                    return(true);
                }
            }
            return(false);
        }
Beispiel #6
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);
        }
Beispiel #7
0
        public override bool TryFix(ConstructFixer fixer, SyntaxTree syntaxTree, IDocument document, TextLocation location, ref int newOffset)
        {
            var stmt = syntaxTree.GetNodeAt <DoWhileStatement>(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, ");");
                    newOffset = insertionOffset + 2;
                    return(true);
                }
            }
            return(false);
        }
Beispiel #8
0
        public override bool TryFix(ConstructFixer fixer, SyntaxTree syntaxTree, IDocument document, TextLocation location, ref int newOffset)
        {
            var invocationExpression = syntaxTree.GetNodeAt <InvocationExpression>(location);

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

                    var insertionOffset = document.GetOffset(lastNode.EndLocation);

                    newOffset = insertionOffset;


                    var text = ")";
                    newOffset++;
                    var expressionStatement = invocationExpression.Parent as ExpressionStatement;
                    if (expressionStatement != null)
                    {
                        if (expressionStatement.SemicolonToken.IsNull)
                        {
                            text = ");";
                        }
                        newOffset++;
                    }
                    document.Insert(insertionOffset, text);


                    return(true);
                }
            }
            return(false);
        }
Beispiel #9
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);
        }
Beispiel #10
0
 public abstract bool TryFix(ConstructFixer fixer, SyntaxTree syntaxTree, IDocument document, TextLocation location, ref int newOffset);