GenerateBody() private method

private GenerateBody ( AstNode node, BraceStyle braceStyle, bool addClosingBracket, int &newOffset ) : string
node AstNode
braceStyle BraceStyle
addClosingBracket bool
newOffset int
return string
Beispiel #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);
        }
Beispiel #2
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 #3
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 #4
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 #5
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 #6
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;
		}