Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
30,800 | boolean (@NotNull PsiClass element) { callback.accept(element); return false; } | execute |
30,801 | void (final boolean generateFinal, GrVariable variable) { perform(generateFinal, PsiModifier.FINAL, variable); } | perform |
30,802 | void (final boolean generateFinal, final String modifier, final GrVariable variable) { final Document document = myEditor.getDocument(); LOG.assertTrue(variable != null); final GrModifierList modifierList = variable.getModifierList(); LOG.assertTrue(modifierList != null); final int textOffset = modifierList.getTextOffset(); final Runnable runnable = () -> { if (generateFinal) { final GrTypeElement typeElement = variable.getTypeElementGroovy(); final int typeOffset = typeElement != null ? typeElement.getTextOffset() : textOffset; document.insertString(typeOffset, modifier + " "); } else { final int idx = modifierList.getText().indexOf(modifier); document.deleteString(textOffset + idx, textOffset + idx + modifier.length() + 1); } }; final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myEditor); if (lookup != null) { lookup.performGuardedChange(runnable); } else { runnable.run(); } PsiDocumentManager.getInstance(variable.getProject()).commitDocument(document); } | perform |
30,803 | GrExpression (GrVariable variable, GrExpression initializer) { PsiType ltype = findLValueType(initializer); PsiType rtype = initializer.getType(); GrExpression rawExpr = (GrExpression)PsiUtil.skipParentheses(initializer, false); if (ltype == null || TypesUtil.isAssignableWithoutConversions(ltype, rtype) || !TypesUtil.isAssignable(ltype, rtype, initializer)) { return rawExpr; } else { // implicit coercion should be replaced with explicit cast GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(variable.getProject()); GrSafeCastExpression cast = (GrSafeCastExpression)factory.createExpressionFromText("a as B"); cast.getOperand().replaceWithExpression(rawExpr, false); cast.getCastTypeElement().replace(factory.createTypeElement(ltype)); return cast; } } | insertExplicitCastIfNeeded |
30,804 | PsiType (GrExpression initializer) { if (initializer.getParent() instanceof GrAssignmentExpression && ((GrAssignmentExpression)initializer.getParent()).getRValue() == initializer) { return ((GrAssignmentExpression)initializer.getParent()).getLValue().getNominalType(); } else if (initializer.getParent() instanceof GrVariable) { return ((GrVariable)initializer.getParent()).getDeclaredType(); } else { return null; } } | findLValueType |
30,805 | GrStatement (PsiElement @NotNull [] occurrences, @NotNull PsiElement scope) { PsiElement parent = PsiTreeUtil.findCommonParent(occurrences); PsiElement container = getEnclosingContainer(parent); assert container != null; PsiElement anchor = findAnchor(occurrences, container); assertStatement(anchor, scope); return (GrStatement)anchor; } | getAnchor |
30,806 | PsiElement (PsiElement place) { PsiElement parent = place; while (true) { if (parent == null) { return null; } if (parent instanceof GrDeclarationHolder && !(parent instanceof GrClosableBlock && parent.getParent() instanceof GrStringInjection)) { return parent; } if (parent instanceof GrLoopStatement) { return parent; } parent = parent.getParent(); } } | getEnclosingContainer |
30,807 | List<GrExpression> (final PsiFile file, final Editor editor, final int offset, boolean acceptVoidCalls) { int correctedOffset = correctOffset(editor, offset); final PsiElement elementAtCaret = file.findElementAt(correctedOffset); return collectExpressions(elementAtCaret, acceptVoidCalls); } | collectExpressions |
30,808 | List<GrExpression> (PsiElement elementAtCaret, boolean acceptVoidCalls) { final List<GrExpression> expressions = new ArrayList<>(); for (GrExpression expression = PsiTreeUtil.getParentOfType(elementAtCaret, GrExpression.class); expression != null; expression = PsiTreeUtil.getParentOfType(expression, GrExpression.class)) { if (expressions.contains(expression)) continue; if (expression instanceof GrParenthesizedExpression && !expressions.contains(((GrParenthesizedExpression)expression).getOperand())) { expressions.add(((GrParenthesizedExpression)expression).getOperand()); } if (expressionIsIncorrect(expression, acceptVoidCalls)) continue; expressions.add(expression); } return expressions; } | collectExpressions |
30,809 | boolean (@Nullable GrExpression expression, boolean acceptVoidCalls) { if (expression instanceof GrParenthesizedExpression) return true; if (PsiUtil.isSuperReference(expression)) return true; if (expression instanceof GrReferenceExpression && expression.getParent() instanceof GrCall) { final GroovyResolveResult resolveResult = ((GrReferenceExpression)expression).advancedResolve(); final PsiElement resolved = resolveResult.getElement(); return resolved instanceof PsiMethod && !resolveResult.isInvokedOnProperty() || resolved instanceof PsiClass; } if (expression instanceof GrReferenceExpression && expression.getParent() instanceof GrReferenceExpression) { return !PsiUtil.isThisReference(expression) && ((GrReferenceExpression)expression).resolve() instanceof PsiClass; } if (expression instanceof GrClosableBlock && expression.getParent() instanceof GrStringInjection) return true; if (!acceptVoidCalls && expression instanceof GrMethodCall && PsiTypes.voidType().equals(expression.getType())) return true; return false; } | expressionIsIncorrect |
30,810 | int (Editor editor, int offset) { Document document = editor.getDocument(); CharSequence text = document.getCharsSequence(); int correctedOffset = offset; int textLength = document.getTextLength(); if (offset >= textLength) { correctedOffset = textLength - 1; } else if (!Character.isJavaIdentifierPart(text.charAt(offset))) { correctedOffset--; } if (correctedOffset < 0) { correctedOffset = offset; } else { char c = text.charAt(correctedOffset); if (c == ';' && correctedOffset != 0) {//initially caret on the end of line correctedOffset--; } else if (!Character.isJavaIdentifierPart(c) && c != ')' && c != ']' && c != '}' && c != '\'' && c != '"' && c != '/') { correctedOffset = offset; } } | correctOffset |
30,811 | GrVariable (final PsiFile file, final Editor editor, final int offset) { final int correctOffset = correctOffset(editor, offset); final PsiElement elementAtCaret = file.findElementAt(correctOffset); final GrVariable variable = PsiTreeUtil.getParentOfType(elementAtCaret, GrVariable.class); if (variable != null && variable.getNameIdentifierGroovy().getTextRange().contains(correctOffset)) return variable; return null; } | findVariableAtCaret |
30,812 | void (@NotNull final Project project, final Editor editor, final PsiFile file, @Nullable final DataContext dataContext) { final SelectionModel selectionModel = editor.getSelectionModel(); if (!selectionModel.hasSelection()) { final int offset = editor.getCaretModel().getOffset(); final List<GrExpression> expressions = collectExpressions(file, editor, offset, false); if (expressions.isEmpty()) { updateSelectionForVariable(editor, file, selectionModel, offset); } else if (expressions.size() == 1 || ApplicationManager.getApplication().isUnitTestMode()) { final TextRange textRange = expressions.get(0).getTextRange(); selectionModel.setSelection(textRange.getStartOffset(), textRange.getEndOffset()); } else { IntroduceTargetChooser.showChooser(editor, expressions, new Pass<>() { @Override public void pass(final GrExpression selectedValue) { invoke(project, editor, file, selectedValue.getTextRange().getStartOffset(), selectedValue.getTextRange().getEndOffset()); } }, GR_EXPRESSION_RENDERER); return; } } invoke(project, editor, file, selectionModel.getSelectionStart(), selectionModel.getSelectionEnd()); } | invoke |
30,813 | void (final GrExpression selectedValue) { invoke(project, editor, file, selectedValue.getTextRange().getStartOffset(), selectedValue.getTextRange().getEndOffset()); } | pass |
30,814 | void (Editor editor, PsiFile file, SelectionModel selectionModel, int offset) { final GrVariable variable = findVariableAtCaret(file, editor, offset); if (variable == null || variable instanceof GrField || variable instanceof GrParameter) { selectionModel.selectLineAtCaret(); } else { final TextRange textRange = variable.getTextRange(); selectionModel.setSelection(textRange.getStartOffset(), textRange.getEndOffset()); } } | updateSelectionForVariable |
30,815 | void (@NotNull Project project, PsiElement @NotNull [] elements, DataContext dataContext) { // Does nothing } | invoke |
30,816 | void (@NotNull final Project project, @NotNull final Editor editor, @Nullable final GrExpression expression, @Nullable final GrVariable variable, @Nullable final StringPartInfo stringPart) { final Scope[] scopes = findPossibleScopes(expression, variable, stringPart, editor); Consumer<? super Scope> callback = scope-> { GrIntroduceContext context = getContext(project, editor, expression, variable, stringPart, scope); invokeImpl(project, context, editor); }; if (scopes.length == 0) { CommonRefactoringUtil.showErrorHint( project, editor, RefactoringBundle.getCannotRefactorMessage(getRefactoringName()), GroovyBundle.message("dialog.title.refactoring.unavailable.in.current.scope"), getHelpID() ); } else if (scopes.length == 1) { callback.accept(scopes[0]); } else { showScopeChooser(scopes, callback, editor); } } | getContextAndInvoke |
30,817 | void (final Ref<GrIntroduceContext> ref) { CommandProcessor.getInstance().executeCommand(ref.get().getProject(), () -> ApplicationManager.getApplication().runWriteAction(() -> { GrIntroduceContext context = ref.get(); StringPartInfo stringPart = context.getStringPart(); assert stringPart != null; GrExpression expression = stringPart.replaceLiteralWithConcatenation(null); ref.set(new GrIntroduceContextImpl(context.getProject(), context.getEditor(), expression, null, null, new PsiElement[]{expression}, context.getScope())); }), getRefactoringName(), getRefactoringName()); } | extractStringPart |
30,818 | void (@NotNull final GrStatement anchor, @NotNull final Ref<GrIntroduceContext> contextRef) { CommandProcessor.getInstance().executeCommand(contextRef.get().getProject(), () -> ApplicationManager.getApplication().runWriteAction(() -> { GrIntroduceContext context = contextRef.get(); SmartPointerManager pointManager = SmartPointerManager.getInstance(context.getProject()); SmartPsiElementPointer<GrExpression> expressionRef = context.getExpression() != null ? pointManager.createSmartPsiElementPointer(context.getExpression()) : null; SmartPsiElementPointer<GrVariable> varRef = context.getVar() != null ? pointManager.createSmartPsiElementPointer(context.getVar()) : null; SmartPsiElementPointer[] occurrencesRefs = new SmartPsiElementPointer[context.getOccurrences().length]; PsiElement[] occurrences = context.getOccurrences(); for (int i = 0; i < occurrences.length; i++) { occurrencesRefs[i] = pointManager.createSmartPsiElementPointer(occurrences[i]); } PsiFile file = anchor.getContainingFile(); SmartPsiFileRange anchorPointer = pointManager.createSmartPsiFileRangePointer(file, anchor.getTextRange()); Document document = context.getEditor().getDocument(); CharSequence sequence = document.getCharsSequence(); TextRange range = anchor.getTextRange(); int end = range.getEndOffset(); document.insertString(end, "\n}"); int start = range.getStartOffset(); while (start > 0 && Character.isWhitespace(sequence.charAt(start - 1))) { start--; } document.insertString(start, "{"); PsiDocumentManager.getInstance(context.getProject()).commitDocument(document); Segment anchorSegment = anchorPointer.getRange(); PsiElement restoredAnchor = PsiImplUtil .findElementInRange(file, anchorSegment.getStartOffset(), anchorSegment.getEndOffset(), PsiElement.class); GrCodeBlock block = (GrCodeBlock)restoredAnchor.getParent(); CodeStyleManager.getInstance(context.getProject()).reformat(block.getRBrace()); CodeStyleManager.getInstance(context.getProject()).reformat(block.getLBrace()); for (int i = 0; i < occurrencesRefs.length; i++) { occurrences[i] = occurrencesRefs[i].getElement(); } contextRef.set(new GrIntroduceContextImpl(context.getProject(), context.getEditor(), expressionRef != null ? expressionRef.getElement() : null, varRef != null ? varRef.getElement() : null, null, occurrences, context.getScope())); }), getRefactoringName(), getRefactoringName()); } | addBraces |
30,819 | GrStatement (@NotNull final GrIntroduceContext context, final boolean replaceAll) { return ReadAction.compute(() -> { PsiElement[] occurrences = replaceAll ? context.getOccurrences() : new GrExpression[]{context.getExpression()}; return getAnchor(occurrences, context.getScope()); }); } | findAnchor |
30,820 | GrIntroduceContext (@NotNull Project project, @NotNull Editor editor, @Nullable GrExpression expression, @Nullable GrVariable variable, @Nullable StringPartInfo stringPart, @NotNull PsiElement scope) { if (variable != null) { final PsiElement[] occurrences = collectVariableUsages(variable, scope); return new GrIntroduceContextImpl(project, editor, null, variable, stringPart, occurrences, scope); } else if (expression != null ) { final PsiElement[] occurrences = findOccurrences(expression, scope); return new GrIntroduceContextImpl(project, editor, expression, variable, stringPart, occurrences, scope); } else { assert stringPart != null; return new GrIntroduceContextImpl(project, editor, expression, variable, stringPart, new PsiElement[]{stringPart.getLiteral()}, scope); } } | getContext |
30,821 | PsiElement[] (GrVariable variable, PsiElement scope) { final List<PsiElement> list = Collections.synchronizedList(new ArrayList<>()); if (scope instanceof GroovyScriptClass) { scope = scope.getContainingFile(); } ReferencesSearch.search(variable, new LocalSearchScope(scope)).forEach(psiReference -> { final PsiElement element = psiReference.getElement(); list.add(element); return true; }); return list.toArray(PsiElement.EMPTY_ARRAY); } | collectVariableUsages |
30,822 | boolean (final Project project, final GrIntroduceContext context, final Editor editor) { try { if (!CommonRefactoringUtil.checkReadOnlyStatus(project, context.getOccurrences())) { return false; } checkOccurrences(context.getOccurrences()); if (isInplace(context.getEditor(), context.getPlace())) { Map<OccurrencesChooser.ReplaceChoice, List<Object>> occurrencesMap = getOccurrenceOptions(context); new IntroduceOccurrencesChooser(editor).showChooser(occurrencesMap,choice-> getIntroducer(context, choice).startInplaceIntroduceTemplate()); } else { final Settings settings = showDialog(context); if (settings == null) return false; CommandProcessor.getInstance().executeCommand(context.getProject(), () -> ApplicationManager.getApplication().runWriteAction(() -> { runRefactoring(context, settings); }), getRefactoringName(), null); } return true; } catch (GrRefactoringError e) { CommonRefactoringUtil.showErrorHint(project, editor, RefactoringBundle.getCannotRefactorMessage(e.getMessage()), getRefactoringName(), getHelpID()); return false; } } | invokeImpl |
30,823 | boolean (@NotNull Editor editor, @NotNull PsiElement place) { final RefactoringSupportProvider supportProvider = LanguageRefactoringSupport.INSTANCE.forContext(place); return supportProvider != null && (editor.getUserData(InplaceRefactoring.INTRODUCE_RESTART) == null || !editor.getUserData(InplaceRefactoring.INTRODUCE_RESTART)) && editor.getUserData(AbstractInplaceIntroducer.ACTIVE_INTRODUCE) == null && editor.getSettings().isVariableInplaceRenameEnabled() && supportProvider.isInplaceIntroduceAvailable(place, place) && !ApplicationManager.getApplication().isUnitTestMode(); } | isInplace |
30,824 | GrVariable (@NotNull PsiFile file, int startOffset, int endOffset) { GrVariable var = PsiImplUtil.findElementInRange(file, startOffset, endOffset, GrVariable.class); if (var == null) { final GrVariableDeclaration variableDeclaration = PsiImplUtil.findElementInRange(file, startOffset, endOffset, GrVariableDeclaration.class); if (variableDeclaration == null) return null; final GrVariable[] variables = variableDeclaration.getVariables(); if (variables.length == 1) { var = variables[0]; } } if (var instanceof GrParameter || var instanceof GrField) { return null; } return var; } | findVariable |
30,825 | GrVariable (@NotNull GrStatement statement) { if (!(statement instanceof GrVariableDeclaration variableDeclaration)) return null; final GrVariable[] variables = variableDeclaration.getVariables(); GrVariable var = null; if (variables.length == 1) { var = variables[0]; } if (var instanceof GrParameter || var instanceof GrField) { return null; } return var; } | findVariable |
30,826 | GrExpression (PsiFile file, int startOffset, int endOffset) { GrExpression selectedExpr = PsiImplUtil.findElementInRange(file, startOffset, endOffset, GrExpression.class); return findExpression(selectedExpr); } | findExpression |
30,827 | GrExpression (GrStatement selectedExpr) { if (!(selectedExpr instanceof GrExpression selected)) return null; while (selected instanceof GrParenthesizedExpression) selected = ((GrParenthesizedExpression)selected).getOperand(); return selected; } | findExpression |
30,828 | Settings (@NotNull GrIntroduceContext context) { // Add occurrences highlighting ArrayList<RangeHighlighter> highlighters = new ArrayList<>(); HighlightManager highlightManager = null; if (context.getEditor() != null) { highlightManager = HighlightManager.getInstance(context.getProject()); if (context.getOccurrences().length > 1) { highlightManager.addOccurrenceHighlights(context.getEditor(), context.getOccurrences(), EditorColors.SEARCH_RESULT_ATTRIBUTES, true, highlighters); } } GrIntroduceDialog<Settings> dialog = getDialog(context); dialog.show(); if (dialog.isOK()) { if (context.getEditor() != null) { for (RangeHighlighter highlighter : highlighters) { highlightManager.removeSegmentHighlighter(context.getEditor(), highlighter); } } return dialog.getSettings(); } else { if (context.getOccurrences().length > 1) { WindowManager.getInstance().getStatusBar(context.getProject()) .setInfo(GroovyRefactoringBundle.message("press.escape.to.remove.the.highlighting")); } } return null; } | showDialog |
30,829 | PsiElement (PsiElement @NotNull [] occurrences, @NotNull PsiElement container) { if (occurrences.length == 0) return null; PsiElement candidate; if (occurrences.length == 1) { candidate = findContainingStatement(occurrences[0]); } else { candidate = occurrences[0]; while (candidate != null && candidate.getParent() != container) { candidate = candidate.getParent(); } } final GrStringInjection injection = PsiTreeUtil.getParentOfType(candidate, GrStringInjection.class); if (injection != null && !injection.getText().contains("\n")) { candidate = findContainingStatement(injection); } if (candidate == null) return null; if ((container instanceof GrWhileStatement) && candidate.equals(((GrWhileStatement)container).getCondition())) { return container; } if ((container instanceof GrIfStatement) && candidate.equals(((GrIfStatement)container).getCondition())) { return container; } if ((container instanceof GrForStatement) && candidate.equals(((GrForStatement)container).getClause())) { return container; } while (candidate instanceof GrIfStatement && candidate.getParent() instanceof GrIfStatement && ((GrIfStatement)candidate.getParent()).getElseBranch() == candidate) { candidate = candidate.getParent(); } return candidate; } | findAnchor |
30,830 | void (@Nullable PsiElement anchor, @NotNull PsiElement scope) { if (!(anchor instanceof GrStatement)) { LOG.error("cannot find anchor for variable", new Throwable(), AttachmentFactory.createContext(scope.getText())); } } | assertStatement |
30,831 | PsiElement (@Nullable PsiElement candidate) { while (candidate != null && (candidate.getParent() instanceof GrLabeledStatement || !(PsiUtil.isExpressionStatement(candidate)))) { candidate = candidate.getParent(); } return candidate; } | findContainingStatement |
30,832 | void (GrVariable var) { final PsiElement parent = var.getParent(); if (((GrVariableDeclaration)parent).getVariables().length == 1) { parent.delete(); } else { GrExpression initializer = var.getInitializerGroovy(); if (initializer != null) initializer.delete(); //don't special check for tuple, but this line is for the tuple case var.delete(); } } | deleteLocalVar |
30,833 | GrVariable (@NotNull GrIntroduceContext context) { final GrVariable var = context.getVar(); if (var != null) { return var; } return resolveLocalVar(context.getExpression()); } | resolveLocalVar |
30,834 | GrVariable (@Nullable GrExpression expression) { if (expression instanceof GrReferenceExpression ref) { final PsiElement resolved = ref.resolve(); if (PsiUtil.isLocalVariable(resolved)) { return (GrVariable)resolved; } return null; } return null; } | resolveLocalVar |
30,835 | boolean (final PsiElement @NotNull [] occurrences) { for (PsiElement element : occurrences) { if (element instanceof GrReferenceExpression) { if (PsiUtil.isLValue((GroovyPsiElement)element)) return true; if (ControlFlowUtils.isIncOrDecOperand((GrReferenceExpression)element)) return true; } } return false; } | hasLhs |
30,836 | PsiElement (@Nullable GrExpression expr, @Nullable GrVariable var, @Nullable StringPartInfo stringPartInfo) { if (var != null) return var; if (expr != null) return expr; if (stringPartInfo != null) return stringPartInfo.getLiteral(); throw new IncorrectOperationException(); } | getCurrentPlace |
30,837 | boolean (GrIntroduceDialog dialog) { final GrIntroduceSettings settings = dialog.getSettings(); if (settings == null) return false; String varName = settings.getName(); boolean allOccurrences = settings.replaceAllOccurrences(); final MultiMap<PsiElement, String> conflicts = isOKImpl(varName, allOccurrences); return conflicts.size() <= 0 || reportConflicts(conflicts, getProject()); } | isOK |
30,838 | boolean (final MultiMap<PsiElement, String> conflicts, final Project project) { ConflictsDialog conflictsDialog = new ConflictsDialog(project, conflicts); return conflictsDialog.showAndGet(); } | reportConflicts |
30,839 | PsiElement (boolean replaceAllOccurrences) { if (replaceAllOccurrences) { if (myContext.getOccurrences().length > 0) { GroovyRefactoringUtil.sortOccurrences(myContext.getOccurrences()); return myContext.getOccurrences()[0]; } else { return myContext.getPlace(); } } else { final GrExpression expression = myContext.getExpression(); return expression != null ? expression : myContext.getStringPart().getLiteral(); } } | getFirstOccurrence |
30,840 | String (String varName, boolean allOccurences) { MultiMap<PsiElement, String> list = isOKImpl(varName, allOccurences); String result = ""; final String[] strings = ArrayUtilRt.toStringArray(list.values()); Arrays.sort(strings); for (String s : strings) { result = result + s.replaceAll("<b><code>", "").replaceAll("</code></b>", "") + "\n"; } if (!list.isEmpty()) { result = result.substring(0, result.length() - 1); } if (result.isEmpty()) { result = "ok"; } return result; } | isOKTest |
30,841 | void (@NotNull PsiElement startElement, @NotNull MultiMap<PsiElement, String> conflicts, @NotNull String varName, double startOffset) { PsiElement child = startElement.getFirstChild(); while (child != null) { // Do not check defined classes, methods, closures and blocks before if (child instanceof GrTypeDefinition || child instanceof GrMethod || GroovyRefactoringUtil.isAppropriateContainerForIntroduceVariable(child) && child.getTextRange().getEndOffset() < startOffset) { myReporter.check(child, conflicts, varName); child = child.getNextSibling(); continue; } if (child instanceof GrVariable) { myReporter.check(child, conflicts, varName); } validateOccurrencesDown(child, conflicts, varName, startOffset); child = child.getNextSibling(); } } | validateOccurrencesDown |
30,842 | void (PsiElement startElement, MultiMap<PsiElement, String> conflicts, @NotNull String varName, double startOffset) { PsiElement prevSibling = startElement.getPrevSibling(); while (prevSibling != null) { if (!(GroovyRefactoringUtil.isAppropriateContainerForIntroduceVariable(prevSibling) && prevSibling.getTextRange().getEndOffset() < startOffset)) { validateOccurrencesDown(prevSibling, conflicts, varName, startOffset); } prevSibling = prevSibling.getPrevSibling(); } PsiElement parent = startElement.getParent(); // Do not check context out of method, type definition and directories if (parent == null || parent instanceof GrMethod || parent instanceof GrTypeDefinition || parent instanceof GroovyFileBase || parent instanceof PsiDirectory) { return; } validateVariableOccurrencesUp(parent, conflicts, varName, startOffset); } | validateVariableOccurrencesUp |
30,843 | String (String name, boolean increaseNumber) { String result = name; if (!isOKImpl(name, true).isEmpty() && !increaseNumber || name.isEmpty()) { return ""; } int i = 1; while (!isOKImpl(result, true).isEmpty()) { result = name + i; i++; } return result; } | validateName |
30,844 | Project () { return myContext.getProject(); } | getProject |
30,845 | String () { throw new UnsupportedOperationException(); } | getName |
30,846 | PsiElement () { return myToSearchFor; } | getToSearchFor |
30,847 | GrParameterListOwner () { return myOwner; } | getToReplaceIn |
30,848 | GrExpression (GrExpression initializer) { if (myField == null) return initializer; final GrReferenceExpression[] replacedRef = {null}; initializer.accept(new GroovyRecursiveElementVisitor() { @Override public void visitReferenceExpression(@NotNull GrReferenceExpression expression) { final GrExpression qualifierExpression = expression.getQualifier(); if (qualifierExpression != null) { qualifierExpression.accept(this); } else { final PsiElement result = expression.resolve(); if (expression.getManager().areElementsEquivalent(result, myField)) { try { replacedRef[0] = qualifyReference(expression, myField, myQualifyingClass); } catch (IncorrectOperationException e) { LOG.error(e); } } } } }); if (!initializer.isValid()) return replacedRef[0]; return initializer; } | fixInitializer |
30,849 | void (@NotNull GrReferenceExpression expression) { final GrExpression qualifierExpression = expression.getQualifier(); if (qualifierExpression != null) { qualifierExpression.accept(this); } else { final PsiElement result = expression.resolve(); if (expression.getManager().areElementsEquivalent(result, myField)) { try { replacedRef[0] = qualifyReference(expression, myField, myQualifyingClass); } catch (IncorrectOperationException e) { LOG.error(e); } } } } | visitReferenceExpression |
30,850 | String () { return myExpression.getText(); } | getText |
30,851 | PsiType () { return myExpression.getType(); } | getType |
30,852 | GrExpression () { if (myExpression.isValid()) { return myExpression; } else if (myMarker != null && myMarker.isValid()) { PsiElement at = myFile.findElementAt(myMarker.getStartOffset()); if (at != null) { return GroovyPsiElementFactory.getInstance(myFile.getProject()).createExpressionFromText(myExpression.getText(), at); } } return GroovyPsiElementFactory.getInstance(myFile.getProject()).createExpressionFromText(myExpression.getText(), null); } | getExpression |
30,853 | void () { super.init(); JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance(); initReplaceFieldsWithGetters(settings); myDeclareFinalCheckBox.setSelected(hasFinalModifier()); myDelegateViaOverloadingMethodCheckBox.setVisible(myInfo.getToSearchFor() != null); setTitle(RefactoringBundle.message("introduce.parameter.title")); myTable.init(myInfo); final GrParameter[] parameters = myInfo.getToReplaceIn().getParameters(); for (Object2IntMap.Entry<JCheckBox> entry : toRemoveCBs.object2IntEntrySet()) { entry.getKey().setSelected(true); final GrParameter param = parameters[entry.getIntValue()]; final ParameterInfo pinfo = findParamByOldName(param.getName()); if (pinfo != null) { pinfo.passAsParameter = false; } } updateSignature(); if (myCanIntroduceSimpleParameter) { mySignaturePanel.setVisible(false); //action to hide signature panel if we have variants to introduce simple parameter myTypeComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { mySignaturePanel.setVisible(myTypeComboBox.isClosureSelected()); pack(); } }); } final PsiType closureReturnType = inferClosureReturnType(); if (PsiTypes.voidType().equals(closureReturnType)) { myForceReturnCheckBox.setEnabled(false); myForceReturnCheckBox.setSelected(false); } else { myForceReturnCheckBox.setSelected(isForceReturn()); } if (myInfo.getToReplaceIn() instanceof GrClosableBlock) { myDelegateViaOverloadingMethodCheckBox.setEnabled(false); myDelegateViaOverloadingMethodCheckBox.setToolTipText(GroovyBundle.message("introduce.parameter.delegating.unavailable.tooltip")); } pack(); } | init |
30,854 | void (ItemEvent e) { mySignaturePanel.setVisible(myTypeComboBox.isClosureSelected()); pack(); } | itemStateChanged |
30,855 | boolean () { return GroovyApplicationSettings.getInstance().FORCE_RETURN; } | isForceReturn |
30,856 | JComponent () { JPanel north = new JPanel(); north.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, true)); final JPanel namePanel = createNamePanel(); namePanel.setAlignmentX(Component.LEFT_ALIGNMENT); north.add(namePanel); createCheckBoxes(north); myGetterPanel = createFieldPanel(); myGetterPanel.setAlignmentX(Component.LEFT_ALIGNMENT); north.add(myGetterPanel); final JPanel root = new JPanel(new BorderLayout()); mySignaturePanel = createSignaturePanel(); root.add(mySignaturePanel, BorderLayout.CENTER); root.add(north, BorderLayout.NORTH); return root; } | createCenterPanel |
30,857 | JPanel () { mySignature = new GrMethodSignatureComponent("", myProject); myTable = new GrParameterTablePanel() { @Override protected void updateSignature() { GrIntroduceParameterDialog.this.updateSignature(); } @Override protected void doEnterAction() { clickDefaultButton(); } @Override protected void doCancelAction() { GrIntroduceParameterDialog.this.doCancelAction(); } }; mySignature.setBorder(IdeBorderFactory.createTitledBorder(GroovyRefactoringBundle.message("signature.preview.border.title"), false)); Splitter splitter = new Splitter(true); splitter.setFirstComponent(myTable); splitter.setSecondComponent(mySignature); mySignature.setPreferredSize(JBUI.size(500, 100)); mySignature.setSize(JBUI.size(500, 100)); splitter.setShowDividerIcon(false); final JPanel panel = new JPanel(new BorderLayout()); panel.add(splitter, BorderLayout.CENTER); myForceReturnCheckBox = new JCheckBox(UIUtil.replaceMnemonicAmpersand( GroovyBundle.message("introduce.parameter.explicit.return.statement.option.label") )); panel.add(myForceReturnCheckBox, BorderLayout.NORTH); return panel; } | createSignaturePanel |
30,858 | void () { GrIntroduceParameterDialog.this.updateSignature(); } | updateSignature |
30,859 | void () { clickDefaultButton(); } | doEnterAction |
30,860 | void () { GrIntroduceParameterDialog.this.doCancelAction(); } | doCancelAction |
30,861 | JPanel () { myDoNotReplaceRadioButton = new JBRadioButton(UIUtil.replaceMnemonicAmpersand( GroovyBundle.message("introduce.parameter.do.not.replace.option.label") )); myReplaceFieldsInaccessibleInRadioButton = new JBRadioButton(UIUtil.replaceMnemonicAmpersand( GroovyBundle.message("introduce.parameter.replace.inaccessible.fields.option.label") )); myReplaceAllFieldsRadioButton = new JBRadioButton(UIUtil.replaceMnemonicAmpersand( GroovyBundle.message("introduce.parameter.replace.all.fields.option.label") )); myDoNotReplaceRadioButton.setFocusable(false); myReplaceFieldsInaccessibleInRadioButton.setFocusable(false); myReplaceAllFieldsRadioButton.setFocusable(false); final ButtonGroup group = new ButtonGroup(); group.add(myDoNotReplaceRadioButton); group.add(myReplaceFieldsInaccessibleInRadioButton); group.add(myReplaceAllFieldsRadioButton); final JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(myDoNotReplaceRadioButton); panel.add(myReplaceFieldsInaccessibleInRadioButton); panel.add(myReplaceAllFieldsRadioButton); panel.setBorder(IdeBorderFactory.createTitledBorder(GroovyBundle.message("introduce.parameter.replace.fields.border.title"))); return panel; } | createFieldPanel |
30,862 | JPanel () { final GridBag c = new GridBag().setDefaultAnchor(GridBagConstraints.WEST).setDefaultInsets(1, 1, 1, 1); final JPanel namePanel = new JPanel(new GridBagLayout()); final JLabel typeLabel = new JLabel(UIUtil.replaceMnemonicAmpersand(GroovyBundle.message("introduce.variable.type.label"))); c.nextLine().next().weightx(0).fillCellNone(); namePanel.add(typeLabel, c); myTypeComboBox = createTypeComboBox(GroovyIntroduceParameterUtil.findVar(myInfo), GroovyIntroduceParameterUtil.findExpr(myInfo), findStringPart()); c.next().weightx(1).fillCellHorizontally(); namePanel.add(myTypeComboBox, c); typeLabel.setLabelFor(myTypeComboBox); final JLabel nameLabel = new JLabel(UIUtil.replaceMnemonicAmpersand(GroovyBundle.message("introduce.variable.name.label"))); c.nextLine().next().weightx(0).fillCellNone(); namePanel.add(nameLabel, c); myNameSuggestionsField = createNameField(GroovyIntroduceParameterUtil.findVar(myInfo)); c.next().weightx(1).fillCellHorizontally(); namePanel.add(myNameSuggestionsField, c); nameLabel.setLabelFor(myNameSuggestionsField); GrTypeComboBox.registerUpDownHint(myNameSuggestionsField, myTypeComboBox); return namePanel; } | createNamePanel |
30,863 | void (JPanel panel) { myDeclareFinalCheckBox = new JCheckBox(UIUtil.replaceMnemonicAmpersand(GroovyBundle.message( "introduce.variable.declare.final.label"))); myDeclareFinalCheckBox.setFocusable(false); panel.add(myDeclareFinalCheckBox); myDelegateViaOverloadingMethodCheckBox = new JCheckBox(UIUtil.replaceMnemonicAmpersand( GroovyBundle.message("introduce.parameter.delegate.via.overload") )); myDelegateViaOverloadingMethodCheckBox.setFocusable(false); panel.add(myDelegateViaOverloadingMethodCheckBox); for (JCheckBox cb : toRemoveCBs.keySet()) { cb.setFocusable(false); panel.add(cb); } } | createCheckBoxes |
30,864 | GrTypeComboBox (GrVariable var, GrExpression expr, StringPartInfo stringPartInfo) { GrTypeComboBox box; if (var != null) { box = GrTypeComboBox.createTypeComboBoxWithDefType(var.getDeclaredType(), var); } else if (expr != null) { box = GrTypeComboBox.createTypeComboBoxFromExpression(expr); } else if (stringPartInfo != null) { box = GrTypeComboBox.createTypeComboBoxFromExpression(stringPartInfo.getLiteral()); } else { box = GrTypeComboBox.createEmptyTypeComboBox(); } box.addClosureTypesFrom(inferClosureReturnType(), myInfo.getContext()); if (expr == null && var == null && stringPartInfo == null) { box.setSelectedIndex(box.getItemCount() - 1); } return box; } | createTypeComboBox |
30,865 | PsiType () { final ExtractClosureHelperImpl mockHelper = new ExtractClosureHelperImpl(myInfo, "__test___n_", false, new IntArrayList(), false, IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false); return WriteAction.compute(() -> ExtractClosureProcessorBase.generateClosure(mockHelper).getReturnType()); } | inferClosureReturnType |
30,866 | NameSuggestionsField (GrVariable var) { List<String> names = new ArrayList<>(); if (var != null) { names.add(var.getName()); } names.addAll(suggestNames()); return new NameSuggestionsField(ArrayUtilRt.toStringArray(names), myProject, GroovyFileType.GROOVY_FILE_TYPE); } | createNameField |
30,867 | void (JavaRefactoringSettings settings) { final PsiField[] usedFields = GroovyIntroduceParameterUtil.findUsedFieldsWithGetters(myInfo.getStatements(), getContainingClass()); myGetterPanel.setVisible(usedFields.length > 0); switch (settings.INTRODUCE_PARAMETER_REPLACE_FIELDS_WITH_GETTERS) { case IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL -> myReplaceAllFieldsRadioButton.setSelected(true); case IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE -> myReplaceFieldsInaccessibleInRadioButton.setSelected(true); case IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE -> myDoNotReplaceRadioButton.setSelected(true); } } | initReplaceFieldsWithGetters |
30,868 | void () { StringBuilder b = new StringBuilder(); b.append("{ "); String[] params = ExtractUtil.getParameterString(myInfo, false); for (int i = 0; i < params.length; i++) { if (i > 0) { b.append(" "); } b.append(params[i]); b.append('\n'); } b.append(" ->\n}"); mySignature.setSignature(b.toString()); } | updateSignature |
30,869 | ValidationInfo () { final String text = getEnteredName(); if (!GroovyNamesUtil.isIdentifier(text)) { return new ValidationInfo(GroovyRefactoringBundle.message("name.is.wrong", text), myNameSuggestionsField); } if (myTypeComboBox.isClosureSelected()) { final Ref<ValidationInfo> info = new Ref<>(); for (Object2IntMap.Entry<JCheckBox> entry : toRemoveCBs.object2IntEntrySet()) { if (!entry.getKey().isSelected()) { continue; } final GrParameter param = myInfo.getToReplaceIn().getParameters()[entry.getIntValue()]; final ParameterInfo pinfo = findParamByOldName(param.getName()); if (pinfo == null || !pinfo.passAsParameter) { continue; } final String message = GroovyRefactoringBundle .message("you.cannot.pass.as.parameter.0.because.you.remove.1.from.base.method", pinfo.getName(), param.getName()); info.set(new ValidationInfo(message)); break; } if (info.get() != null) { return info.get(); } } return null; } | doValidate |
30,870 | ParameterInfo (String name) { for (ParameterInfo info : myInfo.getParameterInfos()) { if (name.equals(info.getOriginalName())) return info; } return null; } | findParamByOldName |
30,871 | PsiClass () { final GrParameterListOwner toReplaceIn = myInfo.getToReplaceIn(); if (toReplaceIn instanceof GrMethod) { return ((GrMethod)toReplaceIn).getContainingClass(); } else { return PsiTreeUtil.getContextOfType(toReplaceIn, PsiClass.class); } } | getContainingClass |
30,872 | boolean () { final Boolean createFinals = JavaRefactoringSettings.getInstance().INTRODUCE_PARAMETER_CREATE_FINALS; return createFinals == null ? JavaCodeStyleSettings.getInstance(myFile).GENERATE_FINAL_PARAMETERS : createFinals.booleanValue(); } | hasFinalModifier |
30,873 | void () { saveSettings(); super.doOKAction(); final GrParameterListOwner toReplaceIn = myInfo.getToReplaceIn(); final GrExpression expr = GroovyIntroduceParameterUtil.findExpr(myInfo); final GrVariable var = GroovyIntroduceParameterUtil.findVar(myInfo); final StringPartInfo stringPart = findStringPart(); if (myTypeComboBox.isClosureSelected() || expr == null && var == null && stringPart == null) { GrIntroduceParameterSettings settings = new ExtractClosureHelperImpl(myInfo, getEnteredName(), myDeclareFinalCheckBox.isSelected(), getParametersToRemove(), myDelegateViaOverloadingMethodCheckBox.isSelected(), getReplaceFieldsWithGetter(), myForceReturnCheckBox.isSelected(), false, myTypeComboBox.getSelectedType() == null); if (toReplaceIn instanceof GrMethod) { invokeRefactoring(new ExtractClosureFromMethodProcessor(settings)); } else { invokeRefactoring(new ExtractClosureFromClosureProcessor(settings)); } } else { GrIntroduceParameterSettings settings = new GrIntroduceExpressionSettingsImpl(myInfo, getEnteredName(), myDeclareFinalCheckBox.isSelected(), getParametersToRemove(), myDelegateViaOverloadingMethodCheckBox.isSelected(), getReplaceFieldsWithGetter(), expr, var, myTypeComboBox.getSelectedType(), var != null, true, myForceReturnCheckBox.isSelected()); if (toReplaceIn instanceof GrMethod) { invokeRefactoring(new GrIntroduceParameterProcessor(settings)); } else { invokeRefactoring(new GrIntroduceClosureParameterProcessor(settings)); } } } | doOKAction |
30,874 | String () { return myNameSuggestionsField.getEnteredName(); } | getEnteredName |
30,875 | void () { final JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance(); settings.INTRODUCE_PARAMETER_CREATE_FINALS = myDeclareFinalCheckBox.isSelected(); if (myGetterPanel.isVisible()) { settings.INTRODUCE_PARAMETER_REPLACE_FIELDS_WITH_GETTERS = getReplaceFieldsWithGetter(); } if (myForceReturnCheckBox.isEnabled() && mySignaturePanel.isVisible()) { GroovyApplicationSettings.getInstance().FORCE_RETURN = myForceReturnCheckBox.isSelected(); } } | saveSettings |
30,876 | void (BaseRefactoringProcessor processor) { final Runnable prepareSuccessfulCallback = () -> close(DialogWrapper.OK_EXIT_CODE); processor.setPrepareSuccessfulSwingThreadCallback(prepareSuccessfulCallback); processor.setPreviewUsages(false); processor.run(); } | invokeRefactoring |
30,877 | LinkedHashSet<String> () { GrVariable var = GroovyIntroduceParameterUtil.findVar(myInfo); GrExpression expr = GroovyIntroduceParameterUtil.findExpr(myInfo); StringPartInfo stringPart = findStringPart(); return GroovyIntroduceParameterUtil.suggestNames(var, expr, stringPart, myInfo.getToReplaceIn(), myProject); } | suggestNames |
30,878 | int () { if (myDoNotReplaceRadioButton.isSelected()) return IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE; if (myReplaceFieldsInaccessibleInRadioButton.isSelected()) return IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE; if (myReplaceAllFieldsRadioButton.isSelected()) return IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL; throw new GrRefactoringError("no check box selected"); } | getReplaceFieldsWithGetter |
30,879 | JComponent () { return myNameSuggestionsField; } | getPreferredFocusedComponent |
30,880 | String () { return HelpID.GROOVY_INTRODUCE_PARAMETER; } | getHelpId |
30,881 | IntList () { IntList list=new IntArrayList(); for (JCheckBox o : toRemoveCBs.keySet()) { if (o.isSelected()) { list.add(toRemoveCBs.getInt(o)); } } return list; } | getParametersToRemove |
30,882 | StringPartInfo () { return myInfo.getStringPartInfo(); } | findStringPart |
30,883 | void (@NotNull final Project project, final Editor editor, final PsiFile file, @Nullable final DataContext dataContext) { if (editor == null || file == null) return; final SelectionModel selectionModel = editor.getSelectionModel(); if (!selectionModel.hasSelection()) { final int offset = editor.getCaretModel().getOffset(); final List<GrExpression> expressions = GrIntroduceHandlerBase.collectExpressions(file, editor, offset, false); if (expressions.isEmpty()) { GrIntroduceHandlerBase.updateSelectionForVariable(editor, file, selectionModel, offset); } else if (expressions.size() == 1 || ApplicationManager.getApplication().isUnitTestMode()) { final TextRange textRange = expressions.get(0).getTextRange(); selectionModel.setSelection(textRange.getStartOffset(), textRange.getEndOffset()); } else { IntroduceTargetChooser.showChooser(editor, expressions, new Pass<>() { @Override public void pass(final GrExpression selectedValue) { invoke(project, editor, file, selectedValue.getTextRange().getStartOffset(), selectedValue.getTextRange().getEndOffset()); } }, grExpression -> grExpression.getText() ); return; } } invoke(project, editor, file, selectionModel.getSelectionStart(), selectionModel.getSelectionEnd()); } | invoke |
30,884 | void (final GrExpression selectedValue) { invoke(project, editor, file, selectedValue.getTextRange().getStartOffset(), selectedValue.getTextRange().getEndOffset()); } | pass |
30,885 | void (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file, int startOffset, int endOffset) { try { final InitialInfo initialInfo = GroovyExtractChooser.invoke(project, editor, file, startOffset, endOffset, false); chooseScopeAndRun(initialInfo, editor); } catch (GrRefactoringError e) { if (ApplicationManager.getApplication().isUnitTestMode()) throw e; CommonRefactoringUtil.showErrorHint(project, editor, e.getMessage(), RefactoringBundle.message("introduce.parameter.title"), HelpID.GROOVY_INTRODUCE_PARAMETER); } } | invoke |
30,886 | void (@NotNull final InitialInfo initialInfo, @NotNull final Editor editor) { final List<GrParameterListOwner> scopes = findScopes(initialInfo); if (scopes.isEmpty()) { throw new GrRefactoringError(GroovyRefactoringBundle.message("there.is.no.method.or.closure")); } else if (scopes.size() == 1 || ApplicationManager.getApplication().isUnitTestMode()) { final GrParameterListOwner owner = scopes.get(0); final PsiElement toSearchFor; if (owner instanceof GrMethod) { toSearchFor = SuperMethodWarningUtil.checkSuperMethod((PsiMethod)owner); if (toSearchFor == null) return; //if it is null, refactoring was canceled } else { toSearchFor = MethodOrClosureScopeChooser.findVariableToUse(owner); } showDialogOrStartInplace(new IntroduceParameterInfoImpl(initialInfo, owner, toSearchFor), editor); } else { myEnclosingMethodsPopup = MethodOrClosureScopeChooser.create(scopes, editor, this, (owner, element) -> { showDialogOrStartInplace(new IntroduceParameterInfoImpl(initialInfo, owner, element), editor); return null; }); myEnclosingMethodsPopup.showInBestPositionFor(editor); } } | chooseScopeAndRun |
30,887 | List<GrParameterListOwner> (@NotNull InitialInfo initialInfo) { PsiElement place = initialInfo.getContext(); final List<GrParameterListOwner> scopes = new ArrayList<>(); while (true) { final GrParameterListOwner parent = PsiTreeUtil.getParentOfType(place, GrParameterListOwner.class); if (parent == null) break; scopes.add(parent); place = parent; } return scopes; } | findScopes |
30,888 | JBPopup () { return myEnclosingMethodsPopup; } | get |
30,889 | void (@NotNull final IntroduceParameterInfo info, @NotNull final Editor editor) { if (isInplace(info, editor)) { final GrIntroduceContext context = createContext(info, editor); Map<OccurrencesChooser.ReplaceChoice, List<Object>> occurrencesMap = GrIntroduceHandlerBase.fillChoice(context); new IntroduceOccurrencesChooser(editor).showChooser(occurrencesMap,choice -> startInplace(info, context, choice)); } else { showDialog(info); } } | showDialogOrStartInplace |
30,890 | void (IntroduceParameterInfo info) { new GrIntroduceParameterDialog(info).show(); } | showDialog |
30,891 | void (@NotNull final IntroduceParameterInfo info, @NotNull final GrIntroduceContext context, OccurrencesChooser.ReplaceChoice replaceChoice) { new GrInplaceParameterIntroducer(info, context, replaceChoice).startInplaceIntroduceTemplate(); } | startInplace |
30,892 | boolean (@NotNull IntroduceParameterInfo info, @NotNull Editor editor) { return GroovyIntroduceParameterUtil.findExpr(info) != null && info.getToReplaceIn() instanceof GrMethod && info.getToSearchFor() instanceof PsiMethod && GrIntroduceHandlerBase.isInplace(editor, info.getContext()); } | isInplace |
30,893 | void (@NotNull Project project, PsiElement @NotNull [] elements, DataContext dataContext) { // Does nothing } | invoke |
30,894 | GrIntroduceContext (@NotNull IntroduceParameterInfo info, @NotNull Editor editor) { GrExpression expr = GroovyIntroduceParameterUtil.findExpr(info); GrVariable var = GroovyIntroduceParameterUtil.findVar(info); StringPartInfo stringPart = info.getStringPartInfo(); return new GrIntroduceVariableHandler().getContext(info.getProject(), editor, expr, var, stringPart, info.getToReplaceIn()); } | createContext |
30,895 | GrExpressionWrapper (GrIntroduceParameterSettings settings) { LOG.assertTrue(settings.getToReplaceIn() instanceof GrMethod); LOG.assertTrue(settings.getToSearchFor() instanceof PsiMethod); final StringPartInfo stringPartInfo = settings.getStringPartInfo(); GrVariable var = settings.getVar(); final GrExpression expression = stringPartInfo != null ? stringPartInfo.createLiteralFromSelected() : var != null ? var.getInitializerGroovy() : settings.getExpression(); return new GrExpressionWrapper(expression); } | createExpressionWrapper |
30,896 | UsageViewDescriptor (final UsageInfo @NotNull [] usages) { return new UsageViewDescriptorAdapter() { @Override public PsiElement @NotNull [] getElements() { return new PsiElement[]{mySettings.getToSearchFor()}; } @Override public String getProcessedElementsHeader() { return JavaRefactoringBundle.message("introduce.parameter.elements.header"); } }; } | createUsageViewDescriptor |
30,897 | String () { return JavaRefactoringBundle.message("introduce.parameter.elements.header"); } | getProcessedElementsHeader |
30,898 | boolean (@NotNull Ref<UsageInfo[]> refUsages) { UsageInfo[] usagesIn = refUsages.get(); MultiMap<PsiElement, String> conflicts = new MultiMap<>(); if (!mySettings.generateDelegate()) { GroovyIntroduceParameterUtil.detectAccessibilityConflicts(mySettings.getExpression(), usagesIn, conflicts, mySettings.replaceFieldsWithGetters() != IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, myProject ); } final GrMethod toReplaceIn = (GrMethod)mySettings.getToReplaceIn(); if (mySettings.getExpression() != null && !toReplaceIn.hasModifierProperty(PsiModifier.PRIVATE)) { final AnySupers anySupers = new AnySupers(); mySettings.getExpression().accept(anySupers); if (anySupers.containsSupers()) { for (UsageInfo usageInfo : usagesIn) { if (!(usageInfo.getElement() instanceof PsiMethod) && !(usageInfo instanceof InternalUsageInfo)) { if (!PsiTreeUtil.isAncestor(toReplaceIn.getContainingClass(), usageInfo.getElement(), false)) { conflicts.putValue(mySettings.getExpression(), JavaRefactoringBundle.message("parameter.initializer.contains.0.but.not.all.calls.to.method.are.in.its.class", CommonRefactoringUtil.htmlEmphasize(PsiKeyword.SUPER))); break; } } } } } for (IntroduceParameterMethodUsagesProcessor processor : IntroduceParameterMethodUsagesProcessor.EP_NAME.getExtensions()) { processor.findConflicts(this, refUsages.get(), conflicts); } return showConflicts(conflicts, usagesIn); } | preprocessUsages |
30,899 | void (UsageInfo @NotNull [] usages) { GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(myProject); //PsiType initializerType = mySettings.getSelectedType(); // Changing external occurrences (the tricky part) IntroduceParameterUtil.processUsages(usages, this); final GrMethod toReplaceIn = (GrMethod)mySettings.getToReplaceIn(); final PsiMethod toSearchFor = (PsiMethod)mySettings.getToSearchFor(); final boolean methodsToProcessAreDifferent = toReplaceIn != toSearchFor; if (mySettings.generateDelegate()) { generateDelegate(toReplaceIn, toSearchFor, methodsToProcessAreDifferent); } // Changing signature of initial method // (signature of myMethodToReplaceIn will be either changed now or have already been changed) //LOG.assertTrue(initializerType == null || initializerType.isValid()); final FieldConflictsResolver fieldConflictsResolver = new FieldConflictsResolver(mySettings.getName(), toReplaceIn.getBlock()); processMethodSignature(usages, toReplaceIn, toSearchFor, methodsToProcessAreDifferent); processUsages(usages, factory); processStringPart(); processVar(); fieldConflictsResolver.fix(); } | performRefactoring |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.