Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
35,300
MethodSignature (String name, List<PsiType> paramTypes, PsiTypeParameter[] typeParameters, PsiSubstitutor substitutor) { return MethodSignatureUtil.createMethodSignature(name, paramTypes.toArray(PsiType.createArray(paramTypes.size())), typeParameters, substitutor); }
generateSignature
35,301
void (@NotNull String name, @NotNull GrSignature signature, PsiTypeParameter @NotNull [] typeParameters, @NotNull PsiSubstitutor substitutor, List<? super MethodSignature> result) { GrClosureParameter[] params = signature.getParameters(); ArrayList<PsiType> newParams = new ArrayList<>(params.length); ArrayList<GrClosureParameter> opts = new ArrayList<>(params.length); ArrayList<Integer> optInds = new ArrayList<>(params.length); for (int i = 0; i < params.length; i++) { if (params[i].isOptional()) { opts.add(params[i]); optInds.add(i); } else { newParams.add(params[i].getType()); } } result.add(generateSignature(name, newParams, typeParameters, substitutor)); for (int i = 0; i < opts.size(); i++) { newParams.add(optInds.get(i), opts.get(i).getType()); result.add(generateSignature(name, newParams, typeParameters, substitutor)); } }
generateAllMethodSignaturesByClosureSignature
35,302
List<MethodSignature> (@NotNull final String name, @NotNull final List<? extends GrSignature> signatures) { final ArrayList<MethodSignature> result = new ArrayList<>(); for (GrSignature signature : signatures) { generateAllMethodSignaturesByClosureSignature(name, signature, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY, result); } return result; }
generateAllMethodSignaturesBySignature
35,303
PsiType (ArgInfo<? extends PsiElement> arg, PsiManager manager, GlobalSearchScope resolveScope) { if (arg.isMultiArg) { if (arg.args.isEmpty()) return LazyFqnClassType.getLazyType(CommonClassNames.JAVA_LANG_OBJECT, LanguageLevel.JDK_1_5, resolveScope, JavaPsiFacade.getInstance(manager.getProject())).createArrayType(); PsiType leastUpperBound = null; PsiElement first = arg.args.get(0); if (first instanceof GrNamedArgument) { GrNamedArgument[] args=new GrNamedArgument[arg.args.size()]; for (int i = 0, size = arg.args.size(); i < size; i++) { args[i] = (GrNamedArgument)arg.args.get(i); } return GrMapType.createFromNamedArgs(first, args); } else { for (PsiElement elem : arg.args) { if (elem instanceof GrExpression) { leastUpperBound = TypesUtil.getLeastUpperBoundNullable(leastUpperBound, ((GrExpression)elem).getType(), manager); } } if (leastUpperBound == null) return null; return leastUpperBound.createArrayType(); } } else { if (arg.args.isEmpty()) return null; PsiElement elem = arg.args.get(0); if (elem instanceof GrExpression) { return ((GrExpression)elem).getType(); } return null; } }
getTypeByArg
35,304
PsiType (List<? extends GrSignature> signatures) { if (signatures.size() == 1) { return signatures.get(0).getReturnType(); } else if (signatures.size() > 1) { final PsiType type = signatures.get(0).getReturnType(); if (type == null) return null; String firstType = type.getCanonicalText(); for (int i = 1; i < signatures.size(); i++) { final PsiType _type = signatures.get(i).getReturnType(); if (_type == null) return null; if (!firstType.equals(_type.getCanonicalText())) return null; } return type; } else { return null; } }
getReturnType
35,305
List<GrSignature> (@NotNull List<? extends GrSignature> signatures) { final List<GrSignature> result = new ArrayList<>(); for (GrSignature signature : signatures) { final GrClosureParameter[] original = signature.getParameters(); final ArrayList<GrClosureParameter> parameters = new ArrayList<>(original.length); for (GrClosureParameter parameter : original) { parameters.add(new GrDelegatingClosureParameter(parameter) { @Override public boolean isOptional() { return false; } @Nullable @Override public GrExpression getDefaultInitializer() { return null; } }); } final int pCount = signature.isVarargs() ? signature.getParameterCount() - 2 : signature.getParameterCount() - 1; for (int i = pCount; i >= 0; i--) { if (original[i].isOptional()) { result.add(new GrImmediateClosureSignatureImpl(parameters.toArray(GrClosureParameter.EMPTY_ARRAY), signature.getReturnType(), signature.isVarargs(), false)); parameters.remove(i); } } result.add(new GrImmediateClosureSignatureImpl(parameters.toArray(GrClosureParameter.EMPTY_ARRAY), signature.getReturnType(), signature.isVarargs(), false)); } return result; }
generateSimpleSignatures
35,306
boolean () { return false; }
isOptional
35,307
GrExpression () { return null; }
getDefaultInitializer
35,308
GrMethodCall (@NotNull GrFunctionalExpression expression) { PsiElement parent = expression.getParent(); if (parent instanceof GrMethodCall && ArrayUtil.contains(expression, ((GrMethodCall)parent).getClosureArguments())) { return (GrMethodCall)parent; } if (parent instanceof GrArgumentList) { PsiElement grandparent = parent.getParent(); if (grandparent instanceof GrMethodCall) { return (GrMethodCall)grandparent; } } return null; }
findCall
35,309
PsiType () { PsiType correctType = PsiClassImplUtil.correctType(myParameter.getType(), myContext.getResolveScope()); PsiType type = mySubstitutor.substitute(correctType); return myEraseType ? TypeConversionUtil.erasure(type, mySubstitutor) : type; }
getType
35,310
boolean () { return myParameter instanceof GrParameter && ((GrParameter)myParameter).isOptional(); }
isOptional
35,311
GrExpression () { return myParameter instanceof GrParameter ? ((GrParameter)myParameter).getInitializerGroovy() : null; }
getDefaultInitializer
35,312
boolean () { return myContext.isValid() && myParameter.isValid(); }
isValid
35,313
String () { return myParameter.getName(); }
getName
35,314
PsiClass (@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) { final List<PsiClass> classes = myCache.getClassesByFQName(qualifiedName, scope, true); if (classes.isEmpty()) return null; if (classes.size() == 1) return classes.get(0); return Collections.min(classes, PsiClassUtil .createScopeComparator(scope) .thenComparing(c -> c.getQualifiedName(), Comparator.nullsLast(Comparator.naturalOrder())) .thenComparing(c -> { PsiFile file = c.getContainingFile(); return file instanceof GroovyFileBase ? ((GroovyFileBase)file).getPackageName() : ""; })); }
findClass
35,315
GrClassReferenceType () { final GrCodeReferenceElement reference = mySmartPsiElementPointer.getElement(); if (reference != null) { return new GrClassReferenceType(reference); } try { final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(myProject); GrTypeElement typeElement = factory.createTypeElement(myReferenceText, null); return (GrClassReferenceType)typeElement.getType(); } catch (IncorrectOperationException e) { LOG.error(e); } return null; }
calcType
35,316
SmartTypePointer (@NotNull PsiClassType classType, @NotNull Project project) { if (classType instanceof GrClassReferenceType) { return new GrClassReferenceTypePointer(((GrClassReferenceType)classType), project); } return null; }
createClassTypePointer
35,317
void (@NotNull GroovyElementVisitor visitor) { visitor.visitWhileStatement(this); }
accept
35,318
String () { return "WHILE statement"; }
toString
35,319
GrStatement () { PsiElement rParenth = getRParenth(); if (rParenth == null) return null; PsiElement afterRParenth = PsiUtil.skipWhitespacesAndComments(rParenth.getNextSibling(), true); return afterRParenth instanceof GrStatement ? (GrStatement)afterRParenth : null; }
getBody
35,320
void (@NotNull GroovyElementVisitor visitor) { visitor.visitTryStatement(this); }
accept
35,321
String () { return "Try statement"; }
toString
35,322
GrTryResourceList () { return findChildByClass(GrTryResourceList.class); }
getResourceList
35,323
GrOpenBlock () { return findChildByClass(GrOpenBlock.class); }
getTryBlock
35,324
GrFinallyClause () { return findChildByClass(GrFinallyClause.class); }
getFinallyClause
35,325
GrCatchClause (@NotNull GrCatchClause clause, @Nullable GrCatchClause anchorBefore) { PsiElement anchor = anchorBefore; if (anchor == null) { anchor = getTryBlock(); } return (GrCatchClause)addAfter(clause, anchor); }
addCatchClause
35,326
boolean (@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, @Nullable PsiElement lastParent, @NotNull PsiElement place) { final GrTryResourceList resourceList = getResourceList(); if (resourceList != null && lastParent == getTryBlock()) { return resourceList.processDeclarations(processor, state, null, place); } return true; }
processDeclarations
35,327
void (@NotNull GroovyElementVisitor visitor) { visitor.visitVariable(this); }
accept
35,328
String () { return "Variable"; }
toString
35,329
PsiElement () { return ResolveUtil.isScriptField(this) ? getContainingFile() : super.getContext(); }
getContext
35,330
SearchScope () { GrScriptField field = ResolveUtil.findScriptField(this); return field != null ? field.getUseScope() : super.getUseScope(); }
getUseScope
35,331
Icon (int flags) { return JetgroovyIcons.Groovy.Variable; }
getElementIcon
35,332
GrExpression () { return findExpressionChild(this); }
getCondition
35,333
PsiElement () { return findChildByType(GroovyTokenTypes.mRPAREN); }
getRParenth
35,334
PsiElement () { return findChildByType(GroovyTokenTypes.mLCURLY); }
getLBrace
35,335
void (@NotNull GroovyElementVisitor visitor) { visitor.visitSwitchStatement(this); }
accept
35,336
String () { return "Switch statement"; }
toString
35,337
void (@NotNull GroovyElementVisitor visitor) { visitor.visitFinallyClause(this); }
accept
35,338
String () { return "Finally clause"; }
toString
35,339
GrOpenBlock () { return findChildByClass(GrOpenBlock.class); }
getBody
35,340
void (@NotNull GroovyElementVisitor visitor) { visitor.visitForStatement(this); }
accept
35,341
String () { return "For statement"; }
toString
35,342
GrForClause () { return findChildByClass(GrForClause.class); }
getClause
35,343
GrStatement () { return findChildByClass(GrStatement.class); }
getBody
35,344
boolean (@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, @Nullable PsiElement lastParent, @NotNull PsiElement place) { if (!shouldProcessLocals(processor)) return true; if (lastParent != getBody()) return true; final GrForClause forClause = getClause(); return forClause == null || forClause.processDeclarations(processor, state, null, place); }
processDeclarations
35,345
PsiElement () { return findChildByType(GroovyTokenTypes.mRPAREN); }
getRParenth
35,346
void (@NotNull GroovyElementVisitor visitor) { visitor.visitIfStatement(this); }
accept
35,347
String () { return "IF statement"; }
toString
35,348
GrExpression () { PsiElement lParenth = getLParenth(); if (lParenth == null) return null; PsiElement afterLParenth = PsiUtil.skipWhitespacesAndComments(lParenth.getNextSibling(), true); if (afterLParenth instanceof GrExpression) return (GrExpression)afterLParenth; return null; }
getCondition
35,349
GrStatement () { List<GrStatement> statements = new ArrayList<>(); for (PsiElement cur = getFirstChild(); cur != null; cur = cur.getNextSibling()) { if (cur instanceof GrStatement) statements.add((GrStatement)cur); } if (getCondition() == null && !statements.isEmpty()) return statements.get(0); if (statements.size() > 1) return statements.get(1); return null; }
getThenBranch
35,350
GrStatement () { List<GrStatement> statements = new ArrayList<>(); for (PsiElement cur = getFirstChild(); cur != null; cur = cur.getNextSibling()) { if (cur instanceof GrStatement) statements.add((GrStatement)cur); } if (statements.size() == 3) { return statements.get(2); } return null; }
getElseBranch
35,351
void (@NotNull ASTNode child) { GrStatement elseBranch = getElseBranch(); if (elseBranch != null && child == elseBranch.getNode()) { PsiElement elseKeywordElement = findChildByType(GroovyTokenTypes.kELSE); if (elseKeywordElement != null) { super.deleteChildInternal(elseKeywordElement.getNode()); } } super.deleteChildInternal(child); }
deleteChildInternal
35,352
PsiElement () { return findChildByType(GroovyTokenTypes.kELSE); }
getElseKeyword
35,353
PsiElement () { return findChildByType(GroovyTokenTypes.mRPAREN); }
getRParenth
35,354
PsiElement () { return findChildByType(GroovyTokenTypes.mLPAREN); }
getLParenth
35,355
void (@NotNull GroovyElementVisitor visitor) { visitor.visitBlockStatement(this); }
accept
35,356
String () { return "Block statement"; }
toString
35,357
GrOpenBlock () { return findNotNullChildByClass(GrOpenBlock.class); }
getBlock
35,358
void (@NotNull GroovyElementVisitor visitor) { visitor.visitCatchClause(this); }
accept
35,359
String () { return "Catch clause"; }
toString
35,360
GrParameter () { return findChildByClass(GrParameter.class); }
getParameter
35,361
GrOpenBlock () { return findChildByClass(GrOpenBlock.class); }
getBody
35,362
boolean (@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, @Nullable PsiElement lastParent, @NotNull PsiElement place) { if (!shouldProcessLocals(processor)) return true; GrParameter parameter = getParameter(); return parameter == null || ResolveUtil.processElement(processor, parameter, state); }
processDeclarations
35,363
PsiElement () { return findChildByType(GroovyTokenTypes.mRPAREN); }
getRParenth
35,364
PsiElement () { return findChildByType(GroovyTokenTypes.mLCURLY); }
getLBrace
35,365
PsiTypeElement () { return PsiImplUtil.getOrCreateTypeElement(getTypeElementGroovy()); }
getTypeElement
35,366
PsiExpression () { return null; }
getInitializer
35,367
boolean () { return false; }
hasInitializer
35,368
Object () { return null; }
computeConstantValue
35,369
boolean (@NonNls @NotNull String property) { PsiModifierList modifierList = getModifierList(); return modifierList != null && modifierList.hasModifierProperty(property); }
hasModifierProperty
35,370
PsiType () { PsiType type = getDeclaredType(); return type != null ? type : TypesUtil.getJavaLangObject(this); }
getType
35,371
GrTypeElement () { T stub = getStub(); if (stub != null) { return stub.getTypeElement(); } PsiElement parent = getParent(); if (parent instanceof GrVariableDeclaration) { return ((GrVariableDeclaration)parent).getTypeElementGroovyForVariable(this); } return findChildByClass(GrTypeElement.class); }
getTypeElementGroovy
35,372
PsiType () { GrTypeElement typeElement = getTypeElementGroovy(); PsiType declaredType = null; if (typeElement != null) { declaredType = typeElement.getType(); if (!(declaredType instanceof PsiClassType)) { return declaredType; } } PsiType initializerType = RecursionManager.doPreventingRecursion(this, true, this::getInitializerType); if (declaredType == null) { return initializerType; } if (initializerType instanceof PsiClassType && TypesUtil.isAssignableWithoutConversions(declaredType, initializerType)) { return initializerType; } return declaredType; }
getTypeGroovy
35,373
void (@Nullable PsiType type) { final GrVariableDeclaration variableDeclaration = getDeclaration(); if (variableDeclaration == null) return; final GrTypeElement typeElement = variableDeclaration.getTypeElementGroovyForVariable(this); if (type == null) { if (typeElement != null) { if (!variableDeclaration.isTuple() && variableDeclaration.getModifierList().getModifiers().length == 0) { variableDeclaration.getModifierList().setModifierProperty(GrModifier.DEF, true); } typeElement.delete(); } return; } type = TypesUtil.unboxPrimitiveTypeWrapper(type); GrTypeElement newTypeElement; try { newTypeElement = GroovyPsiElementFactory.getInstance(getProject()).createTypeElement(type); } catch (IncorrectOperationException e) { LOG.error(e); return; } if (typeElement == null) { newTypeElement = (GrTypeElement)getParent().addBefore(newTypeElement, this); } else { newTypeElement = (GrTypeElement)typeElement.replace(newTypeElement); } JavaCodeStyleManager.getInstance(getProject()).shortenClassReferences(newTypeElement); }
setType
35,374
PsiElement () { PsiElement ident = findChildByType(TokenSets.PROPERTY_NAMES); assert ident != null : getText(); return ident; }
getNameIdentifierGroovy
35,375
int () { return getNameIdentifierGroovy().getTextRange().getStartOffset(); }
getTextOffset
35,376
SearchScope () { final GrVariableDeclarationOwner owner = PsiTreeUtil.getParentOfType(this, GrVariableDeclarationOwner.class); if (owner != null) return new LocalSearchScope(owner); return super.getUseScope(); }
getUseScope
35,377
String () { T stub = getGreenStub(); if (stub != null) { String name = stub.getName(); if (name != null) { return name; } } return PsiImplUtil.getName(this); }
getName
35,378
PsiIdentifier () { return PsiUtil.getJavaNameIdentifier(this); }
getNameIdentifier
35,379
GrModifierList () { final GrVariableDeclaration variableDeclaration = getDeclaration(); if (variableDeclaration != null) return variableDeclaration.getModifierList(); return null; }
getModifierList
35,380
GrVariableDeclaration () { PsiElement parent = getParent(); if (parent instanceof GrVariableDeclaration) { return (GrVariableDeclaration)parent; } return null; }
getDeclaration
35,381
void (@NotNull ASTNode child) { final PsiElement psi = child.getPsi(); if (psi == getInitializerGroovy()) { deleteChildInternal(findNotNullChildByType(GroovyTokenTypes.mASSIGN).getNode()); } super.deleteChildInternal(child); }
deleteChildInternal
35,382
void (GrExpression initializer) { if (getParent() instanceof GrVariableDeclaration && ((GrVariableDeclaration)getParent()).isTuple()) { throw new UnsupportedOperationException("don't invoke 'setInitializer()' for tuple declaration"); } GrExpression oldInitializer = getInitializerGroovy(); if (initializer == null) { if (oldInitializer != null) { oldInitializer.delete(); PsiElement assign = findChildByType(GroovyTokenTypes.mASSIGN); if (assign != null) { assign.delete(); } } return; } if (oldInitializer != null) { oldInitializer.replaceWithExpression(initializer, true); } else { getNode().addLeaf(TokenType.WHITE_SPACE, " ", null); getNode().addLeaf(GroovyTokenTypes.mASSIGN, "=", null); addAfter(initializer, getLastChild()); } }
setInitializerGroovy
35,383
void (@NotNull GroovyElementVisitor visitor) { visitor.visitLabeledStatement(this); }
accept
35,384
String () { return "Labeled statement"; }
toString
35,385
String () { return getName(); }
getLabelName
35,386
PsiElement () { final PsiElement label = findChildByType(GroovyTokenTypes.mIDENT); assert label != null; return label; }
getLabel
35,387
GrStatement () { return findChildByClass(GrStatement.class); }
getStatement
35,388
boolean (@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, @Nullable PsiElement lastParent, @NotNull PsiElement place) { GrStatement statement = getStatement(); return statement == null || statement == lastParent || statement.processDeclarations(processor, state, lastParent, place); }
processDeclarations
35,389
SearchScope () { return new LocalSearchScope(this); }
getUseScope
35,390
String () { final PsiElement label = getLabel(); return label.getText(); }
getName
35,391
PsiElement () { return getLabel(); }
getNameIdentifierGroovy
35,392
PsiElement () { return getNameIdentifierGroovy(); }
getNameIdentifier
35,393
void (@NotNull ASTNode child) { GrStatement statement = getStatement(); if (statement != null && child == statement.getNode()) { delete(); } else { super.deleteChildInternal(child); } }
deleteChildInternal
35,394
void (@NotNull GroovyElementVisitor visitor) { visitor.visitSynchronizedStatement(this); }
accept
35,395
String () { return "Synchronized statement"; }
toString
35,396
GrExpression () { return findExpressionChild(this); }
getMonitor
35,397
GrOpenBlock () { return findChildByClass(GrOpenBlock.class); }
getBody
35,398
PsiElement () { return findChildByType(GroovyTokenTypes.mRPAREN); }
getRParenth
35,399
void (@NotNull GroovyElementVisitor visitor) { visitor.visitClassInitializer(this); }
accept