Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
30,500
void (@NotNull GrForStatement forStatement) { if (myChild == forStatement.getBody() && !TokenSets.BLOCK_SET.contains(myChildType)) { myResult = getNormalIndent(); } else if (myChild == forStatement.getClause()) { myResult = getContinuationWithoutFirstIndent(); } }
visitForStatement
30,501
CommonCodeStyleSettings () { return myBlock.getContext().getSettings(); }
getGroovySettings
30,502
void (@NotNull GrParenthesizedExpression expression) { if (myChildType == GroovyTokenTypes.mLPAREN || myChildType == GroovyTokenTypes.mRPAREN) { myResult = getNoneIndent(); } else { myResult = getContinuationIndent(); } }
visitParenthesizedExpression
30,503
Indent (@NotNull CommonCodeStyleSettings settings) { if (settings.INDENT_CASE_FROM_SWITCH) { return getIndentInBlock(settings.BRACE_STYLE); } else { return getNoneIndent(); } }
getSwitchCaseIndent
30,504
void (@NotNull GrParameterList parameterList) { if (myChildType == T_LPAREN || myChildType == T_RPAREN) { myResult = getNoneIndent(); } else { myResult = getContinuationWithoutFirstIndent(); } }
visitParameterList
30,505
void (@NotNull GrArrayDeclaration arrayDeclaration) { myResult = getContinuationWithoutFirstIndent(); }
visitArrayDeclaration
30,506
void (@NotNull GrExpression expression) { myResult = getContinuationWithoutFirstIndent(); }
visitExpression
30,507
void (@NotNull GrTypeArgumentList typeArgumentList) { myResult = getContinuationWithoutFirstIndent(); }
visitTypeArgumentList
30,508
void (@NotNull GrCodeReferenceElement refElement) { myResult = getContinuationWithoutFirstIndent(); }
visitCodeReferenceElement
30,509
void (@NotNull GrWildcardTypeArgument wildcardTypeArgument) { myResult = getContinuationWithoutFirstIndent(); }
visitWildcardTypeArgument
30,510
void (@NotNull GrAnnotationMethod annotationMethod) { if (myChild instanceof GrAnnotationMemberValue) { myResult = getContinuationIndent(); } else { super.visitAnnotationMethod(annotationMethod); } }
visitAnnotationMethod
30,511
void (@NotNull GrAnnotationNameValuePair nameValuePair) { myResult = getContinuationWithoutFirstIndent(); }
visitAnnotationNameValuePair
30,512
void (@NotNull GrForInClause forInClause) { myResult = getContinuationWithoutFirstIndent(); }
visitForInClause
30,513
void (@NotNull GrForClause forClause) { myResult = getContinuationWithoutFirstIndent(); }
visitForClause
30,514
void (@NotNull GrCatchClause catchClause) { if (myChild == catchClause.getBody()) { myResult = getBlockIndent(getGroovySettings().BRACE_STYLE); } else { myResult = getContinuationWithoutFirstIndent(); } }
visitCatchClause
30,515
void (@NotNull GrTryCatchStatement tryCatchStatement) { if (myChildType instanceof GrBlockElementType) { myResult = getBlockIndent(getGroovySettings().BRACE_STYLE); } }
visitTryStatement
30,516
void (@NotNull GrTryResourceList resourceList) { if (myChildType != T_LPAREN && myChildType != T_RPAREN) { myResult = getContinuationWithoutFirstIndent(); } }
visitTryResourceList
30,517
void (@NotNull GrBlockStatement blockStatement) { myResult = getBlockIndent(getGroovySettings().BRACE_STYLE); }
visitBlockStatement
30,518
void (@NotNull GrFinallyClause catchClause) { if (myChildType instanceof GrBlockElementType) { myResult = getBlockIndent(getGroovySettings().BRACE_STYLE); } }
visitFinallyClause
30,519
void (@NotNull GrTypeParameterList list) { myResult = getContinuationWithoutFirstIndent(); }
visitTypeParameterList
30,520
void (@NotNull GrArrayInitializer arrayInitializer) { if (myChildType != T_LBRACE && myChildType != T_RBRACE) { myResult = getContinuationWithoutFirstIndent(); } }
visitArrayInitializer
30,521
Indent (int braceStyle) { return braceStyle == NEXT_LINE_SHIFTED ? getNoneIndent() : getNormalIndent(); }
getIndentInBlock
30,522
Indent (int braceStyle) { return braceStyle == NEXT_LINE_SHIFTED || braceStyle == NEXT_LINE_SHIFTED2 ? getNormalIndent() : getNoneIndent(); }
getBlockIndent
30,523
ChildAttributes (GrCaseSection psiParent, int newIndex) { Indent indent = isFinishedCase(psiParent, newIndex) ? getNoneIndent() : getNormalIndent(); return new ChildAttributes(indent, null); }
getChildSwitchIndent
30,524
boolean (GrCaseSection psiParent, int newIndex) { GrStatement[] statements = psiParent.getStatements(); newIndex--; if (psiParent.getArrow() != null && statements.length == 1) { return true; } for (int i = 0; i < statements.length && i < newIndex; i++) { PsiElement child = statements[i]; if (child instanceof GrBreakStatement || child instanceof GrContinueStatement || child instanceof GrReturnStatement || child instanceof GrYieldStatement || child instanceof GrThrowStatement) { return true; } } return false; }
isFinishedCase
30,525
Wrap (ASTNode childNode) { if (myContext.isForbidWrapping()) return createNoneWrap(); final IElementType childType = childNode.getElementType(); if (SKIP.contains(childType)) { return createNoneWrap(); } if (myParentType == ARGUMENT_LIST) { if (childType == T_LBRACK || childType == T_RBRACK) { return createNoneWrap(); } } if (myParentType == APPLICATION_ARGUMENT_LIST) { if (myNode.getFirstChildNode() == childNode) { return createNoneWrap(); } } if (myParentType == GroovyStubElementTypes.EXTENDS_CLAUSE || myParentType == GroovyStubElementTypes.IMPLEMENTS_CLAUSE) { if (childType == GroovyTokenTypes.kEXTENDS || childType == GroovyTokenTypes.kIMPLEMENTS) { return Wrap.createWrap(mySettings.EXTENDS_KEYWORD_WRAP, true); } } if (myParentType == GroovyElementTypes.ARGUMENTS || myParentType == TRY_RESOURCE_LIST) { if (childType == GroovyTokenTypes.mLPAREN || childType == GroovyTokenTypes.mRPAREN) { return createNoneWrap(); } } if (myParentType == ARRAY_INITIALIZER) { if (childType == T_LBRACE || childType == T_RBRACE) { return createNoneWrap(); } } if (myParentType == GroovyStubElementTypes.THROWS_CLAUSE && childType == GroovyTokenTypes.kTHROWS) { return Wrap.createWrap(mySettings.THROWS_KEYWORD_WRAP, true); } if (myParentType == GroovyStubElementTypes.MODIFIER_LIST) { if (getLeftSiblingType(childNode) == GroovyStubElementTypes.ANNOTATION) { return getCommonWrap(); } else { return null; } } if (myParentType == PARAMETER_LIST) { if (childType == T_LPAREN || childType == T_RPAREN) { return createNoneWrap(); } } if (myParentType == CLOSURE) { final ASTNode leftSibling = getLeftSibling(childNode); if (leftSibling != null && leftSibling.getElementType() == T_LBRACE || childType == T_RBRACE) { boolean simpleClosure = mySettings.KEEP_SIMPLE_LAMBDAS_IN_ONE_LINE && !myNode.textContains('\n'); return simpleClosure ? createNoneWrap() : getCommonWrap(); } } if (ANNOTATION_CONTAINERS.contains(myParentType)) { final ASTNode leftSibling = getLeftSibling(childNode); if (leftSibling != null && leftSibling.getElementType() == GroovyStubElementTypes.MODIFIER_LIST && endsWithAnnotation(leftSibling)) { final int wrapType = getAnnotationsWrapType(childNode); if (wrapType != -1) { return Wrap.createWrap(wrapType, true); } } } return getCommonWrap(); }
getChildWrap
30,526
IElementType (ASTNode node) { ASTNode prev = getLeftSibling(node); return prev != null ? prev.getElementType() : null; }
getLeftSiblingType
30,527
ASTNode (ASTNode node) { ASTNode prev = node.getTreePrev(); while (prev != null && StringUtil.isEmptyOrSpaces(prev.getText())) { prev = prev.getTreePrev(); } return prev; }
getLeftSibling
30,528
boolean (ASTNode modifierListNode) { final PsiElement psi = modifierListNode.getPsi(); return psi instanceof GrModifierList && psi.getLastChild() instanceof GrAnnotation; }
endsWithAnnotation
30,529
Wrap () { if (myCommonWrap == null) { return createNoneWrap(); //return null; } if (myUsedDefaultWrap) { return myCommonWrap; } else { myUsedDefaultWrap = true; return createNoneWrap(); //return null; } }
getCommonWrap
30,530
Wrap () { return Wrap.createWrap(WrapType.NORMAL, true); }
createNormalWrap
30,531
Wrap () { return Wrap.createWrap(WrapType.NONE, false); }
createNoneWrap
30,532
Wrap () { if (myParentType == GroovyStubElementTypes.EXTENDS_CLAUSE || myParentType == GroovyStubElementTypes.IMPLEMENTS_CLAUSE) { myUsedDefaultWrap = true; return Wrap.createWrap(mySettings.EXTENDS_LIST_WRAP, true); } if (myParentType == GroovyStubElementTypes.THROWS_CLAUSE) { myUsedDefaultWrap = true; return Wrap.createWrap(mySettings.THROWS_LIST_WRAP, true); } if (myParentType == GroovyEmptyStubElementTypes.PARAMETER_LIST) { myUsedDefaultWrap = true; return Wrap.createWrap(mySettings.METHOD_PARAMETERS_WRAP, false); } if (myParentType == GroovyElementTypes.ARGUMENTS || myParentType == GroovyElementTypes.COMMAND_ARGUMENTS) { myUsedDefaultWrap = true; return Wrap.createWrap(mySettings.CALL_PARAMETERS_WRAP, myParentType == GroovyElementTypes.COMMAND_ARGUMENTS); } if (myParentType == TRY_RESOURCE_LIST) { myUsedDefaultWrap = true; return Wrap.createWrap(mySettings.RESOURCE_LIST_WRAP, false); } if (myParentType == GroovyElementTypes.FOR_TRADITIONAL_CLAUSE || myParentType == GroovyElementTypes.FOR_IN_CLAUSE) { myUsedDefaultWrap = true; return Wrap.createWrap(mySettings.FOR_STATEMENT_WRAP, true); } if (TokenSets.BINARY_EXPRESSIONS.contains(myParentType)) { return Wrap.createWrap(mySettings.BINARY_OPERATION_WRAP, false); } if (myParentType == GroovyElementTypes.ASSIGNMENT_EXPRESSION || myParentType == GroovyElementTypes.TUPLE_ASSIGNMENT_EXPRESSION) { return Wrap.createWrap(mySettings.ASSIGNMENT_WRAP, false); } if (myParentType == GroovyElementTypes.CONDITIONAL_EXPRESSION || myParentType == GroovyElementTypes.ELVIS_EXPRESSION) { return Wrap.createWrap(mySettings.TERNARY_OPERATION_WRAP, false); } if (myParentType == GroovyElementTypes.ASSERT_STATEMENT) { return Wrap.createWrap(mySettings.ASSERT_STATEMENT_WRAP, false); } if (myParentType == ARRAY_INITIALIZER) { myUsedDefaultWrap = true; return Wrap.createWrap(mySettings.ARRAY_INITIALIZER_WRAP, false); } if (TokenSets.BLOCK_SET.contains(myParentType)) { return createNormalWrap(); } if (myParentType == GroovyStubElementTypes.MODIFIER_LIST) { final int wrapType = getAnnotationsWrapType(myNode); if (wrapType != -1) { myUsedDefaultWrap = true; return Wrap.createWrap(wrapType, true); } } return null; }
createCommonWrap
30,533
Wrap () { return myContext.isForbidWrapping() ? Wrap.createWrap(WrapType.NONE, false) : Wrap.createWrap(mySettings.METHOD_CALL_CHAIN_WRAP, false); }
getChainedMethodCallWrap
30,534
int (ASTNode modifierList) { final IElementType containerType = modifierList.getTreeParent().getElementType(); if (TokenSets.TYPE_DEFINITIONS.contains(containerType)) { return mySettings.CLASS_ANNOTATION_WRAP; } if (TokenSets.METHOD_DEFS.contains(containerType)) { return mySettings.METHOD_ANNOTATION_WRAP; } if (GroovyStubElementTypes.VARIABLE_DECLARATION == containerType) { final IElementType pparentType = modifierList.getTreeParent().getTreeParent().getElementType(); if (pparentType == GroovyEmptyStubElementTypes.CLASS_BODY || pparentType == GroovyEmptyStubElementTypes.ENUM_BODY) { return mySettings.FIELD_ANNOTATION_WRAP; } else { return mySettings.VARIABLE_ANNOTATION_WRAP; } } if (GroovyStubElementTypes.PARAMETER == containerType) { return mySettings.PARAMETER_ANNOTATION_WRAP; } if (GroovyStubElementTypes.ENUM_CONSTANT == containerType) { return mySettings.ENUM_CONSTANTS_WRAP; } if (GroovyStubElementTypes.IMPORT == containerType) { return myContext.getGroovySettings().IMPORT_ANNOTATION_WRAP; } return -1; }
getAnnotationsWrapType
30,535
Spacing (GroovyBlock child1, GroovyBlock child2, FormattingContext context) { ASTNode leftNode = child1.getNode(); ASTNode rightNode = child2.getNode(); final PsiElement left = leftNode.getPsi(); final PsiElement right = rightNode.getPsi(); IElementType leftType = leftNode.getElementType(); IElementType rightType = rightNode.getElementType(); final CommonCodeStyleSettings settings = context.getSettings(); final GroovyCodeStyleSettings groovySettings = context.getGroovySettings(); if (!(mirrorsAst(child1) && mirrorsAst(child2))) { return NO_SPACING; } if (child2 instanceof ClosureBodyBlock) { return settings.SPACE_WITHIN_BRACES ? COMMON_SPACING : NO_SPACING_WITH_NEWLINE; } if (child1 instanceof ClosureBodyBlock) { return createDependentSpacingForClosure(settings, groovySettings, (GrClosableBlock)left.getParent(), false); } if (groovySettings.isGroovyDocFormattingAllowed() && leftType == GroovyDocElementTypes.GROOVY_DOC_COMMENT) { return COMMON_SPACING_WITH_NL; } if (right instanceof GrTypeArgumentList) { return NO_SPACING_WITH_NEWLINE; } // ********** punctuation marks ************ if (GroovyTokenTypes.mCOMMA == leftType) { return settings.SPACE_AFTER_COMMA ? COMMON_SPACING : NO_SPACING_WITH_NEWLINE; } if (GroovyTokenTypes.mCOMMA == rightType) { return settings.SPACE_BEFORE_COMMA ? COMMON_SPACING : NO_SPACING_WITH_NEWLINE; } if (GroovyTokenTypes.mSEMI == leftType) { return settings.SPACE_AFTER_SEMICOLON ? COMMON_SPACING : NO_SPACING_WITH_NEWLINE; } if (GroovyTokenTypes.mSEMI == rightType) { return settings.SPACE_BEFORE_SEMICOLON ? COMMON_SPACING : NO_SPACING_WITH_NEWLINE; } // For dots, commas etc. if ((TokenSets.DOTS.contains(rightType)) || (GroovyTokenTypes.mCOLON.equals(rightType) && !(right.getParent() instanceof GrConditionalExpression))) { return NO_SPACING_WITH_NEWLINE; } if (TokenSets.DOTS.contains(leftType)) { return NO_SPACING_WITH_NEWLINE; } //todo:check it for multiple assignments if ((GroovyStubElementTypes.VARIABLE_DECLARATION.equals(leftType) || GroovyStubElementTypes.VARIABLE_DECLARATION.equals(rightType)) && !(leftNode.getTreeNext() instanceof PsiErrorElement)) { return getStatementSpacing(context); } // For regexes if (leftNode.getTreeParent().getElementType() == GroovyTokenTypes.mREGEX_LITERAL || leftNode.getTreeParent().getElementType() == GroovyTokenTypes.mDOLLAR_SLASH_REGEX_LITERAL) { return NO_SPACING; } // ********** exclusions ************ // For << and >> ... if ((GroovyTokenTypes.mLT.equals(leftType) && GroovyTokenTypes.mLT.equals(rightType)) || (GroovyTokenTypes.mGT.equals(leftType) && GroovyTokenTypes.mGT.equals(rightType))) { return NO_SPACING_WITH_NEWLINE; } // Unary and postfix expressions if (SpacingTokens.PREFIXES.contains(leftType) || SpacingTokens.POSTFIXES.contains(rightType) || (SpacingTokens.PREFIXES_OPTIONAL.contains(leftType) && left.getParent() instanceof GrUnaryExpression)) { return NO_SPACING_WITH_NEWLINE; } if (RANGES.contains(leftType) || RANGES.contains(rightType)) { return NO_SPACING_WITH_NEWLINE; } if (GroovyDocTokenTypes.mGDOC_ASTERISKS == leftType && GroovyDocTokenTypes.mGDOC_COMMENT_DATA == rightType) { if (!groovySettings.isGroovyDocFormattingAllowed()) { return LAZY_SPACING; } String text = rightNode.getText(); if (!text.isEmpty() && !StringUtil.startsWithChar(text, ' ')) { return COMMON_SPACING; } return NO_SPACING; } if (leftType == GroovyDocTokenTypes.mGDOC_TAG_VALUE_TOKEN && rightType == GroovyDocTokenTypes.mGDOC_COMMENT_DATA) { return LAZY_SPACING; } if (left instanceof GrStatement && right instanceof GrStatement && left.getParent() instanceof GrStatementOwner && right.getParent() instanceof GrStatementOwner) { return getStatementSpacing(context); } Spacing rightSpacing = getGroovyDocBraceSpacing(right); Spacing actualSpacing = rightSpacing == null ? getGroovyDocBraceSpacing(left) : rightSpacing; if (actualSpacing != null) { if (!groovySettings.isGroovyDocFormattingAllowed()) { return LAZY_SPACING; } return actualSpacing; } if ((leftType == GroovyDocElementTypes.GDOC_INLINED_TAG && rightType == GroovyDocTokenTypes.mGDOC_COMMENT_DATA) || (leftType == GroovyDocTokenTypes.mGDOC_COMMENT_DATA && rightType == GroovyDocElementTypes.GDOC_INLINED_TAG)) { if (!groovySettings.isGroovyDocFormattingAllowed()) { return LAZY_SPACING; } // Keep formatting between groovy doc text and groovy doc reference tag as is. return NO_SPACING; } if (leftType == GroovyElementTypes.CLASS_TYPE_ELEMENT && rightType == GroovyTokenTypes.mTRIPLE_DOT) { return NO_SPACING; } // diamonds if (rightType == GroovyTokenTypes.mLT || rightType == GroovyTokenTypes.mGT) { if (right.getParent() instanceof GrCodeReferenceElement) { PsiElement p = right.getParent().getParent(); if (p instanceof GrNewExpression || p instanceof GrAnonymousClassDefinition) { return NO_SPACING; } } } return COMMON_SPACING; }
getSpacing
30,536
Spacing (FormattingContext context) { return Spacing.createSpacing(0, 0, 1, context.getSettings().KEEP_LINE_BREAKS, context.getSettings().KEEP_BLANK_LINES_IN_CODE); }
getStatementSpacing
30,537
Spacing (@NotNull CommonCodeStyleSettings settings, @NotNull GroovyCodeStyleSettings groovySettings, @NotNull GrClosableBlock closure, final boolean forArrow) { boolean spaceWithinBraces = closure.getParent() instanceof GrStringInjection ? groovySettings.SPACE_WITHIN_GSTRING_INJECTION_BRACES : settings.SPACE_WITHIN_BRACES; GrStatement[] statements = closure.getStatements(); if (statements.length > 0) { final PsiElement startElem = forArrow ? statements[0] : closure; int start = startElem.getTextRange().getStartOffset(); int end = statements[statements.length - 1].getTextRange().getEndOffset(); TextRange range = new TextRange(start, end); int minSpaces = spaceWithinBraces || forArrow ? 1 : 0; int maxSpaces = spaceWithinBraces || forArrow ? 1 : 0; return Spacing.createDependentLFSpacing(minSpaces, maxSpaces, range, settings.KEEP_LINE_BREAKS, settings.KEEP_BLANK_LINES_IN_CODE); } return spaceWithinBraces || forArrow ? COMMON_SPACING : NO_SPACING_WITH_NEWLINE; }
createDependentSpacingForClosure
30,538
boolean (GroovyBlock block) { return block.getNode().getTextRange().equals(block.getTextRange()) || block instanceof MethodCallWithoutQualifierBlock || block instanceof ClosureBodyBlock || block instanceof GrLabelBlock; }
mirrorsAst
30,539
PsiClass (@NotNull PsiElement place) { if (place.getLanguage() == GroovyLanguage.INSTANCE) { PsiClass containingClass = PsiTreeUtil.getParentOfType(place, PsiClass.class, false); while (containingClass instanceof PsiTypeParameter) { containingClass = PsiTreeUtil.getParentOfType(containingClass, PsiClass.class); } if (containingClass != null) return containingClass; PsiFile file = place.getContainingFile(); if (file instanceof GroovyFile && ((GroovyFile)file).isScript()) { return ((GroovyFile)file).getScriptClass(); } } return null; }
findClass
30,540
String () { return "//"; }
getLineCommentPrefix
30,541
String () { return "/*"; }
getBlockCommentPrefix
30,542
String () { return "*/"; }
getBlockCommentSuffix
30,543
String () { return null; }
getCommentedBlockCommentPrefix
30,544
String () { return null; }
getCommentedBlockCommentSuffix
30,545
IElementType () { return GroovyTokenTypes.mSL_COMMENT; }
getLineCommentTokenType
30,546
IElementType () { return GroovyTokenTypes.mML_COMMENT; }
getBlockCommentTokenType
30,547
IElementType () { return GroovyDocElementTypes.GROOVY_DOC_COMMENT; }
getDocumentationCommentTokenType
30,548
String () { return "/**"; }
getDocumentationCommentPrefix
30,549
String () { return "*"; }
getDocumentationCommentLinePrefix
30,550
String () { return "*/"; }
getDocumentationCommentSuffix
30,551
boolean (PsiComment element) { return element.getText().startsWith(getDocumentationCommentPrefix()); }
isDocumentationComment
30,552
boolean (@NotNull IElementType braceType, @Nullable IElementType tokenType) { return tokenType == null || tokenType == TokenType.WHITE_SPACE || tokenType == NL || tokenType == GroovyTokenTypes.mSEMI || tokenType == GroovyTokenTypes.mCOMMA || tokenType == GroovyTokenTypes.mRPAREN || tokenType == GroovyTokenTypes.mRBRACK || tokenType == GroovyTokenTypes.mRCURLY || TokenSets.COMMENT_SET.contains(tokenType) || tokenType.getLanguage() != GroovyLanguage.INSTANCE; }
isPairedBracesAllowedBeforeType
30,553
int (PsiFile file, int openingBraceOffset) { return openingBraceOffset; }
getCodeConstructStart
30,554
Lexer (@NotNull OccurrenceConsumer consumer) { return new GroovyFilterLexer(new GroovyLexer(), consumer); }
createLexer
30,555
void (MouseEvent e, PsiElement element) { PsiElement parent = element.getParent(); if (!(parent instanceof GrField field)) return; final List<GrAccessorMethod> accessors = GroovyPropertyUtils.getFieldAccessors(field); final ArrayList<PsiMethod> superMethods = new ArrayList<>(); for (GrAccessorMethod method : accessors) { Collections.addAll(superMethods, method.findSuperMethods(false)); } if (superMethods.isEmpty()) return; final PsiMethod[] supers = superMethods.toArray(PsiMethod.EMPTY_ARRAY); boolean showMethodNames = !PsiUtil.allMethodsHaveSameSignature(supers); PsiElementListNavigator.openTargets(e, supers, DaemonBundle.message("navigation.title.super.method", field.getName()), DaemonBundle.message("navigation.findUsages.title.super.method", field.getName()), new MethodCellRenderer(showMethodNames)); }
browse
30,556
void (MouseEvent e, PsiElement element) { PsiElement parent = element.getParent(); if (!(parent instanceof GrField field)) return; if (DumbService.isDumb(element.getProject())) { DumbService.getInstance(element.getProject()).showDumbModeNotificationForFunctionality( GroovyBundle.message("popup.content.navigation.to.overriding.classes.unavailable"), DumbModeBlockedFunctionality.GroovyMarkers ); return; } Set<PsiMethod> result = new HashSet<>(); Processor<PsiMethod> collectProcessor = Processors.cancelableCollectProcessor(result); if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> ApplicationManager.getApplication().runReadAction(() -> { for (GrAccessorMethod method : GroovyPropertyUtils.getFieldAccessors(field)) { OverridingMethodsSearch.search(method).forEach(collectProcessor); } }), JavaAnalysisBundle.message("searching.for.overriding.methods"), true, field.getProject(), (JComponent)e.getComponent())) { return; } PsiMethod[] overridings = result.toArray(PsiMethod.EMPTY_ARRAY); if (overridings.length == 0) return; String title = DaemonBundle.message("navigation.title.overrider.method", field.getName(), overridings.length); boolean showMethodNames = !PsiUtil.allMethodsHaveSameSignature(overridings); MethodCellRenderer renderer = new MethodCellRenderer(showMethodNames); Arrays.sort(overridings, renderer.getComparator()); PsiElementListNavigator.openTargets(e, overridings, title, GroovyBundle.message("overriding.methods.of.0",field.getName()) , renderer); }
browse
30,557
void (MouseEvent e, PsiElement element) { PsiElement parent = element.getParent(); if (!(parent instanceof GrMethod method)) return; Set<PsiMethod> superMethods = collectSuperMethods(method); if (superMethods.isEmpty()) return; PsiElementListNavigator.openTargets(e, superMethods.toArray(PsiMethod.EMPTY_ARRAY), DaemonBundle.message("navigation.title.super.method", method.getName()), DaemonBundle.message("navigation.findUsages.title.super.method", method.getName()), new MethodCellRenderer(true)); }
browse
30,558
boolean (PsiMethod method) { if (method instanceof GrTraitMethod) { return true; } return processor.execute(method); }
processInReadAction
30,559
void (MouseEvent e, PsiElement element) { PsiElement parent = element.getParent(); if (!(parent instanceof GrMethod method)) return; if (DumbService.isDumb(element.getProject())) { DumbService.getInstance(element.getProject()).showDumbModeNotificationForFunctionality( GroovyBundle.message("popup.content.navigation.to.overriding.classes.unavailable"), DumbModeBlockedFunctionality.GroovyMarkers); return; } final OverridingMethodsUpdater methodsUpdater = new OverridingMethodsUpdater(method); new PsiTargetNavigator<>(() -> getOverridingMethods(method, (JComponent)e.getComponent())) .tabTitle(GroovyBundle.message("overriding.methods.of.0", method.getName())) .updater(methodsUpdater) .navigate(e, null, element.getProject()); }
browse
30,560
Collection<PsiMethod> (GrMethod method, JComponent component) { //collect all overriding methods (including fields with implicit accessors and method with default parameters) final PsiElementProcessor.CollectElementsWithLimit<PsiMethod> collectProcessor = new PsiElementProcessor.CollectElementsWithLimit<>(2, new HashSet<>()); for (GrMethod m : PsiImplUtil.getMethodOrReflectedMethods(method)) { OverridingMethodsSearch.search(m).forEach(new ReadActionProcessor<>() { @Override public boolean processInReadAction(PsiMethod psiMethod) { if (psiMethod instanceof GrReflectedMethod) { psiMethod = ((GrReflectedMethod)psiMethod).getBaseMethod(); } return collectProcessor.execute(psiMethod); } }); } return collectProcessor.getCollection(); }
getOverridingMethods
30,561
boolean (PsiMethod psiMethod) { if (psiMethod instanceof GrReflectedMethod) { psiMethod = ((GrReflectedMethod)psiMethod).getBaseMethod(); } return collectProcessor.execute(psiMethod); }
processInReadAction
30,562
Set<PsiMethod> (GrMethod method) { Set<PsiMethod> superMethods = new HashSet<>(); for (GrMethod m : PsiImplUtil.getMethodOrReflectedMethods(method)) { for (PsiMethod superMethod : m.findSuperMethods(false)) { if (superMethod instanceof GrReflectedMethod) { superMethod = ((GrReflectedMethod)superMethod).getBaseMethod(); } superMethods.add(superMethod); } } return superMethods; }
collectSuperMethods
30,563
StringBuilder (PsiElement @NotNull [] elements, final String pattern, StringBuilder result) { Set<String> names = new LinkedHashSet<>(); for (PsiElement element : elements) { String methodName = ((PsiMethod)element).getName(); PsiClass aClass = ((PsiMethod)element).getContainingClass(); String className = aClass == null ? "" : ClassPresentationUtil.getNameForClass(aClass, true); names.add(MessageFormat.format(pattern, methodName, className)); } @NonNls String sep = ""; for (String name : names) { result.append(sep); sep = "<br>"; result.append(name); } return result; }
composeText
30,564
void (@NotNull final ProgressIndicator indicator) { super.run(indicator); for (PsiMethod method : PsiImplUtil.getMethodOrReflectedMethods(myMethod)) { OverridingMethodsSearch.search(method).forEach( new CommonProcessors.CollectProcessor<>() { @Override public boolean process(PsiMethod psiMethod) { if (!updateComponent(com.intellij.psi.impl.PsiImplUtil.handleMirror(psiMethod))) { indicator.cancel(); } indicator.checkCanceled(); return true; } }); } }
run
30,565
boolean (PsiMethod psiMethod) { if (!updateComponent(com.intellij.psi.impl.PsiImplUtil.handleMirror(psiMethod))) { indicator.cancel(); } indicator.checkCanceled(); return true; }
process
30,566
boolean (@NotNull GrMethod method) { final GrReflectedMethod[] reflectedMethods = method.getReflectedMethods(); if (reflectedMethods.length > 0) { for (GrReflectedMethod reflectedMethod : reflectedMethods) { final MethodSignatureBackedByPsiMethod first = SuperMethodsSearch.search(reflectedMethod, null, true, false).findFirst(); if (first != null) return true; } return false; } else { return SuperMethodsSearch.search(method, null, true, false).findFirst() != null; } }
hasSuperMethods
30,567
int (@NotNull PsiElement element, @NotNull CharSequence documentChars) { if (element instanceof GrVariableDeclarationImpl) { GrVariable[] variables = ((GrVariableDeclarationImpl)element).getVariables(); if (variables.length == 1 && variables[0] instanceof GrField && variables[0].getInitializerGroovy() instanceof GrClosableBlock) { return 2; } } if (element instanceof GrField || element instanceof GrTypeParameter) return 1; if (element instanceof GrTypeDefinition || element instanceof GrClassInitializer) return 2; if (element instanceof GrMethod) { if (((GrMethod)element).hasModifierProperty(PsiModifier.ABSTRACT) && !(((GrMethod)element).getBlock() != null && GrTraitUtil.isTrait(((GrMethod)element).getContainingClass()))) { return 1; } TextRange textRange = element.getTextRange(); int start = textRange.getStartOffset(); int end = Math.min(documentChars.length(), textRange.getEndOffset()); int crlf = StringUtil.getLineBreakCount(documentChars.subSequence(start, end)); return crlf == 0 ? 1 : 2; } return 0; }
getGroovyCategory
30,568
void (final @NotNull List<? extends PsiElement> elements, final @NotNull Collection<? super LineMarkerInfo<?>> result) { Set<PsiMethod> methods = new HashSet<>(); for (PsiElement element : elements) { ProgressManager.checkCanceled(); if (element instanceof GrField) { methods.addAll(GroovyPropertyUtils.getFieldAccessors((GrField)element)); } else if (element instanceof GrMethod) { GrReflectedMethod[] reflected = ((GrMethod)element).getReflectedMethods(); if (reflected.length != 0) { Collections.addAll(methods, reflected); } else { methods.add((PsiMethod)element); } } else if (element instanceof PsiClass && !(element instanceof PsiTypeParameter)) { result.addAll(collectInheritingClasses((PsiClass)element)); } } collectOverridingMethods(methods, result); }
collectSlowLineMarkers
30,569
void (final @NotNull Set<? extends PsiMethod> methods, @NotNull Collection<? super LineMarkerInfo<?>> result) { final Set<PsiElement> overridden = new HashSet<>(); Set<PsiClass> classes = new HashSet<>(); for (PsiMethod method : methods) { ProgressManager.checkCanceled(); final PsiClass parentClass = method.getContainingClass(); if (parentClass != null && !CommonClassNames.JAVA_LANG_OBJECT.equals(parentClass.getQualifiedName())) { classes.add(parentClass); } } for (final PsiClass aClass : classes) { AllOverridingMethodsSearch.search(aClass).forEach(pair -> { ProgressManager.checkCanceled(); final PsiMethod superMethod = pair.getFirst(); if (isCorrectTarget(superMethod) && isCorrectTarget(pair.getSecond())) { if (methods.remove(superMethod)) { overridden.add(PsiImplUtil.handleMirror(superMethod)); } } return !methods.isEmpty(); }); } for (PsiElement element : overridden) { final Icon icon = AllIcons.Gutter.OverridenMethod; element = PsiImplUtil.handleMirror(element); PsiElement range = element instanceof GrNamedElement ? ((GrNamedElement)element).getNameIdentifierGroovy() : element; final MarkerType type = element instanceof GrField ? GroovyMarkerTypes.OVERRIDEN_PROPERTY_TYPE : GroovyMarkerTypes.GR_OVERRIDDEN_METHOD; LineMarkerInfo<?> info = new LineMarkerInfo<>(range, range.getTextRange(), icon, type.getTooltip(), type.getNavigationHandler(), GutterIconRenderer.Alignment.RIGHT); result.add(info); } }
collectOverridingMethods
30,570
boolean (@NotNull PsiMethod method) { if (method instanceof GrTraitMethod) return false; final PsiElement navigationElement = method.getNavigationElement(); return method.isPhysical() || navigationElement.isPhysical() && !(navigationElement instanceof PsiClass); }
isCorrectTarget
30,571
String () { return GotoSuperAction.FEATURE_ID; }
getFeatureUsedKey
30,572
GotoData (Editor editor, PsiFile file) { final PsiMember e = findSource(editor, file); if (e == null) return null; return new GotoData(e, findTargets(e), Collections.emptyList()); }
getSourceAndTargetElements
30,573
String (@NotNull PsiElement sourceElement, String name, int length, boolean finished) { return CodeInsightBundle.message("goto.super.method.chooser.title"); }
getChooserTitle
30,574
String (@NotNull PsiElement sourceElement, String name, int length) { return CodeInsightBundle.message("goto.super.method.findUsages.title", name); }
getFindUsagesTitle
30,575
String (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { final PsiMember source = findSource(editor, file); if (source instanceof PsiClass) { return GroovyBundle.message("no.super.classes.found"); } else if (source instanceof PsiMethod || source instanceof GrField) { return GroovyBundle.message("no.super.method.found"); } else { throw new IncorrectOperationException("incorrect element is found: " + (source == null ? "null" : source.getClass().getCanonicalName())); } }
getNotFoundMessage
30,576
PsiMember (Editor editor, PsiFile file) { PsiElement element = file.findElementAt(editor.getCaretModel().getOffset()); if (element == null) return null; return PsiTreeUtil.getParentOfType(element, PsiMethod.class, GrField.class, PsiClass.class); }
findSource
30,577
boolean (Editor editor, PsiFile file) { return file != null && GroovyFileType.GROOVY_FILE_TYPE.equals(file.getFileType()); }
isValidFor
30,578
TextRange (@NotNull GrMethod method) { final TextRange textRange = method.getModifierList().getTextRange(); int startOffset = textRange != null ? textRange.getStartOffset():method.getTextOffset(); int endOffset = method.getThrowsList().getTextRange().getEndOffset(); return new TextRange(startOffset, endOffset); }
getDeclarationRange
30,579
TextRange (@NotNull GrClassInitializer initializer) { int startOffset = initializer.getModifierList().getTextRange().getStartOffset(); int endOffset = initializer.getBlock().getTextRange().getStartOffset(); return new TextRange(startOffset, endOffset); }
getDeclarationRange
30,580
List<GrExpression> (@NotNull PsiElement elementAt) { return GrIntroduceHandlerBase.collectExpressions(elementAt, true); }
getExpressionsAt
30,581
TextRange (@NotNull GrTypeDefinition aClass) { if (aClass instanceof GrAnonymousClassDefinition){ GrNewExpression call = (GrNewExpression)aClass.getParent(); int startOffset = call.getTextRange().getStartOffset(); int endOffset = call.getArgumentList().getTextRange().getEndOffset(); return new TextRange(startOffset, endOffset); } else{ final PsiModifierList modifierList = aClass.getModifierList(); int startOffset = modifierList == null ? aClass.getTextRange().getStartOffset() : modifierList.getTextRange().getStartOffset(); final GrImplementsClause implementsList = aClass.getImplementsClause(); int endOffset = implementsList == null ? aClass.getTextRange().getEndOffset() : implementsList.getTextRange().getEndOffset(); return new TextRange(startOffset, endOffset); } }
getDeclarationRange
30,582
Set<GroovyFile> (UsageInfo @NotNull [] usages) { Set<GroovyFile> files = new HashSet<>(); for (UsageInfo usage : usages) { if (usage.isNonCodeUsage) continue; PsiFile file = usage.getFile(); if (file instanceof GroovyFile && ReadAction.compute(() -> file.isValid()) && file.isPhysical()) { files.add((GroovyFile)file); } } return files; }
prepareOperation
30,583
void (@NotNull final Project project, final Set<GroovyFile> files) { final ProgressManager progressManager = ProgressManager.getInstance(); final Map<GroovyFile, Pair<List<GrImportStatement>, Set<GrImportStatement>>> redundants = new HashMap<>(); final Runnable findUnusedImports = () -> { final ProgressIndicator progressIndicator = progressManager.getProgressIndicator(); if (progressIndicator != null) { progressIndicator.setIndeterminate(false); } final int total = files.size(); int i = 0; for (final GroovyFile file : files) { double fraction = (double)i++ / total; ApplicationManager.getApplication().runReadAction(() -> { if (!file.isValid()) return; final VirtualFile virtualFile = file.getVirtualFile(); if (progressIndicator != null) { progressIndicator.setText2(virtualFile.getPresentableUrl()); progressIndicator.setFraction(fraction); } if (ProjectRootManager.getInstance(project).getFileIndex().isInSource(virtualFile)) { final Set<GrImportStatement> usedImports = usedImports(file); final List<GrImportStatement> validImports = PsiUtil.getValidImportStatements(file); redundants.put(file, Pair.create(validImports, usedImports)); } }); } }; if (!progressManager.runProcessWithProgressSynchronously(findUnusedImports, GroovyBundle.message("optimize.imports.progress.title"), false, project)) { return; } WriteAction.run(() -> { for (GroovyFile groovyFile : redundants.keySet()) { if (!groovyFile.isValid()) continue; final Pair<List<GrImportStatement>, Set<GrImportStatement>> pair = redundants.get(groovyFile); final List<GrImportStatement> validImports = pair.getFirst(); final Set<GrImportStatement> usedImports = pair.getSecond(); for (GrImportStatement importStatement : validImports) { if (!usedImports.contains(importStatement)) { groovyFile.removeImport(importStatement); } } } }); }
performOperation
30,584
void (@NotNull Set<? extends GrMember> membersToMove, @NotNull PsiClass targetClass, @NotNull MultiMap<PsiElement, String> conflicts, @Nullable String newVisibility) { analyzeAccessibilityConflicts(membersToMove, targetClass, conflicts, newVisibility, targetClass, null); }
analyzeAccessibilityConflicts
30,585
void (@NotNull Set<? extends GrMember> membersToMove, @Nullable PsiClass targetClass, @NotNull MultiMap<PsiElement, String> conflicts, @Nullable String newVisibility, @NotNull PsiElement context, @Nullable Set<? extends PsiMethod> abstractMethods) { if (VisibilityUtil.ESCALATE_VISIBILITY.equals(newVisibility)) { //Still need to check for access object newVisibility = PsiModifier.PUBLIC; } for (GrMember member : membersToMove) { checkUsedElements(member, member, membersToMove, abstractMethods, targetClass, context, conflicts); RefactoringConflictsUtilImpl .checkAccessibilityConflictsAfterMove(member, newVisibility, targetClass, membersToMove, conflicts, Conditions.alwaysTrue()); } }
analyzeAccessibilityConflicts
30,586
void (PsiMember member, PsiElement scope, @NotNull Set<? extends GrMember> membersToMove, @Nullable Set<? extends PsiMethod> abstractMethods, @Nullable PsiClass targetClass, @NotNull PsiElement context, MultiMap<PsiElement, String> conflicts) { final Set<PsiMember> moving = new HashSet<>(membersToMove); if (abstractMethods != null) { moving.addAll(abstractMethods); } if (scope instanceof GrReferenceExpression) { GrReferenceExpression refExpr = (GrReferenceExpression)scope; PsiElement refElement = refExpr.resolve(); if (refElement instanceof PsiMember) { if (!RefactoringHierarchyUtil.willBeInTargetClass(refElement, moving, targetClass, false)) { GrExpression qualifier = refExpr.getQualifierExpression(); PsiClass accessClass = (PsiClass)(qualifier != null ? PsiUtil.getAccessObjectClass( qualifier).getElement() : null); RefactoringConflictsUtilImpl.analyzeAccessibilityAfterMove((PsiMember)refElement, context, accessClass, member, conflicts); } } } else if (scope instanceof GrNewExpression newExpression) { final GrAnonymousClassDefinition anonymousClass = newExpression.getAnonymousClassDefinition(); if (anonymousClass != null) { if (!RefactoringHierarchyUtil.willBeInTargetClass(anonymousClass, moving, targetClass, false)) { RefactoringConflictsUtilImpl.analyzeAccessibilityAfterMove(anonymousClass, context, anonymousClass, member, conflicts); } } else { final PsiMethod refElement = newExpression.resolveMethod(); if (refElement != null) { if (!RefactoringHierarchyUtil.willBeInTargetClass(refElement, moving, targetClass, false)) { RefactoringConflictsUtilImpl.analyzeAccessibilityAfterMove(refElement, context, null, member, conflicts); } } } } else if (scope instanceof GrCodeReferenceElement refExpr) { PsiElement refElement = refExpr.resolve(); if (refElement instanceof PsiMember) { if (!RefactoringHierarchyUtil.willBeInTargetClass(refElement, moving, targetClass, false)) { RefactoringConflictsUtilImpl.analyzeAccessibilityAfterMove((PsiMember)refElement, context, null, member, conflicts); } } } for (PsiElement child : scope.getChildren()) { if (child instanceof PsiWhiteSpace || child instanceof PsiComment) continue; checkUsedElements(member, child, membersToMove, abstractMethods, targetClass, context, conflicts); } }
checkUsedElements
30,587
void (final Project project, final Collection<? extends PsiElement> scopes, final UsageInfo[] usages, final PsiElement target, final MultiMap<PsiElement,String> conflicts) { if (scopes == null) return; final VirtualFile vFile = PsiUtilCore.getVirtualFile(target); if (vFile == null) return; List<GroovyPsiElement> groovyScopes = ContainerUtil.collect(scopes.iterator(), new FilteringIterator.InstanceOf<>(GroovyPsiElement.class)); analyzeModuleConflicts(project, groovyScopes, usages, vFile, conflicts); scopes.removeAll(groovyScopes); RefactoringConflictsUtil.getInstance().analyzeModuleConflicts(project, scopes, usages, vFile, conflicts); }
analyzeModuleConflicts
30,588
void (final Project project, final Collection<? extends GroovyPsiElement> scopes, final UsageInfo[] usages, final VirtualFile vFile, final MultiMap<PsiElement, String> conflicts) { if (scopes == null) return; for (final PsiElement scope : scopes) { if (scope instanceof PsiPackage) return; } final Module targetModule = ModuleUtilCore.findModuleForFile(vFile, project); if (targetModule == null) return; final GlobalSearchScope resolveScope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(targetModule); final HashSet<PsiElement> reported = new HashSet<>(); for (final GroovyPsiElement scope : scopes) { scope.accept(new GroovyRecursiveElementVisitor() { @Override public void visitCodeReferenceElement(@NotNull GrCodeReferenceElement refElement) { super.visitCodeReferenceElement(refElement); visit(refElement); } @Override public void visitReferenceExpression(@NotNull GrReferenceExpression reference) { super.visitReferenceExpression(reference); visit(reference); } private void visit(GrReferenceElement<? extends GroovyPsiElement> reference) { final PsiElement resolved = reference.resolve(); if (resolved != null && !reported.contains(resolved) && !CommonRefactoringUtil.isAncestor(resolved, scopes) && !PsiSearchScopeUtil.isInScope(resolveScope, resolved) && !(resolved instanceof LightElement)) { final String scopeDescription = RefactoringUIUtil.getDescription(ConflictsUtil.getContainer(reference), true); final String message = RefactoringBundle.message("0.referenced.in.1.will.not.be.accessible.in.module.2", RefactoringUIUtil.getDescription(resolved, true), scopeDescription, CommonRefactoringUtil.htmlEmphasize(targetModule.getName())); conflicts.putValue(resolved, StringUtil.capitalize(message)); reported.add(resolved); } } }); } boolean isInTestSources = ModuleRootManager.getInstance(targetModule).getFileIndex().isInTestSourceContent(vFile); NextUsage: for (UsageInfo usage : usages) { final PsiElement element = usage.getElement(); if (element != null && PsiTreeUtil.getParentOfType(element, GrImportStatement.class, false) == null) { for (PsiElement scope : scopes) { if (PsiTreeUtil.isAncestor(scope, element, false)) continue NextUsage; } final GlobalSearchScope resolveScope1 = element.getResolveScope(); if (!resolveScope1.isSearchInModuleContent(targetModule, isInTestSources)) { final PsiFile usageFile = element.getContainingFile(); PsiElement container; if (usageFile instanceof PsiJavaFile) { container = ConflictsUtil.getContainer(element); } else { container = usageFile; } final String scopeDescription = RefactoringUIUtil.getDescription(container, true); final VirtualFile usageVFile = usageFile.getVirtualFile(); if (usageVFile != null) { Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(usageVFile); if (module != null) { final String message; final PsiElement referencedElement; if (usage instanceof MoveRenameUsageInfo) { referencedElement = ((MoveRenameUsageInfo)usage).getReferencedElement(); } else { referencedElement = usage.getElement(); } assert referencedElement != null : usage; if (module == targetModule && isInTestSources) { message = RefactoringBundle.message("0.referenced.in.1.will.not.be.accessible.from.production.of.module.2", RefactoringUIUtil.getDescription(referencedElement, true), scopeDescription, CommonRefactoringUtil.htmlEmphasize(module.getName())); } else { message = RefactoringBundle.message("0.referenced.in.1.will.not.be.accessible.from.module.2", RefactoringUIUtil.getDescription(referencedElement, true), scopeDescription, CommonRefactoringUtil.htmlEmphasize(module.getName())); } conflicts.putValue(referencedElement, StringUtil.capitalize(message)); } } } } } }
analyzeModuleConflicts
30,589
void (@NotNull GrCodeReferenceElement refElement) { super.visitCodeReferenceElement(refElement); visit(refElement); }
visitCodeReferenceElement
30,590
void (@NotNull GrReferenceExpression reference) { super.visitReferenceExpression(reference); visit(reference); }
visitReferenceExpression
30,591
void (GrReferenceElement<? extends GroovyPsiElement> reference) { final PsiElement resolved = reference.resolve(); if (resolved != null && !reported.contains(resolved) && !CommonRefactoringUtil.isAncestor(resolved, scopes) && !PsiSearchScopeUtil.isInScope(resolveScope, resolved) && !(resolved instanceof LightElement)) { final String scopeDescription = RefactoringUIUtil.getDescription(ConflictsUtil.getContainer(reference), true); final String message = RefactoringBundle.message("0.referenced.in.1.will.not.be.accessible.in.module.2", RefactoringUIUtil.getDescription(resolved, true), scopeDescription, CommonRefactoringUtil.htmlEmphasize(targetModule.getName())); conflicts.putValue(resolved, StringUtil.capitalize(message)); reported.add(resolved); } }
visit
30,592
SuggestedNameInfo (@NotNull PsiElement element, @Nullable PsiElement nameSuggestionContext, @NotNull Set<String> result) { if (nameSuggestionContext == null) nameSuggestionContext = element; if (element instanceof GrVariable && nameSuggestionContext instanceof GroovyPsiElement) { final PsiType type = ((GrVariable)element).getTypeGroovy(); if (type != null) { final String[] names = GroovyNameSuggestionUtil .suggestVariableNameByType(type, new DefaultGroovyVariableNameValidator((GroovyPsiElement)nameSuggestionContext)); result.addAll(Arrays.asList(names)); final VariableKind kind = JavaCodeStyleManager.getInstance(element.getProject()).getVariableKind((GrVariable)element); final String typeText = type.getCanonicalText(); return new SuggestedNameInfo(names) { @Override public void nameChosen(String name) { JavaStatisticsManager.incVariableNameUseCount(name, kind, ((GrVariable)element).getName(), typeText); } }; } } return null; }
getSuggestedNames
30,593
void (String name) { JavaStatisticsManager.incVariableNameUseCount(name, kind, ((GrVariable)element).getName(), typeText); }
nameChosen
30,594
PsiElement[] (@NotNull PsiElement expr, @NotNull PsiElement scope) { ArrayList<PsiElement> occurrences = new ArrayList<>(); BiPredicate<PsiElement, PsiElement> comparator = (element1, element2) -> { if (element1 != null && element1.equals(element2)) return true; return element1 instanceof GrParameter param1 && element2 instanceof GrParameter param2 && param1.getName().equals(param2.getName()); }; if (scope instanceof GrLoopStatement) { PsiElement son = expr; while (son.getParent() != null && !(son.getParent() instanceof GrLoopStatement)) { son = son.getParent(); } assert scope.equals(son.getParent()); collectOccurrences(expr, son, occurrences, comparator, false); } else { collectOccurrences(expr, scope, occurrences, comparator, scope instanceof GrTypeDefinition || scope instanceof GroovyFileBase); } return PsiUtilCore.toPsiElementArray(occurrences); }
getExpressionOccurrences
30,595
void (@NotNull PsiElement expr, @NotNull PsiElement scope, @NotNull ArrayList<? super PsiElement> acc, BiPredicate<PsiElement, PsiElement> comparator, boolean goIntoInner) { if (scope.equals(expr)) { acc.add(expr); return; } for (PsiElement child : scope.getChildren()) { if (goIntoInner || !(child instanceof GrTypeDefinition) && !(child instanceof GrMethod && scope instanceof GroovyFileBase)) { if (PsiEquivalenceUtil.areEquivalent(child, expr, comparator, false)) { acc.add(child); } else { collectOccurrences(expr, child, acc, comparator, goIntoInner); } } } }
collectOccurrences
30,596
boolean (PsiElement tempContainer) { return tempContainer instanceof GrOpenBlock || tempContainer instanceof GrClosableBlock || tempContainer instanceof GroovyFileBase || tempContainer instanceof GrCaseSection || tempContainer instanceof GrLoopStatement || tempContainer instanceof GrIfStatement; }
isAppropriateContainerForIntroduceVariable
30,597
void (PsiElement[] occurrences) { Arrays.sort(occurrences, (elem1, elem2) -> { final int offset1 = elem1.getTextRange().getStartOffset(); final int offset2 = elem2.getTextRange().getStartOffset(); return offset1 - offset2; }); }
sortOccurrences
30,598
void (Project project, @Nullable Editor editor, PsiElement[] elements) { if (editor == null) return; ArrayList<RangeHighlighter> highlighters = new ArrayList<>(); HighlightManager highlightManager = HighlightManager.getInstance(project); if (elements.length > 0) { highlightManager.addOccurrenceHighlights(editor, elements, EditorColors.SEARCH_RESULT_ATTRIBUTES, false, highlighters); } }
highlightOccurrences
30,599
void (Project project, Editor editor, TextRange[] ranges) { if (editor == null) return; ArrayList<RangeHighlighter> highlighters = new ArrayList<>(); HighlightManager highlightManager = HighlightManager.getInstance(project); for (TextRange range : ranges) { highlightManager.addRangeHighlight(editor, range.getStartOffset(), range.getEndOffset(), EditorColors.SEARCH_RESULT_ATTRIBUTES, false, highlighters); } }
highlightOccurrencesByRanges