Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
35,200
GrDocComment () { return null; }
getDocComment
35,201
boolean () { return false; }
isDeprecated
35,202
boolean () { return false; }
hasTypeParameters
35,203
GrTypeParameterList () { return null; }
getTypeParameterList
35,204
String () { final GrTypeParameterStub stub = getStub(); if (stub != null) { return stub.getName(); } return getNameIdentifierGroovy().getText(); }
getName
35,205
boolean (@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) { return GrClassImplUtil.processDeclarations(this, processor, state, lastParent, place); }
processDeclarations
35,206
PsiAnnotation (@NotNull @NonNls String qualifiedName) { return null; }
findAnnotation
35,207
PsiAnnotation (@NotNull @NonNls String qualifiedName) { throw new IncorrectOperationException(); }
addAnnotation
35,208
void (@NotNull GroovyElementVisitor visitor) { visitor.visitTypeParameter(this); }
accept
35,209
void (@NotNull GroovyElementVisitor visitor) { visitor.visitClassTypeElement(this); }
accept
35,210
String () { return "Type element"; }
toString
35,211
GrCodeReferenceElement () { return findNotNullChildByType(GroovyElementTypes.REFERENCE_ELEMENT); }
getReferenceElement
35,212
PsiType () { return new GrClassReferenceType(getReferenceElement()); }
getType
35,213
void (@NotNull GroovyElementVisitor visitor) { visitor.visitBuiltinTypeElement(this); }
accept
35,214
String () { return "Built in type"; }
toString
35,215
PsiType () { return TypesUtil.getPrimitiveTypeByText(getText()); }
getType
35,216
String () { return "Type extends bounds list"; }
toString
35,217
Role () { return Role.EXTENDS_BOUNDS_LIST; }
getRole
35,218
IElementType () { return null; }
getKeywordType
35,219
PsiElement () { return null; }
getKeyword
35,220
void (@NotNull GroovyElementVisitor visitor) { visitor.visitImportStatement(this); }
accept
35,221
String () { return "Import statement"; }
toString
35,222
PsiClass () { return CachedValuesManager.getCachedValue(this, () -> { GrCodeReferenceElement reference = getImportReference(); GrCodeReferenceElement qualifier = reference == null ? null : reference.getQualifier(); PsiElement target = qualifier == null ? null : qualifier.resolve(); PsiClass clazz = target instanceof PsiClass ? (PsiClass)target : null; return CachedValueProvider.Result.create(clazz, PsiModificationTracker.MODIFICATION_COUNT, this); }); }
resolveQualifier
35,223
GrCodeReferenceElement () { return findChildByType(GroovyElementTypes.REFERENCE_ELEMENT); }
getImportReference
35,224
String () { GrImportStatementStub stub = getGreenStub(); if (stub != null) { return stub.getFqn(); } GrCodeReferenceElement reference = getImportReference(); return reference == null ? null : reference.getQualifiedReferenceName(); }
getImportFqn
35,225
String () { if (isOnDemand()) return null; GrImportStatementStub stub = getStub(); if (stub != null) { String name = stub.getAliasName(); if (name != null) { return name; } String referenceText = stub.getFqn(); return referenceText == null ? null : StringUtil.getShortName(referenceText); } GrImportAlias alias = getAlias(); if (alias != null) { String aliasName = alias.getName(); if (aliasName != null) { return aliasName; } } GrCodeReferenceElement ref = getImportReference(); return ref == null ? null : ref.getReferenceName(); }
getImportedName
35,226
boolean () { GrImportStatementStub stub = getStub(); if (stub != null) { return stub.isStatic(); } return findChildByType(GroovyTokenTypes.kSTATIC) != null; }
isStatic
35,227
boolean () { GrImportStatementStub stub = getStub(); if (stub != null) { return stub.getAliasName() != null; } GrImportAlias alias = getAlias(); return alias != null && alias.getName() != null; }
isAliasedImport
35,228
boolean () { GrImportStatementStub stub = getStub(); if (stub != null) { return stub.isOnDemand(); } return findChildByType(GroovyTokenTypes.mSTAR) != null; }
isOnDemand
35,229
GrModifierList () { GrImportStatementStub stub = getStub(); if (stub != null) { return Objects.requireNonNull(getStubOrPsiChild(GroovyStubElementTypes.MODIFIER_LIST)); } return findNotNullChildByClass(GrModifierList.class); }
getAnnotationList
35,230
PsiClass () { final GrCodeReferenceElement ref = getImportReference(); if (ref == null) return null; final PsiElement resolved; if (!isStatic() || isOnDemand()) { resolved = ref.resolve(); } else { resolved = resolveQualifier(); } return resolved instanceof PsiClass ? (PsiClass)resolved : null; }
resolveTargetClass
35,231
GrImportAlias () { return findChildByClass(GrImportAlias.class); }
getAlias
35,232
GroovyImport () { return createImportFromStatement(this); }
getImport
35,233
void (@NotNull GroovyElementVisitor visitor) { visitor.visitPackageDefinition(this); }
accept
35,234
String () { return "Package definition"; }
toString
35,235
String () { final GrPackageDefinitionStub stub = getStub(); if (stub != null) { return stub.getPackageName(); } GrCodeReferenceElement ref = getPackageReference(); return ref == null ? "" : ref.getQualifiedReferenceName(); }
getPackageName
35,236
GrCodeReferenceElement () { return findChildByType(GroovyElementTypes.REFERENCE_ELEMENT); }
getPackageReference
35,237
GrModifierList () { return getStubOrPsiChild(GroovyStubElementTypes.MODIFIER_LIST); }
getAnnotationList
35,238
PsiModifierList () { return getAnnotationList(); }
getModifierList
35,239
boolean (@NonNls @NotNull String name) { final PsiModifierList list = getModifierList(); return list != null && list.hasExplicitModifier(name); }
hasModifierProperty
35,240
PsiSubstitutor () { return mySubstitutor; }
getSubstitutor
35,241
PsiMethod () { return myMethod; }
getMethod
35,242
int () { return myMethod.getParameterList().getParametersCount(); }
getParameterCount
35,243
boolean () { return GrClosureSignatureUtil.isVarArgsImpl(getParameters()); }
isVarargs
35,244
PsiType () { PsiType type = getReturnTypeInner(); return myEraseParameterTypes ? TypeConversionUtil.erasure(type) : type; }
getReturnType
35,245
PsiType () { PsiSubstitutor substitutor = getSubstitutor(); if (myMethod.isConstructor()) { PsiClass clazz = myMethod.getContainingClass(); if (clazz == null) return null; return GroovyPsiElementFactory.getInstance(myMethod.getProject()).createType(clazz, substitutor); } else { return substitutor.substitute(PsiUtil.getSmartReturnType(myMethod)); } }
getReturnTypeInner
35,246
boolean () { return false; }
isCurried
35,247
boolean () { return myContext.isValid() && myMethod.isValid() && getSubstitutor().isValid(); }
isValid
35,248
PsiType () { return myDelegate.getType(); }
getType
35,249
boolean () { return myDelegate.isOptional(); }
isOptional
35,250
GrExpression () { return myDelegate.getDefaultInitializer(); }
getDefaultInitializer
35,251
boolean () { return myDelegate.isValid(); }
isValid
35,252
String () { return myDelegate.getName(); }
getName
35,253
boolean () { return myIsVarargs; }
isVarargs
35,254
PsiType () { return myReturnType; }
getReturnType
35,255
PsiSubstitutor () { return mySubstitutor; }
getSubstitutor
35,256
int () { return myParameters.length; }
getParameterCount
35,257
boolean () { for (GrClosureParameter parameter : myParameters) { if (!parameter.isValid()) return false; } final PsiType returnType = getReturnType(); return returnType == null || returnType.isValid(); }
isValid
35,258
boolean (Object obj) { if (obj instanceof GrSignature) { return Arrays.equals(myParameters, ((GrSignature)obj).getParameters()) && myIsVarargs == ((GrSignature)obj).isVarargs(); } return super.equals(obj); }
equals
35,259
boolean () { return myCurried; }
isCurried
35,260
GrSignature (@NotNull GrSignature signature1, @NotNull GrSignature signature2, @NotNull PsiManager manager) { GrClosureParameter[] parameters1 = signature1.getParameters(); GrClosureParameter[] parameters2 = signature2.getParameters(); if (parameters1.length == parameters2.length) { GrClosureParameter[] params = new GrClosureParameter[parameters1.length]; for (int i = 0; i < params.length; i++) { final PsiType type = GenericsUtil.getGreatestLowerBound(parameters1[i].getType(), parameters2[i].getType()); boolean opt = parameters1[i].isOptional() && parameters2[i].isOptional(); String name = StringUtil.equals(parameters1[i].getName(), parameters2[i].getName()) ? parameters1[i].getName() : null; params[i] = new GrImmediateClosureParameterImpl(type, name, opt, null); } final PsiType s1type = signature1.getReturnType(); final PsiType s2type = signature2.getReturnType(); PsiType returnType = null; if (s1type != null && s2type != null) { returnType = TypesUtil.getLeastUpperBound(s1type, s2type, manager); } boolean isVarArgs = signature1.isVarargs() && signature2.isVarargs(); return new GrImmediateClosureSignatureImpl(params, returnType, isVarArgs, false); } return null; //todo }
getLeastUpperBound
35,261
PsiSubstitutor () { return PsiSubstitutor.EMPTY; }
getSubstitutor
35,262
int () { return myExpression.getAllParameters().length; }
getParameterCount
35,263
boolean () { GrParameter last = ArrayUtil.getLastElement(myExpression.getAllParameters()); return last != null && last.getType() instanceof PsiArrayType; }
isVarargs
35,264
PsiType () { return myExpression.getReturnType(); }
getReturnType
35,265
boolean () { return false; }
isCurried
35,266
boolean () { return myExpression.isValid(); }
isValid
35,267
PsiType (@NotNull PsiParameter parameter) { return parameter instanceof GrParameter ? ((GrParameter)parameter).getDeclaredType() : parameter.getType(); }
getParameterType
35,268
GrExpression (PsiParameter parameter) { return parameter instanceof GrParameter ? ((GrParameter)parameter).getInitializerGroovy() : null; }
getDefaultInitializer
35,269
boolean (PsiParameter parameter) { return parameter instanceof GrParameter && ((GrParameter)parameter).isOptional(); }
isParameterOptional
35,270
String (@NotNull PsiParameter param) { if (param instanceof PsiCompiledElement) { // don't try to find out a compiled parameter name return null; } else { return param.getName(); } }
getParameterName
35,271
PsiType () { return myType; }
getType
35,272
boolean () { return myOptional; }
isOptional
35,273
GrExpression () { return myDefaultInitializer; }
getDefaultInitializer
35,274
boolean () { return (myType == null || myType.isValid()) && (myDefaultInitializer == null || myDefaultInitializer.isValid()); }
isValid
35,275
String () { return myName; }
getName
35,276
boolean (Object obj) { if (obj instanceof GrClosureParameter) { return Comparing.equal(myType, ((GrClosureParameter)obj).getType()) && Comparing.equal(myOptional, ((GrClosureParameter)obj).isOptional()) && Comparing.equal(myDefaultInitializer, ((GrClosureParameter)obj).getDefaultInitializer()); } return super.equals(obj); }
equals
35,277
GrSignature (GrCall call) { if (call instanceof GrMethodCall) { final GrExpression invokedExpression = ((GrMethodCall)call).getInvokedExpression(); final PsiType type = invokedExpression.getType(); if (type instanceof GroovyClosureType) { Collection<CallSignature<?>> signatures = ((GroovyClosureType)type).applicableSignatures(ArgumentsKt.getArguments(call)); if (signatures.size() == 1) { return new GrCallSignatureAdapter(ContainerUtil.getFirstItem(signatures)); } } } final GroovyResolveResult resolveResult = call.advancedResolve(); final PsiElement element = resolveResult.getElement(); if (element instanceof PsiMethod) { return createSignature((PsiMethod)element, resolveResult.getSubstitutor()); } return null; }
createSignature
35,278
GrSignature (@NotNull MethodSignature signature) { final PsiType[] types = signature.getParameterTypes(); GrClosureParameter[] parameters = ContainerUtil.map(types, type -> new GrImmediateClosureParameterImpl(type, null, false, null), new GrClosureParameter[types.length] ); return new GrImmediateClosureSignatureImpl(parameters, null, false, false); }
createSignature
35,279
GrSignature (@NotNull GrFunctionalExpression expression) { return new GrFunctionalExpressionSignature(expression); }
createSignature
35,280
GrSignature (@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor) { return createSignature(method, substitutor, false); }
createSignature
35,281
GrSignature (@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor, boolean eraseParameterTypes) { return createSignature(method, substitutor, eraseParameterTypes, method); }
createSignature
35,282
GrSignature (@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor, boolean types, @NotNull PsiElement place) { return new GrMethodSignatureImpl(method, substitutor, types, place); }
createSignature
35,283
GrSignature (PsiParameter[] parameters, @Nullable PsiType returnType) { return new GrImmediateClosureSignatureImpl(parameters, returnType); }
createSignature
35,284
PsiType (@NotNull final List<? extends GrSignature> signatures, @NotNull GrMethodCall expr) { return getReturnType(signatures, PsiUtil.getArgumentTypes(expr.getInvokedExpression(), true), expr); }
getReturnType
35,285
PsiType (@NotNull final List<? extends GrSignature> signatures, PsiType @Nullable [] args, @NotNull PsiElement context) { if (signatures.size() == 1) { return signatures.get(0).getReturnType(); } final PsiManager manager = context.getManager(); if (args == null) { return TypesUtil.getLeastUpperBoundNullable(ContainerUtil.map(signatures, GrSignature::getReturnType), manager); } final List<Trinity<GrSignature, ArgInfo<PsiType>[], Applicability>> results = getSignatureApplicabilities(signatures, args, context); if (results.size() == 1) return results.get(0).first.getReturnType(); return TypesUtil.getLeastUpperBoundNullable(ContainerUtil.map(results, it -> it.first.getReturnType()), manager); }
getReturnType
35,286
boolean (@NotNull List<? extends GrSignature> signature, PsiType @NotNull [] args, @NotNull PsiElement context) { return isSignatureApplicableConcrete(signature, args, context) != Applicability.inapplicable; }
isSignatureApplicable
35,287
Applicability (@NotNull List<? extends GrSignature> signatures, final PsiType @NotNull [] args, @NotNull final PsiElement context) { final List<Trinity<GrSignature, ArgInfo<PsiType>[], Applicability>> results = getSignatureApplicabilities(signatures, args, context); if (results.isEmpty()) { return Applicability.inapplicable; } else if (results.size() == 1) { return results.get(0).third; } else { return Applicability.applicable; } }
isSignatureApplicableConcrete
35,288
Applicability (ArgInfo<PsiType> @NotNull [] infos, @NotNull GrSignature signature) { GrClosureParameter[] parameters = signature.getParameters(); for (int i = 0; i < infos.length; i++) { ArgInfo<PsiType> info = infos[i]; if (info.args.size() != 1 || info.isMultiArg) continue; PsiType type = info.args.get(0); if (type != null) continue; PsiType pType = parameters[i].getType(); if (pType != null && !pType.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) { return Applicability.canBeApplicable; } } return Applicability.applicable; }
isSignatureApplicableInner
35,289
List<GrSignature> (@NotNull GrSignature original, PsiType[] args, int position, @NotNull PsiElement context) { GrClosureParameter[] params = original.getParameters(); List<GrClosureParameter> newParams = new ArrayList<>(params.length); List<GrClosureParameter> opts = new ArrayList<>(params.length); List<Integer> optInds = new ArrayList<>(params.length); if (position == -1) { position = params.length - args.length; } if (position < 0 || position >= params.length) { return Collections.emptyList(); } for (int i = 0; i < params.length; i++) { if (params[i].isOptional()) { opts.add(params[i]); optInds.add(i); } else { newParams.add(params[i]); } } final PsiType rtype = original.getReturnType(); final ArrayList<GrSignature> result = new ArrayList<>(); checkAndAddSignature(result, args, position, newParams, rtype, context); for (int i = 0; i < opts.size(); i++) { newParams.add(optInds.get(i), opts.get(i)); checkAndAddSignature(result, args, position, newParams, rtype, context); } return result; }
curryImpl
35,290
boolean (GrClosureParameter @NotNull [] parameters) { return parameters.length > 0 && parameters[parameters.length - 1].getType() instanceof PsiArrayType; }
isVarArgsImpl
35,291
boolean (@NotNull GrSignature signature, final int argCount) { if (argCount > 0 || signature.isCurried()) return false; final GrClosureParameter[] parameters = signature.getParameters(); if (parameters.length != 1) return false; final PsiType type = parameters[0].getType(); return InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_MAP); }
checkForOnlyMapParam
35,292
boolean (@Nullable PsiType paramType, @Nullable PsiType argType, @NotNull PsiElement context) { if (argType == null || paramType == null) { return true; } if (TypesUtil.isAssignableByMethodCallConversion(paramType, argType, context)) { return true; } final PsiType lType = TypesUtil.rawSecondGeneric(paramType, context.getProject()); final PsiType rType = TypesUtil.rawSecondGeneric(argType, context.getProject()); if (lType == null && rType == null) return false; return TypesUtil.isAssignableByMethodCallConversion(lType != null ? lType : paramType, rType != null ? rType : argType, context); }
isAssignableByConversion
35,293
void (List<? super GrSignature> list, PsiType[] args, int position, List<? extends GrClosureParameter> params, PsiType returnType, @NotNull PsiElement context) { final int last = position + args.length; if (last > params.size()) return; for (int i = position; i < last; i++) { final GrClosureParameter p = params.get(i); final PsiType type = p.getType(); if (!isAssignableByConversion(type, args[i - position], context)) return; } GrClosureParameter[] _p = new GrClosureParameter[params.size() - args.length]; int j = 0; for (int i = 0; i < position; i++) { _p[j++] = params.get(i); } for (int i = position + args.length; i < params.size(); i++) { _p[j++] = params.get(i); } list.add(new GrImmediateClosureSignatureImpl(_p, returnType, _p.length > 0 && _p[_p.length - 1].getType() instanceof PsiArrayType, true)); }
checkAndAddSignature
35,294
GrSignature (GroovyResolveResult resolveResult) { final PsiElement resolved = resolveResult.getElement(); if (!(resolved instanceof PsiMethod)) return null; final PsiSubstitutor substitutor = resolveResult.getSubstitutor(); return createSignature((PsiMethod)resolved, substitutor); }
createSignature
35,295
boolean (int curParam, int curArg, int notOptional) { boolean skipOptionals = false; int startParam = curParam; if (notOptional > args.length - curArg) return false; if (notOptional == args.length - curArg) skipOptionals = true; while (curArg < args.length) { if (skipOptionals) { while (curParam < paramLength && params[curParam].isOptional()) curParam++; } if (curParam == paramLength) break; if (params[curParam].isOptional()) { if (isAssignableByConversion(params[curParam].getType(), types[curArg], context) && isApplicableInternal(curParam + 1, curArg + 1, notOptional)) { map[curParam] = new ArgInfo<>(args[curArg], types[curArg]); return true; } skipOptionals = true; } else { if (!isAssignableByConversion(params[curParam].getType(), types[curArg], context)) { for (int i = startParam; i < curParam; i++) map[i] = null; return false; } map[curParam] = new ArgInfo<>(args[curArg], types[curArg]); notOptional--; curArg++; curParam++; } } List<Arg> varargs = new ArrayList<>(); for (; curArg < args.length; curArg++) { if (!isAssignableByConversion(vararg, types[curArg], context)) { for (int i = startParam; i < curParam; i++) map[i] = null; return false; } varargs.add(args[curArg]); } map[paramLength] = new ArgInfo<>(varargs, true, new PsiEllipsisType(vararg)); return true; }
isApplicableInternal
35,296
int (@NotNull GrSignature signature, @NotNull PsiElement context) { GrClosureParameter[] parameters = signature.getParameters(); boolean isCompileStatic = CompileStaticUtil.isCompileStatic(context); if (parameters.length == 1 && !(parameters[0].getType() instanceof PsiPrimitiveType) && !signature.isCurried() && !isCompileStatic) return 1; int count = 0; for (GrClosureParameter parameter : parameters) { if (parameter.isOptional()) count++; } return count; }
getOptionalParamCount
35,297
ArgInfo<PsiElement>[] (@NotNull GrSignature signature, @NotNull List<? extends InnerArg> innerArgs, boolean hasNamedArgs, boolean partial, @NotNull PsiElement context) { final ArgInfo<InnerArg>[] innerMap = mapParametersToArguments(signature, innerArgs.toArray(new InnerArg[0]), o -> o.type, context, partial); if (innerMap == null) return null; //noinspection unchecked ArgInfo<PsiElement>[] map = new ArgInfo[innerMap.length]; int i = 0; if (hasNamedArgs) { map[i] = new ArgInfo<>(innerMap[i].args.iterator().next().list, true, innerArgs.get(i).type); i++; } for (; i < innerMap.length; i++) { final ArgInfo<InnerArg> innerArg = innerMap[i]; if (innerArg == null) { map[i] = null; } else { List<PsiElement> argList = new ArrayList<>(); for (InnerArg arg : innerArg.args) { argList.addAll(arg.list); } boolean multiArg = innerArg.isMultiArg || argList.size() > 1; map[i] = new ArgInfo<>(argList, multiArg, innerArg.type); } } return map; }
mapParametersToArguments
35,298
List<MethodSignature> (GrMethod method, PsiSubstitutor substitutor) { GrSignature signature = createSignature(method, substitutor); String name = method.getName(); PsiTypeParameter[] typeParameters = method.getTypeParameters(); final ArrayList<MethodSignature> result = new ArrayList<>(); generateAllMethodSignaturesByClosureSignature(name, signature, typeParameters, substitutor, result); return result; }
generateAllSignaturesForMethod
35,299
PsiSubstitutor (@NotNull Map<PsiTypeParameter, PsiType> initialMap, @NotNull PsiSubstitutor initialSubstitutor, @NotNull PsiMethod actual) { if (actual.hasTypeParameters()) { final HashMap<PsiTypeParameter, PsiType> map1 = new HashMap<>(initialMap); for (PsiTypeParameter parameter : actual.getTypeParameters()) { map1.put(parameter, null); } return PsiSubstitutor.createSubstitutor(map1); } else { return initialSubstitutor; } }
calcRawSubstitutor