Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
30,700 | List<GrParameterInfo> (@NotNull GrMethod sourceMethod) { return new GrMethodDescriptor(sourceMethod).getParameters(); } | getAllMethodParameters |
30,701 | GrParameterInfo (GroovyIntroduceObjectClassDescriptor descriptor, GrMethod method, List<? extends GrParameterInfo> oldMethodParameters) { final GroovyPsiElementFactory elementFactory = GroovyPsiElementFactory.getInstance(method.getProject()); PsiType classType = elementFactory.createTypeByFQClassName(StringUtil.getQualifiedName(descriptor.getPackageName(), descriptor.getClassName())); return new GrParameterInfo(descriptor.getClassName(), null, null, classType, NEW_PARAMETER, false) { @Nullable @Override public PsiElement getActualValue(PsiElement callExpression, Object substitutor) { final IntroduceParameterObjectDelegate<PsiNamedElement, ParameterInfo, IntroduceParameterObjectClassDescriptor<PsiNamedElement, ParameterInfo>> delegate = findDelegate(callExpression); return delegate != null ? delegate.createNewParameterInitializerAtCallSite(callExpression, descriptor, oldMethodParameters, substitutor) : null; } }; } | createMergedParameterInfo |
30,702 | PsiElement (PsiElement callExpression, Object substitutor) { final IntroduceParameterObjectDelegate<PsiNamedElement, ParameterInfo, IntroduceParameterObjectClassDescriptor<PsiNamedElement, ParameterInfo>> delegate = findDelegate(callExpression); return delegate != null ? delegate.createNewParameterInitializerAtCallSite(callExpression, descriptor, oldMethodParameters, substitutor) : null; } | getActualValue |
30,703 | PsiElement (PsiElement callExpression, IntroduceParameterObjectClassDescriptor descriptor, List<? extends ParameterInfo> oldMethodParameters, Object substitutor) { if (callExpression instanceof GrCallExpression) { final GrArgumentList list = ((GrCallExpression)callExpression).getArgumentList(); if (list == null) { return null; } final GrExpression[] args = list.getExpressionArguments(); final String qualifiedName = StringUtil.getQualifiedName(descriptor.getPackageName(), descriptor.getClassName()); String newExpression = "new " + qualifiedName + '(' + JavaIntroduceParameterObjectDelegate.getMergedArgs(descriptor, oldMethodParameters, args) + ')'; GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(callExpression.getProject()); return factory.createExpressionFromText(newExpression, callExpression); } return null; } | createNewParameterInitializerAtCallSite |
30,704 | ChangeInfo (GrMethod method, List<? extends GrParameterInfo> newParameterInfos, boolean delegate) { final PsiType returnType = method.getReturnType(); return new GrChangeInfoImpl(method, VisibilityUtil.getVisibilityModifier(method.getModifierList()), returnType != null ? CanonicalTypes.createTypeWrapper(returnType) : null, method.getName(), newParameterInfos, null, delegate); } | createChangeSignatureInfo |
30,705 | void (Collection<? super FixableUsageInfo> usages, GrMethod method, GroovyIntroduceObjectClassDescriptor descriptor, ReadWriteAccessDetector.Access[] accessors) { throw new UnsupportedOperationException(); } | collectUsagesToGenerateMissedFieldAccessors |
30,706 | void (Collection<? super FixableUsageInfo> usages, GrMethod method, GroovyIntroduceObjectClassDescriptor descriptor) { throw new UnsupportedOperationException(); } | collectAdditionalFixes |
30,707 | void (MultiMap<PsiElement, String> conflicts, UsageInfo[] infos, GrMethod method, GroovyIntroduceObjectClassDescriptor classDescriptor) { throw new UnsupportedOperationException(); } | collectConflicts |
30,708 | String (GrParameterInfo paramInfo, @NotNull PsiElement context) { throw new UnsupportedOperationException(); } | getSetterName |
30,709 | String (GrParameterInfo paramInfo, @NotNull PsiElement context, ReadWriteAccessDetector.Access access) { throw new UnsupportedOperationException(); } | getGetterName |
30,710 | GrMethod (GrMethod method) { throw new UnsupportedOperationException(); } | findCompatibleConstructorInExistingClass |
30,711 | PsiElement (GrMethod method, ReadWriteAccessDetector.Access[] accessors) { throw new UnsupportedOperationException(); } | createClass |
30,712 | void (@NotNull PsiElement location, @InspectionMessage @NotNull String description, @NotNull LocalQuickFix @Nullable [] fixes, @NotNull ProblemHighlightType highlightType) { if (highlightType == ProblemHighlightType.GENERIC_ERROR) { if (fixes != null && fixes.length > 0 && location.isPhysical()) { final InspectionManager manager = InspectionManager.getInstance(location.getProject()); final ProblemDescriptor descriptor = manager.createProblemDescriptor(location, description, fixes, highlightType, fixes.length == 1, false); toApply.add(new ProblemFix(fixes[0], descriptor)); } } } | registerError |
30,713 | List<ProblemFix> () { return toApply; } | getFixes |
30,714 | LocalQuickFix () { return fix; } | getFix |
30,715 | ProblemDescriptor () { return descriptor; } | getDescriptor |
30,716 | void () { fix.applyFix(descriptor.getPsiElement().getProject(), descriptor); } | apply |
30,717 | void (@NotNull GrReferenceExpression referenceExpression) { accessibilityChecker.visitReferenceExpression(referenceExpression); PsiElement resolved = referenceExpression.resolve(); if (resolved == null) { myCallback.trigger(referenceExpression, null); } else if (referenceExpression.getType() == null) { if (!(resolved instanceof GrMethod) || !((GrMethod)resolved).isConstructor()) myCallback.trigger(referenceExpression, null); } super.visitReferenceExpression(referenceExpression); } | visitReferenceExpression |
30,718 | void (@NotNull GrCodeReferenceElement refElement) { accessibilityChecker.visitCodeReferenceElement(refElement); super.visitCodeReferenceElement(refElement); } | visitCodeReferenceElement |
30,719 | void (@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) { invokeInner(project, new PsiElement[]{file}); } | invoke |
30,720 | void (@NotNull Project project, PsiElement @NotNull [] elements, DataContext dataContext) { invokeInner(project, elements); } | invoke |
30,721 | void (Project project, PsiElement[] elements) { Set<GroovyFile> files = collectFilesForProcessing(elements); new ConvertToStaticProcessor(project, files.toArray(GroovyFile.EMPTY_ARRAY)).run(); } | invokeInner |
30,722 | Set<GroovyFile> (PsiElement @NotNull [] elements) { Set<GroovyFile> files = new HashSet<>(); for (PsiElement element : elements) { PsiFile containingFile = element.getContainingFile(); if (containingFile instanceof GroovyFile) { files.add((GroovyFile)containingFile); } } return files; } | collectFilesForProcessing |
30,723 | UsageViewDescriptor (UsageInfo @NotNull [] usages) { return new UsageViewDescriptorAdapter() { @Override public PsiElement @NotNull [] getElements() { return myFiles; } @Override public String getProcessedElementsHeader() { return GroovyRefactoringBundle.message("files.to.be.converted"); } }; } | createUsageViewDescriptor |
30,724 | String () { return GroovyRefactoringBundle.message("files.to.be.converted"); } | getProcessedElementsHeader |
30,725 | void (UsageInfo @NotNull [] usages) { int counter = 0; final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); LOG.assertTrue(progressIndicator != null); progressIndicator.setIndeterminate(false); for (GroovyFile file : myFiles) { counter++; commitFile(file); progressIndicator.setText2(file.getName()); progressIndicator.setFraction(counter / (double)myFiles.length); try { applyDeclarationFixes(file); putCompileAnnotations(file); applyErrorFixes(file); commitFile(file); } catch (Exception e) { LOG.error("Error in converting file: " + file.getName(), e); } } } | performRefactoring |
30,726 | void (@NotNull GroovyFile file) { final Document document = PsiDocumentManager.getInstance(myProject).getDocument(file); PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(file.getProject()); LOG.assertTrue(document != null); psiDocumentManager.commitDocument(document); LOG.assertTrue(file.isValid()); } | commitFile |
30,727 | void (@NotNull GroovyFile file) { Set<GrTypeDefinition> classesWithUnresolvedRef = new HashSet<>(); Set<GrMethod> methodsWithUnresolvedRef = new HashSet<>(); VisitorCallback callback = (element, info) -> { GrMethod containingMethod = PsiTreeUtil.getParentOfType(element, GrMethod.class); if (containingMethod != null) { methodsWithUnresolvedRef.add(containingMethod); return; } GrTypeDefinition containingClass = PsiTreeUtil.getParentOfType(element, GrTypeDefinition.class); if (containingClass != null) classesWithUnresolvedRef.add(containingClass); }; file.accept(new DynamicFeaturesVisitor(file, myProject, callback)); file.accept(new GroovyRecursiveElementVisitor() { @Override public void visitTypeDefinition(@NotNull GrTypeDefinition typeDef) { processDefinitions(typeDef, classesWithUnresolvedRef); super.visitTypeDefinition(typeDef); } @Override public void visitMethod(@NotNull GrMethod method) { processMethods(method, methodsWithUnresolvedRef); super.visitMethod(method); } }); } | putCompileAnnotations |
30,728 | void (@NotNull GrTypeDefinition typeDef) { processDefinitions(typeDef, classesWithUnresolvedRef); super.visitTypeDefinition(typeDef); } | visitTypeDefinition |
30,729 | void (@NotNull GrMethod method) { processMethods(method, methodsWithUnresolvedRef); super.visitMethod(method); } | visitMethod |
30,730 | void (@NotNull GrMethod method, Set<GrMethod> dynamicMethods) { PsiElement containingClass = method.getContainingClass(); boolean isOuterStatic = containingClass != null && CompileStaticUtil.isCompileStatic(containingClass); boolean isStatic = dynamicMethods.stream().noneMatch(method::isEquivalentTo); if (isOuterStatic != isStatic) { addAnnotation(method, isStatic); } } | processMethods |
30,731 | void (GrTypeDefinition typeDef, Set<GrTypeDefinition> dynamicClasses) { PsiElement containingClass = typeDef.getContainingClass(); boolean isOuterStatic = containingClass != null && CompileStaticUtil.isCompileStatic(containingClass); boolean isStatic = !dynamicClasses.contains(typeDef); if (isOuterStatic && !isStatic) { addAnnotation(typeDef, false); } if (!isOuterStatic && isStatic) { addAnnotation(typeDef, true); } } | processDefinitions |
30,732 | String () { return GroovyRefactoringBundle.message("converting.files.to.static"); } | getCommandName |
30,733 | boolean (@NotNull MoveMembersOptions options, @NotNull MoveMembersProcessor.MoveMembersUsageInfo usage) { final PsiElement element = usage.getElement(); if (element == null || !element.isValid()) return true; if (usage.reference instanceof GrReferenceExpression refExpr) { GrExpression qualifier = refExpr.getQualifierExpression(); if (qualifier != null) { if (usage.qualifierClass != null) { changeQualifier(refExpr, usage.qualifierClass, usage.member); } else { refExpr.setQualifier(null); } } else { // no qualifier if (usage.qualifierClass != null) { changeQualifier(refExpr, usage.qualifierClass, usage.member); } } return true; } return false; } | changeExternalUsage |
30,734 | PsiMember (@NotNull MoveMembersOptions options, @NotNull PsiMember member, PsiElement anchor, @NotNull PsiClass targetClass) { GroovyChangeContextUtil.encodeContextInfo(member); final PsiDocComment docComment; if (member instanceof PsiDocCommentOwner) { docComment = ((PsiDocCommentOwner)member).getDocComment(); } else { docComment = null; } PsiMember moved; if (options.makeEnumConstant() && member instanceof GrVariable && EnumConstantsUtil.isSuitableForEnumConstant(((PsiVariable)member).getType(), targetClass)) { final GrEnumConstant prototype = createEnumConstant(member.getName(), ((GrVariable)member).getInitializerGroovy(), member.getProject()); moved = (PsiMember)addEnumConstant(targetClass, prototype, anchor); member.delete(); } else if (member instanceof GrEnumConstant) { moved = (PsiMember)addEnumConstant(targetClass, (GrEnumConstant)member, null); } else if (member instanceof GrField) { if (anchor != null) anchor = anchor.getParent(); final GrVariableDeclaration parent = (GrVariableDeclaration)member.getParent(); GrVariableDeclaration movedDeclaration = (GrVariableDeclaration)targetClass.addAfter(parent, anchor); int number = ArrayUtil.find(parent.getMembers(), member); final GrMember[] members = movedDeclaration.getMembers(); for (int i = 0; i < number; i++) { members[i].delete(); } for (int i = number + 1; i < members.length; i++) { members[i].delete(); } if (member.getContainingClass().isInterface() && !targetClass.isInterface()) { //might need to make modifiers explicit, see IDEADEV-11416 final PsiModifierList list = movedDeclaration.getModifierList(); VisibilityUtil.setVisibility(list, VisibilityUtil.getVisibilityModifier(member.getModifierList())); list.setModifierProperty(PsiModifier.STATIC, member.hasModifierProperty(PsiModifier.STATIC)); list.setModifierProperty(PsiModifier.FINAL, member.hasModifierProperty(PsiModifier.FINAL)); } moved = movedDeclaration.getMembers()[0]; } else if (member instanceof GrMethod) { moved = (PsiMember)targetClass.addAfter(member, anchor); if (member.getContainingClass().isInterface() && !targetClass.isInterface()) { //might need to make modifiers explicit, see IDEADEV-11416 final PsiModifierList list = moved.getModifierList(); assert list != null; list.setModifierProperty(PsiModifier.STATIC, member.hasModifierProperty(PsiModifier.STATIC)); list.setModifierProperty(PsiModifier.FINAL, member.hasModifierProperty(PsiModifier.FINAL)); VisibilityUtil.setVisibility(list, VisibilityUtil.getVisibilityModifier(member.getModifierList())); } } else { moved = (PsiMember)targetClass.addAfter(member, anchor); } if (docComment != null) { PsiElement insertedDocComment = targetClass.addBefore(docComment, moved); PsiElement prevSibling = insertedDocComment.getPrevSibling(); addLineFeedIfNeeded(prevSibling); docComment.delete(); } member.delete(); return moved; } | doMove |
30,735 | void (PsiElement prevSibling) { if (prevSibling == null) return; ASTNode node = prevSibling.getNode(); IElementType type = node.getElementType(); if (type == GroovyTokenTypes.mNLS) { String text = prevSibling.getText(); int lfCount = StringUtil.countChars(text, '\n'); if (lfCount < 2) { ASTNode parent = node.getTreeParent(); parent.addLeaf(GroovyTokenTypes.mNLS, text + "\n ", node); parent.removeChild(node); } } else { node.getTreeParent().addLeaf(GroovyTokenTypes.mNLS, "\n\n ", node.getTreeNext()); } } | addLineFeedIfNeeded |
30,736 | void (@NotNull PsiElement scope) { GroovyChangeContextUtil.decodeContextInfo(scope, null, null); } | decodeContextInfo |
30,737 | boolean (GrReferenceExpression refExpr, PsiMember member) { if (!(refExpr.getContainingFile() instanceof GroovyFile)) return false; final GrImportStatement[] imports = ((GroovyFile)refExpr.getContainingFile()).getImportStatements(); for (GrImportStatement stmt : imports) { if (!stmt.isOnDemand() && stmt.resolveTargetClass() == member.getContainingClass() && Comparing.strEqual(stmt.getImportReference().getReferenceName(), member.getName())) { return true; } } return false; } | hasStaticImport |
30,738 | boolean (final PsiElement element, final PsiClass aClass) { if (element.getContainingFile() instanceof GroovyFile) { final GrImportStatement[] importStatements = ((GroovyFile)element.getContainingFile()).getImportStatements(); for (GrImportStatement stmt : importStatements) { final GrCodeReferenceElement ref = stmt.getImportReference(); if (ref != null && stmt.isStatic() && stmt.isOnDemand() && ref.resolve() == aClass) { return true; } } } return false; } | hasOnDemandStaticImport |
30,739 | PsiElement (@NotNull final PsiMember member, @NotNull final PsiClass targetClass, Set<PsiMember> membersToMove) { if (member instanceof GrField && member.hasModifierProperty(PsiModifier.STATIC)) { final List<PsiField> referencedFields = new ArrayList<>(); final GrExpression psiExpression = ((GrField)member).getInitializerGroovy(); if (psiExpression != null) { psiExpression.accept(new GroovyRecursiveElementVisitor() { @Override public void visitReferenceExpression(@NotNull final GrReferenceExpression expression) { super.visitReferenceExpression(expression); final PsiElement psiElement = expression.resolve(); if (psiElement instanceof GrField grField) { if (grField.getContainingClass() == targetClass && !referencedFields.contains(grField)) { referencedFields.add(grField); } } } }); } if (!referencedFields.isEmpty()) { referencedFields.sort((o1, o2) -> -PsiUtilCore.compareElementsByPosition(o1, o2)); return referencedFields.get(0); } } return null; } | getAnchor |
30,740 | void (@NotNull final GrReferenceExpression expression) { super.visitReferenceExpression(expression); final PsiElement psiElement = expression.resolve(); if (psiElement instanceof GrField grField) { if (grField.getContainingClass() == targetClass && !referencedFields.contains(grField)) { referencedFields.add(grField); } } } | visitReferenceExpression |
30,741 | PsiElement (PsiClass targetClass, GrEnumConstant constant, @Nullable PsiElement anchor) { if (targetClass instanceof GrEnumTypeDefinition enumeration) { final GrEnumConstantList constantList = enumeration.getEnumConstantList(); if (constantList != null) { ASTNode node = constantList.getNode(); node.addLeaf(GroovyTokenTypes.mCOMMA, ",", node.getFirstChildNode()); return constantList.addBefore(constant, constantList.getFirstChild()); } else { final PsiElement parent = constant.getParent(); assert parent instanceof GrEnumConstantList; final GrEnumConstantList constListCopy = ((GrEnumConstantList)targetClass.add(parent)); return constListCopy.getEnumConstants()[0]; } } return (anchor != null ? targetClass.addAfter(constant, anchor) : targetClass.add(constant)); } | addEnumConstant |
30,742 | void (@NotNull MoveMembersProcessor.MoveMembersUsageInfo usageInfo, @Nullable String newVisibility, @Nullable PsiModifierList modifierListCopy, @NotNull PsiClass targetClass, @NotNull Set<PsiMember> membersToMove, @NotNull MultiMap<PsiElement, String> conflicts) { final PsiElement element = usageInfo.getElement(); if (element == null) return; final PsiMember member = usageInfo.member; if (element instanceof GrReferenceExpression) { GrExpression qualifier = ((GrReferenceExpression)element).getQualifier(); PsiClass accessObjectClass = null; if (qualifier != null) { accessObjectClass = (PsiClass)PsiUtil.getAccessObjectClass(qualifier).getElement(); } if (!JavaResolveUtil.isAccessible(member, targetClass, modifierListCopy, element, accessObjectClass, null)) { String visibility = newVisibility != null ? newVisibility : VisibilityUtil.getVisibilityStringToDisplay(member); String message = RefactoringBundle.message("0.with.1.visibility.is.not.accessible.from.2", RefactoringUIUtil.getDescription(member, false), visibility, RefactoringUIUtil.getDescription(ConflictsUtil.getContainer(element), true)); conflicts.putValue(member, StringUtil.capitalize(message)); } } } | checkConflictsOnUsage |
30,743 | void (@NotNull PsiMember member, @Nullable String newVisibility, @Nullable PsiModifierList modifierListCopy, @NotNull PsiClass targetClass, @NotNull Set<PsiMember> membersToMove, @NotNull MultiMap<PsiElement, String> conflicts) { } | checkConflictsOnMember |
30,744 | PsiClass (@NotNull PsiClass aClass, @NotNull PsiClass targetClass) { if (!(aClass instanceof GrTypeDefinition)) return null; GroovyChangeContextUtil.encodeContextInfo(aClass); PsiDocComment doc = aClass.getDocComment(); PsiElement brace = targetClass.getRBrace(); PsiClass newClass = (PsiClass)targetClass.addBefore(aClass, brace); PsiElement sibling = newClass.getPrevSibling(); GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(targetClass.getProject()); if (!org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.isNewLine(sibling)) { targetClass.addBefore(factory.createLineTerminator("\n "), newClass); } else if (doc != null) { LOG.assertTrue(sibling != null); sibling.replace(factory.createLineTerminator(sibling.getText() + " ")); } if (doc != null) { targetClass.addBefore(doc, newClass); targetClass.addBefore(factory.createLineTerminator("\n"), newClass); } if (targetClass.isInterface()) { PsiUtil.setModifierProperty(newClass, PsiModifier.PUBLIC, true); } else { PsiUtil.setModifierProperty(newClass, PsiModifier.STATIC, true); } GroovyChangeContextUtil.decodeContextInfo(newClass, null, null); return newClass; } | moveClass |
30,745 | List<PsiElement> (@NotNull List<UsageInfo> usageInfos, @NotNull Project project) { final List<PsiElement> importStatements = new ArrayList<>(); if (!CodeStyleSettingsManager.getSettings(project).getCustomSettings(GroovyCodeStyleSettings.class).INSERT_INNER_CLASS_IMPORTS) { filterUsagesInImportStatements(usageInfos, importStatements); } else { //rebind imports first usageInfos.sort((o1, o2) -> PsiUtil.BY_POSITION.compare(o1.getElement(), o2.getElement())); } return importStatements; } | filterImports |
30,746 | void (final List<UsageInfo> usages, final List<PsiElement> importStatements) { for (Iterator<UsageInfo> iterator = usages.iterator(); iterator.hasNext(); ) { UsageInfo usage = iterator.next(); PsiElement element = usage.getElement(); if (element == null) continue; GrImportStatement stmt = PsiTreeUtil.getParentOfType(element, GrImportStatement.class); if (stmt != null) { importStatements.add(stmt); iterator.remove(); } } } | filterUsagesInImportStatements |
30,747 | void (@NotNull final Map<PsiElement, PsiElement> oldToNewElementsMapping) { for (final PsiElement newClass : oldToNewElementsMapping.values()) { if (!(newClass instanceof GrTypeDefinition)) continue; ((GrTypeDefinition)newClass).accept(new GroovyRecursiveElementVisitor() { @Override public void visitReferenceExpression(@NotNull GrReferenceExpression reference) { if (visitRef(reference)) return; super.visitReferenceExpression(reference); } @Override public void visitCodeReferenceElement(@NotNull GrCodeReferenceElement refElement) { visitRef(refElement); super.visitCodeReferenceElement(refElement); } private boolean visitRef(GrReferenceElement reference) { PsiElement element = reference.resolve(); if (element instanceof PsiClass) { for (PsiElement oldClass : oldToNewElementsMapping.keySet()) { if (PsiTreeUtil.isAncestor(oldClass, element, false)) { PsiClass newInnerClass = findMatchingClass((PsiClass)oldClass, (PsiClass)oldToNewElementsMapping.get(oldClass), (PsiClass)element); try { reference.bindToElement(newInnerClass); return true; } catch (IncorrectOperationException ex) { LOG.error(ex); } } } } return false; } }); } } | retargetClassRefsInMoved |
30,748 | void (@NotNull GrReferenceExpression reference) { if (visitRef(reference)) return; super.visitReferenceExpression(reference); } | visitReferenceExpression |
30,749 | void (@NotNull GrCodeReferenceElement refElement) { visitRef(refElement); super.visitCodeReferenceElement(refElement); } | visitCodeReferenceElement |
30,750 | boolean (GrReferenceElement reference) { PsiElement element = reference.resolve(); if (element instanceof PsiClass) { for (PsiElement oldClass : oldToNewElementsMapping.keySet()) { if (PsiTreeUtil.isAncestor(oldClass, element, false)) { PsiClass newInnerClass = findMatchingClass((PsiClass)oldClass, (PsiClass)oldToNewElementsMapping.get(oldClass), (PsiClass)element); try { reference.bindToElement(newInnerClass); return true; } catch (IncorrectOperationException ex) { LOG.error(ex); } } } } return false; } | visitRef |
30,751 | PsiClass (final PsiClass classToMove, final PsiClass newClass, final PsiClass innerClass) { if (classToMove == innerClass) { return newClass; } PsiClass parentClass = findMatchingClass(classToMove, newClass, innerClass.getContainingClass()); PsiClass newInnerClass = parentClass.findInnerClassByName(innerClass.getName(), false); assert newInnerClass != null; return newInnerClass; } | findMatchingClass |
30,752 | void (@NotNull final Map<PsiElement, PsiElement> oldToNewElementMap, final NonCodeUsageInfo @NotNull [] nonCodeUsages) { for (PsiElement newClass : oldToNewElementMap.values()) { if (!(newClass instanceof GrTypeDefinition)) continue; newClass.accept(new PsiRecursiveElementVisitor() { @Override public void visitElement(@NotNull final PsiElement element) { super.visitElement(element); List<NonCodeUsageInfo> list = element.getCopyableUserData(MoveClassToInnerProcessor.ourNonCodeUsageKey); if (list != null) { for (NonCodeUsageInfo info : list) { for (int i = 0; i < nonCodeUsages.length; i++) { if (nonCodeUsages[i] == info) { nonCodeUsages[i] = info.replaceElement(element); break; } } } element.putCopyableUserData(MoveClassToInnerProcessor.ourNonCodeUsageKey, null); } } }); } } | retargetNonCodeUsages |
30,753 | void (@NotNull final PsiElement element) { super.visitElement(element); List<NonCodeUsageInfo> list = element.getCopyableUserData(MoveClassToInnerProcessor.ourNonCodeUsageKey); if (list != null) { for (NonCodeUsageInfo info : list) { for (int i = 0; i < nonCodeUsages.length; i++) { if (nonCodeUsages[i] == info) { nonCodeUsages[i] = info.replaceElement(element); break; } } } element.putCopyableUserData(MoveClassToInnerProcessor.ourNonCodeUsageKey, null); } } | visitElement |
30,754 | void (PsiFile targetClassFile) { if (!(targetClassFile instanceof GroovyFile file)) return; for (GrImportStatement unusedImport : unusedImports(file)) { file.removeImport(unusedImport); } } | removeRedundantImports |
30,755 | boolean (PsiFile element) { return element instanceof GroovyFile; } | canProcessElement |
30,756 | void (PsiFile file, PsiDirectory moveDestination, Map<PsiElement, PsiElement> oldToNewMap) { final GroovyFile groovyFile = (GroovyFile)file; GroovyChangeContextUtil.encodeContextInfo(groovyFile); for (PsiClass psiClass : groovyFile.getClasses()) { oldToNewMap.put(psiClass, MoveClassesOrPackagesUtil.doMoveClass(psiClass, moveDestination)); } } | prepareMovedFile |
30,757 | List<UsageInfo> (PsiFile psiFile, PsiDirectory newParent, boolean searchInComments, boolean searchInNonJavaFiles) { final List<UsageInfo> result = new ArrayList<>(); final PsiPackage newParentPackage = JavaDirectoryService.getInstance().getPackage(newParent); final String qualifiedName = newParentPackage == null ? "" : newParentPackage.getQualifiedName(); for (PsiClass aClass : ((GroovyFile)psiFile).getClasses()) { Collections.addAll(result, MoveClassesOrPackagesUtil .findUsages(aClass, searchInComments, searchInNonJavaFiles, StringUtil.getQualifiedName(qualifiedName, StringUtil.notNullize(aClass.getName())))); } return result.isEmpty() ? null : result; } | findUsages |
30,758 | void (List<UsageInfo> usageInfos, Map<PsiElement, PsiElement> oldToNewMap) { for (UsageInfo usage : usageInfos) { if (usage instanceof MoveRenameUsageInfo moveRenameUsage) { final PsiElement oldElement = moveRenameUsage.getReferencedElement(); final PsiElement newElement = oldToNewMap.get(oldElement); final PsiReference reference = moveRenameUsage.getReference(); if (reference != null) { try { LOG.assertTrue(newElement != null, oldElement != null ? oldElement : reference); reference.bindToElement(newElement); } catch (IncorrectOperationException ex) { LOG.error(ex); } } } } } | retargetUsages |
30,759 | void (Collection<UsageInfo> results) { removeAllAliasImportedUsages(results); } | preprocessUsages |
30,760 | PsiClass (MoveInnerOptions options) { PsiClass innerClass = options.getInnerClass(); if (!(innerClass instanceof GrTypeDefinition)) { return super.createNewClass(options); } PsiDirectory dir = (PsiDirectory)options.getTargetContainer(); return CreateClassActionBase.createClassByType(dir, options.getNewClassName(), options.getInnerClass().getManager(), options.getInnerClass(), GroovyTemplates.GROOVY_CLASS, false); } | createNewClass |
30,761 | void (GroovyFile file, GroovyFile newFile, String newPackageName) { String modifiersText = null; final GrPackageDefinition packageDefinition = file.getPackageDefinition(); if (packageDefinition != null) { final PsiModifierList modifierList = packageDefinition.getModifierList(); if (modifierList != null) { modifiersText = modifierList.getText().trim(); } } if (modifiersText != null && !modifiersText.isEmpty()) { final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(file.getProject()); final GrPackageDefinition newPackageDefinition = (GrPackageDefinition)factory.createTopElementFromText(modifiersText + " package " + newPackageName); newFile.setPackage(newPackageDefinition); } else { newFile.setPackageName(newPackageName); } } | setPackageDefinition |
30,762 | GroovyFile (GroovyFile file, PsiPackage newPackage) { for (GrImportStatement importStatement : file.getImportStatements()) { importStatement.delete(); } final GroovyFile newFile = GroovyPsiElementFactory.getInstance(file.getProject()).createGroovyFile("", true, null); newFile.addRange(file.getFirstChild(), file.getLastChild()); final PsiClass[] newFileClasses = newFile.getClasses(); for (PsiClass psiClass : newFileClasses) { if (psiClass instanceof GroovyScriptClass) continue; final GrDocComment docComment = GrDocCommentUtil.findDocComment((GrDocCommentOwner)psiClass); if (docComment != null) docComment.delete(); psiClass.delete(); } final GrPackageDefinition packageDefinition = newFile.getPackageDefinition(); if (packageDefinition != null) packageDefinition.delete(); PsiElement cur = newFile.getFirstChild(); while (cur != null && PsiImplUtil.isWhiteSpaceOrNls(cur)) { cur = cur.getNextSibling(); } if (cur != null && cur != newFile.getFirstChild()) { cur = cur.getPrevSibling(); newFile.deleteChildRange(newFile.getFirstChild(), cur); } cur = newFile.getLastChild(); while (cur != null && PsiImplUtil.isWhiteSpaceOrNls(cur)) { cur = cur.getPrevSibling(); } if (cur != null && cur != newFile.getLastChild()) { cur = cur.getNextSibling(); newFile.deleteChildRange(cur, newFile.getLastChild()); } newFile.setName(file.getName()); setPackageDefinition(file, newFile, newPackage.getQualifiedName()); GroovyChangeContextUtil.decodeContextInfo(newFile, null, null); return newFile; } | generateNewScript |
30,763 | String (PsiClass clazz) { final PsiFile file = clazz.getContainingFile(); if (!(file instanceof GroovyFile)) return null; return ((GroovyFile)file).getClasses().length > 1 ? clazz.getName() + "." + GroovyFileType.DEFAULT_EXTENSION : file.getName(); } | getName |
30,764 | void (Collection<UsageInfo> results) { removeAllAliasImportedUsages(results); } | preprocessUsages |
30,765 | void (Collection<UsageInfo> results) { for (Iterator<UsageInfo> iterator = results.iterator(); iterator.hasNext(); ) { UsageInfo info = iterator.next(); if (info == null) continue; final PsiReference ref = info.getReference(); if (ref == null) continue; final PsiElement element = ref.getElement(); if (!(element instanceof GrReferenceElement)) continue; final GroovyResolveResult resolveResult = ((GrReferenceElement<?>)element).advancedResolve(); final PsiElement context = resolveResult.getCurrentFileResolveContext(); if ((context instanceof GrImportStatement) && ((GrImportStatement)context).isAliasedImport()) { iterator.remove(); } } } | removeAllAliasImportedUsages |
30,766 | void (@NotNull PsiClass aClass) { if (aClass.getContainingFile() instanceof GroovyFileBase) { GroovyChangeContextUtil.encodeContextInfo(getRealElement(aClass)); } } | prepareMove |
30,767 | void (@NotNull PsiClass aClass) { if (aClass.getContainingFile() instanceof GroovyFileBase) { GroovyChangeContextUtil.decodeContextInfo(getRealElement(aClass), null, null); } } | finishMoveClass |
30,768 | PsiElement (PsiClass aClass) { return aClass instanceof GroovyScriptClass ? aClass.getContainingFile() : aClass; } | getRealElement |
30,769 | void (final PsiClass newClass, final PsiClass oldClass) { final Collection<PsiReference> all = ReferencesSearch.search(oldClass, new LocalSearchScope(newClass.getContainingFile())).findAll(); for (PsiReference reference : all) { final PsiElement element = reference.getElement(); final PsiElement parent = element.getParent(); if (parent instanceof GrImportStatement && !((GrImportStatement)parent).isStatic()) { parent.delete(); } reference.bindToElement(newClass); } } | correctOldClassReferences |
30,770 | void (final PsiClass aClass, final PsiPackage newContainingPackage) { final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(aClass.getContainingFile().getContainingDirectory()); if (aPackage == null) { return; } for (PsiReference reference : ReferencesSearch.search(aClass, new LocalSearchScope(aClass)).findAll()) { if (reference instanceof GrCodeReferenceElement) { final GrCodeReferenceElement qualifier = ((GrCodeReferenceElement)reference).getQualifier(); if (qualifier != null) { qualifier.bindToElement(newContainingPackage); } } } } | correctSelfReferences |
30,771 | TextRange (Object occurrence) { if (occurrence instanceof PsiElement) { return ((PsiElement)occurrence).getTextRange(); } else if (occurrence instanceof StringPartInfo) { return ((StringPartInfo)occurrence).getRange(); } else { return null; } } | getOccurrenceRange |
30,772 | Project () { return myProject; } | getProject |
30,773 | Editor () { return myEditor; } | getEditor |
30,774 | GrExpression () { return myExpression; } | getExpression |
30,775 | PsiElement () { return myScope; } | getScope |
30,776 | GrVariable () { return myVar; } | getVar |
30,777 | StringPartInfo () { return myStringPart; } | getStringPart |
30,778 | PsiElement () { return myPlace; } | getPlace |
30,779 | GrIntroduceContext () { return myContext; } | getContext |
30,780 | void (boolean allOccurrences) { throw new IncorrectOperationException("don't invoke this method"); } | setReplaceAllOccurrences |
30,781 | GrExpression (@NotNull PsiFile containingFile, @NotNull GrVariable variable, @NotNull RangeMarker marker, String exprText) { if (exprText == null) return null; if (!variable.isValid()) return null; final PsiElement refVariableElement = containingFile.findElementAt(marker.getStartOffset()); final PsiElement refVariableElementParent = refVariableElement != null ? refVariableElement.getParent() : null; GrExpression expression = refVariableElementParent instanceof GrNewExpression && refVariableElement.getNode().getElementType() == GroovyTokenTypes.kNEW ? (GrNewExpression)refVariableElementParent : refVariableElementParent instanceof GrParenthesizedExpression ? ((GrParenthesizedExpression)refVariableElementParent).getOperand() : PsiTreeUtil.getParentOfType(refVariableElement, GrReferenceExpression.class); if (expression instanceof GrReferenceExpression) { final String referenceName = ((GrReferenceExpression)expression).getReferenceName(); if (((GrReferenceExpression)expression).resolve() == variable || Comparing.strEqual(variable.getName(), referenceName) || Comparing.strEqual(exprText, referenceName)) { return (GrExpression)expression .replace(GroovyPsiElementFactory.getInstance(myProject).createExpressionFromText(exprText, variable)); } } if (expression == null) { expression = PsiTreeUtil.getParentOfType(refVariableElement, GrExpression.class); } while (expression instanceof GrReferenceExpression || expression instanceof GrCall) { final PsiElement parent = expression.getParent(); if (parent instanceof GrMethodCallExpression) { if (parent.getText().equals(exprText)) return (GrExpression)parent; } if (parent instanceof GrExpression) { expression = (GrExpression)parent; if (expression.getText().equals(exprText)) { return expression; } } else if (expression instanceof GrReferenceExpression){ return null; } else { break; } } if (expression != null && expression.isValid() && expression.getText().equals(exprText)) { return expression; } if (refVariableElementParent instanceof GrExpression && refVariableElementParent.getText().equals(exprText)) { return (GrExpression)refVariableElementParent; } return null; } | restoreExpression |
30,782 | void (@Nullable GrVariable variable, String value) { if (variable == null) { super.updateTitle(variable, value); } else { final String variableText = variable.getParent().getText(); final PsiElement identifier = variable.getNameIdentifierGroovy(); final int startOffsetInParent = identifier.getStartOffsetInParent() + variable.getStartOffsetInParent(); setPreviewText( variableText.substring(0, startOffsetInParent) + value + variableText.substring(startOffsetInParent + identifier.getTextLength())); revalidate(); } } | updateTitle |
30,783 | void (@Nullable GrVariable variable) { if (variable == null) return; setPreviewText(variable.getParent().getText()); revalidate(); } | updateTitle |
30,784 | PsiElement () { return ((GrVariable)myElementToRename).getNameIdentifierGroovy(); } | getNameIdentifier |
30,785 | GrVariable () { if (myVarMarker == null) return null; int offset = myVarMarker.getStartOffset(); PsiElement at = myFile.findElementAt(offset); GrVariable var = PsiTreeUtil.getParentOfType(at, GrVariable.class); return var; } | getVariable |
30,786 | void () { runRefactoring(new IntroduceContextAdapter(), getSettings(), true); } | performIntroduce |
30,787 | GrVariable (boolean replaceAll, String @NotNull [] names) { final Settings settings = getInitialSettingsForInplace(myContext, myReplaceChoice, names); if (settings == null) return null; GrVariable var = runRefactoring(myContext, settings, false); if (var != null) { myVarMarker = myContext.getEditor().getDocument().createRangeMarker(var.getTextRange()); } return var; } | createFieldToStartTemplateOn |
30,788 | GrVariable (Computable<? extends GrVariable> computable) { SmartPsiElementPointer<GrVariable> pointer = WriteAction.compute(() -> { GrVariable var = computable.compute(); return var != null ? SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(var) : null; }); return pointer != null ? pointer.getElement() : null; } | refactorInWriteAction |
30,789 | boolean () { return myReplaceChoice != OccurrencesChooser.ReplaceChoice.NO; } | isReplaceAllOccurrences |
30,790 | void (@NotNull GrVariable psiField) { PsiType declaredType = psiField.getDeclaredType(); myTypePointer = declaredType != null ? SmartTypePointerManager.getInstance(myProject).createSmartTypePointer(declaredType) : null; super.restoreState(psiField); } | restoreState |
30,791 | PsiType () { return myTypePointer != null ? myTypePointer.getType() : null; } | getSelectedType |
30,792 | Project () { return myProject; } | getProject |
30,793 | Editor () { return myEditor; } | getEditor |
30,794 | GrExpression () { return (GrExpression)getExpr(); } | getExpression |
30,795 | GrVariable () { return getLocalVariable(); } | getVar |
30,796 | StringPartInfo () { return null; } | getStringPart |
30,797 | PsiElement () { return myScope; } | getScope |
30,798 | PsiElement () { GrExpression expression = getExpression(); return expression != null ? expression : getLocalVariable(); } | getPlace |
30,799 | void (PsiClass[] scopes, final Consumer<? super PsiClass> callback, Editor editor) { PsiElementProcessor<PsiClass> processor = new PsiElementProcessor<>() { @Override public boolean execute(@NotNull PsiClass element) { callback.accept(element); return false; } }; NavigationUtil.getPsiElementPopup(scopes, new PsiClassListCellRenderer(), JavaRefactoringBundle.message("popup.title.choose.class.to.introduce.field"), processor).showInBestPositionFor(editor); } | showScopeChooser |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.