Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
33,300
boolean (@NotNull PsiElement element) { if (element instanceof PsiNamedElement && Objects.equals(((PsiNamedElement)element).getName(), getReferenceName())) { return getManager().areElementsEquivalent(element, resolve()); } return false; }
isReferenceTo
33,301
void (@NotNull List<FoldingDescriptor> descriptors, @NotNull PsiElement root, @NotNull Document document, boolean quick) { appendDescriptors(root, descriptors, new HashSet<>()); }
buildLanguageFoldRegions
33,302
void (final PsiElement element, List<? super FoldingDescriptor> descriptors, Set<? super PsiElement> usedComments) { ASTNode node = element.getNode(); if (node == null) return; IElementType type = node.getElementType(); if (TokenSets.BLOCK_SET.contains(type) && !isSingleHighLevelClassBody(element) || type == GroovyElementTypes.CLOSABLE_BLOCK) { if (isMultiline(element)) { collapseBlock(descriptors, element); } } // comments if (type.equals(GroovyTokenTypes.mML_COMMENT) && isMultiline(element) && isWellEndedComment(element)) { descriptors.add(new FoldingDescriptor(node, node.getTextRange(), null, "/*...*/", isFileHeader(node) && JavaCodeFoldingSettings.getInstance().isCollapseFileHeader(), Collections.emptySet())); } if (type.equals(GroovyDocElementTypes.GROOVY_DOC_COMMENT) && isMultiline(element) && isWellEndedComment(element)) { descriptors.add(new FoldingDescriptor(node, node.getTextRange(), null, "/**...*/", isFileHeader(node) ? JavaCodeFoldingSettings.getInstance().isCollapseFileHeader() : JavaCodeFoldingSettings.getInstance().isCollapseJavadocs(), Collections.emptySet())); } if (type.equals(GroovyTokenTypes.mSL_COMMENT) && usedComments.add(element) && !isCustomRegionElement(element)) { PsiElement end = null; for (PsiElement current = element.getNextSibling(); current != null; current = current.getNextSibling()) { if (PsiImplUtil.isWhiteSpaceOrNls(current)) continue; IElementType elementType = current.getNode().getElementType(); if (elementType == GroovyTokenTypes.mSL_COMMENT && usedComments.add(current) && !isCustomRegionElement(current)) { end = current; continue; } break; } if (end != null) { final TextRange range = new TextRange(element.getTextRange().getStartOffset(), end.getTextRange().getEndOffset()); descriptors.add(new FoldingDescriptor(node, range, null, "...", isFileHeader(node) ? JavaCodeFoldingSettings.getInstance().isCollapseFileHeader() : JavaCodeFoldingSettings.getInstance().isCollapseEndOfLineComments(), Collections.emptySet())); } } //multiline strings addFoldingForStrings(descriptors, node); Set<PsiElement> newUsedComments = new HashSet<>(); for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) { appendDescriptors(child, descriptors, newUsedComments); } if (element instanceof GroovyFile) { processImports(descriptors, ((GroovyFile)element).getImportStatements()); } }
appendDescriptors
33,303
boolean (@NotNull ASTNode node) { IElementType type = node.getElementType(); JavaCodeFoldingSettings settings = JavaCodeFoldingSettings.getInstance(); if ((type instanceof GrBlockElementType || type == GroovyElementTypes.CONSTRUCTOR_BODY) && node.getTreeParent().getElementType() == GroovyStubElementTypes.METHOD) { return settings.isCollapseMethods(); } if (type == GroovyElementTypes.CLOSABLE_BLOCK) { return settings.isCollapseAnonymousClasses(); } if (type == GroovyEmptyStubElementTypes.CLASS_BODY) { final PsiElement parent = node.getPsi().getParent(); if (parent instanceof PsiClass) { if (parent instanceof PsiAnonymousClass) { return settings.isCollapseAnonymousClasses(); } if (((PsiClass)parent).getContainingClass() != null) { return settings.isCollapseInnerClasses(); } } } return false; }
isCollapseBlock
33,304
void (List<? super FoldingDescriptor> descriptors, @NotNull PsiElement psi) { ASTNode node = psi.getNode(); boolean collapse = isCollapseBlock(node); if (psi instanceof GrCodeBlock) { final int lineFeedCount = StringUtil.countChars(psi.getText(), '\n'); if (lineFeedCount <= 2) { final PsiElement lbrace = ((GrCodeBlock)psi).getLBrace(); final PsiElement rbrace = ((GrCodeBlock)psi).getRBrace(); if (lbrace != null && rbrace != null) { final PsiElement next = lbrace.getNextSibling(); final PsiElement prev = rbrace.getPrevSibling(); if (PsiImplUtil.isWhiteSpaceOrNls(next) && PsiImplUtil.isWhiteSpaceOrNls(prev)) { final FoldingGroup group = FoldingGroup.newGroup("block_group"); descriptors.add(new FoldingDescriptor(node, new TextRange(lbrace.getTextRange().getStartOffset(), next.getTextRange().getEndOffset()), group, "{", collapse, Collections.emptySet())); descriptors.add(new FoldingDescriptor(node, new TextRange(prev.getTextRange().getStartOffset(), rbrace.getTextRange().getEndOffset()), group, "}", collapse, Collections.emptySet())); return; } } } } descriptors.add(new FoldingDescriptor(node, node.getTextRange(), null, "{...}", collapse, Collections.emptySet())); }
collapseBlock
33,305
boolean (PsiElement element) { if (!(element instanceof GrTypeDefinitionBody)) return false; final PsiElement parent = element.getParent(); if (!(parent instanceof GrTypeDefinition clazz)) return false; if (clazz.isAnonymous() || clazz.getContainingClass() != null) return false; final PsiFile file = element.getContainingFile(); return file instanceof GroovyFile && ((GroovyFile)file).getClasses().length == 1; }
isSingleHighLevelClassBody
33,306
void (List<? super FoldingDescriptor> descriptors, ASTNode node) { if (!isMultiLineStringLiteral(node)) return; if (!node.getElementType().equals(GroovyElementTypes.GSTRING) && !node.getElementType().equals(GroovyElementTypes.REGEX)) { descriptors.add(new FoldingDescriptor(node, node.getTextRange(), null, multiLineStringLiteralPlaceholder(node), false, Collections.emptySet())); return; } final GrString grString = (GrString)node.getPsi(); if (grString == null) return; final GrStringInjection[] injections = grString.getInjections(); if (injections.length == 0) { descriptors.add(new FoldingDescriptor(node, node.getTextRange(), null, multiLineStringLiteralPlaceholder(node), false, Collections.emptySet())); return; } final FoldingGroup group = FoldingGroup.newGroup("GString"); final TextRange nodeRange = node.getTextRange(); int startOffset = nodeRange.getStartOffset(); GrStringInjection injection = injections[0]; TextRange injectionRange = injection.getTextRange(); if (startOffset + 1 < injectionRange.getStartOffset()) { final String start_quote = GrStringUtil.getStartQuote(node.getText()); descriptors.add(new FoldingDescriptor(node, new TextRange(startOffset, injectionRange.getStartOffset()), group, start_quote, false, Collections.emptySet())); } startOffset = injectionRange.getEndOffset(); for (int i = 1; i < injections.length; i++) { injection = injections[i]; injectionRange = injection.getTextRange(); final int endOffset = injectionRange.getStartOffset(); if (endOffset - startOffset >= 2) { descriptors.add(new FoldingDescriptor(injection.getNode().getTreePrev(), new TextRange(startOffset, endOffset), group, " ", false, Collections.emptySet())); } startOffset = injectionRange.getEndOffset(); } if (startOffset + 1 < nodeRange.getEndOffset()) { final String end_quote = GrStringUtil.getEndQuote(node.getText()); descriptors.add(new FoldingDescriptor(node.getLastChildNode(), new TextRange(startOffset, nodeRange.getEndOffset()), group, end_quote, false, Collections.emptySet())); } }
addFoldingForStrings
33,307
void (final List<? super FoldingDescriptor> descriptors, GrImportStatement[] imports) { if (imports.length < 2) return; PsiElement first = imports[0]; while (first != null) { PsiElement marker = first; PsiElement next = first.getNextSibling(); while (next instanceof GrImportStatement || next instanceof LeafPsiElement) { if (next instanceof GrImportStatement) marker = next; next = next.getNextSibling(); } if (marker != first) { int start = first.getTextRange().getStartOffset(); int end = marker.getTextRange().getEndOffset(); int tail = "import ".length(); if (start + tail < end && !JavaFoldingBuilderBase.hasErrorElementsNearby(first.getContainingFile(), start, end)) { FoldingDescriptor descriptor = new FoldingDescriptor(first.getNode(), new TextRange(start + tail, end), null, "...", JavaCodeFoldingSettings.getInstance().isCollapseImports(), Collections.emptySet()); // imports are often added/removed automatically, so we enable autoupdate of folded region for foldings even if it's collapsed descriptor.setCanBeRemovedWhenCollapsed(true); descriptors.add(descriptor); } } while (!(next instanceof GrImportStatement) && next != null) next = next.getNextSibling(); first = next; } }
processImports
33,308
boolean (PsiElement element) { return element.getText().endsWith("*/"); }
isWellEndedComment
33,309
boolean (@NotNull PsiElement element) { String text = element.getText(); return text.contains("\n") || text.contains("\r"); }
isMultiline
33,310
String (@NotNull ASTNode node, @NotNull TextRange range) { return null; }
getLanguagePlaceholderText
33,311
String (@NotNull ASTNode node) { final String start_quote = GrStringUtil.getStartQuote(node.getText()); final String end_quote = GrStringUtil.getEndQuote(node.getText()); return start_quote + "..." + end_quote; }
multiLineStringLiteralPlaceholder
33,312
boolean (ASTNode node) { PsiElement element = node.getPsi(); PsiElement parent = element.getParent(); if (parent instanceof GroovyFile) { PsiElement firstChild = parent.getFirstChild(); if (firstChild instanceof PsiWhiteSpace) { firstChild = firstChild.getNextSibling(); } return element.equals(firstChild); } return false; }
isFileHeader
33,313
boolean (@NotNull ASTNode node) { return false; }
isRegionCollapsedByDefault
33,314
boolean (ASTNode node) { return (TokenSets.STRING_LITERAL_SET.contains(node.getElementType()) || node.getElementType().equals(GroovyElementTypes.GSTRING) || node.getElementType().equals(GroovyElementTypes.REGEX)) && isMultiline(node.getPsi()) && GrStringUtil.isWellEndedString(node.getPsi()); }
isMultiLineStringLiteral
33,315
boolean (@NotNull ASTNode node) { return node.getElementType() == GroovyTokenTypes.mSL_COMMENT; }
isCustomFoldingCandidate
33,316
boolean (@NotNull ASTNode node) { IElementType nodeType = node.getElementType(); return nodeType == GroovyStubElementTypes.CLASS_TYPE_DEFINITION || nodeType instanceof GrBlockElementType; }
isCustomFoldingRoot
33,317
GroovyShortNamesCache (Project project) { return Objects .requireNonNull(ContainerUtil.findInstance(PsiShortNamesCache.EP_NAME.getExtensionList(project), GroovyShortNamesCache.class)); }
getGroovyShortNamesCache
33,318
String (@NotNull String fqName) { int index = fqName.indexOf('.'); return index >= 1 ? fqName.substring(0, index) : ""; }
toTopLevelName
33,319
List<PsiClass> (final String name, final GlobalSearchScope scope, final boolean srcOnly) { TopLevelFQNames names = getScriptTopLevelNames(); if (names != null) { String topLevelName = toTopLevelName(name); if (!names.names.contains(topLevelName)) { return Collections.emptyList(); } } GlobalSearchScope actualScope = srcOnly ? new GrSourceFilterScope(scope) : scope; return ContainerUtil.map( StubIndex.getElements(GrFullScriptNameStringIndex.KEY, name, myProject, actualScope, GroovyFile.class), o -> Objects.requireNonNull(o.getScriptClass())); }
getScriptClassesByFQName
33,320
List<PsiClass> (String name, GlobalSearchScope scope, boolean inSource) { TopLevelFQNames names = ReadAction.compute(() -> getTopLevelNames()); if (names != null) { String topLevelName = toTopLevelName(name); if (!names.names.contains(topLevelName)) { return Collections.emptyList(); } } if (DumbService.getInstance(myProject).isAlternativeResolveEnabled()) { return Collections.emptyList(); } GlobalSearchScope actualScope = inSource ? new GrSourceFilterScope(scope) : scope; return ReadAction.compute(() -> { List<PsiClass> result = new ArrayList<>(); result.addAll(StubIndex.getElements(GrFullClassNameStringIndex.KEY, name, myProject, actualScope, PsiClass.class)); result.addAll(getScriptClassesByFQName(name, scope, inSource)); return result; }); }
getClassesByFQName
33,321
boolean (@NonNls @NotNull String name, @NotNull GlobalSearchScope scope, @NotNull Processor<? super PsiMethod> processor) { return processMethodsWithName(name, processor, scope, null); }
processMethodsWithName
33,322
boolean (@NonNls @NotNull String name, @NotNull Processor<? super PsiMethod> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { GrSourceFilterScope filterScope = new GrSourceFilterScope(scope); return StubIndex.getInstance().processElements(GrMethodNameIndex.KEY, name, myProject, filterScope, filter, GrMethod.class, processor) && StubIndex.getInstance().processElements(GrAnnotationMethodNameIndex.KEY, name, myProject, filterScope, filter, GrAnnotationMethod.class, processor); }
processMethodsWithName
33,323
boolean (@NotNull String name, @NotNull Processor<? super PsiField> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { return StubIndex.getInstance().processElements(GrFieldNameIndex.KEY, name, myProject, new GrSourceFilterScope(scope), filter, GrField.class, processor); }
processFieldsWithName
33,324
boolean (@NotNull String name, @NotNull Processor<? super PsiClass> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { return processClasses(name, processor, scope, filter) && processScriptClasses(name, processor, scope, filter); }
processClassesWithName
33,325
boolean (@NotNull String name, @NotNull Processor<? super PsiClass> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { return StubIndex.getInstance().processElements( CLASS_SHORT_NAMES, name, myProject, new GrSourceFilterScope(scope), filter, PsiClass.class, processor ); }
processClasses
33,326
boolean (@NotNull String name, @NotNull Processor<? super PsiClass> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { for (GroovyFile file : StubIndex.getElements(GrScriptClassNameIndex.KEY, name, myProject, new GrSourceFilterScope(scope), filter, GroovyFile.class)) { PsiClass aClass = file.getScriptClass(); if (aClass != null && !processor.process(aClass)) return true; } return true; }
processScriptClasses
33,327
TopLevelFQNames (TopLevelFQNames other) { boolean mergedUseful = useful && other.useful; Set<String> set; if (mergedUseful) { set = new HashSet<>(names); set.addAll(other.names); } else { set = Collections.emptySet(); } return new TopLevelFQNames(timestamp + other.timestamp, set, mergedUseful); }
merge
33,328
void (@NotNull PsiElement element) { if (element instanceof GroovyPsiElement) { ((GroovyPsiElement) element).accept(myGroovyElementVisitor); } }
visitElement
33,329
GrBlockStatement (GrStatement... statements) { StringBuilder text = new StringBuilder(); text.append("{\n"); for (GrStatement statement : statements) { text.append(statement.getText()).append("\n"); } text.append("}"); return createBlockStatementFromText(text.toString(), null); }
createBlockStatement
33,330
GroovyPsiElementFactory (@NotNull Project project) { return project.getService(GroovyPsiElementFactory.class); }
getInstance
33,331
GrCodeReferenceElement (@NlsSafe @NotNull String text) { return createCodeReference(text, null); }
createCodeReference
33,332
GrExpression (@NlsSafe @NotNull CharSequence exprText) { return createExpressionFromText(exprText.toString(), null); }
createExpressionFromText
33,333
GrLambdaExpression (@NlsSafe @NotNull String text) { return createLambdaFromText(text, null); }
createLambdaFromText
33,334
GrMethod (@NlsSafe @NotNull CharSequence methodText) { return createMethodFromText(methodText.toString(), null); }
createMethodFromText
33,335
GrMethod (@NlsSafe @NotNull String constructorName, @NlsSafe String @NotNull [] paramTypes, String @NotNull [] paramNames, @Nullable String body) { return createConstructorFromText(constructorName, paramTypes, paramNames, body, null); }
createConstructorFromText
33,336
void (@NotNull GroovyPsiElement element) { element.acceptChildren(this); }
visitElement
33,337
void (@NotNull GroovyPsiElement element) {}
visitElement
33,338
void (@NotNull GroovyFileBase file) { visitElement(file); }
visitFile
33,339
void (@NotNull GrPackageDefinition packageDefinition) { visitElement(packageDefinition); }
visitPackageDefinition
33,340
void (@NotNull GrStatement statement) { visitElement(statement); }
visitStatement
33,341
void (@NotNull GrClosableBlock closure) { visitFunctionalExpression(closure); }
visitClosure
33,342
void (@NotNull GrFunctionalExpression expression) { visitExpression(expression); }
visitFunctionalExpression
33,343
void (@NotNull GrOpenBlock block) { visitElement(block); }
visitOpenBlock
33,344
void (@NotNull GrLambdaExpression expression) { visitFunctionalExpression(expression); }
visitLambdaExpression
33,345
void (@NotNull GrBlockLambdaBody body) { visitLambdaBody(body); }
visitBlockLambdaBody
33,346
void (@NotNull GrExpressionLambdaBody body) { visitLambdaBody(body); }
visitExpressionLambdaBody
33,347
void (@NotNull GrLambdaBody body) { visitElement(body); }
visitLambdaBody
33,348
void (@NotNull GrEnumConstantList enumConstantsSection) { visitElement(enumConstantsSection); }
visitEnumConstants
33,349
void (@NotNull GrEnumConstant enumConstant) { visitField(enumConstant); }
visitEnumConstant
33,350
void (@NotNull GrImportStatement importStatement) { visitElement(importStatement); }
visitImportStatement
33,351
void (@NotNull GrBreakStatement breakStatement) { visitFlowInterruptStatement(breakStatement); }
visitBreakStatement
33,352
void (@NotNull GrContinueStatement continueStatement) { visitFlowInterruptStatement(continueStatement); }
visitContinueStatement
33,353
void (@NotNull GrFlowInterruptingStatement statement) { visitStatement(statement); }
visitFlowInterruptStatement
33,354
void (@NotNull GrReturnStatement returnStatement) { visitStatement(returnStatement); }
visitReturnStatement
33,355
void (@NotNull GrYieldStatement yieldStatement) { visitStatement(yieldStatement); }
visitYieldStatement
33,356
void (@NotNull GrAssertStatement assertStatement) { visitStatement(assertStatement); }
visitAssertStatement
33,357
void (@NotNull GrThrowStatement throwStatement) { visitStatement(throwStatement); }
visitThrowStatement
33,358
void (@NotNull GrLabeledStatement labeledStatement) { visitStatement(labeledStatement); }
visitLabeledStatement
33,359
void (@NotNull GrExpression expression) { visitElement(expression); }
visitExpression
33,360
void (@NotNull GrCallExpression callExpression) { visitExpression(callExpression); }
visitCallExpression
33,361
void (@NotNull GrNewExpression newExpression) { visitCallExpression(newExpression); }
visitNewExpression
33,362
void (@NotNull GrMethodCall call) { visitCallExpression(call); }
visitMethodCall
33,363
void (@NotNull GrMethodCallExpression methodCallExpression) { visitMethodCall(methodCallExpression); }
visitMethodCallExpression
33,364
void (@NotNull GrApplicationStatement applicationStatement) { visitMethodCall(applicationStatement); }
visitApplicationStatement
33,365
void (@NotNull GrArrayDeclaration arrayDeclaration) { visitElement(arrayDeclaration); }
visitArrayDeclaration
33,366
void (@NotNull GrCommandArgumentList argumentList) { visitArgumentList(argumentList); }
visitCommandArguments
33,367
void (@NotNull GrElvisExpression expression) { visitConditionalExpression(expression); }
visitElvisExpression
33,368
void (@NotNull GrConditionalExpression expression) { visitExpression(expression); }
visitConditionalExpression
33,369
void (@NotNull GrAssignmentExpression expression) { visitExpression(expression); }
visitAssignmentExpression
33,370
void (@NotNull GrTupleAssignmentExpression expression) { visitExpression(expression); }
visitTupleAssignmentExpression
33,371
void (@NotNull GrBinaryExpression expression) { visitExpression(expression); }
visitBinaryExpression
33,372
void (@NotNull GrInExpression expression) { visitBinaryExpression(expression); }
visitInExpression
33,373
void (@NotNull GrUnaryExpression expression) { visitExpression(expression); }
visitUnaryExpression
33,374
void (@NotNull GrRegex expression) { visitGStringExpression(expression); }
visitRegexExpression
33,375
void (@NotNull GrLiteral literal) { visitExpression(literal); }
visitLiteralExpression
33,376
void (@NotNull GrString gstring) { visitLiteralExpression(gstring); }
visitGStringExpression
33,377
void (@NotNull GrReferenceExpression referenceExpression) { visitExpression(referenceExpression); }
visitReferenceExpression
33,378
void (@NotNull GrTypeCastExpression typeCastExpression) { visitExpression(typeCastExpression); }
visitCastExpression
33,379
void (@NotNull GrSafeCastExpression typeCastExpression) { visitExpression(typeCastExpression); }
visitSafeCastExpression
33,380
void (@NotNull GrInstanceOfExpression expression) { visitExpression(expression); }
visitInstanceofExpression
33,381
void (@NotNull GrBuiltinTypeClassExpression expression) { visitExpression(expression); }
visitBuiltinTypeClassExpression
33,382
void (@NotNull GrParenthesizedExpression expression) { visitExpression(expression); }
visitParenthesizedExpression
33,383
void (@NotNull GrPropertySelection expression) { visitExpression(expression); }
visitPropertySelection
33,384
void (@NotNull GrIndexProperty expression) { visitExpression(expression); }
visitIndexProperty
33,385
void (@NotNull GrArgumentList list) { visitElement(list); }
visitArgumentList
33,386
void (@NotNull GrNamedArgument argument) { visitElement(argument); }
visitNamedArgument
33,387
void (@NotNull GrArgumentLabel argumentLabel) { visitElement(argumentLabel); }
visitArgumentLabel
33,388
void (@NotNull GrListOrMap listOrMap) { visitExpression(listOrMap); }
visitListOrMap
33,389
void (@NotNull GrTypeElement typeElement) { visitElement(typeElement); }
visitTypeElement
33,390
void (@NotNull GrArrayTypeElement typeElement) { visitTypeElement(typeElement); }
visitArrayTypeElement
33,391
void (@NotNull GrBuiltInTypeElement typeElement) { visitTypeElement(typeElement); }
visitBuiltinTypeElement
33,392
void (@NotNull GrClassTypeElement typeElement) { visitTypeElement(typeElement); }
visitClassTypeElement
33,393
void (@NotNull GrDisjunctionTypeElement disjunctionTypeElement) { visitTypeElement(disjunctionTypeElement); }
visitDisjunctionTypeElement
33,394
void (@NotNull GrCodeReferenceElement refElement) { visitElement(refElement); }
visitCodeReferenceElement
33,395
void (@NotNull GrTypeDefinition typeDefinition) { visitElement(typeDefinition); }
visitTypeDefinition
33,396
void (@NotNull GrClassDefinition classDefinition) { visitTypeDefinition(classDefinition); }
visitClassDefinition
33,397
void (@NotNull GrRecordDefinition recordDefinition) { visitTypeDefinition(recordDefinition); }
visitRecordDefinition
33,398
void (@NotNull GrEnumTypeDefinition enumDefinition) { visitTypeDefinition(enumDefinition); }
visitEnumDefinition
33,399
void (@NotNull GrInterfaceDefinition interfaceDefinition) { visitTypeDefinition(interfaceDefinition); }
visitInterfaceDefinition