Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
30,300 | GroovyCodeStyleSettings () { return myGroovySettings; } | getGroovySettings |
30,301 | FormattingContext (boolean forbidWrapping, boolean forbidNewLineInSpacing) { return new FormattingContext( mySettings, myAlignmentProvider, myGroovySettings, myForbidWrapping || forbidWrapping, myForbidNewLineInSpacing || forbidNewLineInSpacing, myGroovyBlockProducer ); } | createContext |
30,302 | boolean () { return myForbidWrapping; } | isForbidWrapping |
30,303 | boolean () { return myForbidNewLineInSpacing; } | isForbidNewLineInSpacing |
30,304 | Block (@NotNull final ASTNode node, @NotNull final Indent indent, @Nullable final Wrap wrap) { return myGroovyBlockProducer.generateBlock(node, indent, wrap, this); } | createBlock |
30,305 | List<ASTNode> (final ASTNode node) { List<ASTNode> children = visibleChildren(node); if (!children.isEmpty()) { ASTNode first = children.get(0); if (first.getElementType() == mLCURLY) children.remove(0); } if (!children.isEmpty()) { ASTNode last = children.get(children.size() - 1); if (last.getElementType() == GroovyTokenTypes.mRCURLY) children.remove(children.size() - 1); } return children; } | getClosureBodyVisibleChildren |
30,306 | List<Block> () { //For binary expressions PsiElement blockPsi = myNode.getPsi(); IElementType elementType = myNode.getElementType(); if (blockPsi instanceof GrBinaryExpression && !(blockPsi.getParent() instanceof GrBinaryExpression)) { return generateForBinaryExpr(); } //For multiline strings if (GroovyTokenSets.STRING_LITERALS.contains(elementType) && myBlock.getTextRange().equals(myNode.getTextRange())) { String text = myNode.getText(); if (text.length() > 6) { if (text.startsWith("'''") && text.endsWith("'''") || text.startsWith("\"\"\"") && text.endsWith("\"\"\"")) { return generateForMultiLineString(); } } } //for gstrings if (elementType == GroovyElementTypes.GSTRING || elementType == GroovyElementTypes.REGEX || elementType == GroovyTokenTypes.mREGEX_LITERAL || elementType == GroovyTokenTypes.mDOLLAR_SLASH_REGEX_LITERAL) { boolean isPlainGString = myNode.getPsi() instanceof GrString && ((GrString)myNode.getPsi()).isPlainString(); final FormattingContext context = isPlainGString ? myContext.createContext(true, true) : myContext.createContext(false, true); final ArrayList<Block> subBlocks = new ArrayList<>(); ASTNode[] children = getGroovyChildren(myNode); for (ASTNode childNode : children) { if (childNode.getTextRange().getLength() > 0) { subBlocks.add(context.createBlock(childNode, getIndent(childNode), Wrap.createWrap(WrapType.NONE, false))); } } return subBlocks; } final CommonCodeStyleSettings settings = myContext.getSettings(); // chained properties, calls, indexing, etc if (NESTED.contains(elementType) && blockPsi.getParent() != null && !NESTED.contains(blockPsi.getParent().getNode().getElementType())) { final List<Block> subBlocks = new ArrayList<>(); AlignmentProvider.Aligner dotsAligner = settings.ALIGN_MULTILINE_CHAINED_METHODS ? myAlignmentProvider.createAligner(false) : null; final Wrap wrap = myWrappingProcessor.getChainedMethodCallWrap(); addNestedChildren(myNode.getPsi(), subBlocks, dotsAligner, true, wrap); return subBlocks; } if (blockPsi instanceof GrListOrMap && ((GrListOrMap)blockPsi).isMap() && myContext.getGroovySettings().ALIGN_NAMED_ARGS_IN_MAP) { AlignmentProvider.Aligner labels = myAlignmentProvider.createAligner(false); AlignmentProvider.Aligner exprs = myAlignmentProvider.createAligner(true); GrNamedArgument[] namedArgs = ((GrListOrMap)blockPsi).getNamedArguments(); for (GrNamedArgument arg : namedArgs) { GrArgumentLabel label = arg.getLabel(); if (label != null) labels.append(label); PsiElement colon = arg.getColon(); if (colon == null) colon = arg.getExpression(); if (colon != null) exprs.append(colon); } } if (blockPsi instanceof GrParameterList) { final List<ASTNode> children = visibleChildren(myNode); if (settings.ALIGN_MULTILINE_METHOD_BRACKETS) { PsiElement lParen = ((GrParameterList)blockPsi).getLParen(); if (lParen != null) { PsiElement rParen = ((GrParameterList)blockPsi).getRParen(); if (rParen != null) { myAlignmentProvider.addPair(lParen, rParen, false); } } } if (settings.ALIGN_MULTILINE_PARAMETERS) { final AlignmentProvider.Aligner aligner = myAlignmentProvider.createAligner(false); for (ASTNode node : children) { if (isKeyword(node)) continue; IElementType type = node.getElementType(); if (type == T_LPAREN || type == T_RPAREN) continue; aligner.append(node.getPsi()); } } return getGenericBlocks(children); } // For Parameter lists if (isListLikeClause(blockPsi)) { List<ASTNode> astNodes = visibleChildren(myNode); if (mustAlign(blockPsi, astNodes)) { final AlignmentProvider.Aligner aligner = myAlignmentProvider.createAligner(false); for (ASTNode node : astNodes) { if (!isKeyword(node)) aligner.append(node.getPsi()); } } return getGenericBlocks(astNodes); } if (blockPsi instanceof GrSwitchElement) { final ArrayList<Block> subBlocks = new ArrayList<>(); final ArrayList<Block> bodyBlocks = new ArrayList<>(); List<ASTNode> astNodes = visibleChildren(myNode); boolean switchBody = false; for (ASTNode childNode : astNodes) { if (childNode.getElementType() == mLCURLY) { switchBody = true; } if (switchBody) { bodyBlocks.add(myContext.createBlock(childNode, getIndent(childNode), getChildWrap(childNode))); } else { subBlocks.add(myContext.createBlock(childNode, getIndent(childNode), getChildWrap(childNode))); } } if (!bodyBlocks.isEmpty()) { subBlocks.add(createSwitchBodyBlock(bodyBlocks)); } return subBlocks; } boolean classLevel = blockPsi instanceof GrTypeDefinitionBody; if (blockPsi instanceof GrClosableBlock closableBlock && ((GrClosableBlock)blockPsi).getArrow() != null && ((GrClosableBlock)blockPsi).getParameters().length > 0 && !getClosureBodyVisibleChildren(myNode).isEmpty()) { ArrayList<Block> blocks = new ArrayList<>(); PsiElement lbrace = closableBlock.getLBrace(); { ASTNode node = lbrace.getNode(); blocks.add(myContext.createBlock(node, getIndent(node), Wrap.createWrap(WrapType.NONE, false))); } { Indent indent = getNormalIndent(); ASTNode parameterListNode = closableBlock.getParameterList().getNode(); boolean simpleClosure = shouldHandleAsSimpleClosure(closableBlock, settings); FormattingContext closureContext = myContext.createContext(simpleClosure, simpleClosure); ClosureBodyBlock bodyBlock = new ClosureBodyBlock(parameterListNode, indent, Wrap.createWrap(WrapType.NONE, false), closureContext); blocks.add(bodyBlock); } PsiElement rbrace = closableBlock.getRBrace(); if (rbrace != null) { ASTNode node = rbrace.getNode(); blocks.add(myContext.createBlock(node, getIndent(node), Wrap.createWrap(WrapType.NONE, false))); } return blocks; } if (blockPsi instanceof GrClosableBlock) { FormattingContext oldContext = myContext; try { boolean simpleClosure = shouldHandleAsSimpleClosure((GrClosableBlock)blockPsi, settings); myContext = myContext.createContext(simpleClosure, simpleClosure); return generateCodeSubBlocks(visibleChildren(myNode)); } finally { myContext = oldContext; } } if (blockPsi instanceof GrCodeBlock || blockPsi instanceof GroovyFile) { return generateCodeSubBlocks(visibleChildren(myNode)); } if (classLevel) { List<ASTNode> children = visibleChildren(myNode); calculateAlignments(children, true); return generateSubBlocks(children); } if (blockPsi instanceof GrTraditionalForClause) { if (settings.ALIGN_MULTILINE_FOR) { final GrTraditionalForClause clause = (GrTraditionalForClause)blockPsi; final AlignmentProvider.Aligner parenthesesAligner = myAlignmentProvider.createAligner(false); parenthesesAligner.append(clause.getInitialization()); parenthesesAligner.append(clause.getCondition()); parenthesesAligner.append(clause.getUpdate()); } } else if (blockPsi instanceof GrBinaryExpression) { if (settings.ALIGN_MULTILINE_BINARY_OPERATION) { final GrBinaryExpression binary = (GrBinaryExpression)blockPsi; final GrExpression left = binary.getLeftOperand(); final GrExpression right = binary.getRightOperand(); if (right != null) { myAlignmentProvider.addPair(left, right, false); } } } else if (blockPsi instanceof GrAssignmentExpression) { if (settings.ALIGN_MULTILINE_ASSIGNMENT) { final GrAssignmentExpression assignment = (GrAssignmentExpression)blockPsi; final GrExpression lValue = assignment.getLValue(); final GrExpression rValue = assignment.getRValue(); if (rValue != null) { myAlignmentProvider.addPair(lValue, rValue, false); } } } else if (blockPsi instanceof GrConditionalExpression) { if (settings.ALIGN_MULTILINE_TERNARY_OPERATION) { final GrConditionalExpression conditional = (GrConditionalExpression)blockPsi; final AlignmentProvider.Aligner exprAligner = myAlignmentProvider.createAligner(false); exprAligner.append(conditional.getCondition()); if (!(conditional instanceof GrElvisExpression)) { exprAligner.append(conditional.getThenBranch()); } exprAligner.append(conditional.getElseBranch()); ASTNode question = conditional.getNode().findChildByType(GroovyTokenTypes.mQUESTION); ASTNode colon = conditional.getNode().findChildByType(GroovyTokenTypes.mCOLON); if (question != null && colon != null) { AlignmentProvider.Aligner questionColonAligner = myAlignmentProvider.createAligner(false); questionColonAligner.append(question.getPsi()); questionColonAligner.append(colon.getPsi()); } } } // For other cases return getGenericBlocks(visibleChildren(myNode)); } | generateSubBlocks |
30,307 | List<Block> (@NotNull List<ASTNode> astNodes) { return ContainerUtil.map(astNodes, it -> myContext.createBlock(it, getIndent(it), getChildWrap(it))); } | getGenericBlocks |
30,308 | Block (List<Block> bodyBlocks) { CommonCodeStyleSettings settings = myContext.getSettings(); return new SyntheticGroovyBlock( bodyBlocks, Wrap.createWrap(WrapType.NONE, false), GroovyIndentProcessor.getBlockIndent(settings.BRACE_STYLE), GroovyIndentProcessor.getIndentInBlock(settings.BRACE_STYLE), myContext) { @NotNull @Override public ChildAttributes getChildAttributes(int newChildIndex) { List<Block> subBlocks = getSubBlocks(); if (newChildIndex > 0) { Block block = subBlocks.get(newChildIndex - 1); if (block instanceof GroovyBlock) { PsiElement anchorPsi = ((GroovyBlock)block).getNode().getPsi(); if (anchorPsi instanceof GrCaseSection) { boolean finished = GroovyIndentProcessor.isFinishedCase((GrCaseSection)anchorPsi, Integer.MAX_VALUE); Indent indent = GroovyIndentProcessor.getSwitchCaseIndent(settings); int indentSize = 0; CommonCodeStyleSettings.IndentOptions options = settings.getIndentOptions(); if (options != null) { indentSize = options.INDENT_SIZE; } if (!finished) { indent = getSpaceIndent((indent.getType() == Type.NORMAL ? indentSize : 0) + indentSize); } return new ChildAttributes(indent, null); } } } return super.getChildAttributes(newChildIndex); } }; } | createSwitchBodyBlock |
30,309 | ChildAttributes (int newChildIndex) { List<Block> subBlocks = getSubBlocks(); if (newChildIndex > 0) { Block block = subBlocks.get(newChildIndex - 1); if (block instanceof GroovyBlock) { PsiElement anchorPsi = ((GroovyBlock)block).getNode().getPsi(); if (anchorPsi instanceof GrCaseSection) { boolean finished = GroovyIndentProcessor.isFinishedCase((GrCaseSection)anchorPsi, Integer.MAX_VALUE); Indent indent = GroovyIndentProcessor.getSwitchCaseIndent(settings); int indentSize = 0; CommonCodeStyleSettings.IndentOptions options = settings.getIndentOptions(); if (options != null) { indentSize = options.INDENT_SIZE; } if (!finished) { indent = getSpaceIndent((indent.getType() == Type.NORMAL ? indentSize : 0) + indentSize); } return new ChildAttributes(indent, null); } } } return super.getChildAttributes(newChildIndex); } | getChildAttributes |
30,310 | Wrap (ASTNode childNode) { return myWrappingProcessor.getChildWrap(childNode); } | getChildWrap |
30,311 | List<Block> (final List<ASTNode> children) { final ArrayList<Block> subBlocks = new ArrayList<>(); List<ASTNode> flattenChildren = flattenChildren(children); calculateAlignments(flattenChildren, false); for (int i = 0; i < flattenChildren.size(); i++) { ASTNode childNode = flattenChildren.get(i); if (childNode.getElementType() == GroovyElementTypes.LABELED_STATEMENT) { int start = i; do { i++; } while (i < flattenChildren.size() && flattenChildren.get(i).getElementType() != GroovyElementTypes.LABELED_STATEMENT && flattenChildren.get(i).getElementType() != GroovyTokenTypes.mRCURLY); subBlocks.add( new GrLabelBlock( childNode, flattenChildren.subList(start + 1, i), getIndent(childNode), getChildWrap(childNode), myContext) ); i--; } else { subBlocks.add(myContext.createBlock(childNode, getIndent(childNode), getChildWrap(childNode))); } } return subBlocks; } | generateCodeSubBlocks |
30,312 | List<ASTNode> (List<ASTNode> children) { ArrayList<ASTNode> result = new ArrayList<>(); for (ASTNode child : children) { processNodeFlattening(result, child); } return result; } | flattenChildren |
30,313 | void (ArrayList<ASTNode> result, ASTNode child) { result.add(child); if (child.getElementType() == GroovyElementTypes.LABELED_STATEMENT) { for (ASTNode node : visibleChildren(child)) { processNodeFlattening(result, node); } } } | processNodeFlattening |
30,314 | Indent (ASTNode childNode) { return new GroovyIndentProcessor().getChildIndent(myBlock, childNode); } | getIndent |
30,315 | void (List<ASTNode> children, boolean classLevel) { List<GrStatement> currentGroup = null; boolean spock = true; for (ASTNode child : children) { PsiElement psi = child.getPsi(); if (psi instanceof GrLabeledStatement) { if (((GrLabeledStatement)psi).getLabel().getText().equals("where")) { alignGroup(currentGroup, spock, classLevel); currentGroup = new ArrayList<>(); spock = true; } } else if (currentGroup != null && spock && isTablePart(psi)) { currentGroup.add((GrStatement)psi); } else if (psi instanceof GrVariableDeclaration) { GrVariable[] variables = ((GrVariableDeclaration)psi).getVariables(); if (variables.length > 0) { if (!classLevel || currentGroup == null || fieldGroupEnded(psi) || spock) { alignGroup(currentGroup, spock, classLevel); currentGroup = new ArrayList<>(); spock = false; } currentGroup.add((GrStatement)psi); } } else { if (shouldSkip(classLevel, psi)) continue; alignGroup(currentGroup, spock, classLevel); currentGroup = psi instanceof GrReferenceExpression && Pattern.matches("^__+$", psi.getText()) ? new ArrayList<>() : null; } } if (currentGroup != null) { alignGroup(currentGroup, spock, classLevel); } } | calculateAlignments |
30,316 | boolean (boolean classLevel, PsiElement psi) { if (psi instanceof PsiComment) { PsiElement prev = psi.getPrevSibling(); if (prev != null) { if (!classLevel || !PsiUtil.isNewLine(prev) || !fieldGroupEnded(psi)) { return true; } } } if (psi.getParent() instanceof GrLabeledStatement) { if (psi instanceof GrLiteral && GrStringUtil.isStringLiteral((GrLiteral)psi) //skip string comments at the beginning of spock table || !(psi instanceof GrStatement)) { return true; } } return false; } | shouldSkip |
30,317 | void (@Nullable List<GrStatement> group, boolean spock, boolean classLevel) { if (group == null) { return; } if (spock) { alignSpockTable(group); } else { alignVariableDeclarations(group, classLevel); } } | alignGroup |
30,318 | void (List<GrStatement> group, boolean classLevel) { AlignmentProvider.Aligner typeElement = myAlignmentProvider.createAligner(true); AlignmentProvider.Aligner varName = myAlignmentProvider.createAligner(true); AlignmentProvider.Aligner eq = myAlignmentProvider.createAligner(true); for (GrStatement statement : group) { GrVariableDeclaration varDeclaration = (GrVariableDeclaration)statement; GrVariable[] variables = varDeclaration.getVariables(); for (GrVariable variable : variables) { varName.append(variable.getNameIdentifierGroovy()); } if (classLevel && myContext.getSettings().ALIGN_GROUP_FIELD_DECLARATIONS) { typeElement.append(varDeclaration.getTypeElementGroovy()); ASTNode current_eq = variables[variables.length - 1].getNode().findChildByType(GroovyTokenTypes.mASSIGN); if (current_eq != null) { eq.append(current_eq.getPsi()); } } } } | alignVariableDeclarations |
30,319 | void (List<GrStatement> group) { if (group.size() < 2) { return; } GrStatement inner = group.get(0); boolean embedded = inner != null && isTablePart(inner); GrStatement first = embedded ? inner : group.get(1); List<AlignmentProvider.Aligner> alignments = ContainerUtil .map(getSpockTable(first), leaf -> myAlignmentProvider.createAligner(leaf, true, Alignment.Anchor.RIGHT)); int second = embedded ? 1 : 2; for (int i = second; i < group.size(); i++) { List<LeafPsiElement> table = getSpockTable(group.get(i)); for (int j = 0; j < Math.min(table.size(), alignments.size()); j++) { alignments.get(j).append(table.get(j)); } } } | alignSpockTable |
30,320 | boolean (PsiElement psi) { if (!myContext.getSettings().ALIGN_GROUP_FIELD_DECLARATIONS) { return true; } int maxBlankLines = myContext.getSettings().KEEP_BLANK_LINES_IN_DECLARATIONS; if (maxBlankLines == 0) { return false; } PsiElement prevSibling = psi.getPrevSibling(); return prevSibling != null && StringUtil.countChars(prevSibling.getText(), '\n') > 1; } | fieldGroupEnded |
30,321 | List<LeafPsiElement> (GrStatement statement) { List<LeafPsiElement> result = new ArrayList<>(); statement.accept(new GroovyElementVisitor() { @Override public void visitBinaryExpression(@NotNull GrBinaryExpression expression) { if (isTablePart(expression)) { result.add((LeafPsiElement)expression.getOperationToken()); expression.acceptChildren(this); } } }); result.sort(Comparator.comparingInt(TreeElement::getStartOffset)); return result; } | getSpockTable |
30,322 | void (@NotNull GrBinaryExpression expression) { if (isTablePart(expression)) { result.add((LeafPsiElement)expression.getOperationToken()); expression.acceptChildren(this); } } | visitBinaryExpression |
30,323 | boolean (PsiElement psi) { return psi instanceof GrBinaryExpression && (GroovyTokenTypes.mBOR == ((GrBinaryExpression)psi).getOperationTokenType() || GroovyTokenTypes.mLOR == ((GrBinaryExpression)psi).getOperationTokenType()); } | isTablePart |
30,324 | List<ASTNode> (ASTNode node) { ArrayList<ASTNode> list = new ArrayList<>(); for (ASTNode astNode : getGroovyChildren(node)) { if (canBeCorrectBlock(astNode)) { list.add(astNode); } } return list; } | visibleChildren |
30,325 | boolean (PsiElement blockPsi, List<ASTNode> children) { // We don't want to align single call argument if it's a closure. The reason is that it looks better to have call like // // foo({ // println 'xxx' // }) // // than // // foo({ // println 'xxx' // }) if (blockPsi instanceof GrArgumentList && myContext.getSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS) { return !(children.size() == 3 && children.get(0).getElementType() == GroovyTokenTypes.mLPAREN && (children.get(1).getElementType() == GroovyElementTypes.CLOSABLE_BLOCK || children.get(1).getElementType() == GroovyElementTypes.LIST_OR_MAP) && children.get(2).getElementType() == GroovyTokenTypes.mRPAREN); } if (blockPsi instanceof GrAssignmentExpression && ((GrAssignmentExpression)blockPsi).getRValue() instanceof GrAssignmentExpression) { return myContext.getSettings().ALIGN_MULTILINE_ASSIGNMENT; } return blockPsi instanceof GrExtendsClause && myContext.getSettings().ALIGN_MULTILINE_EXTENDS_LIST || blockPsi instanceof GrThrowsClause && myContext.getSettings().ALIGN_MULTILINE_THROWS_LIST || blockPsi instanceof GrListOrMap && myContext.getGroovySettings().ALIGN_MULTILINE_LIST_OR_MAP || blockPsi instanceof GrTryResourceList && myContext.getSettings().ALIGN_MULTILINE_RESOURCES || blockPsi instanceof GrArrayInitializer && myContext.getSettings().ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION; } | mustAlign |
30,326 | boolean (PsiElement blockPsi) { return blockPsi instanceof GrArgumentList || blockPsi instanceof GrAssignmentExpression || blockPsi instanceof GrExtendsClause || blockPsi instanceof GrThrowsClause || blockPsi instanceof GrListOrMap || blockPsi instanceof GrTryResourceList || blockPsi instanceof GrArrayInitializer; } | isListLikeClause |
30,327 | boolean (ASTNode node) { if (node == null) return false; return TokenSets.KEYWORDS.contains(node.getElementType()) || TokenSets.BRACES.contains(node.getElementType()) && !isClosingParenthesisAfterTrailingComma(node); } | isKeyword |
30,328 | boolean (ASTNode node) { if (node.getElementType() != T_RPAREN) { return false; } if (!(node.getTreeParent().getPsi() instanceof GrArgumentList)) { return false; } PsiElement prev = PsiUtilKt.skipWhiteSpacesAndNewLinesBackward(node.getPsi()); if (prev == null) { return false; } return prev.getNode().getElementType() == T_COMMA; } | isClosingParenthesisAfterTrailingComma |
30,329 | List<Block> () { final ArrayList<Block> subBlocks = new ArrayList<>(); final int start = myNode.getTextRange().getStartOffset(); final int end = myNode.getTextRange().getEndOffset(); subBlocks.add( new GroovyBlockWithRange(myNode, getNoneIndent(), new TextRange(start, start + 3), Wrap.createWrap(WrapType.NONE, false), myContext)); subBlocks.add( new GroovyBlockWithRange(myNode, getAbsoluteNoneIndent(), new TextRange(start + 3, end - 3), Wrap.createWrap(WrapType.NONE, false), myContext)); subBlocks.add( new GroovyBlockWithRange(myNode, getAbsoluteNoneIndent(), new TextRange(end - 3, end), Wrap.createWrap(WrapType.NONE, false), myContext)); return subBlocks; } | generateForMultiLineString |
30,330 | boolean (final ASTNode node) { return !node.getText().trim().isEmpty(); } | canBeCorrectBlock |
30,331 | ASTNode[] (final ASTNode node) { PsiElement psi = node.getPsi(); if (psi instanceof OuterLanguageElement) { TextRange range = node.getTextRange(); ArrayList<ASTNode> childList = new ArrayList<>(); PsiFile groovyFile = psi.getContainingFile().getViewProvider().getPsi(GroovyLanguage.INSTANCE); if (groovyFile instanceof GroovyFileBase) { addChildNodes(groovyFile, childList, range, psi); } return childList.toArray(ASTNode.EMPTY_ARRAY); } return node.getChildren(null); } | getGroovyChildren |
30,332 | void (PsiElement elem, ArrayList<ASTNode> childNodes, TextRange range, PsiElement root) { ASTNode node = elem.getNode(); if (range.contains(elem.getTextRange()) && node != null && elem != root && !(elem instanceof PsiFile)) { childNodes.add(node); } else { for (PsiElement child : elem.getChildren()) { addChildNodes(child, childNodes, range, root); } } } | addChildNodes |
30,333 | List<Block> () { final ArrayList<Block> subBlocks = new ArrayList<>(); AlignmentProvider.Aligner alignment = myContext.getSettings().ALIGN_MULTILINE_BINARY_OPERATION ? myAlignmentProvider.createAligner(false) : null; GrBinaryExpression binary = (GrBinaryExpression)myNode.getPsi(); LOG.assertTrue(binary != null); addBinaryChildrenRecursively(binary, subBlocks, getContinuationWithoutFirstIndent(), alignment); return subBlocks; } | generateForBinaryExpr |
30,334 | void (PsiElement elem, List<Block> list, Indent indent, @Nullable AlignmentProvider.Aligner aligner) { if (elem == null) return; // For binary expressions if ((elem instanceof GrBinaryExpression myExpr)) { if (myExpr.getLeftOperand() instanceof GrBinaryExpression) { addBinaryChildrenRecursively(myExpr.getLeftOperand(), list, getContinuationWithoutFirstIndent(), aligner); } PsiElement op = ((GrBinaryExpression)elem).getOperationToken(); for (ASTNode childNode : visibleChildren(elem.getNode())) { PsiElement psi = childNode.getPsi(); if (!(psi instanceof GrBinaryExpression)) { if (op != psi && aligner != null) { aligner.append(psi); } list.add(myContext.createBlock(childNode, indent, getChildWrap(childNode))); } } if (myExpr.getRightOperand() instanceof GrBinaryExpression) { addBinaryChildrenRecursively(myExpr.getRightOperand(), list, getContinuationWithoutFirstIndent(), aligner ); } } } | addBinaryChildrenRecursively |
30,335 | void (@NotNull PsiElement elem, @NotNull List<Block> list, @Nullable AlignmentProvider.Aligner aligner, final boolean topLevel, @NotNull Wrap wrap) { final List<ASTNode> children = visibleChildren(elem.getNode()); List<ASTNode> nodes = flattenQualifiedReference(elem); if (nodes != null && !nodes.isEmpty()) { int i = 0; while (i < nodes.size()) { ASTNode node = nodes.get(i); if (TokenSets.DOTS.contains(node.getElementType())) break; i++; } if (i == nodes.size()) { list.add(new MethodCallWithoutQualifierBlock(wrap, topLevel, nodes, myContext)); return; } if (i > 0) { processNestedChildrenPrefix(list, aligner, false, nodes.subList(0, i), wrap); } Indent indent = getContinuationWithoutFirstIndent(); List<Block> childBlocks = new ArrayList<>(); ASTNode dotNode = nodes.get(i); if (aligner != null) { aligner.append(dotNode.getPsi()); } Wrap noneWrap = Wrap.createWrap(WrapType.NONE, false); boolean shouldWrapAfterDot = myContext.getGroovySettings().WRAP_CHAIN_CALLS_AFTER_DOT; Wrap identifierWrap = shouldWrapAfterDot ? wrap : noneWrap; Wrap dotWrap = shouldWrapAfterDot ? noneWrap : wrap; childBlocks.add(myContext.createBlock(dotNode, getIndent(dotNode), dotWrap)); List<ASTNode> callNodes = nodes.subList(i + 1, nodes.size()); if (!callNodes.isEmpty()) { childBlocks.add(new MethodCallWithoutQualifierBlock(identifierWrap, topLevel, callNodes, myContext)); } SyntheticGroovyBlock synBlock = new SyntheticGroovyBlock(childBlocks, noneWrap, indent, indent, myContext); list.add(synBlock); return; } processNestedChildrenPrefix(list, aligner, topLevel, children, wrap); } | addNestedChildren |
30,336 | boolean (ASTNode dot) { PsiElement dotPsi = dot.getPsi(); PsiElement prev = PsiUtil.skipWhitespaces(dotPsi.getPrevSibling(), false); if (prev != null) { if (prev instanceof GrMethodCall) { final PsiElement last = prev.getLastChild(); if (last instanceof GrClosableBlock) { return last.getText().contains("\n"); } } } return false; } | isAfterMultiLineClosure |
30,337 | void (List<Block> list, @Nullable AlignmentProvider.Aligner aligner, boolean topLevel, List<ASTNode> children, Wrap wrap) { LOG.assertTrue(children.size() > 0); ASTNode fst = children.get(0); if (NESTED.contains(fst.getElementType())) { addNestedChildren(fst.getPsi(), list, aligner, false, wrap); } else { Indent indent = getContinuationWithoutFirstIndent(); list.add(myContext.createBlock(fst, indent, getChildWrap(fst))); } addNestedChildrenSuffix(list, topLevel, children.subList(1, children.size())); } | processNestedChildrenPrefix |
30,338 | TextRange (List<ASTNode> subStatements) { ASTNode first = subStatements.get(0); ASTNode last = subStatements.get(subStatements.size() - 1); return new TextRange(first.getTextRange().getStartOffset(), last.getTextRange().getEndOffset()); } | createTextRange |
30,339 | List<Block> () { return myBlocks; } | getSubBlocks |
30,340 | List<Block> () { if (mySubBlocks == null) { mySubBlocks = new ArrayList<>(); new GroovyBlockGenerator(this).addNestedChildrenSuffix(mySubBlocks, myTopLevel, myChildren); } return mySubBlocks; } | getSubBlocks |
30,341 | TextRange () { return new TextRange(myChildren.get(0).getTextRange().getStartOffset(), myChildren.get(myChildren.size() - 1).getTextRange().getEndOffset()); } | getTextRange |
30,342 | boolean () { return false; } | isLeaf |
30,343 | ASTNode () { return myNode; } | getNode |
30,344 | TextRange () { return myNode.getTextRange(); } | getTextRange |
30,345 | List<Block> () { if (mySubBlocks == null) { mySubBlocks = new GroovyBlockGenerator(this).generateSubBlocks(); } return mySubBlocks; } | getSubBlocks |
30,346 | Wrap () { return myWrap; } | getWrap |
30,347 | Indent () { return myIndent; } | getIndent |
30,348 | Alignment () { if (myAlignment == null) { myAlignment = myContext.getAlignmentProvider().getAlignment(myNode.getPsi()); } return myAlignment; } | getAlignment |
30,349 | Spacing (Block child1, @NotNull Block child2) { return GroovySpacingProcessor.getSpacing(child1, child2, myContext); } | getSpacing |
30,350 | ChildAttributes (final int newChildIndex) { ASTNode astNode = getNode(); final PsiElement psiParent = astNode.getPsi(); if (psiParent instanceof GroovyFileBase) { return new ChildAttributes(Indent.getNoneIndent(), null); } if (psiParent instanceof GrSwitchElement) { return new ChildAttributes(Indent.getNoneIndent(), null); } if (psiParent instanceof GrCaseSection) { return new ChildAttributes(GroovyIndentProcessor.getSwitchCaseIndent(getContext().getSettings()), null); } if (astNode.getElementType() == LAMBDA_EXPRESSION) { return new ChildAttributes(Indent.getNormalIndent(), null); } if (astNode.getElementType() == BLOCK_LAMBDA_BODY) { return new ChildAttributes(Indent.getNormalIndent(), null); } if (TokenSets.BLOCK_SET.contains(astNode.getElementType()) || GroovyElementTypes.SWITCH_STATEMENT.equals(astNode.getElementType()) || GroovyElementTypes.SWITCH_EXPRESSION.equals(astNode.getElementType())) { return new ChildAttributes(Indent.getNormalIndent(), null); } if (GroovyElementTypes.CASE_SECTION.equals(astNode.getElementType())) { return new ChildAttributes(Indent.getNormalIndent(), null); } if (psiParent instanceof GrBinaryExpression || psiParent instanceof GrConditionalExpression || psiParent instanceof GrArgumentList || psiParent instanceof GrParameterList || psiParent instanceof GrListOrMap || psiParent instanceof GrAnnotationArgumentList || psiParent instanceof GrVariable || psiParent instanceof GrAssignmentExpression) { return new ChildAttributes(Indent.getContinuationWithoutFirstIndent(), null); } if (psiParent instanceof GrDocComment || psiParent instanceof GrDocTag) { return new ChildAttributes(Indent.getSpaceIndent(GroovyIndentProcessor.GDOC_COMMENT_INDENT), null); } if (psiParent instanceof GrIfStatement || psiParent instanceof GrLoopStatement) { return new ChildAttributes(Indent.getNormalIndent(), null); } if (psiParent instanceof GrLabeledStatement && newChildIndex == 2) { final Indent indent = getContext().getGroovySettings().INDENT_LABEL_BLOCKS ? Indent.getLabelIndent() : Indent.getNoneIndent(); return new ChildAttributes(indent, null); } return new ChildAttributes(Indent.getNoneIndent(), null); } | getChildAttributes |
30,351 | boolean () { return isIncomplete(myNode); } | isIncomplete |
30,352 | boolean (@NotNull final ASTNode node) { if (node.getElementType() instanceof ILazyParseableElementType) return false; ASTNode lastChild = node.getLastChildNode(); while (lastChild != null && !(lastChild.getElementType() instanceof ILazyParseableElementType) && (lastChild.getPsi() instanceof PsiWhiteSpace || lastChild.getPsi() instanceof PsiComment)) { lastChild = lastChild.getTreePrev(); } return lastChild != null && (lastChild.getPsi() instanceof PsiErrorElement || isIncomplete(lastChild)); } | isIncomplete |
30,353 | boolean () { return myNode.getFirstChildNode() == null; } | isLeaf |
30,354 | String () { return getTextRange() + ": " + myNode; } | toString |
30,355 | FormattingContext () { return myContext; } | getContext |
30,356 | TextRange () { init(); return myTextRange; } | getTextRange |
30,357 | void () { if (mySubBlocks == null) { GroovyBlockGenerator generator = new GroovyBlockGenerator(this); List<ASTNode> children = GroovyBlockGenerator.getClosureBodyVisibleChildren(myNode.getTreeParent()); mySubBlocks = generator.generateCodeSubBlocks(children); //at least -> exists assert !mySubBlocks.isEmpty(); TextRange firstRange = mySubBlocks.get(0).getTextRange(); TextRange lastRange = mySubBlocks.get(mySubBlocks.size() - 1).getTextRange(); myTextRange = new TextRange(firstRange.getStartOffset(), lastRange.getEndOffset()); } } | init |
30,358 | List<Block> () { init(); return mySubBlocks; } | getSubBlocks |
30,359 | ChildAttributes (int newChildIndex) { return new ChildAttributes(Indent.getNormalIndent(), null); } | getChildAttributes |
30,360 | boolean () { return true; } | isIncomplete |
30,361 | TextRange () { return myTextRange; } | getTextRange |
30,362 | boolean (ASTNode node) { _init(node); if (myChild1 == null || myChild2 == null) { return true; } PsiElement psi1 = myChild1.getPsi(); PsiElement psi2 = myChild2.getPsi(); if (psi1 == null || psi2 == null) { return true; } if (psi1.getLanguage() != GroovyLanguage.INSTANCE || psi2.getLanguage() != GroovyLanguage.INSTANCE) { return true; } return false; } | init |
30,363 | void (@Nullable final ASTNode child) { if (child == null) return; ASTNode treePrev = child.getTreePrev(); while (treePrev != null && isWhiteSpace(treePrev)) { treePrev = treePrev.getTreePrev(); } if (treePrev == null) { _init(child.getTreeParent()); } else { myChild2 = child; myType2 = myChild2.getElementType(); myChild1 = treePrev; myType1 = myChild1.getElementType(); final CompositeElement parent = (CompositeElement)treePrev.getTreeParent(); myParent = SourceTreeToPsiMap.treeElementToPsi(parent); } } | _init |
30,364 | boolean () { if (mySettings.KEEP_FIRST_COLUMN_COMMENT && TokenSets.COMMENT_SET.contains(myType2)) { if (!isAfterElementOrSemi(GroovyStubElementTypes.IMPORT)) { myResult = Spacing.createKeepingFirstColumnSpacing(0, Integer.MAX_VALUE, mySettings.KEEP_LINE_BREAKS, keepBlankLines()); return true; } return false; } ASTNode prev = FormatterUtil.getPreviousNonWhitespaceLeaf(myChild2); if (prev != null && prev.getElementType() == GroovyTokenTypes.mNLS) { prev = FormatterUtil.getPreviousNonWhitespaceLeaf(prev); } if (prev != null && prev.getElementType() == GroovyTokenTypes.mSL_COMMENT) { myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines()); return true; } return false; } | manageComments |
30,365 | void (@NotNull GrLiteral literal) { createSpaceInCode(false); } | visitLiteralExpression |
30,366 | void (@NotNull GrStringInjection injection) { createSpaceInCode(false); } | visitGStringInjection |
30,367 | void (@NotNull GrLabeledStatement labeledStatement) { if (myType1 == GroovyTokenTypes.mCOLON) { if (myGroovySettings.INDENT_LABEL_BLOCKS && !(myType2 == GroovyElementTypes.LITERAL)) { createLF(true); } else { createSpaceInCode(true); } } } | visitLabeledStatement |
30,368 | void (@NotNull GrAnnotation annotation) { if (myType2 == GroovyEmptyStubElementTypes.ANNOTATION_ARGUMENT_LIST) { createSpaceInCode(mySettings.SPACE_BEFORE_ANOTATION_PARAMETER_LIST); } } | visitAnnotation |
30,369 | void (@NotNull GrAnnotationArgumentList annotationArgumentList) { if (isWithinParentheses()) { createSpaceInCode(mySettings.SPACE_WITHIN_ANNOTATION_PARENTHESES); } } | visitAnnotationArgumentList |
30,370 | void (@NotNull GrArgumentList list) { if (list.getParent() instanceof GrIndexProperty) { processBrackets( mySettings.SPACE_WITHIN_BRACKETS, null, mySettings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE, mySettings.CALL_PARAMETERS_RPAREN_ON_NEXT_LINE ); } else { processParentheses( mySettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES, mySettings.SPACE_WITHIN_EMPTY_METHOD_CALL_PARENTHESES, mySettings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE, mySettings.CALL_PARAMETERS_RPAREN_ON_NEXT_LINE ); } } | visitArgumentList |
30,371 | void (final boolean isLineFeed, final boolean isSpace, @NotNull final TextRange range) { if (isLineFeed) { myResult = Spacing.createDependentLFSpacing(isSpace ? 1 : 0, isSpace ? 1 : 0, range, mySettings.KEEP_LINE_BREAKS, keepBlankLines()); } else { createSpaceInCode(isSpace); } } | createDependentLFSpacing |
30,372 | void (@NotNull GrLambdaExpression expression) { boolean spaceAroundArrow = mySettings.SPACE_AROUND_LAMBDA_ARROW; if (myType2 == T_ARROW) { createSpaceProperty(spaceAroundArrow, mySettings.KEEP_LINE_BREAKS, keepBlankLines()); } if (myType2 == BLOCK_LAMBDA_BODY) { createSpaceBeforeLBrace(spaceAroundArrow, mySettings.LAMBDA_BRACE_STYLE, null, mySettings.KEEP_SIMPLE_LAMBDAS_IN_ONE_LINE); } if (myType2 == EXPRESSION_LAMBDA_BODY) { createSpaceProperty(spaceAroundArrow, mySettings.KEEP_LINE_BREAKS, keepBlankLines()); } } | visitLambdaExpression |
30,373 | void (@NotNull GrBlockLambdaBody body) { if (myType2 == GroovyTokenTypes.mLCURLY) { myResult = Spacing.createSpacing(0, 0, 0, false, 0); } if (myType1 == GroovyTokenTypes.mLCURLY || myType2 == GroovyTokenTypes.mRCURLY) { boolean simpleLambda = shouldHandleAsSimpleLambda(body); int spaces = simpleLambda && mySettings.SPACE_WITHIN_BRACES ? 1 : 0; myResult = Spacing.createSpacing(spaces, spaces, simpleLambda ? 0 : 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines()); } } | visitBlockLambdaBody |
30,374 | boolean (GrBlockLambdaBody lambda) { return mySettings.KEEP_SIMPLE_LAMBDAS_IN_ONE_LINE && !lambda.textContains('\n'); } | shouldHandleAsSimpleLambda |
30,375 | void (@NotNull GrConditionalExpression expression) { if (myType2 == GroovyTokenTypes.mQUESTION) { createSpaceInCode(mySettings.SPACE_BEFORE_QUEST); } else if (myType1 == GroovyTokenTypes.mQUESTION) { createSpaceInCode(mySettings.SPACE_AFTER_QUEST); } else if (myType2 == GroovyTokenTypes.mCOLON) { createSpaceInCode(mySettings.SPACE_BEFORE_COLON); } else if (myType1 == GroovyTokenTypes.mCOLON) { createSpaceInCode(mySettings.SPACE_AFTER_COLON); } } | visitConditionalExpression |
30,376 | void (@NotNull GrElvisExpression expression) { if (myType1 == GroovyTokenTypes.mELVIS) { createSpaceInCode(mySettings.SPACE_AFTER_COLON); } else if (myType2 == GroovyTokenTypes.mELVIS) { createSpaceInCode(mySettings.SPACE_BEFORE_QUEST); } } | visitElvisExpression |
30,377 | void (@NotNull GrMethodCallExpression methodCallExpression) { if (myType2 == GroovyElementTypes.ARGUMENTS) { manageSpaceBeforeCallLParenth(); } else if (myType2 == GroovyElementTypes.CLOSABLE_BLOCK) { createSpaceInCode(myGroovySettings.SPACE_BEFORE_CLOSURE_LBRACE); } } | visitMethodCallExpression |
30,378 | void () { createSpaceInCode(mySettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES); } | manageSpaceBeforeCallLParenth |
30,379 | void (@NotNull GrApplicationStatement applicationStatement) { if (myType2 == GroovyElementTypes.ARGUMENTS) manageSpaceBeforeCallLParenth(); } | visitApplicationStatement |
30,380 | void (@NotNull GrIndexProperty expression) { if (myType2 == GroovyTokenTypes.mQUESTION) createSpaceInCode(false); if (myType2 == GroovyElementTypes.ARGUMENTS) manageSpaceBeforeCallLParenth(); } | visitIndexProperty |
30,381 | void (@NotNull GrConstructorInvocation invocation) { if (myType2 == GroovyElementTypes.ARGUMENTS) manageSpaceBeforeCallLParenth(); } | visitConstructorInvocation |
30,382 | void (@NotNull GrNewExpression newExpression) { if (myType1 == GroovyTokenTypes.kNEW) { createSpaceInCode(true); } else if (myType2 == GroovyElementTypes.ARGUMENTS) { manageSpaceBeforeCallLParenth(); } else if (myType2 == GroovyElementTypes.ARRAY_DECLARATOR) { createSpaceInCode(false); } else if (myType2 == ARRAY_INITIALIZER) { createSpaceInCode(mySettings.SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE); } } | visitNewExpression |
30,383 | void (@NotNull GrArrayDeclaration arrayDeclaration) { createSpaceInCode(false); } | visitArrayDeclaration |
30,384 | void (@NotNull GrArrayTypeElement typeElement) { createSpaceInCode(false); } | visitArrayTypeElement |
30,385 | void () { if (isWithinParentheses()) { createSpaceInCode(myGroovySettings.SPACE_WITHIN_TUPLE_EXPRESSION); } } | manageSpaceInTuple |
30,386 | void (@NotNull GrEnumConstant enumConstant) { if (myType1 == GroovyStubElementTypes.MODIFIER_LIST) { createSpaceInCode(true); } else { manageSpaceBeforeCallLParenth(); } } | visitEnumConstant |
30,387 | void (@NotNull GrVariableDeclaration variableDeclaration) { manageSpaceInTuple(); } | visitVariableDeclaration |
30,388 | void (@NotNull GrTuple tuple) { manageSpaceInTuple(); } | visitTuple |
30,389 | void (@NotNull GrSpreadArgument spreadArgument) { if (myType1 == GroovyTokenTypes.mSTAR) { createSpaceInCode(mySettings.SPACE_AROUND_UNARY_OPERATOR); } } | visitSpreadArgument |
30,390 | void (@NotNull GroovyFileBase file) { if (isAfterElementOrSemi(GroovyStubElementTypes.PACKAGE_DEFINITION)) { myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AFTER_PACKAGE + 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines()); } else if (myType2 == GroovyStubElementTypes.PACKAGE_DEFINITION) { myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_BEFORE_PACKAGE + 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines()); } else if (isLeftOrRight(TokenSets.TYPE_DEFINITIONS)) { if (myType1 == GroovyDocElementTypes.GROOVY_DOC_COMMENT) { if (isGroovyDocFormattingAllowed()) createLF(true); } else { myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AROUND_CLASS + 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines()); } } else if (isAfterElementOrSemi(GroovyStubElementTypes.IMPORT) && myType2 != GroovyStubElementTypes.IMPORT) { //after imports myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AFTER_IMPORTS + 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines()); } else if (myType1 != GroovyStubElementTypes.IMPORT && !isSemiAfter(GroovyStubElementTypes.IMPORT) && myType2 == GroovyStubElementTypes.IMPORT) { //before imports myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_BEFORE_IMPORTS, mySettings.KEEP_LINE_BREAKS, keepBlankLines()); } else if (isAfterElementOrSemi(GroovyStubElementTypes.IMPORT) && myType2 == GroovyStubElementTypes.IMPORT) { myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines()); } else { processClassMembers(null); } } | visitFile |
30,391 | boolean (final IElementType elementType) { return myType1 == elementType && myType2 != GroovyTokenTypes.mSEMI || isSemiAfter(elementType); } | isAfterElementOrSemi |
30,392 | boolean (@NotNull IElementType statement) { return myType1 == GroovyTokenTypes.mSEMI && getStatementTypeBySemi(myChild1) == statement; } | isSemiAfter |
30,393 | boolean (@NotNull TokenSet set) { return myType1 == GroovyTokenTypes.mSEMI && set.contains(getStatementTypeBySemi(myChild1)); } | isSemiAfter |
30,394 | IElementType (@NotNull ASTNode semi) { final GrTopStatement statement = getStatementBySemicolon(semi.getPsi()); if (statement == null) return null; return statement.getNode().getElementType(); } | getStatementTypeBySemi |
30,395 | GrTopStatement (@NotNull PsiElement semi) { PsiElement prev = semi.getPrevSibling(); while (prev != null && TokenSets.WHITE_SPACES_OR_COMMENTS.contains(prev.getNode().getElementType()) && prev.getText().indexOf('\n') < 0) { prev = prev.getPrevSibling(); } if (prev instanceof GrTopStatement) return (GrTopStatement)prev; return null; } | getStatementBySemicolon |
30,396 | void (@NotNull GrClosableBlock closure) { ASTNode rBraceAtTheEnd = GeeseUtil.getClosureRBraceAtTheEnd(myChild1); boolean spacesWithinBraces = closure.getParent() instanceof GrStringInjection ? myGroovySettings.SPACE_WITHIN_GSTRING_INJECTION_BRACES : mySettings.SPACE_WITHIN_BRACES; boolean simpleClosure = shouldHandleAsSimpleClosure(closure, mySettings) || myForbidNewLineInSpacing; int spaces = simpleClosure && spacesWithinBraces ? 1 : 0; if (myGroovySettings.USE_FLYING_GEESE_BRACES && myType2 == GroovyTokenTypes.mRCURLY && rBraceAtTheEnd != null) { String text = rBraceAtTheEnd.getTreeParent().getText(); if (text.indexOf('\n') < 0) { /* the case: foo { bar {print x}<we are here>} */ myResult = Spacing.createSpacing(1, 1, simpleClosure ? 0 : 1, false, 1); } else { myResult = Spacing.createSpacing(0, 0, 0, true, 100, 0); } } else if (myType1 == GroovyTokenTypes.mLCURLY && myType2 == GroovyTokenTypes.mRCURLY) { //empty closure createSpaceInCode(false); } else if (myType1 == GroovyTokenTypes.mLCURLY && myType2 != GroovyEmptyStubElementTypes.PARAMETER_LIST && myType2 != GroovyTokenTypes.mCLOSABLE_BLOCK_OP || myType2 == GroovyTokenTypes.mRCURLY) { //spaces between statements myResult = Spacing.createSpacing(spaces, spaces, simpleClosure ? 0 : 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines()); } else if (myType1 == GroovyTokenTypes.mCLOSABLE_BLOCK_OP) { myResult = GroovySpacingProcessorBasic.createDependentSpacingForClosure(mySettings, myGroovySettings, closure, true); } else if (myType1 == GroovyTokenTypes.mLCURLY) { createSpaceInCode(spacesWithinBraces); } } | visitClosure |
30,397 | void (@NotNull GrOpenBlock block) { boolean isMethod = block.getParent() instanceof GrMethod; boolean keepInOneLine = myForbidNewLineInSpacing || isMethod ? mySettings.KEEP_SIMPLE_METHODS_IN_ONE_LINE : mySettings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE; if (myType1 == GroovyTokenTypes.mLCURLY && myType2 == GroovyTokenTypes.mRCURLY) { createLF(!keepInOneLine); } else if (myType1 == GroovyTokenTypes.mLCURLY) { if (keepInOneLine) { createDependentLFSpacing(true, mySettings.SPACE_WITHIN_BRACES, block.getTextRange()); } else { int lineFeedsCount = isMethod ? mySettings.BLANK_LINES_BEFORE_METHOD_BODY + 1 : 1; myResult = Spacing.createSpacing(0, 0, lineFeedsCount, mySettings.KEEP_LINE_BREAKS, keepBlankLines()); } } else if (myType2 == GroovyTokenTypes.mRCURLY) { if (keepInOneLine) { createDependentLFSpacing(true, mySettings.SPACE_WITHIN_BRACES, block.getTextRange()); } else { createLF(true); } } } | visitOpenBlock |
30,398 | void (@NotNull GrTypeDefinition typeDefinition) { if (myType2 == GroovyEmptyStubElementTypes.CLASS_BODY) { if (typeDefinition instanceof GrAnonymousClassDefinition) { createSpaceProperty(mySettings.SPACE_BEFORE_CLASS_LBRACE, true, 100); //don't manually remove line feeds because this line is ambiguous } else { PsiElement nameIdentifier = typeDefinition.getNameIdentifierGroovy(); int dependenceStart = nameIdentifier.getTextRange().getStartOffset(); final TextRange range = new TextRange(dependenceStart, myChild1.getTextRange().getEndOffset()); createSpaceBeforeLBrace(mySettings.SPACE_BEFORE_CLASS_LBRACE, mySettings.CLASS_BRACE_STYLE, range, false); } } else if (myType2 == GroovyEmptyStubElementTypes.TYPE_PARAMETER_LIST) { createSpaceInCode(false); } else if (myType2 == GroovyElementTypes.ARGUMENTS) { manageSpaceBeforeCallLParenth(); } } | visitTypeDefinition |
30,399 | void (@NotNull GrTypeDefinitionBody typeDefinitionBody) { if (myType1 == GroovyTokenTypes.mLCURLY && myType2 == GroovyTokenTypes.mRCURLY) { if (mySettings.KEEP_SIMPLE_CLASSES_IN_ONE_LINE) { createSpaceInCode(false); } else { createLF(true); } } else if (myType1 == GroovyTokenTypes.mLCURLY) { myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AFTER_CLASS_HEADER + 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines()); } else if (myType2 == GroovyTokenTypes.mRCURLY) { createLF(true); } else { processClassMembers(typeDefinitionBody); } } | visitTypeDefinitionBody |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.