Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
16,500 | void (final ActionEvent e) { validateButtons(); } | actionPerformed |
16,501 | void (ActionEvent actionEvent) { toggleRadioEnablement(); } | actionPerformed |
16,502 | void (@NotNull com.intellij.openapi.editor.event.DocumentEvent e) { final JavaPsiFacade facade = JavaPsiFacade.getInstance(myProject); final PsiClass currentClass = facade.findClass(existingClassField.getText(), GlobalSearchScope.allScope(myProject)); if (currentClass != null) { model.removeAllElements(); final PsiType returnType = sourceMethod.getReturnType(); assert returnType != null; for (PsiField field : currentClass.getFields()) { final PsiType fieldType = field.getType(); if (TypeConversionUtil.isAssignable(fieldType, returnType)) { model.addElement(field); } else { if (WrapReturnValueProcessor.getInferredType(fieldType, returnType, currentClass, sourceMethod) != null) { model.addElement(field); } } } } } | documentChanged |
16,503 | void () { UIUtil.setEnabled(myExistingClassPanel, useExistingClassButton.isSelected(), true); UIUtil.setEnabled(myNewClassPanel, createNewClassButton.isSelected(), true); UIUtil.setEnabled(myCreateInnerPanel, myCreateInnerClassButton.isSelected(), true); final IdeFocusManager focusManager = IdeFocusManager.getInstance(myProject); if (useExistingClassButton.isSelected()) { focusManager.requestFocus(existingClassField, true); } else if (myCreateInnerClassButton.isSelected()) { focusManager.requestFocus(myInnerClassNameTextField, true); } else { focusManager.requestFocus(classNameField, true); } validateButtons(); } | toggleRadioEnablement |
16,504 | JComponent () { return classNameField; } | getPreferredFocusedComponent |
16,505 | String () { return HelpID.WrapReturnValue; } | getHelpId |
16,506 | void () { final com.intellij.openapi.editor.event.DocumentListener adapter = new com.intellij.openapi.editor.event.DocumentListener() { @Override public void documentChanged(@NotNull com.intellij.openapi.editor.event.DocumentEvent e) { validateButtons(); } }; packageTextField = new PackageNameReferenceEditorCombo("", myProject, RECENT_KEYS, RefactoringBundle.message("choose.destination.package")); packageTextField.getChildComponent().getDocument().addDocumentListener(adapter); existingClassField = new ReferenceEditorComboWithBrowseButton(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final TreeClassChooser chooser = TreeClassChooserFactory.getInstance(getProject()) .createWithInnerClassesScopeChooser(RefactorJBundle.message("select.wrapper.class"), GlobalSearchScope.allScope(myProject), null, null); final String classText = existingClassField.getText(); final PsiClass currentClass = JavaPsiFacade.getInstance(myProject).findClass(classText, GlobalSearchScope.allScope(myProject)); if (currentClass != null) { chooser.select(currentClass); } chooser.showDialog(); final PsiClass selectedClass = chooser.getSelected(); if (selectedClass != null) { existingClassField.setText(selectedClass.getQualifiedName()); } } }, "", myProject, true, RECENT_KEYS); existingClassField.getChildComponent().getDocument().addDocumentListener(adapter); myDestinationCb = new DestinationFolderComboBox() { @Override public String getTargetPackage() { return getPackageName(); } }; ((DestinationFolderComboBox)myDestinationCb).setData(myProject, sourceMethod.getContainingFile().getContainingDirectory(), packageTextField.getChildComponent()); } | createUIComponents |
16,507 | void (@NotNull com.intellij.openapi.editor.event.DocumentEvent e) { validateButtons(); } | documentChanged |
16,508 | void (ActionEvent e) { final TreeClassChooser chooser = TreeClassChooserFactory.getInstance(getProject()) .createWithInnerClassesScopeChooser(RefactorJBundle.message("select.wrapper.class"), GlobalSearchScope.allScope(myProject), null, null); final String classText = existingClassField.getText(); final PsiClass currentClass = JavaPsiFacade.getInstance(myProject).findClass(classText, GlobalSearchScope.allScope(myProject)); if (currentClass != null) { chooser.select(currentClass); } chooser.showDialog(); final PsiClass selectedClass = chooser.getSelected(); if (selectedClass != null) { existingClassField.setText(selectedClass.getQualifiedName()); } } | actionPerformed |
16,509 | String () { return getPackageName(); } | getTargetPackage |
16,510 | RefactoringActionHandler (@NotNull DataContext context) { return new RemoveMiddlemanHandler(); } | getHandler |
16,511 | boolean (@NotNull PsiElement element, @NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext context) { return element instanceof PsiField; } | isAvailableOnElementInEditorAndFile |
16,512 | boolean () { return false; } | isAvailableInEditorOnly |
16,513 | boolean (PsiElement @NotNull [] elements) { return elements.length == 1 && PsiTreeUtil.getParentOfType(elements[0], PsiField.class, false) != null; } | isEnabledOnElements |
16,514 | boolean () { return false; } | isAvailableInEditorOnly |
16,515 | boolean (@NotNull PsiElement element, @NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext context, @NotNull String place) { if (ActionPlaces.isPopupPlace(place) && !place.equals(ActionPlaces.REFACTORING_QUICKLIST)) { return element instanceof PsiClass || element instanceof PsiJavaFile; } return super.isAvailableOnElementInEditorAndFile(element, editor, file, context, place); } | isAvailableOnElementInEditorAndFile |
16,516 | boolean (PsiElement @NotNull [] elements) { return elements.length > 0 && Arrays.stream(elements).allMatch( e -> e instanceof PsiClass || e instanceof PsiJavaFile || e instanceof PsiDirectory || e instanceof PsiPackage); } | isEnabledOnElements |
16,517 | RefactoringActionHandler (@NotNull DataContext dataContext) { return getHandler(); } | getHandler |
16,518 | RefactoringActionHandler () { return new TypeCookHandler(); } | getHandler |
16,519 | boolean () { return true; } | isAvailableInEditorOnly |
16,520 | boolean (PsiElement @NotNull [] elements) { return false; } | isEnabledOnElements |
16,521 | RefactoringActionHandler (@NotNull DataContext dataContext) { return new TempWithQueryHandler(); } | getHandler |
16,522 | boolean (@NotNull final PsiElement element, @NotNull final Editor editor, @NotNull PsiFile file, @NotNull DataContext context) { return element instanceof PsiLocalVariable && ((PsiLocalVariable) element).getInitializer() != null; } | isAvailableOnElementInEditorAndFile |
16,523 | void (@NotNull final Project project, final Editor editor, PsiFile file, DataContext dataContext) { PsiElement element = TargetElementUtil.findTargetElement(editor, TargetElementUtil .ELEMENT_NAME_ACCEPTED | TargetElementUtil .LOOKUP_ITEM_ACCEPTED | TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED); editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); if (!(element instanceof PsiLocalVariable)) { String message = RefactoringBundle.getCannotRefactorMessage(JavaRareRefactoringsBundle.message("error.wrong.caret.position.local.name")); CommonRefactoringUtil.showErrorHint(project, editor, message, getRefactoringName(), HelpID.REPLACE_TEMP_WITH_QUERY); return; } invokeOnVariable(file, project, (PsiLocalVariable)element, editor); } | invoke |
16,524 | void (final PsiFile file, final Project project, final PsiLocalVariable local, final Editor editor) { if (!CommonRefactoringUtil.checkReadOnlyStatus(project, file)) return; String localName = local.getName(); final PsiExpression initializer = local.getInitializer(); if (initializer == null) { String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("variable.has.no.initializer", localName)); CommonRefactoringUtil.showErrorHint(project, editor, message, getRefactoringName(), HelpID.REPLACE_TEMP_WITH_QUERY); return; } final PsiReference[] refs = ReferencesSearch.search(local, GlobalSearchScope.projectScope(project), false).toArray( PsiReference.EMPTY_ARRAY); if (refs.length == 0) { String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("variable.is.never.used", localName)); CommonRefactoringUtil.showErrorHint(project, editor, message, getRefactoringName(), HelpID.REPLACE_TEMP_WITH_QUERY); return; } final HighlightManager highlightManager = HighlightManager.getInstance(project); ArrayList<PsiReference> array = new ArrayList<>(); for (PsiReference ref : refs) { PsiElement refElement = ref.getElement(); if (PsiUtil.isAccessedForWriting((PsiExpression)refElement)) { array.add(ref); } if (!array.isEmpty()) { PsiReference[] refsForWriting = array.toArray(PsiReference.EMPTY_ARRAY); highlightManager.addOccurrenceHighlights(editor, refsForWriting, EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null); String message = RefactoringBundle.getCannotRefactorMessage(JavaRefactoringBundle.message("variable.is.accessed.for.writing", localName)); CommonRefactoringUtil.showErrorHint(project, editor, message, getRefactoringName(), HelpID.REPLACE_TEMP_WITH_QUERY); WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting")); return; } } final ExtractMethodProcessor processor = new ExtractMethodProcessor( project, editor, new PsiElement[]{initializer}, local.getType(), getRefactoringName(), localName, HelpID.REPLACE_TEMP_WITH_QUERY ); try { if (!processor.prepare()) return; } catch (PrepareFailedException e) { CommonRefactoringUtil.showErrorHint(project, editor, e.getMessage(), getRefactoringName(), HelpID.REPLACE_TEMP_WITH_QUERY); ExtractMethodHandler.highlightPrepareError(e, file, editor, project); return; } final PsiClass targetClass = processor.getTargetClass(); if (targetClass != null && targetClass.isInterface()) { String message = JavaRareRefactoringsBundle.message("cannot.replace.temp.with.query.in.interface"); CommonRefactoringUtil.showErrorHint(project, editor, message, getRefactoringName(), HelpID.REPLACE_TEMP_WITH_QUERY); return; } if (processor.showDialog()) { CommandProcessor.getInstance().executeCommand( project, () -> { final Runnable action = () -> { try { processor.doRefactoring(); local.normalizeDeclaration(); PsiExpression initializer1 = local.getInitializer(); PsiExpression[] exprs = new PsiExpression[refs.length]; for (int idx = 0; idx < refs.length; idx++) { PsiElement ref = refs[idx].getElement(); exprs[idx] = (PsiExpression) ref.replace(initializer1); } PsiDeclarationStatement declaration = (PsiDeclarationStatement) local.getParent(); declaration.delete(); highlightManager.addOccurrenceHighlights(editor, exprs, EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null); } catch (IncorrectOperationException e) { LOG.error(e); } }; PostprocessReformattingAspect.getInstance(project).postponeFormattingInside(() -> { ApplicationManager.getApplication().runWriteAction(action); DuplicatesImpl.processDuplicates(processor, project, editor); }); }, getRefactoringName(), null ); } WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting")); } | invokeOnVariable |
16,525 | void (@NotNull Project project, PsiElement @NotNull [] elements, DataContext dataContext) { if (elements.length == 1 && elements[0] instanceof PsiLocalVariable) { if (dataContext != null) { final PsiFile file = CommonDataKeys.PSI_FILE.getData(dataContext); final Editor editor = CommonDataKeys.EDITOR.getData(dataContext); if (file != null && editor != null) { invokeOnVariable(file, project, (PsiLocalVariable)elements[0], editor); } } } } | invoke |
16,526 | boolean () { return dropObsoleteCasts; } | dropObsoleteCasts |
16,527 | boolean () { return leaveObjectsRaw; } | leaveObjectParameterizedTypesRaw |
16,528 | boolean () { return exhaustiveSearch; } | exhaustive |
16,529 | boolean () { return cookObjects; } | cookObjects |
16,530 | boolean () { return cookToWildcards; } | cookToWildcards |
16,531 | boolean () { return preserveRawArrays; } | preserveRawArrays |
16,532 | List<PsiElement> () { return myProcessor.getElements(); } | getElements |
16,533 | JComponent () { return null; } | createCenterPanel |
16,534 | String () { return "refactoring.generify"; } | getHelpId |
16,535 | JComponent () { JPanel optionsPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbConstraints = new GridBagConstraints(); if (myCbDropCasts.isEnabled()) { myCbDropCasts.setSelected(JavaRefactoringSettings.getInstance().TYPE_COOK_DROP_CASTS); } if (myCbPreserveRawArrays.isEnabled()) { myCbPreserveRawArrays.setSelected(JavaRefactoringSettings.getInstance().TYPE_COOK_PRESERVE_RAW_ARRAYS); } if (myCbLeaveObjectParameterizedTypesRaw.isEnabled()) { myCbLeaveObjectParameterizedTypesRaw.setSelected( JavaRefactoringSettings.getInstance().TYPE_COOK_LEAVE_OBJECT_PARAMETERIZED_TYPES_RAW); } if (myCbExhaustive.isEnabled()) { myCbExhaustive.setSelected( JavaRefactoringSettings.getInstance().TYPE_COOK_EXHAUSTIVE); } if (myCbCookObjects.isEnabled()) { myCbCookObjects.setSelected( JavaRefactoringSettings.getInstance().TYPE_COOK_COOK_OBJECTS); } if (myCbCookToWildcards.isEnabled()) { myCbCookToWildcards.setSelected( JavaRefactoringSettings.getInstance().TYPE_COOK_PRODUCE_WILDCARDS); } myCbDropCasts.setText(JavaRareRefactoringsBundle.message("type.cook.drop.obsolete.casts")); myCbPreserveRawArrays.setText(JavaRareRefactoringsBundle.message("type.cook.preserve.raw.arrays")); myCbLeaveObjectParameterizedTypesRaw.setText(JavaRareRefactoringsBundle.message("type.cook.leave.object.parameterized.types.raw")); myCbExhaustive.setText(JavaRareRefactoringsBundle.message("type.cook.perform.exhaustive.search")); myCbCookObjects.setText(JavaRareRefactoringsBundle.message("type.cook.generify.objects")); myCbCookToWildcards.setText(JavaRareRefactoringsBundle.message("type.cook.produce.wildcard.types")); gbConstraints.insets = JBInsets.create(4, 8); gbConstraints.weighty = 1; gbConstraints.weightx = 1; gbConstraints.gridwidth = GridBagConstraints.REMAINDER; gbConstraints.fill = GridBagConstraints.BOTH; optionsPanel.add(myClassNameLabel, gbConstraints); gbConstraints.gridx = 0; gbConstraints.weightx = 1; gbConstraints.gridwidth = 1; gbConstraints.gridy = 1; gbConstraints.fill = GridBagConstraints.BOTH; optionsPanel.add(myCbDropCasts, gbConstraints); gbConstraints.gridx = 1; gbConstraints.weightx = 1; gbConstraints.gridwidth = GridBagConstraints.REMAINDER; gbConstraints.fill = GridBagConstraints.BOTH; optionsPanel.add(myCbPreserveRawArrays, gbConstraints); gbConstraints.gridx = 0; gbConstraints.gridwidth = 2; gbConstraints.gridy = 2; optionsPanel.add(myCbLeaveObjectParameterizedTypesRaw, gbConstraints); gbConstraints.gridy++; optionsPanel.add(myCbExhaustive, gbConstraints); gbConstraints.gridy++; optionsPanel.add(myCbCookObjects, gbConstraints); gbConstraints.gridy++; optionsPanel.add(myCbCookToWildcards, gbConstraints); return optionsPanel; } | createNorthPanel |
16,536 | void () { JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance(); settings.TYPE_COOK_DROP_CASTS = myCbDropCasts.isSelected(); settings.TYPE_COOK_PRESERVE_RAW_ARRAYS = myCbPreserveRawArrays.isSelected(); settings.TYPE_COOK_LEAVE_OBJECT_PARAMETERIZED_TYPES_RAW = myCbLeaveObjectParameterizedTypesRaw.isSelected(); settings.TYPE_COOK_EXHAUSTIVE = myCbExhaustive.isSelected(); settings.TYPE_COOK_COOK_OBJECTS = myCbCookObjects.isSelected(); settings.TYPE_COOK_PRODUCE_WILDCARDS = myCbCookToWildcards.isSelected(); invokeRefactoring(new TypeCookProcessor(getProject(), myElements, getSettings())); } | doAction |
16,537 | Settings () { final boolean dropCasts = myCbDropCasts.isSelected(); final boolean preserveRawArrays = true; //myCbPreserveRawArrays.isSelected(); final boolean leaveObjectParameterizedTypesRaw = myCbLeaveObjectParameterizedTypesRaw.isSelected(); final boolean exhaustive = myCbExhaustive.isSelected(); final boolean cookObjects = myCbCookObjects.isSelected(); final boolean cookToWildcards = myCbCookToWildcards.isSelected(); return new Settings() { @Override public boolean dropObsoleteCasts() { return dropCasts; } @Override public boolean preserveRawArrays() { return preserveRawArrays; } @Override public boolean leaveObjectParameterizedTypesRaw() { return leaveObjectParameterizedTypesRaw; } @Override public boolean exhaustive() { return exhaustive; } @Override public boolean cookObjects() { return cookObjects; } @Override public boolean cookToWildcards() { return cookToWildcards; } }; } | getSettings |
16,538 | boolean () { return dropCasts; } | dropObsoleteCasts |
16,539 | boolean () { return preserveRawArrays; } | preserveRawArrays |
16,540 | boolean () { return leaveObjectParameterizedTypesRaw; } | leaveObjectParameterizedTypesRaw |
16,541 | boolean () { return exhaustive; } | exhaustive |
16,542 | boolean () { return cookObjects; } | cookObjects |
16,543 | boolean () { return cookToWildcards; } | cookToWildcards |
16,544 | String () { return JavaRareRefactoringsBundle.message("generify.title"); } | getRefactoringName |
16,545 | PsiType (PsiType t, boolean objectBottom) { if (t instanceof PsiArrayType) { PsiType normType = normalize(((PsiArrayType)t).getComponentType(), objectBottom); return normType == null ? null : normType.createArrayType(); } else if (t instanceof PsiClassType) { PsiClassType.ClassResolveResult result = resolveType(t); PsiClass aclass = result.getElement(); PsiSubstitutor subst = result.getSubstitutor(); PsiManager manager = aclass.getManager(); PsiSubstitutor newbst = PsiSubstitutor.EMPTY; boolean anyBottom = false; for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable(aclass)) { PsiType p = subst.substitute(typeParameter); if (p != null) { PsiType pp = normalize(p, objectBottom); if (pp == null) { return null; } if (pp == Bottom.BOTTOM || (objectBottom && pp.getCanonicalText().equals(CommonClassNames.JAVA_LANG_OBJECT))) { anyBottom = true; } newbst = newbst.put(typeParameter, pp); } else { anyBottom = true; } } if (anyBottom || newbst == PsiSubstitutor.EMPTY) { newbst = JavaPsiFacade.getElementFactory(manager.getProject()).createRawSubstitutor(aclass); } return JavaPsiFacade.getElementFactory(manager.getProject()).createType(aclass, newbst); } else { return t; } } | normalize |
16,546 | boolean (PsiType t, final Settings settings) { return isRaw(t, settings, true); } | isRaw |
16,547 | boolean (PsiType t, final Settings settings, final boolean upper) { if (t instanceof PsiClassType) { final PsiClassType.ClassResolveResult resolveResult = resolveType(t); if (resolveResult.getElement() == null) { return false; } if (PsiClassType.isRaw(resolveResult)) { return true; } final PsiSubstitutor subst = resolveResult.getSubstitutor(); final PsiClass element = resolveResult.getElement(); final PsiManager manager = element.getManager(); if (settings.cookObjects() && upper && t.equals(PsiType.getJavaLangObject(manager, GlobalSearchScope.allScope(manager.getProject())))) { return true; } for (PsiTypeParameter parameter : PsiUtil.typeParametersIterable(element)) { final PsiType actual = subst.substitute(parameter); if (isRaw(actual, settings, false)) return true; } return false; } else if (t instanceof PsiArrayType) { return !settings.preserveRawArrays() && isRaw(((PsiArrayType)t).getComponentType(), settings, upper); } return false; } | isRaw |
16,548 | PsiType (final PsiType t) { if (t instanceof PsiClassType) { final PsiClassType.ClassResolveResult result = resolveType(t); final PsiClass theClass = result.getElement(); if (theClass == null) { return t; } final PsiSubstitutor theSubst = result.getSubstitutor(); final PsiManager theManager = theClass.getManager(); PsiSubstitutor subst = PsiSubstitutor.EMPTY; for (final PsiTypeParameter theParm : theSubst.getSubstitutionMap().keySet()) { final PsiType actualType = theSubst.substitute(theParm); if (actualType == null /*|| actualType instanceof PsiWildcardType*/) { subst = subst.put(theParm, Bottom.BOTTOM); } else if (actualType instanceof PsiWildcardType wctype) { final PsiType bound = wctype.getBound(); if (bound == null) { subst = subst.put(theParm, actualType); } else { final PsiType banabound = banalize(bound); subst = subst.put(theParm, wctype.isExtends() ? PsiWildcardType.createExtends(theManager, banabound) : PsiWildcardType.createSuper(theManager, banabound)); } } else { final PsiType banType = banalize(actualType); if (banType == null) { return t; } subst = subst.put(theParm, banType); } } return JavaPsiFacade.getElementFactory(theManager.getProject()).createType(theClass, subst); } else if (t instanceof PsiArrayType) { return banalize(((PsiArrayType)t).getComponentType()).createArrayType(); } return t; } | banalize |
16,549 | PsiSubstitutor (PsiSubstitutor f, PsiSubstitutor g) { if (f == PsiSubstitutor.EMPTY) { return g; } PsiSubstitutor subst = PsiSubstitutor.EMPTY; Set<PsiTypeParameter> base = g.getSubstitutionMap().keySet(); for (PsiTypeParameter p : base) { PsiType type = g.substitute(p); subst = subst.put(p, type == null ? null : f.substitute(type)); } return subst; } | composeSubstitutors |
16,550 | boolean (PsiType t, Set<? extends PsiTypeParameter> params) { if (t instanceof PsiWildcardType wct) { final PsiType bound = wct.getBound(); return bound != null && wct.isExtends() && bindsTypeParameters(bound, params); } final PsiClassType.ClassResolveResult result = resolveType(t); final PsiClass theClass = result.getElement(); final PsiSubstitutor theSubst = result.getSubstitutor(); if (theClass == null) { return false; } if (theClass instanceof PsiTypeParameter) { return params == null || params.contains(theClass); } else if (theClass.hasTypeParameters()) { for (PsiTypeParameter parameter : PsiUtil.typeParametersIterable(theClass)) { PsiType bound = theSubst.substitute(parameter); if (bound != null && bindsTypeParameters(bound, params)) { return true; } } } return false; } | bindsTypeParameters |
16,551 | PsiType (PsiElement element) { if (element instanceof PsiVariable) { return ((PsiVariable)element).getType(); } else if (element instanceof PsiExpression) { return ((PsiExpression)element).getType(); } else if (element instanceof PsiMethod) { return ((PsiMethod)element).getReturnType(); } return null; } | getType |
16,552 | PsiType (final PsiType t, final PsiTypeVariableFactory factory, final PsiElement context) { return createParameterizedType(t, factory, true, context); } | createParameterizedType |
16,553 | PsiType (final PsiType t, final PsiTypeVariableFactory factory) { return createParameterizedType(t, factory, true, null); } | createParameterizedType |
16,554 | PsiType (final PsiType t, final PsiTypeVariableFactory factory, final boolean upper, final PsiElement context) { if (t == null || (upper && t.getCanonicalText().equals(CommonClassNames.JAVA_LANG_OBJECT))) { return factory.create(context); } if (t instanceof PsiClassType) { final PsiClassType.ClassResolveResult result = resolveType(t); final PsiSubstitutor aSubst = result.getSubstitutor(); final PsiClass aClass = result.getElement(); PsiSubstitutor theSubst = PsiSubstitutor.EMPTY; final Set<PsiTypeVariable> cluster = new HashSet<>(); for (final PsiTypeParameter parm : aSubst.getSubstitutionMap().keySet()) { final PsiType type = createParameterizedType(aSubst.substitute(parm), factory, false, context); if (type instanceof PsiTypeVariable) { cluster.add((PsiTypeVariable)type); } theSubst = theSubst.put(parm, type); } if (cluster.size() > 1) { factory.registerCluster(cluster); } return JavaPsiFacade.getElementFactory(aClass.getProject()).createType(aClass, theSubst); } else if (t instanceof PsiArrayType) { return createParameterizedType(((PsiArrayType)t).getComponentType(), factory, upper, context).createArrayType(); } return t; } | createParameterizedType |
16,555 | boolean (final PsiType t) { if (t == null) { return false; } if (t instanceof PsiTypeVariable) { return true; } if (t instanceof PsiArrayType) { return bindsTypeVariables(((PsiArrayType)t).getComponentType()); } if (t instanceof PsiWildcardType) { return bindsTypeVariables(((PsiWildcardType)t).getBound()); } if (t instanceof PsiIntersectionType) { final PsiType[] conjuncts = ((PsiIntersectionType)t).getConjuncts(); for (PsiType conjunct : conjuncts) { if (bindsTypeVariables(conjunct)) return true; } return false; } final PsiClassType.ClassResolveResult result = resolveType(t); if (result.getElement() != null) { final PsiSubstitutor subst = result.getSubstitutor(); for (final PsiType psiType : subst.getSubstitutionMap().values()) { if (bindsTypeVariables(psiType)) { return true; } } } return false; } | bindsTypeVariables |
16,556 | void (final PsiElement element, final PsiType type) { try { if (element instanceof PsiTypeCastExpression cast) { cast.getCastType().replace(JavaPsiFacade.getElementFactory(cast.getProject()).createTypeElement(type)); } else if (element instanceof PsiVariable field) { field.normalizeDeclaration(); field.getTypeElement().replace(JavaPsiFacade.getElementFactory(field.getProject()).createTypeElement(type)); } else if (element instanceof PsiMethod method) { method.getReturnTypeElement().replace(JavaPsiFacade.getElementFactory(method.getProject()).createTypeElement(type)); } else if (element instanceof PsiNewExpression newx) { final PsiClassType.ClassResolveResult result = resolveType(type); final PsiSubstitutor subst = result.getSubstitutor(); final PsiTypeParameter[] parms = result.getElement().getTypeParameters(); if (parms.length > 0 && subst.substitute(parms[0]) != null) { PsiJavaCodeReferenceElement classReference = newx.getClassOrAnonymousClassReference(); PsiReferenceParameterList list = classReference.getParameterList(); if (list == null) { return; } final PsiElementFactory factory = JavaPsiFacade.getElementFactory(newx.getProject()); PsiTypeElement[] elements = list.getTypeParameterElements(); for (PsiTypeElement element1 : elements) { element1.delete(); } for (PsiTypeParameter parm : parms) { PsiType aType = subst.substitute(parm); if (aType instanceof PsiWildcardType) { aType = ((PsiWildcardType)aType).getBound(); } list .add(factory.createTypeElement(aType == null ? PsiType.getJavaLangObject(list.getManager(), list.getResolveScope()) : aType)); } if (PsiDiamondTypeUtil.canCollapseToDiamond(newx, newx, newx.getType())) { RemoveRedundantTypeArgumentsUtil.replaceExplicitWithDiamond(list); } } } else { LOG.error("Unexpected element type " + element.getClass().getName()); } } catch (IncorrectOperationException e) { LOG.error("Incorrect Operation Exception thrown in CastRole.\n"); } } | changeType |
16,557 | boolean (@NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext dataContext) { return false; } | isAvailableForQuickList |
16,558 | void (@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) { invoke(project, new PsiElement[]{file}, dataContext); } | invoke |
16,559 | void (@NotNull Project project, PsiElement @NotNull [] elements, DataContext dataContext) { if (elements.length != 0) { new TypeCookDialog(project, elements).show(); } } | invoke |
16,560 | UsageViewDescriptor (UsageInfo @NotNull [] usages) { return new TypeCookViewDescriptor(myElements); } | createUsageViewDescriptor |
16,561 | String () { return myResult.getCookedType(element).getCanonicalText(); } | getTooltipText |
16,562 | void (PsiElement @NotNull [] elements) { myElements = elements; } | refreshElements |
16,563 | void (UsageInfo @NotNull [] usages) { final Set<PsiElement> victims = new HashSet<>(); for (UsageInfo usage : usages) { victims.add(usage.getElement()); } myResult.apply (victims); WindowManager.getInstance().getStatusBar(myProject).setInfo(myResult.getReport()); } | performRefactoring |
16,564 | boolean () { return true; } | isGlobalUndoAction |
16,565 | String () { return JavaRareRefactoringsBundle.message("type.cook.command"); } | getCommandName |
16,566 | List<PsiElement> () { return List.of(myElements); } | getElements |
16,567 | String () { return JavaRareRefactoringsBundle.message("type.cook.elements.header"); } | getProcessedElementsHeader |
16,568 | String (int usagesCount, int filesCount) { return JavaRareRefactoringsBundle.message("declaration.s.to.be.generified", UsageViewBundle.getReferencesString(usagesCount, filesCount)); } | getCodeReferencesText |
16,569 | int () { return myCurrent; } | getNumber |
16,570 | void (final Set<PsiTypeVariable> cluster) { myClusters.add(cluster); for (final PsiTypeVariable aCluster : cluster) { myVarCluster.put(Integer.valueOf(aCluster.getIndex()), cluster); } } | registerCluster |
16,571 | List<Set<PsiTypeVariable>> () { return myClusters; } | getClusters |
16,572 | Set<PsiTypeVariable> (final int var) { return myVarCluster.get(Integer.valueOf(var)); } | getClusterOf |
16,573 | PsiTypeVariable () { return create(null); } | create |
16,574 | PsiTypeVariable (final PsiElement context) { return new PsiTypeVariable() { private final int myIndex = myCurrent++; private final PsiElement myContext = context; @Override public boolean isValidInContext(final PsiType type) { if (myContext == null) { return true; } if (type == null) { return true; } return type.accept(new PsiTypeVisitor<Boolean>() { @Override public Boolean visitType(@NotNull final PsiType type) { return Boolean.TRUE; } @Override public Boolean visitArrayType(@NotNull final PsiArrayType arrayType) { return arrayType.getDeepComponentType().accept(this); } @Override public Boolean visitWildcardType(@NotNull final PsiWildcardType wildcardType) { final PsiType bound = wildcardType.getBound(); if (bound != null) { bound.accept(this); } return Boolean.TRUE; } @Override public Boolean visitClassType(@NotNull final PsiClassType classType) { final PsiClassType.ClassResolveResult result = classType.resolveGenerics(); final PsiClass aClass = result.getElement(); final PsiSubstitutor aSubst = result.getSubstitutor(); if (aClass != null) { final PsiManager manager = aClass.getManager(); final JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject()); if (aClass instanceof PsiTypeParameter) { final PsiTypeParameterListOwner owner = PsiTreeUtil.getParentOfType(myContext, PsiTypeParameterListOwner.class); if (owner != null) { boolean found = false; for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable(owner)) { found = manager.areElementsEquivalent(typeParameter, aClass); if (found) break; } if (!found) { return Boolean.FALSE; } } else { return Boolean.FALSE; } } else if (!facade.getResolveHelper().isAccessible(aClass, myContext, null)) { return Boolean.FALSE; } for (PsiTypeParameter parm : PsiUtil.typeParametersIterable(aClass)) { final PsiType type = aSubst.substitute(parm); if (type != null) { final Boolean b = type.accept(this); if (!b.booleanValue()) { return Boolean.FALSE; } } } return Boolean.TRUE; } else { return Boolean.FALSE; } } }).booleanValue(); } @Override @NotNull public String getPresentableText() { return "$" + myIndex; } @Override @NotNull public String getCanonicalText() { return getPresentableText(); } @Override public boolean isValid() { return true; } @Override public boolean equalsToText(@NotNull String text) { return text.equals(getPresentableText()); } @Override public GlobalSearchScope getResolveScope() { return null; } @Override public PsiType @NotNull [] getSuperTypes() { return EMPTY_ARRAY; } public boolean equals(Object o) { if (this == o) return true; return o instanceof PsiTypeVariable psiTypeVariable && myIndex == psiTypeVariable.getIndex(); } public int hashCode() { return myIndex; } @Override public int getIndex() { return myIndex; } }; } | create |
16,575 | boolean (final PsiType type) { if (myContext == null) { return true; } if (type == null) { return true; } return type.accept(new PsiTypeVisitor<Boolean>() { @Override public Boolean visitType(@NotNull final PsiType type) { return Boolean.TRUE; } @Override public Boolean visitArrayType(@NotNull final PsiArrayType arrayType) { return arrayType.getDeepComponentType().accept(this); } @Override public Boolean visitWildcardType(@NotNull final PsiWildcardType wildcardType) { final PsiType bound = wildcardType.getBound(); if (bound != null) { bound.accept(this); } return Boolean.TRUE; } @Override public Boolean visitClassType(@NotNull final PsiClassType classType) { final PsiClassType.ClassResolveResult result = classType.resolveGenerics(); final PsiClass aClass = result.getElement(); final PsiSubstitutor aSubst = result.getSubstitutor(); if (aClass != null) { final PsiManager manager = aClass.getManager(); final JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject()); if (aClass instanceof PsiTypeParameter) { final PsiTypeParameterListOwner owner = PsiTreeUtil.getParentOfType(myContext, PsiTypeParameterListOwner.class); if (owner != null) { boolean found = false; for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable(owner)) { found = manager.areElementsEquivalent(typeParameter, aClass); if (found) break; } if (!found) { return Boolean.FALSE; } } else { return Boolean.FALSE; } } else if (!facade.getResolveHelper().isAccessible(aClass, myContext, null)) { return Boolean.FALSE; } for (PsiTypeParameter parm : PsiUtil.typeParametersIterable(aClass)) { final PsiType type = aSubst.substitute(parm); if (type != null) { final Boolean b = type.accept(this); if (!b.booleanValue()) { return Boolean.FALSE; } } } return Boolean.TRUE; } else { return Boolean.FALSE; } } }).booleanValue(); } | isValidInContext |
16,576 | Boolean (@NotNull final PsiType type) { return Boolean.TRUE; } | visitType |
16,577 | Boolean (@NotNull final PsiArrayType arrayType) { return arrayType.getDeepComponentType().accept(this); } | visitArrayType |
16,578 | Boolean (@NotNull final PsiWildcardType wildcardType) { final PsiType bound = wildcardType.getBound(); if (bound != null) { bound.accept(this); } return Boolean.TRUE; } | visitWildcardType |
16,579 | Boolean (@NotNull final PsiClassType classType) { final PsiClassType.ClassResolveResult result = classType.resolveGenerics(); final PsiClass aClass = result.getElement(); final PsiSubstitutor aSubst = result.getSubstitutor(); if (aClass != null) { final PsiManager manager = aClass.getManager(); final JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject()); if (aClass instanceof PsiTypeParameter) { final PsiTypeParameterListOwner owner = PsiTreeUtil.getParentOfType(myContext, PsiTypeParameterListOwner.class); if (owner != null) { boolean found = false; for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable(owner)) { found = manager.areElementsEquivalent(typeParameter, aClass); if (found) break; } if (!found) { return Boolean.FALSE; } } else { return Boolean.FALSE; } } else if (!facade.getResolveHelper().isAccessible(aClass, myContext, null)) { return Boolean.FALSE; } for (PsiTypeParameter parm : PsiUtil.typeParametersIterable(aClass)) { final PsiType type = aSubst.substitute(parm); if (type != null) { final Boolean b = type.accept(this); if (!b.booleanValue()) { return Boolean.FALSE; } } } return Boolean.TRUE; } else { return Boolean.FALSE; } } | visitClassType |
16,580 | String () { return "$" + myIndex; } | getPresentableText |
16,581 | String () { return getPresentableText(); } | getCanonicalText |
16,582 | boolean () { return true; } | isValid |
16,583 | boolean (@NotNull String text) { return text.equals(getPresentableText()); } | equalsToText |
16,584 | GlobalSearchScope () { return null; } | getResolveScope |
16,585 | boolean (Object o) { if (this == o) return true; return o instanceof PsiTypeVariable psiTypeVariable && myIndex == psiTypeVariable.getIndex(); } | equals |
16,586 | int () { return myIndex; } | hashCode |
16,587 | int () { return myIndex; } | getIndex |
16,588 | X (@NotNull final PsiClassType classType) { super.visitClassType(classType); final PsiClassType.ClassResolveResult result = classType.resolveGenerics(); if (result.getElement() != null) { for (final PsiType type : result.getSubstitutor().getSubstitutionMap().values()) { if (type != null) { type.accept(this); } } } return null; } | visitClassType |
16,589 | void (final PsiElement element, final PsiType t) { if (Util.isRaw(t, mySettings)) { if (element instanceof PsiNewExpression && t.getCanonicalText().equals(CommonClassNames.JAVA_LANG_OBJECT)){ return; } myVictims.add(element); } } | testNAdd |
16,590 | Set<PsiElement> () { for (PsiElement element : myElements) { element.accept(this); } return myVictims; } | getVictims |
16,591 | Project () { return myProject; } | getProject |
16,592 | Set<Constraint> () { return myConstraints; } | getConstraints |
16,593 | void (final PsiTypeCastExpression cast, final PsiType operandType) { myCastToOperandType.put(cast, operandType); } | addCast |
16,594 | void (PsiType left, PsiType right) { if (left instanceof PsiPrimitiveType) left = ((PsiPrimitiveType)left).getBoxedType(PsiManager.getInstance(myProject), GlobalSearchScope.allScope(myProject)); if (right instanceof PsiPrimitiveType) right = ((PsiPrimitiveType)right).getBoxedType(PsiManager.getInstance(myProject), GlobalSearchScope.allScope(myProject)); if (left == null || right == null) { return; } if ((Util.bindsTypeVariables(left) || Util.bindsTypeVariables(right)) ) { final Subtype c = new Subtype(left, right); myConstraints.add(c); } } | addSubtypeConstraint |
16,595 | String (final PsiMember member) { return member.getContainingClass().getQualifiedName() + "." + member.getName(); } | memberString |
16,596 | String (final PsiLocalVariable var) { final PsiMethod method = PsiTreeUtil.getParentOfType(var, PsiMethod.class); return memberString(method) + "#" + var.getName(); } | variableString |
16,597 | String () { @NonNls StringBuilder buffer = new StringBuilder(); buffer.append("Victims:\n"); for (final PsiElement element : myElements) { final PsiType type = myTypes.get(element); if (type == null) { continue; } if (element instanceof PsiParameter param) { final PsiElement declarationScope = param.getDeclarationScope(); if (declarationScope instanceof PsiMethod method) { buffer.append(" parameter " + method.getParameterList().getParameterIndex(param) + " of " + memberString(method)); } else { buffer.append(" parameter of foreach"); } } else if (element instanceof PsiField) { buffer.append(" field " + memberString(((PsiField)element))); } else if (element instanceof PsiLocalVariable) { buffer.append(" local " + variableString(((PsiLocalVariable)element))); } else if (element instanceof PsiMethod) { buffer.append(" return of " + memberString(((PsiMethod)element))); } else if (element instanceof PsiNewExpression) { buffer.append(" " + element.getText()); } else if (element instanceof PsiTypeCastExpression) { buffer.append(" " + element.getText()); } else { buffer.append(" unknown: " + (element == null ? "null" : element.getClass().getName())); } buffer.append(" " + type.getCanonicalText() + "\n"); } buffer.append("Variables: " + myTypeVariableFactory.getNumber() + "\n"); buffer.append("Bound variables: "); if (myBoundVariables == null) { buffer.append(" not specified\n"); } else { for (final PsiTypeVariable boundVariable : myBoundVariables) { buffer.append(boundVariable.getIndex() + ", "); } } buffer.append("Constraints: " + myConstraints.size() + "\n"); for (final Constraint constraint : myConstraints) { buffer.append(" " + constraint + "\n"); } return buffer.toString(); } | toString |
16,598 | ReductionSystem[] () { class Node { int myComponent = -1; final Constraint myConstraint; final Set<Node> myNeighbours = new HashSet<>(); Node() { myConstraint = null; } Node(final Constraint c) { myConstraint = c; } public Constraint getConstraint() { return myConstraint; } public void addEdge(final Node n) { if (!myNeighbours.contains(n)) { myNeighbours.add(n); n.addEdge(this); } } } final Node[] typeVariableNodes = new Node[myTypeVariableFactory.getNumber()]; final Node[] constraintNodes = new Node[myConstraints.size()]; final Map<Constraint, Set<PsiTypeVariable>> boundVariables = new HashMap<>(); for (int i = 0; i < typeVariableNodes.length; i++) { typeVariableNodes[i] = new Node(); } { int j = 0; for (final Constraint constraint : myConstraints) { constraintNodes[j++] = new Node(constraint); } } { int l = 0; for (final Constraint constraint : myConstraints) { final Set<PsiTypeVariable> boundVars = new LinkedHashSet<>(); final Node constraintNode = constraintNodes[l++]; new Object() { void visit(final Constraint c) { visit(c.getLeft()); visit(c.getRight()); } private void visit(final PsiType t) { if (t instanceof PsiTypeVariable) { boundVars.add((PsiTypeVariable)t); } else if (t instanceof PsiArrayType) { visit(t.getDeepComponentType()); } else if (t instanceof PsiClassType) { final PsiSubstitutor subst = Util.resolveType(t).getSubstitutor(); for (final PsiType type : subst.getSubstitutionMap().values()) { visit(type); } } else if (t instanceof PsiIntersectionType) { final PsiType[] conjuncts = ((PsiIntersectionType)t).getConjuncts(); for (PsiType conjunct : conjuncts) { visit(conjunct); } } else if (t instanceof PsiWildcardType) { final PsiType bound = ((PsiWildcardType)t).getBound(); if (bound != null) { visit(bound); } } } }.visit(constraint); final PsiTypeVariable[] bound = boundVars.toArray(new PsiTypeVariable[]{}); for (int j = 0; j < bound.length; j++) { final int x = bound[j].getIndex(); final Node typeVariableNode = typeVariableNodes[x]; typeVariableNode.addEdge(constraintNode); for (int k = j + 1; k < bound.length; k++) { final int y = bound[k].getIndex(); typeVariableNode.addEdge(typeVariableNodes[y]); } } boundVariables.put(constraint, boundVars); } } List<Set<PsiTypeVariable>> clusters = myTypeVariableFactory.getClusters(); for (final Set<PsiTypeVariable> cluster : clusters) { Node prev = null; for (final PsiTypeVariable variable : cluster) { final Node curr = typeVariableNodes[variable.getIndex()]; if (prev != null) { prev.addEdge(curr); } prev = curr; } } int currComponent = 0; for (final Node node : typeVariableNodes) { if (node.myComponent == -1) { final int component = currComponent; new Object() { void selectComponent(final Node n) { final LinkedList<Node> frontier = new LinkedList<>(); frontier.addFirst(n); while (frontier.size() > 0) { final Node curr = frontier.removeFirst(); curr.myComponent = component; for (final Node p : curr.myNeighbours) { if (p.myComponent == -1) { frontier.addFirst(p); } } } } }.selectComponent(node); currComponent++; } } final ReductionSystem[] systems = new ReductionSystem[currComponent]; for (final Node node : constraintNodes) { final Constraint constraint = node.getConstraint(); final int index = node.myComponent; if (systems[index] == null) { systems[index] = new ReductionSystem(myProject, myElements, myTypes, myTypeVariableFactory, mySettings); } systems[index].addConstraint(constraint, boundVariables.get(constraint)); } return systems; } | isolate |
16,599 | Constraint () { return myConstraint; } | getConstraint |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.