int GetGlobalNewLinesFor(AstNode child) { if (child.NextSibling == null) // last node in the document => no extra newlines return 0; if (child.NextSibling.Role == Roles.RBrace) // Last node in a block => no extra newlines, it's handled later by FixClosingBrace() return 0; int newLines = 1; var nextSibling = child.GetNextSibling(NoWhitespacePredicate); if (nextSibling is PreProcessorDirective) { var directive = (PreProcessorDirective)nextSibling; if (directive.Type == PreProcessorDirectiveType.Endif) return -1; if (directive.Type == PreProcessorDirectiveType.Undef) return -1; } if ((child is UsingDeclaration || child is UsingAliasDeclaration) && !(nextSibling is UsingDeclaration || nextSibling is UsingAliasDeclaration)) { newLines += policy.BlankLinesAfterUsings; } else if ((child is TypeDeclaration) && (nextSibling is TypeDeclaration)) { newLines += policy.BlankLinesBetweenTypes; } return newLines; }
static bool InsertUsingAfter (AstNode node) { return node is NewLineNode && IsCommentOrUsing (node.GetNextSibling (s => !(s is NewLineNode))) || IsCommentOrUsing (node); }
static bool InsertUsingAfter(AstNode node) { return(node is NewLineNode && IsCommentOrUsing(node.GetNextSibling(s => !(s is NewLineNode))) || IsCommentOrUsing(node)); }
int GetTypeLevelNewLinesFor(AstNode child) { var blankLines = 1; var nextSibling = child.GetNextSibling(NoWhitespacePredicate); if (child is PreProcessorDirective || child is Comment) return 1; if (child is EventDeclaration) { if (nextSibling is EventDeclaration) { blankLines += policy.BlankLinesBetweenEventFields; return blankLines; } } if (child is FieldDeclaration || child is FixedFieldDeclaration) { if (nextSibling is FieldDeclaration || nextSibling is FixedFieldDeclaration) { blankLines += policy.BlankLinesBetweenFields; return blankLines; } } if (child is TypeDeclaration) { if (nextSibling is TypeDeclaration) { blankLines += policy.BlankLinesBetweenTypes; return blankLines; } } if (nextSibling.Role == Roles.TypeMemberRole) blankLines += policy.BlankLinesBetweenMembers; return blankLines; }
int GetGlobalNewLinesFor(AstNode child) { int newLines = 1; var nextSibling = child.GetNextSibling(NoWhitespacePredicate); if ((child is UsingDeclaration || child is UsingAliasDeclaration) && !(nextSibling is UsingDeclaration || nextSibling is UsingAliasDeclaration)) { newLines += policy.BlankLinesAfterUsings; } else if ((child is TypeDeclaration) && (nextSibling is TypeDeclaration)) { newLines += policy.BlankLinesBetweenTypes; } return newLines; }
int GetTypeLevelNewLinesFor(AstNode child) { var blankLines = 1; var nextSibling = child.GetNextSibling(NoWhitespacePredicate); if (child is PreProcessorDirective) { var directive = (PreProcessorDirective)child; if (directive.Type == PreProcessorDirectiveType.Region) blankLines += policy.BlankLinesInsideRegion; if (directive.Type == PreProcessorDirectiveType.Endregion) blankLines += policy.BlankLinesAroundRegion; return blankLines; } if (nextSibling is PreProcessorDirective) { var directive = (PreProcessorDirective)nextSibling; if (directive.Type == PreProcessorDirectiveType.Region) blankLines += policy.BlankLinesAroundRegion; if (directive.Type == PreProcessorDirectiveType.Endregion) blankLines += policy.BlankLinesInsideRegion; if (directive.Type == PreProcessorDirectiveType.Endif) return -1; if (directive.Type == PreProcessorDirectiveType.Undef) return -1; return blankLines; } if (child.Role == Roles.LBrace) return 1; if (child is Comment) return 1; if (child is EventDeclaration) { if (nextSibling is EventDeclaration) { blankLines += policy.BlankLinesBetweenEventFields; return blankLines; } } if (child is FieldDeclaration || child is FixedFieldDeclaration) { if (nextSibling is FieldDeclaration || nextSibling is FixedFieldDeclaration) { blankLines += policy.BlankLinesBetweenFields; return blankLines; } } if (child is TypeDeclaration) { if (nextSibling is TypeDeclaration) { blankLines += policy.BlankLinesBetweenTypes; return blankLines; } } if (nextSibling.Role == Roles.TypeMemberRole) blankLines += policy.BlankLinesBetweenMembers; return blankLines; }
int GetGlobalNewLinesFor(AstNode child) { int newLines = 1; var nextSibling = child.GetNextSibling(NoWhitespacePredicate); if (nextSibling is PreProcessorDirective) { var directive = (PreProcessorDirective)nextSibling; if (directive.Type == PreProcessorDirectiveType.Endif) return -1; if (directive.Type == PreProcessorDirectiveType.Undef) return -1; } if ((child is UsingDeclaration || child is UsingAliasDeclaration) && !(nextSibling is UsingDeclaration || nextSibling is UsingAliasDeclaration)) { newLines += policy.BlankLinesAfterUsings; } else if ((child is TypeDeclaration) && (nextSibling is TypeDeclaration)) { newLines += policy.BlankLinesBetweenTypes; } return newLines; }