Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
33,600 | PsiMethod (PsiField field) { final PsiClass containingClass = field.getContainingClass(); final String propertyName = field.getName(); final boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC); return findPropertySetter(containingClass, propertyName, isStatic, true); } | findSetterForField |
33,601 | PsiMethod (PsiField field) { final PsiClass containingClass = field.getContainingClass(); final String propertyName = field.getName(); final boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC); return findPropertyGetter(containingClass, propertyName, isStatic, true); } | findGetterForField |
33,602 | PsiMethod (@Nullable PsiType type, String propertyName, @NotNull GroovyPsiElement context) { final String setterName = getSetterName(propertyName); if (type == null) { final GrExpression fromText = GroovyPsiElementFactory.getInstance(context.getProject()).createExpressionFromText("this", context); return findPropertySetter(fromText.getType(), propertyName, context); } final AccessorProcessor processor = new AccessorProcessor(propertyName, PropertyKind.SETTER, null, context); ResolveUtil.processAllDeclarations(type, processor, ResolveState.initial(), context); return PsiImplUtil.extractUniqueElement(processor.getResults().toArray(GroovyResolveResult.EMPTY_ARRAY)); } | findPropertySetter |
33,603 | PsiMethod (PsiClass aClass, String propertyName, boolean isStatic, boolean checkSuperClasses) { if (aClass == null) return null; PsiMethod[] methods; if (checkSuperClasses) { methods = aClass.getAllMethods(); } else { methods = aClass.getMethods(); } for (PsiMethod method : methods) { if (method.hasModifierProperty(PsiModifier.STATIC) != isStatic) continue; if (isSimplePropertySetter(method)) { if (propertyName.equals(getPropertyNameBySetter(method))) { return method; } } } return null; } | findPropertySetter |
33,604 | PsiMethod (@Nullable PsiClass aClass, String propertyName, @Nullable Boolean isStatic, boolean checkSuperClasses) { if (aClass == null) return null; PsiMethod[] methods; if (checkSuperClasses) { methods = aClass.getAllMethods(); } else { methods = aClass.getMethods(); } for (PsiMethod method : methods) { if (isStatic != null && method.hasModifierProperty(PsiModifier.STATIC) != isStatic) continue; if (isSimplePropertyGetter(method)) { if (propertyName.equals(getPropertyNameByGetter(method))) { return method; } } } return null; } | findPropertyGetter |
33,605 | boolean (PsiMethod method) { return isSimplePropertyGetter(method) || isSimplePropertySetter(method); } | isSimplePropertyAccessor |
33,606 | boolean (PsiMethod method) { return isSimplePropertyGetter(method, null); } | isSimplePropertyGetter |
33,607 | boolean (PsiMethod method, @Nullable String propertyName) { if (method == null || method.isConstructor()) return false; if (!method.getParameterList().isEmpty()) return false; if (!isGetterName(method.getName())) return false; boolean booleanReturnType = isBooleanOrBoxed(method.getReturnType()); if (method.getName().startsWith(IS_PREFIX) && !booleanReturnType) { return false; } if (PsiTypes.voidType().equals(method.getReturnType())) return false; if (propertyName == null) return true; final String byGetter = getPropertyNameByGetter(method); return propertyName.equals(byGetter) || (!isPropertyName(byGetter) && propertyName.equals( getPropertyNameByGetterName(method.getName(), booleanReturnType))); } | isSimplePropertyGetter |
33,608 | boolean (PsiMethod method) { return isSimplePropertySetter(method, null); } | isSimplePropertySetter |
33,609 | boolean (PsiMethod method, @Nullable String propertyName) { if (method == null || method.isConstructor()) return false; if (method.getParameterList().getParametersCount() != 1) return false; if (!isSetterName(method.getName())) return false; if (propertyName==null) return true; final String bySetter = getPropertyNameBySetter(method); return propertyName.equals(bySetter) || (!isPropertyName(bySetter) && propertyName.equals(getPropertyNameBySetterName(method.getName()))); } | isSimplePropertySetter |
33,610 | boolean (@NotNull PsiMethod method, @NotNull String prefix) { if (method.isConstructor()) return false; if (method.getParameterList().getParametersCount() != 1) return false; return isPropertyName(method.getName(), prefix); } | isSetterLike |
33,611 | String (PsiMethod getterMethod) { if (getterMethod instanceof GrAccessorMethod) { return ((GrAccessorMethod)getterMethod).getProperty().getName(); } @NonNls String methodName = getterMethod.getName(); final boolean isPropertyBoolean = isBooleanOrBoxed(getterMethod.getReturnType()); return getPropertyNameByGetterName(methodName, isPropertyBoolean); } | getPropertyNameByGetter |
33,612 | String (@NotNull String methodName, boolean canBeBoolean) { if (methodName.startsWith(GET_PREFIX) && methodName.length() > 3) { return decapitalize(methodName.substring(3)); } if (canBeBoolean && methodName.startsWith(IS_PREFIX) && methodName.length() > 2) { return decapitalize(methodName.substring(2)); } return null; } | getPropertyNameByGetterName |
33,613 | String (PsiMethod setterMethod) { if (setterMethod instanceof GrAccessorMethod) { return ((GrAccessorMethod)setterMethod).getProperty().getName(); } @NonNls String methodName = setterMethod.getName(); return getPropertyNameBySetterName(methodName); } | getPropertyNameBySetter |
33,614 | String (@NotNull String methodName) { if (methodName.startsWith(SET_PREFIX) && methodName.length() > 3) { return StringUtil.decapitalize(methodName.substring(3)); } else { return null; } } | getPropertyNameBySetterName |
33,615 | String (String accessorName) { if (isGetterName(accessorName)) { return getPropertyNameByGetterName(accessorName, true); } else if (isSetterName(accessorName)) { return getPropertyNameBySetterName(accessorName); } return null; } | getPropertyNameByAccessorName |
33,616 | String (PsiMethod accessor) { if (isSimplePropertyGetter(accessor)) return getPropertyNameByGetter(accessor); if (isSimplePropertySetter(accessor)) return getPropertyNameBySetter(accessor); return null; } | getPropertyName |
33,617 | boolean (@NotNull String name) { int prefixLength; if (name.startsWith(GET_PREFIX)) { prefixLength = 3; } else if (name.startsWith(IS_PREFIX)) { prefixLength = 2; } else { return false; } if (name.length() == prefixLength) return false; if (isUpperCase(name.charAt(prefixLength))) return true; return name.length() > prefixLength + 1 && isUpperCase(name.charAt(prefixLength + 1)); } | isGetterName |
33,618 | String (@NotNull String name) { return getAccessorName(GET_PREFIX, name); } | getGetterNameNonBoolean |
33,619 | String (@NotNull String name) { return name; } | getGetterNameForRecordField |
33,620 | String (@NotNull String name) { return getAccessorName(IS_PREFIX, name); } | getGetterNameBoolean |
33,621 | String (@NotNull String name) { return getAccessorName("set", name); } | getSetterName |
33,622 | String (String prefix, String name) { if (name.isEmpty()) return prefix; StringBuilder sb = new StringBuilder(); sb.append(prefix); if (name.length() > 1 && Character.isUpperCase(name.charAt(1))) { sb.append(name); } else { sb.append(Character.toUpperCase(name.charAt(0))); sb.append(name, 1, name.length()); } return sb.toString(); } | getAccessorName |
33,623 | String[] (@NotNull String name) { return new String[]{getGetterNameBoolean(name), getGetterNameNonBoolean(name)}; } | suggestGettersName |
33,624 | boolean (@Nullable String name) { if (name == null || name.isEmpty()) return false; if (Character.isUpperCase(name.charAt(0)) && (name.length() == 1 || !Character.isUpperCase(name.charAt(1)))) return false; return true; } | isPropertyName |
33,625 | String[] (@NotNull String name) { return new String[]{getSetterName(name)}; } | suggestSettersName |
33,626 | boolean (@Nullable String name) { return isPropertyName(name, SET_PREFIX); } | isSetterName |
33,627 | boolean (@Nullable String name, @NotNull String prefix) { return name != null && name.startsWith(prefix) && name.length() > prefix.length() && isUpperCase(name.charAt(prefix.length())); } | isPropertyName |
33,628 | boolean (@Nullable PsiClass aClass, @Nullable String propertyName, boolean isStatic) { if (aClass == null || propertyName == null) return false; final PsiField field = aClass.findFieldByName(propertyName, true); if (field instanceof GrField && ((GrField)field).isProperty() && field.hasModifierProperty(PsiModifier.STATIC) == isStatic) return true; final PsiMethod getter = findPropertyGetter(aClass, propertyName, isStatic, true); if (getter != null && getter.hasModifierProperty(PsiModifier.PUBLIC)) return true; final PsiMethod setter = findPropertySetter(aClass, propertyName, isStatic, true); return setter != null && setter.hasModifierProperty(PsiModifier.PUBLIC); } | isProperty |
33,629 | boolean (GrField field) { final PsiClass clazz = field.getContainingClass(); return isProperty(clazz, field.getName(), field.hasModifierProperty(PsiModifier.STATIC)); } | isProperty |
33,630 | boolean (char c) { return Character.toUpperCase(c) == c; } | isUpperCase |
33,631 | String (String s) { if (s.isEmpty()) return s; if (s.length() == 1) return StringUtil.toUpperCase(s); if (Character.isUpperCase(s.charAt(1))) return s; final char[] chars = s.toCharArray(); chars[0] = Character.toUpperCase(chars[0]); return new String(chars); } | capitalize |
33,632 | String (String s) { return Introspector.decapitalize(s); } | decapitalize |
33,633 | PsiField (PsiMethod accessor, boolean checkSuperClasses) { final PsiClass psiClass = accessor.getContainingClass(); if (psiClass == null) return null; PsiField field = null; if (!checkSuperClasses) { field = psiClass.findFieldByName(getPropertyNameByAccessorName(accessor.getName()), true); } else { final String name = getPropertyNameByAccessorName(accessor.getName()); assert name != null; final PsiField[] allFields = psiClass.getAllFields(); for (PsiField psiField : allFields) { if (name.equals(psiField.getName())) { field = psiField; break; } } } if (field == null) return null; if (field.hasModifierProperty(PsiModifier.STATIC) == accessor.hasModifierProperty(PsiModifier.STATIC)) { return field; } return null; } | findFieldForAccessor |
33,634 | String (PsiMethod getter) { final String name = getter.getName(); if (name.startsWith(GET_PREFIX)) return GET_PREFIX; if (name.startsWith(IS_PREFIX)) return IS_PREFIX; return null; } | getGetterPrefix |
33,635 | String (PsiMethod setter) { if (setter.getName().startsWith(SET_PREFIX)) return SET_PREFIX; return null; } | getSetterPrefix |
33,636 | String (PsiMethod method) { final String prefix = getGetterPrefix(method); if (prefix != null) return prefix; return getSetterPrefix(method); } | getAccessorPrefix |
33,637 | boolean (PsiMethod accessor, PsiField field) { final String accessorName = accessor.getName(); final String fieldName = field.getName(); if (!ArrayUtil.contains(accessorName, suggestGettersName(fieldName)) && !ArrayUtil.contains(accessorName, suggestSettersName(fieldName))) { return false; } final PsiClass accessorClass = accessor.getContainingClass(); final PsiClass fieldClass = field.getContainingClass(); if (!field.getManager().areElementsEquivalent(accessorClass, fieldClass)) return false; return accessor.hasModifierProperty(PsiModifier.STATIC) == field.hasModifierProperty(PsiModifier.STATIC); } | isAccessorFor |
33,638 | List<GrAccessorMethod> (GrField field) { List<GrAccessorMethod> accessors = new ArrayList<>(); final GrAccessorMethod[] getters = field.getGetters(); Collections.addAll(accessors, getters); final GrAccessorMethod setter = field.getSetter(); if (setter != null) accessors.add(setter); return accessors; } | getFieldAccessors |
33,639 | GrMethod (PsiField field) { GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(field.getProject()); String name = field.getName(); String getName = getGetterNameNonBoolean(field.getName()); try { PsiType type = field instanceof GrField ? ((GrField)field).getDeclaredType() : field.getType(); GrMethod getter = factory.createMethod(getName, type); if (field.hasModifierProperty(PsiModifier.STATIC)) { PsiUtil.setModifierProperty(getter, PsiModifier.STATIC, true); } annotateWithNullableStuff(field, getter); GrCodeBlock body = factory.createMethodBodyFromText("\nreturn " + name + "\n"); getter.getBlock().replace(body); return getter; } catch (IncorrectOperationException e) { LOG.error(e); return null; } } | generateGetterPrototype |
33,640 | GrMethod (PsiField field) { Project project = field.getProject(); JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(project); GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(project); String name = field.getName(); boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC); VariableKind kind = codeStyleManager.getVariableKind(field); String propertyName = codeStyleManager.variableNameToPropertyName(name, kind); String setName = getSetterName(field.getName()); final PsiClass containingClass = field.getContainingClass(); try { GrMethod setMethod = factory.createMethod(setName, PsiTypes.voidType()); String parameterName = codeStyleManager.propertyNameToVariableName(propertyName, VariableKind.PARAMETER); final PsiType type = field instanceof GrField ? ((GrField)field).getDeclaredType() : field.getType(); GrParameter param = factory.createParameter(parameterName, type); annotateWithNullableStuff(field, param); setMethod.getParameterList().add(param); PsiUtil.setModifierProperty(setMethod, PsiModifier.STATIC, isStatic); @NonNls StringBuilder builder = new StringBuilder(); if (name.equals(parameterName)) { if (!isStatic) { builder.append("this."); } else { String className = containingClass.getName(); if (className != null) { builder.append(className); builder.append("."); } } } builder.append(name); builder.append("="); builder.append(parameterName); builder.append("\n"); GrCodeBlock body = factory.createMethodBodyFromText(builder.toString()); setMethod.getBlock().replace(body); return setMethod; } catch (IncorrectOperationException e) { LOG.error(e); return null; } } | generateSetterPrototype |
33,641 | boolean (PsiType type) { return PsiTypes.booleanType().equals(type) || PsiTypes.booleanType().equals(PsiPrimitiveType.getUnboxedType(type)); } | isBooleanOrBoxed |
33,642 | PsiClass (@Nullable PsiElement element) { if (element == null) return null; if (DumbService.isDumb(element.getProject())) return null; final PsiFile file = element.getContainingFile(); if (!(file instanceof GroovyFile)) return null; for (PsiClass clazz = PsiTreeUtil.getParentOfType(element, PsiClass.class); clazz != null; clazz = PsiTreeUtil.getParentOfType(clazz, PsiClass.class)) { if (canBeRunByGroovy(clazz)) return clazz; } if (((GroovyFile)file).isScript()) return ((GroovyFile)file).getScriptClass(); final PsiClass[] classes = ((GroovyFile)file).getClasses(); if (classes.length > 0) { return classes[0]; } return null; } | getRunningClass |
33,643 | boolean (@Nullable final PsiClass psiClass) { if (psiClass == null) return false; final PsiClass runnable = JavaPsiFacade.getInstance(psiClass.getProject()).findClass(CommonClassNames.JAVA_LANG_RUNNABLE, psiClass.getResolveScope()); if (runnable == null) return false; return psiClass instanceof GrTypeDefinition && !(psiClass instanceof PsiAnonymousClass) && !psiClass.isInterface() && psiClass.isInheritor(runnable, true); } | isRunnable |
33,644 | boolean (final PsiClass psiClass) { return psiClass instanceof GroovyScriptClass || isRunnable(psiClass) || psiClass instanceof GrTypeDefinition && PsiMethodUtil.hasMainMethod(psiClass); } | canBeRunByGroovy |
33,645 | boolean (@NotNull PsiMethod method, PsiElement place) { if (method instanceof GrMethod && method.isConstructor()) { PsiClass aClass = method.getContainingClass(); if (aClass != null && !aClass.hasModifierProperty(PsiModifier.STATIC)) { PsiClass containingClass = aClass.getContainingClass(); if (containingClass != null && PsiUtil.findEnclosingInstanceClassInScope(containingClass, place, true) == null) { return true; } } } return false; } | isInnerClassConstructorUsedOutsideOfItParent |
33,646 | PsiClass (@NotNull PsiElement place, @NotNull PsiClass aClass) { if (!aClass.hasModifierProperty(PsiModifier.STATIC)) { PsiClass containingClass = aClass.getContainingClass(); if (containingClass != null) { if (PsiUtil.hasEnclosingInstanceInScope(containingClass, place, true)) { return containingClass; } } } return null; } | enclosingClass |
33,647 | PsiClass (GrTypeDefinition grType, String name, boolean checkBases) { if (!checkBases) { for (PsiClass inner : grType.getInnerClasses()) { if (name.equals(inner.getName())) return inner; } return null; } else { Map<String, CandidateInfo> innerClasses = CollectClassMembersUtil.getAllInnerClasses(grType, true); final CandidateInfo info = innerClasses.get(name); return info == null ? null : (PsiClass)info.getElement(); } } | findInnerClassByName |
33,648 | PsiClass (@NotNull GrTypeDefinition grType) { return getSuperClass(grType, grType.getExtendsListTypes()); } | getSuperClass |
33,649 | PsiClass (@NotNull GrTypeDefinition grType, PsiClassType @NotNull [] extendsListTypes) { if (extendsListTypes.length == 0) return getBaseClass(grType); final PsiClass superClass = extendsListTypes[0].resolve(); return superClass != null ? superClass : getBaseClass(grType); } | getSuperClass |
33,650 | PsiClass (GrTypeDefinition grType) { if (grType.isEnum()) { return JavaPsiFacade.getInstance(grType.getProject()).findClass(CommonClassNames.JAVA_LANG_ENUM, grType.getResolveScope()); } else { return JavaPsiFacade.getInstance(grType.getProject()).findClass(CommonClassNames.JAVA_LANG_OBJECT, grType.getResolveScope()); } } | getBaseClass |
33,651 | PsiClassType (GrTypeDefinition grType) { if (grType.isEnum()) { return TypesUtil.createTypeByFQClassName(CommonClassNames.JAVA_LANG_ENUM, grType); } return TypesUtil.getJavaLangObject(grType); } | createBaseClassType |
33,652 | List<PsiMethod> (Collection<? extends PsiClass> classes) { List<PsiMethod> allMethods = new ArrayList<>(); HashSet<PsiClass> visited = new HashSet<>(); for (PsiClass psiClass : classes) { getAllMethodsInner(psiClass, allMethods, visited); } return allMethods; } | getAllMethods |
33,653 | void (PsiClass clazz, List<? super PsiMethod> allMethods, HashSet<? super PsiClass> visited) { if (visited.contains(clazz)) return; visited.add(clazz); ContainerUtil.addAll(allMethods, clazz.getMethods()); final PsiClass[] supers = clazz.getSupers(); for (PsiClass aSuper : supers) { getAllMethodsInner(aSuper, allMethods, visited); } } | getAllMethodsInner |
33,654 | PsiClassType[] (@Nullable GrReferenceList list) { if (list == null) return PsiClassType.EMPTY_ARRAY; return list.getReferencedTypes(); } | getReferenceListTypes |
33,655 | boolean (@NotNull GrTypeDefinition grType, @NotNull PsiScopeProcessor processor, @NotNull ResolveState state, @Nullable PsiElement lastParent, @NotNull PsiElement place) { if (isAnnotationResolve(processor)) return true; //don't process class members while resolving annotation if (processor.getHint(CompilationPhaseHint.HINT_KEY) != null) { return processPhase(grType, processor, state); } if (shouldProcessTypeParameters(processor)) { for (final PsiTypeParameter typeParameter : grType.getTypeParameters()) { if (!ResolveUtil.processElement(processor, typeParameter, state)) return false; } } NameHint nameHint = processor.getHint(NameHint.KEY); String name = nameHint == null ? null : nameHint.getName(state); ElementClassHint classHint = processor.getHint(ElementClassHint.KEY); final PsiSubstitutor substitutor = state.get(PsiSubstitutor.KEY); final PsiElementFactory factory = JavaPsiFacade.getElementFactory(place.getProject()); boolean processInstanceMethods = (ResolveUtil.shouldProcessMethods(classHint) || ResolveUtil.shouldProcessProperties(classHint)) && shouldProcessInstanceMembers(grType, lastParent); LanguageLevel level = PsiUtil.getLanguageLevel(place); if (ResolveUtil.shouldProcessProperties(classHint)) { Map<String, CandidateInfo> fieldsMap = CollectClassMembersUtil.getAllFields(grType); if (name != null) { CandidateInfo fieldInfo = fieldsMap.get(name); if (fieldInfo != null) { if (!processField(grType, processor, state, place, processInstanceMethods, substitutor, factory, level, fieldInfo)) { return false; } } else if (grType.isTrait() && lastParent != null) { PsiField field = findFieldByName(grType, name, false, true); if (field != null && field.hasModifierProperty(PsiModifier.PUBLIC)) { if (!processField(grType, processor, state, place, processInstanceMethods, substitutor, factory, level, new CandidateInfo(field, PsiSubstitutor.EMPTY))) { return false; } } } } else { for (CandidateInfo info : fieldsMap.values()) { if (!processField(grType, processor, state, place, processInstanceMethods, substitutor, factory, level, info)) { return false; } } if (grType.isTrait() && lastParent != null) { for (PsiField field : CollectClassMembersUtil.getFields(grType, true)) { if (field.hasModifierProperty(PsiModifier.PUBLIC)) { if (!processField(grType, processor, state, place, processInstanceMethods, substitutor, factory, level, new CandidateInfo(field, PsiSubstitutor.EMPTY))) { return false; } } } } } } if (ResolveUtil.shouldProcessMethods(classHint)) { Map<String, List<CandidateInfo>> methodsMap = CollectClassMembersUtil.getAllMethods(grType, true); boolean isPlaceGroovy = place.getLanguage() == GroovyLanguage.INSTANCE; if (name == null) { for (List<CandidateInfo> list : methodsMap.values()) { for (CandidateInfo info : list) { if (!processMethod(grType, processor, state, place, processInstanceMethods, substitutor, factory, level, isPlaceGroovy, info)) { return false; } } } } else { List<CandidateInfo> byName = methodsMap.get(name); if (byName != null) { for (CandidateInfo info : byName) { if (!processMethod(grType, processor, state, place, processInstanceMethods, substitutor, factory, level, isPlaceGroovy, info)) { return false; } } } } } if (ResolveUtil.shouldProcessClasses(classHint)) { Map<String, CandidateInfo> classes = CollectClassMembersUtil.getAllInnerClasses(grType, true); if (name == null) { for (CandidateInfo info : classes.values()) { if (!processor.execute(info.getElement(), state)) return false; } } else { CandidateInfo info = classes.get(name); if (info != null) { if (!processor.execute(info.getElement(), state)) return false; } } } return true; } | processDeclarations |
33,656 | boolean (@NotNull GrTypeDefinition grType, @NotNull PsiScopeProcessor processor, @NotNull ResolveState state, @NotNull PsiElement place, boolean processInstanceMethods, @NotNull PsiSubstitutor substitutor, @NotNull PsiElementFactory factory, @NotNull LanguageLevel level, CandidateInfo fieldInfo) { final PsiField field = (PsiField)fieldInfo.getElement(); if (!shouldProcessTraitMember(grType, field, place)) return true; if (!processInstanceMember(processInstanceMethods, field) || isSameDeclaration(place, field)) { return true; } LOG.assertTrue(field.getContainingClass() != null); final PsiSubstitutor finalSubstitutor = PsiClassImplUtil.obtainFinalSubstitutor(field.getContainingClass(), fieldInfo.getSubstitutor(), grType, substitutor, factory, level); return processor.execute(field, state.put(PsiSubstitutor.KEY, finalSubstitutor)); } | processField |
33,657 | boolean (@NotNull GrTypeDefinition grType, @NotNull PsiScopeProcessor processor, @NotNull ResolveState state, @NotNull PsiElement place, boolean processInstanceMethods, @NotNull PsiSubstitutor substitutor, @NotNull PsiElementFactory factory, @NotNull LanguageLevel level, boolean placeGroovy, @NotNull CandidateInfo info) { PsiMethod method = (PsiMethod)info.getElement(); if (!shouldProcessTraitMember(grType, method, place)) return true; if (!processInstanceMember(processInstanceMethods, method) || isSameDeclaration(place, method) || !isMethodVisible(placeGroovy, method)) { return true; } LOG.assertTrue(method.getContainingClass() != null); final PsiSubstitutor finalSubstitutor = PsiClassImplUtil.obtainFinalSubstitutor(method.getContainingClass(), info.getSubstitutor(), grType, substitutor, factory, level); return processor.execute(method, state.put(PsiSubstitutor.KEY, finalSubstitutor)); } | processMethod |
33,658 | boolean (@NotNull GrTypeDefinition grType, @NotNull PsiMember element, @NotNull PsiElement place) { return !grType.isTrait() || !element.hasModifierProperty(PsiModifier.STATIC) || grType.equals(element.getContainingClass()) && PsiTreeUtil.isAncestor(grType, place, true); } | shouldProcessTraitMember |
33,659 | boolean (@NotNull GrTypeDefinition grType, @Nullable PsiElement lastParent) { if (lastParent != null) { final GrModifierList modifierList = grType.getModifierList(); if (modifierList != null && modifierList.hasAnnotation(GroovyCommonClassNames.GROOVY_LANG_CATEGORY)) { return false; } } return true; } | shouldProcessInstanceMembers |
33,660 | boolean (boolean shouldProcessInstance, @NotNull PsiMember member) { if (shouldProcessInstance) return true; if (member instanceof GrReflectedMethod) { return ((GrReflectedMethod)member).getBaseMethod().hasModifierProperty(PsiModifier.STATIC); } else { return member.hasModifierProperty(PsiModifier.STATIC); } } | processInstanceMember |
33,661 | boolean (PsiElement place, PsiElement element) { if (element instanceof GrAccessorMethod) element = ((GrAccessorMethod)element).getProperty(); if (!(element instanceof GrField)) return false; if (element instanceof GrScriptField) element = ((GrScriptField)element).getOriginalVariable(); while (place != null) { if (place == element) return true; place = place.getParent(); if (element instanceof GrField && ((GrField)element).getInitializerGroovy() == place) { return false; } if (place instanceof GrClosableBlock) return false; if (place instanceof GrEnumConstantInitializer) return false; } return false; } | isSameDeclaration |
33,662 | boolean (boolean isPlaceGroovy, PsiMethod method) { return isPlaceGroovy || !(method instanceof GrGdkMethod); } | isMethodVisible |
33,663 | PsiMethod (GrTypeDefinition grType, PsiMethod patternMethod, boolean checkBases) { final MethodSignature patternSignature = patternMethod.getSignature(PsiSubstitutor.EMPTY); for (PsiMethod method : findMethodsByName(grType, patternMethod.getName(), checkBases, false)) { MethodSignature signature = getSignatureForInheritor(method, grType); if (patternSignature.equals(signature)) return method; } return null; } | findMethodBySignature |
33,664 | PsiMethod[] (GrTypeDefinition grType, String name, boolean checkBases, boolean includeSyntheticAccessors) { if (!checkBases) { List<PsiMethod> result = new ArrayList<>(); for (PsiMethod method : CollectClassMembersUtil.getMethods(grType, includeSyntheticAccessors)) { if (name.equals(method.getName())) result.add(method); } return result.toArray(PsiMethod.EMPTY_ARRAY); } Map<String, List<CandidateInfo>> methodsMap = CollectClassMembersUtil.getAllMethods(grType, includeSyntheticAccessors); return PsiImplUtil.mapToMethods(methodsMap.get(name)); } | findMethodsByName |
33,665 | PsiMethod[] (GrTypeDefinition grType, PsiMethod patternMethod, boolean checkBases, boolean includeSynthetic) { ArrayList<PsiMethod> result = new ArrayList<>(); final MethodSignature patternSignature = patternMethod.getSignature(PsiSubstitutor.EMPTY); for (PsiMethod method : findMethodsByName(grType, patternMethod.getName(), checkBases, includeSynthetic)) { MethodSignature signature = getSignatureForInheritor(method, grType); if (patternSignature.equals(signature)) { result.add(method); } } return result.toArray(PsiMethod.EMPTY_ARRAY); } | findMethodsBySignature |
33,666 | MethodSignature (@NotNull PsiMethod methodFromSuperClass, @NotNull GrTypeDefinition inheritor) { final PsiClass clazz = methodFromSuperClass.getContainingClass(); if (clazz == null) return null; PsiSubstitutor superSubstitutor = TypeConversionUtil.getClassSubstitutor(clazz, inheritor, PsiSubstitutor.EMPTY); if (superSubstitutor == null) return null; return methodFromSuperClass.getSignature(superSubstitutor); } | getSignatureForInheritor |
33,667 | PsiField (GrTypeDefinition grType, String name, boolean checkBases, boolean includeSynthetic) { if (!checkBases) { for (PsiField field : CollectClassMembersUtil.getFields(grType, includeSynthetic)) { if (name.equals(field.getName())) return field; } return null; } Map<String, CandidateInfo> fieldsMap = CollectClassMembersUtil.getAllFields(grType, includeSynthetic); final CandidateInfo info = fieldsMap.get(name); return info == null ? null : (PsiField)info.getElement(); } | findFieldByName |
33,668 | PsiField[] (GrTypeDefinition grType) { return getAllFields(grType, true); } | getAllFields |
33,669 | PsiField[] (GrTypeDefinition grType, boolean includeSynthetic) { Map<String, CandidateInfo> fieldsMap = CollectClassMembersUtil.getAllFields(grType, includeSynthetic); return ContainerUtil.map2Array(fieldsMap.values(), PsiField.class, entry -> (PsiField)entry.getElement()); } | getAllFields |
33,670 | boolean (GrTypeDefinitionImpl definition, PsiElement another) { return PsiClassImplUtil.isClassEquivalentTo(definition, another); } | isClassEquivalentTo |
33,671 | Set<MethodSignature> (@NotNull PsiClass clazz) { return CachedValuesManager.getCachedValue(clazz, () -> { PsiElementFactory factory = JavaPsiFacade.getInstance(clazz.getProject()).getElementFactory(); MostlySingularMultiMap<MethodSignature, PsiMethod> signatures = new MostlySingularMultiMap<>(); for (PsiMethod method : clazz.getMethods()) { MethodSignature signature = method.getSignature(factory.createRawSubstitutor(method)); signatures.add(signature, method); } Set<MethodSignature> result = new HashSet<>(); for (MethodSignature signature : signatures.keySet()) { if (signatures.valuesForKey(signature) > 1) { result.add(signature); } } return CachedValueProvider.Result.create(result, clazz); }); } | getDuplicatedSignatures |
33,672 | GrAccessorMethod (GrField field) { return CachedValuesManager.getCachedValue(field, () -> CachedValueProvider.Result.create( doGetSetter(field), PsiModificationTracker.MODIFICATION_COUNT )); } | findSetter |
33,673 | GrAccessorMethod (GrField field) { PsiClass containingClass = field.getContainingClass(); if (containingClass == null) return null; PsiMethod[] setters = containingClass.findMethodsByName(GroovyPropertyUtils.getSetterName(field.getName()), false); for (PsiMethod setter : setters) { if (setter instanceof GrAccessorMethod) { return (GrAccessorMethod)setter; } } return null; } | doGetSetter |
33,674 | GrAccessorMethod[] (GrField field) { return CachedValuesManager.getCachedValue(field, () -> CachedValueProvider.Result.create( doGetGetters(field), PsiModificationTracker.MODIFICATION_COUNT )); } | findGetters |
33,675 | String (String s) { return unescapeRegex(s, true); } | unescapeSlashyString |
33,676 | String (String s) { return unescapeRegex(s, false); } | unescapeDollarSlashyString |
33,677 | String (String str) { final StringBuilder buffer = new StringBuilder(str.length()); escapeSymbolsForSlashyStrings(buffer, str); return buffer.toString(); } | escapeSymbolsForSlashyStrings |
33,678 | void (StringBuilder buffer, String str) { final int length = str.length(); for (int idx = 0; idx < length; idx++) { char ch = str.charAt(idx); if (ch == '/') { buffer.append("\\/"); } else if (Character.isISOControl(ch) && ch != '\n' || ch == '$') { appendUnicode(buffer, ch); } else { buffer.append(ch); } } } | escapeSymbolsForSlashyStrings |
33,679 | String (String str) { final StringBuilder buffer = new StringBuilder(str.length()); escapeSymbolsForDollarSlashyStrings(buffer, str); return buffer.toString(); } | escapeSymbolsForDollarSlashyStrings |
33,680 | void (StringBuilder buffer, String str) { final int length = str.length(); int idx = 0; while (idx < length) { final char ch = str.charAt(idx); if (ch == '/') { if (idx + 1 < length) { char nextCh = str.charAt(idx + 1); if (nextCh == '$') { // /$ -> $/$ buffer.append("$/"); idx++; continue; } } } else if (ch == '$') { if (idx + 1 < length) { final char nextCh = str.charAt(idx + 1); if (nextCh == '$' || nextCh == '/' || GroovyNamesUtil.isIdentifier(Character.toString(nextCh))) { // $$ -> $$$ // $/ -> $$/ buffer.append("$$"); idx += 1; continue; } } else { buffer.append("$$"); idx++; continue; } } if (Character.isISOControl(ch) && ch != '\n') { appendUnicode(buffer, ch); } else { buffer.append(ch); } idx++; } } | escapeSymbolsForDollarSlashyStrings |
33,681 | void (@NlsSafe StringBuilder buffer, char ch) { String hexCode = StringUtil.toUpperCase(Integer.toHexString(ch)); buffer.append("\\u"); int paddingCount = 4 - hexCode.length(); while (paddingCount-- > 0) { buffer.append(0); } buffer.append(hexCode); } | appendUnicode |
33,682 | String (CharSequence s, boolean isSingleLine, boolean unescapeSymbols) { StringBuilder b = new StringBuilder(); escapeSymbolsForGString(s, isSingleLine, unescapeSymbols, b); return b.toString(); } | escapeSymbolsForGString |
33,683 | void (CharSequence s, boolean isSingleLine, boolean unescapeSymbols, StringBuilder b) { escapeStringCharacters(s.length(), s, isSingleLine ? "$\"" : "$", isSingleLine, true, b); if (unescapeSymbols) { unescapeCharacters(b, isSingleLine ? "'" : "'\"", true); } if (!isSingleLine) escapeLastSymbols(b, '\"'); } | escapeSymbolsForGString |
33,684 | String (String s, boolean isSingleLine, boolean forInjection) { final StringBuilder builder = new StringBuilder(); escapeStringCharacters(s.length(), s, isSingleLine ? "'" : "", isSingleLine, true, builder); if (!forInjection) { unescapeCharacters(builder, isSingleLine ? "$\"" : "$'\"", !isSingleLine); } if (!isSingleLine) escapeLastSymbols(builder, '\''); return builder.toString(); } | escapeSymbolsForString |
33,685 | void (StringBuilder builder, char toEscape) { for (int i = builder.length() - 1; i >= 0 && builder.charAt(i) == toEscape; i--) { builder.insert(i, '\\'); } } | escapeLastSymbols |
33,686 | StringBuilder (int length, @NotNull CharSequence str, @Nullable String additionalChars, boolean escapeLineFeeds, boolean escapeBackSlash, @NotNull @NonNls StringBuilder buffer) { for (int idx = 0; idx < length; idx++) { char ch = str.charAt(idx); switch (ch) { case '\b' -> buffer.append("\\b"); case '\t' -> buffer.append("\\t"); case '\f' -> buffer.append("\\f"); case '\\' -> { if (escapeBackSlash) { buffer.append("\\\\"); } else { buffer.append('\\'); } } case '\n' -> { if (escapeLineFeeds) { buffer.append("\\n"); } else { buffer.append('\n'); } } case '\r' -> { if (escapeLineFeeds) { buffer.append("\\r"); } else { buffer.append('\r'); } } default -> { if (additionalChars != null && additionalChars.indexOf(ch) > -1) { buffer.append("\\").append(ch); } else if (Character.isISOControl(ch)) { appendUnicode(buffer, ch); } else { buffer.append(ch); } } } } return buffer; } | escapeStringCharacters |
33,687 | void (StringBuilder builder, String toUnescape, boolean isMultiLine) { for (int i = 0; i < builder.length(); i++) { if (builder.charAt(i) != '\\') continue; if (i + 1 == builder.length()) break; char next = builder.charAt(i + 1); if (next == 'n') { if (isMultiLine) { builder.replace(i, i + 2, "\n"); } } else if (next == 'r') { if (isMultiLine) { builder.replace(i, i + 2, "\r"); } } else if (toUnescape.indexOf(next) != -1) { builder.delete(i, i + 1); } else { i++; } } } | unescapeCharacters |
33,688 | String (String s, String toEscape, String toUnescape, StringBuilder builder) { boolean escaped = false; for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if (escaped) { if (toUnescape.indexOf(ch) < 0) { builder.append('\\'); builder.append(ch); } else { if (ch=='n') builder.append('\n'); else if (ch=='r') builder.append('\r'); else if (ch=='b') builder.append('\b'); else if (ch=='t') builder.append('\t'); else if (ch=='f') builder.append('\r'); else builder.append(ch); } escaped = false; continue; } if (ch == '\\') { escaped = true; continue; } if (toEscape.indexOf(ch) >= 0) { builder.append('\\'); if (ch == '\n') ch = 'n'; else if (ch == '\b') ch = 'b'; else if (ch == '\t') ch = 't'; else if (ch == '\r') ch = 'r'; else if (ch == '\f') ch = 'f'; } builder.append(ch); } return builder.toString(); } | escapeAndUnescapeSymbols |
33,689 | String (@NotNull String s) { String quote = getStartQuote(s); int sL = s.length(); int qL = quote.length(); if (sL >= qL * 2 && DOLLAR_SLASH.equals(quote)) { if (s.endsWith(SLASH_DOLLAR)) { return s.substring(qL, sL - qL); } else { return s.substring(qL); } } if (sL >= qL * 2 && s.endsWith(quote)) { return s.substring(qL, sL - qL); } else { return s.substring(qL); } } | removeQuotes |
33,690 | String (String s, boolean forGString) { if (forGString) { if (s.contains("\n") || s.contains("\r")) { return TRIPLE_DOUBLE_QUOTES + s + TRIPLE_DOUBLE_QUOTES; } else { return DOUBLE_QUOTES + s + DOUBLE_QUOTES; } } else { if (s.contains("\n") || s.contains("\r")) { return TRIPLE_QUOTES + s + TRIPLE_QUOTES; } else { return QUOTE + s + QUOTE; } } } | addQuotes |
33,691 | GrString (GrStringInjection injection, GrLiteral literal) { GrString grString = (GrString)injection.getParent(); final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(grString.getProject()); String literalText; //wrap last injection in inserted literal if it needed // e.g.: "bla bla ${foo}bla bla" and {foo} is replaced if (literal instanceof GrString) { final GrStringInjection[] injections = ((GrString)literal).getInjections(); if (injections.length > 0) { GrStringInjection last = injections[injections.length - 1]; if (last.getExpression() != null) { if (!checkBraceIsUnnecessary(last.getExpression(), injection.getNextSibling())) { wrapInjection(last); } } } literalText = removeQuotes(literal.getText()); } else { final String text = removeQuotes(literal.getText()); boolean escapeDoubleQuotes = !text.contains("\n") && grString.isPlainString(); literalText = escapeSymbolsForGString(text, escapeDoubleQuotes, true); } if (literalText.contains("\n")) { wrapGStringInto(grString, TRIPLE_DOUBLE_QUOTES); } final GrExpression expression = factory.createExpressionFromText("\"\"\"${}" + literalText + "\"\"\""); expression.getFirstChild().delete();//quote expression.getFirstChild().delete();//empty injection final ASTNode node = grString.getNode(); if (expression.getFirstChild() != null) { if (expression.getFirstChild() == expression.getLastChild()) { node.replaceChild(injection.getNode(), expression.getFirstChild().getNode()); } else { node.addChildren(expression.getFirstChild().getNode(), expression.getLastChild().getNode(), injection.getNode()); node.removeChild(injection.getNode()); } } return grString; } | replaceStringInjectionByLiteral |
33,692 | void (GrString grString, String quotes) { GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(grString.getProject()); final PsiElement firstChild = grString.getFirstChild(); final PsiElement lastChild = grString.getLastChild(); final GrExpression template = factory.createExpressionFromText(quotes + "$x" + quotes); if (firstChild != null && firstChild.getNode().getElementType() == GroovyTokenTypes.mGSTRING_BEGIN && !quotes.equals(firstChild.getText())) { grString.getNode().replaceChild(firstChild.getNode(), template.getFirstChild().getNode()); } if (lastChild != null && lastChild.getNode().getElementType() == GroovyTokenTypes.mGSTRING_END && !quotes.equals(lastChild.getText())) { grString.getNode().replaceChild(lastChild.getNode(), template.getLastChild().getNode()); } } | wrapGStringInto |
33,693 | void (GrStringInjection injection) { final GrExpression expression = injection.getExpression(); LOG.assertTrue(expression != null); final GroovyPsiElementFactory instance = GroovyPsiElementFactory.getInstance(injection.getProject()); final GrClosableBlock closure = instance.createClosureFromText("{foo}"); closure.getNode().replaceChild(closure.getStatements()[0].getNode(), expression.getNode()); injection.getNode().addChild(closure.getNode()); CodeEditUtil.setNodeGeneratedRecursively(expression.getNode(), true); } | wrapInjection |
33,694 | boolean (GrStringInjection injection) { final GrClosableBlock block = injection.getClosableBlock(); if (block == null) return false; final GrStatement[] statements = block.getStatements(); if (statements.length != 1) return false; if (!(statements[0] instanceof GrReferenceExpression)) return false; return checkBraceIsUnnecessary(statements[0], injection.getNextSibling()); } | checkGStringInjectionForUnnecessaryBraces |
33,695 | boolean (GrStatement injected, PsiElement next) { if (next.getTextLength() == 0) next = next.getNextSibling(); char nextChar = next.getText().charAt(0); if (nextChar == '"' || nextChar == '$') { return true; } final GroovyPsiElementFactory elementFactory = GroovyPsiElementFactory.getInstance(injected.getProject()); final GrExpression gString; try { gString = elementFactory.createExpressionFromText("\"$" + injected.getText() + next.getText() + '"'); } catch (Exception e) { return false; } if (!(gString instanceof GrString)) return false; PsiElement child = gString.getFirstChild(); if (!(child.getNode().getElementType() == GroovyTokenTypes.mGSTRING_BEGIN)) return false; child = child.getNextSibling(); if (!(child instanceof GrStringInjection)) return false; final PsiElement refExprCopy = ((GrStringInjection)child).getExpression(); if (!(refExprCopy instanceof GrReferenceExpression)) return false; final GrReferenceExpression refExpr = (GrReferenceExpression)injected; return PsiUtil.checkPsiElementsAreEqual(refExpr, refExprCopy); } | checkBraceIsUnnecessary |
33,696 | void (GrString grString) { for (GrStringInjection child : grString.getInjections()) { if (checkGStringInjectionForUnnecessaryBraces(child)) { final GrClosableBlock closableBlock = child.getClosableBlock(); final GrReferenceExpression refExpr = (GrReferenceExpression)closableBlock.getStatements()[0]; final GrReferenceExpression copy = (GrReferenceExpression)refExpr.copy(); final ASTNode oldNode = closableBlock.getNode(); oldNode.getTreeParent().replaceChild(oldNode, copy.getNode()); } } } | removeUnnecessaryBracesInGString |
33,697 | String (String text) { if (text.startsWith(TRIPLE_QUOTES)) return TRIPLE_QUOTES; if (text.startsWith(QUOTE)) return QUOTE; if (text.startsWith(TRIPLE_DOUBLE_QUOTES)) return TRIPLE_DOUBLE_QUOTES; if (text.startsWith(DOUBLE_QUOTES)) return DOUBLE_QUOTES; if (text.startsWith(SLASH)) return SLASH; if (text.startsWith(DOLLAR_SLASH)) return DOLLAR_SLASH; return ""; } | getStartQuote |
33,698 | String (String text) { if (text.endsWith(TRIPLE_QUOTES)) return TRIPLE_QUOTES; if (text.endsWith(QUOTE)) return QUOTE; if (text.endsWith(TRIPLE_DOUBLE_QUOTES)) return TRIPLE_DOUBLE_QUOTES; if (text.endsWith(DOUBLE_QUOTES)) return DOUBLE_QUOTES; if (text.endsWith(SLASH)) return SLASH; if (text.endsWith(SLASH_DOLLAR)) return SLASH_DOLLAR; return ""; } | getEndQuote |
33,699 | TextRange (@Nullable PsiElement element) { if (element == null) return null; IElementType elementType = element.getNode().getElementType(); if (!GroovyTokenSets.STRING_LITERALS.contains(elementType)) return null; String text = element.getText(); String startQuote = getStartQuote(text); String endQuote = getEndQuote(text.substring(startQuote.length())); return new TextRange(startQuote.length(), element.getTextLength() - endQuote.length()); } | getStringContentRange |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.