Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
31,000
String () { return HelpID.INTRODUCE_VARIABLE; }
getHelpID
31,001
GroovyIntroduceVariableDialog (@NotNull GrIntroduceContext context) { final GroovyVariableValidator validator = new GroovyVariableValidator(context); return new GroovyIntroduceVariableDialog(context, validator); }
getDialog
31,002
void () { super.init(); setModal(true); setTitle(GroovyRefactoringBundle.message("introduce.variable.title")); myCbReplaceAllOccurrences.setFocusable(false); myCbIsFinal.setFocusable(false); myCbIsFinal.setSelected(GroovyApplicationSettings.getInstance().INTRODUCE_LOCAL_CREATE_FINALS); // Replace occurrences if (myOccu...
init
31,003
JComponent () { JPanel contentPane = new JPanel(new BorderLayout()); contentPane.add(createNamePanel(), BorderLayout.CENTER); contentPane.add(createCBPanel(), BorderLayout.SOUTH); return contentPane; }
createCenterPanel
31,004
ValidationInfo () { String text = getEnteredName(); if (!GroovyNamesUtil.isIdentifier(text)) { return new ValidationInfo(GroovyRefactoringBundle.message("name.is.wrong", text), myNameField); } return null; }
doValidate
31,005
JPanel () { final JPanel panel = new JPanel(new FlowLayout()); myCbIsFinal = new JCheckBox(UIUtil.replaceMnemonicAmpersand( GroovyBundle.message("introduce.variable.declare.final.label") )); panel.add(myCbIsFinal); myCbReplaceAllOccurrences = new JCheckBox(UIUtil.replaceMnemonicAmpersand( GroovyBundle.message("introduc...
createCBPanel
31,006
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().w...
createNamePanel
31,007
String () { return myNameField.getEnteredName(); }
getEnteredName
31,008
boolean () { return myCbReplaceAllOccurrences.isSelected(); }
isReplaceAllOccurrences
31,009
boolean () { return myCbIsFinal.isSelected(); }
isDeclareFinal
31,010
PsiType () { return myTypeComboBox.getSelectedType(); }
getSelectedType
31,011
NameSuggestionsField () { LinkedHashSet<String> names = suggestNames(); return new NameSuggestionsField(ArrayUtilRt.toStringArray(names), myProject, GroovyFileType.GROOVY_FILE_TYPE); }
setUpNameComboBox
31,012
JComponent () { return myNameField; }
getPreferredFocusedComponent
31,013
void () { if (!myValidator.isOK(this)) { return; } if (myCbIsFinal.isEnabled()) { GroovyApplicationSettings.getInstance().INTRODUCE_LOCAL_CREATE_FINALS = myCbIsFinal.isSelected(); } GroovyApplicationSettings.getInstance().INTRODUCE_LOCAL_SELECT_DEF = (myTypeComboBox.getSelectedType() == null); super.doOKAction(); }
doOKAction
31,014
String () { return HelpID.INTRODUCE_VARIABLE; }
getHelpId
31,015
void () { }
createUIComponents
31,016
GroovyIntroduceVariableSettings () { return new MyGroovyIntroduceVariableSettings(this); }
getSettings
31,017
LinkedHashSet<String> () { return new GrVariableNameSuggester(myContext, myValidator).suggestNames(); }
suggestNames
31,018
String () { return myEnteredName; }
getName
31,019
boolean () { return myIsReplaceAllOccurrences; }
replaceAllOccurrences
31,020
boolean () { return myIsDeclareFinal; }
isDeclareFinal
31,021
PsiType () { return mySelectedType; }
getSelectedType
31,022
String () { return GrIntroduceVariableHandler.getRefactoringNameText(); }
getActionName
31,023
JComponent () { myCanBeFinalCb = new NonFocusableCheckBox(GroovyRefactoringBundle.message("declare.final.checkbox")); myCanBeFinalCb.setSelected(false); myCanBeFinalCb.setMnemonic(KeyEvent.VK_F); final GrFinalListener finalListener = new GrFinalListener(myEditor); myCanBeFinalCb.addActionListener(new ActionListener() {...
getComponent
31,024
void (ActionEvent e) { WriteCommandAction.writeCommandAction(myProject).withName(getCommandName()).withGroupId(getCommandName()).run(() -> { PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.getDocument()); final GrVariable variable = getVariable(); if (variable != null) { finalListener.perform(myCanBeF...
actionPerformed
31,025
GroovyIntroduceVariableSettings (@NotNull final GrIntroduceContext context, @NotNull final OccurrencesChooser.ReplaceChoice choice, final String[] names) { return new GroovyIntroduceVariableSettings() { private final CanonicalTypes.Type myType; { GrExpression expression = context.getExpression(); StringPartInfo stringP...
getInitialSettingsForInplace
31,026
boolean () { return myCanBeFinalCb != null ? myCanBeFinalCb.isSelected() : false; }
isDeclareFinal
31,027
String () { return names[0]; }
getName
31,028
boolean () { return choice == OccurrencesChooser.ReplaceChoice.ALL; }
replaceAllOccurrences
31,029
PsiType () { return myType != null ? myType.getType(context.getPlace()) : null; }
getSelectedType
31,030
void (TemplateBuilderImpl builder) { GrVariable variable = getVariable(); assert variable != null && variable.getInitializerGroovy() != null; final PsiType initializerType = variable.getInitializerGroovy().getType(); TypeConstraint[] constraints = initializerType != null && !initializerType.equals(PsiTypes.nullType()) ...
addAdditionalVariables
31,031
PsiElement (@NotNull GrVariable variable) { GrTypeElement typeElement = variable.getTypeElementGroovy(); if (typeElement != null) return typeElement; GrModifierList modifierList = variable.getModifierList(); if (modifierList != null) return modifierList.getModifier(GrModifier.DEF); return null; }
getTypeELementOrDef
31,032
GroovyIntroduceVariableSettings () { return new GroovyIntroduceVariableSettings() { @Override public boolean isDeclareFinal() { return myCanBeFinalCb.isSelected(); } @Nullable @Override public String getName() { return GrInplaceVariableIntroducer.this.getInputName(); } @Override public boolean replaceAllOccurrences() {...
getSettings
31,033
boolean () { return myCanBeFinalCb.isSelected(); }
isDeclareFinal
31,034
String () { return GrInplaceVariableIntroducer.this.getInputName(); }
getName
31,035
boolean () { return isReplaceAllOccurrences(); }
replaceAllOccurrences
31,036
PsiType () { return GrInplaceVariableIntroducer.this.getSelectedType(); }
getSelectedType
31,037
void (@NotNull GrVariable variable) { GroovyApplicationSettings.getInstance().INTRODUCE_LOCAL_SELECT_DEF = variable.getDeclaredType() == null; }
saveSettings
31,038
int () { return getVariable().getNameIdentifierGroovy().getTextRange().getEndOffset(); }
getCaretOffset
31,039
LinkedHashSet<String> () { GrExpression expression = myContext.getExpression() != null ? myContext.getExpression() : myContext.getStringPart().getLiteral(); return new LinkedHashSet<>(Arrays.asList(GroovyNameSuggestionUtil.suggestVariableNames(expression, myValidator))); }
suggestNames
31,040
void (PsiElement element, MultiMap<PsiElement, String> conflicts, String varName) { if (!(element instanceof GrVariable var)) return; if (var instanceof GrField) return; if (var instanceof GrParameter && varName.equals(var.getName())) { conflicts.putValue(var, GroovyRefactoringBundle .message("introduced.variable.confl...
check
31,041
GrVariable (@NotNull GrVariableDeclaration declaration) { resolveLocalConflicts(myContext.getScope(), mySettings.getName()); preprocessOccurrences(); int expressionIndex = ArrayUtilRt.find(myOccurrences, myExpression); final PsiElement[] replaced = myProcessUsages ? processOccurrences() : myOccurrences; PsiElement repl...
processExpression
31,042
boolean (GrStatement statement) { return statement.getParent() instanceof GrLoopStatement && statement == ((GrLoopStatement)statement.getParent()).getBody() || statement.getParent() instanceof GrIfStatement && (statement == ((GrIfStatement)statement.getParent()).getThenBranch() || statement == ((GrIfStatement)statement...
isControlStatementBranch
31,043
PsiElement[] () { List<PsiElement> result = new ArrayList<>(); GrReferenceExpression templateRef = GroovyPsiElementFactory.getInstance(myContext.getProject()).createReferenceExpressionFromText(mySettings.getName()); for (PsiElement occurrence : myOccurrences) { if (!(occurrence instanceof GrExpression)) { throw new Inc...
processOccurrences
31,044
GrExpression () { GroovyRefactoringUtil.sortOccurrences(myOccurrences); if (myOccurrences.length == 0 || !(myOccurrences[0] instanceof GrExpression)) { throw new IncorrectOperationException("Wrong expression occurrence"); } return (GrExpression)myOccurrences[0]; }
preprocessOccurrences
31,045
void (@NotNull PsiElement tempContainer, @NotNull String varName) { for (PsiElement child : tempContainer.getChildren()) { if (child instanceof GrReferenceExpression && !child.getText().contains(".")) { PsiReference psiReference = child.getReference(); if (psiReference != null) { final PsiElement resolved = psiReferenc...
resolveLocalConflicts
31,046
GrStatement (@NotNull GrStatement anchor) { GrBlockStatement blockStatement = GroovyPsiElementFactory.getInstance(anchor.getProject()).createBlockStatement(); blockStatement.getBlock().addStatementBefore(anchor, null); GrBlockStatement newBlockStatement = ((GrBlockStatement)anchor.replace(blockStatement)); return newBl...
insertBraces
31,047
boolean (PsiElement expression) { PsiElement parent = expression.getParent(); return parent instanceof GrClosableBlock && parent.getParent() instanceof GrStringInjection; }
isSingleGStringInjectionExpr
31,048
String (@Nullable PsiElement element) { if (element instanceof GrAccessorMethod) element = ((GrAccessorMethod)element).getProperty(); return element instanceof GrField ? ((GrField)element).getName() : null; }
getFieldName
31,049
GrField () { final PsiClass targetClass = settings.getTargetClass(); if (targetClass == null) return null; if (checkErrors(targetClass)) { return null; } final GrVariableDeclaration declaration = addDeclaration(targetClass); final GrField field = (GrField)declaration.getVariables()[0]; GrVariable localVar = GrIntroduce...
run
31,050
void (GrField field) { final PsiElement[] occurrences = context.getOccurrences(); GroovyRefactoringUtil.sortOccurrences(occurrences); for (PsiElement occurrence : occurrences) { replaceOccurrence(field, occurrence, isEscalateVisibility()); } }
processOccurrences
31,051
void (PsiElement element) { context.getEditor().getCaretModel().moveToOffset(element.getTextRange().getEndOffset()); context.getEditor().getSelectionModel().removeSelection(); }
updateCaretPosition
31,052
GrVariableDeclaration (PsiClass targetClass) { GrVariableDeclaration declaration = createField(targetClass); final GrVariableDeclaration added; if (targetClass instanceof GrEnumTypeDefinition) { final GrEnumConstantList enumConstants = ((GrEnumTypeDefinition)targetClass).getEnumConstantList(); added = (GrVariableDeclar...
addDeclaration
31,053
boolean (@NotNull PsiClass targetClass) { String fieldName = settings.getName(); String errorString = check(targetClass, fieldName); if (errorString != null) { String message = RefactoringBundle.getCannotRefactorMessage(errorString); CommonRefactoringUtil .showErrorMessage(GroovyBundle.message("introduce.constant.title...
checkErrors
31,054
PsiElement (@NotNull GrField field, @NotNull PsiElement occurrence, boolean escalateVisibility) { boolean isOriginal = occurrence == context.getExpression(); final GrReferenceExpression newExpr = createRefExpression(field, occurrence); final PsiElement replaced = occurrence instanceof GrExpression ? ((GrExpression)occu...
replaceOccurrence
31,055
GrReferenceExpression (@NotNull GrField field, @NotNull PsiElement place) { final PsiClass containingClass = field.getContainingClass(); assert containingClass != null; final String qname = containingClass.getQualifiedName(); final String fieldName = field.getName(); final String refText = qname != null && !qname.equal...
createRefExpression
31,056
GrExpression () { GrVariable var = GrIntroduceHandlerBase.resolveLocalVar(context); GrExpression expression = context.getExpression(); if (var != null) { return var.getInitializerGroovy(); } else if (expression != null) { return expression; } else { return context.getStringPart().createLiteralFromSelected(); } }
getInitializer
31,057
boolean () { return VisibilityUtil.ESCALATE_VISIBILITY.equals(settings.getVisibilityModifier()); }
isEscalateVisibility
31,058
PsiClass (PsiElement occurrence) { PsiElement cur = occurrence; while (true) { final PsiClass parentClass = PsiTreeUtil.getParentOfType(cur, PsiClass.class, true); if (parentClass == null || parentClass.hasModifierProperty(PsiModifier.STATIC)) return parentClass; cur = parentClass; } }
getParentClass
31,059
JComponent () { return myNameField; }
getPreferredFocusedComponent
31,060
JComponent () { return null; }
createCenterPanel
31,061
JComponent () { initializeName(); initializeTargetClassEditor(); if (GrIntroduceHandlerBase.resolveLocalVar(myContext) != null) { myReplaceAllOccurrences.setEnabled(false); myReplaceAllOccurrences.setSelected(true); } else if (myContext.getOccurrences().length < 2) { myReplaceAllOccurrences.setVisible(false); } return ...
createNorthPanel
31,062
void () { myTargetClassEditor = new ReferenceEditorComboWithBrowseButton(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myContext.getProject()) .createWithInnerClassesScopeChooser(RefactoringBundle.message("choose.destination....
initializeTargetClassEditor
31,063
void (ActionEvent e) { TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myContext.getProject()) .createWithInnerClassesScopeChooser(RefactoringBundle.message("choose.destination.class"), GlobalSearchScope.projectScope(myContext.getProject()), new ClassFilter() { @Override public boolean isAccepted(PsiClas...
actionPerformed
31,064
boolean (PsiClass aClass) { return aClass.getParent() instanceof GroovyFile || aClass.hasModifierProperty(PsiModifier.STATIC); }
isAccepted
31,065
void (@NotNull DocumentEvent e) { targetClassChanged(); updateOkStatus(); // enableEnumDependant(introduceEnumConstant()); }
documentChanged
31,066
void () { myNameLabel.setLabelFor(myNameField); myPanel.registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myNameField, true)); } }, KeyStroke.getKeyStroke(...
initializeName
31,067
void (ActionEvent e) { IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myNameField, true)); }
actionPerformed
31,068
String () { return myJavaVisibilityPanel.getVisibility(); }
getVisibilityModifier
31,069
PsiClass () { return myTargetClassInfo.getTargetClass(); }
getTargetClass
31,070
String () { return myTargetClassEditor.getText(); }
getTargetClassName
31,071
GrIntroduceConstantSettings () { return this; }
getSettings
31,072
LinkedHashSet<String> () { return new GrFieldNameSuggester(myContext, new GroovyVariableValidator(myContext), true).suggestNames(); }
suggestNames
31,073
String () { return myNameField.getEnteredName(); }
getName
31,074
boolean () { return myReplaceAllOccurrences.isSelected(); }
replaceAllOccurrences
31,075
PsiType () { return myTypeCombo.getSelectedType(); }
getSelectedType
31,076
void () { myJavaVisibilityPanel = new JavaVisibilityPanel(false, true); final GrVariable var = myContext.getVar(); final GrExpression expression = myContext.getExpression(); final StringPartInfo stringPart = myContext.getStringPart(); if (expression != null) { myTypeCombo = GrTypeComboBox.createTypeComboBoxFromExpressi...
createUIComponents
31,077
void () { final String targetClassName = getTargetClassName(); myTargetClass = JavaPsiFacade.getInstance(myContext.getProject()).findClass(targetClassName, GlobalSearchScope.projectScope(myContext.getProject())); updateVisibilityPanel(); // myIntroduceEnumConstantCb.setEnabled(EnumConstantsUtil.isSuitableForEnumConstan...
targetClassChanged
31,078
void () { if (myTargetClass != null && myTargetClass.isInterface()) { myJavaVisibilityPanel.disableAllButPublic(); } else { UIUtil.setEnabled(myJavaVisibilityPanel, true, true); // exclude all modifiers not visible from all occurrences final Set<String> visible = new HashSet<>(); visible.add(PsiModifier.PRIVATE); visib...
updateVisibilityPanel
31,079
void () { if (myTargetClassEditor == null) return; //dialog is not initialized yet String text = getName(); if (!GroovyNamesUtil.isIdentifier(text)) { setOKActionEnabled(false); return; } final String targetClassName = myTargetClassEditor.getText(); if (targetClassName.trim().isEmpty() && myDefaultTargetClass == null) ...
updateOkStatus
31,080
void () { final String targetClassName = getTargetClassName(); if (myDefaultTargetClass == null || !targetClassName.isEmpty() && !Comparing.strEqual(targetClassName, myDefaultTargetClass.getQualifiedName())) { final Module module = ModuleUtilCore.findModuleForPsiElement(myContext.getPlace()); JavaPsiFacade facade = Jav...
doOKAction
31,081
PsiClass () { if (myTargetClass == null) { myTargetClass = getTargetClass(myQualifiedName, myBaseDirectory, myProject, myModule); } return myTargetClass; }
getTargetClass
31,082
PsiClass (String qualifiedName, PsiDirectory baseDirectory, Project project, Module module) { GlobalSearchScope scope = GlobalSearchScope.projectScope(project); PsiClass targetClass = JavaPsiFacade.getInstance(project).findClass(qualifiedName, scope); if (targetClass != null) return targetClass; final String packageNam...
getTargetClass
31,083
String () { return GroovyBundle.message("introduce.constant.title"); }
getActionName
31,084
JComponent () { return myPanel.getRootPane(); }
getComponent
31,085
void (@NotNull GrVariable variable) { }
saveSettings
31,086
GrVariable (GrIntroduceContext context, GrIntroduceConstantSettings settings, boolean processUsages) { return refactorInWriteAction(() -> { if (processUsages) { return new GrIntroduceConstantProcessor(context, settings).run(); } else { PsiElement scope = context.getScope(); return new GrIntroduceConstantProcessor(conte...
runRefactoring
31,087
GrIntroduceConstantSettings (@NotNull final GrIntroduceContext context, @NotNull final OccurrencesChooser.ReplaceChoice choice, final String[] names) { return new GrIntroduceConstantSettings() { @Override public String getVisibilityModifier() { return PsiModifier.PUBLIC; } @Nullable @Override public PsiClass getTargetC...
getInitialSettingsForInplace
31,088
String () { return PsiModifier.PUBLIC; }
getVisibilityModifier
31,089
PsiClass () { return (PsiClass)context.getScope(); }
getTargetClass
31,090
String () { return names[0]; }
getName
31,091
boolean () { return isReplaceAllOccurrences(); }
replaceAllOccurrences
31,092
PsiType () { GrExpression expression = context.getExpression(); GrVariable var = context.getVar(); StringPartInfo stringPart = context.getStringPart(); return var != null ? var.getDeclaredType() : expression != null ? expression.getType() : stringPart != null ? stringPart.getLiteral().getType() : null; }
getSelectedType
31,093
GrIntroduceConstantSettings () { return new GrIntroduceConstantSettings() { @Override public String getVisibilityModifier() { return PsiModifier.PUBLIC; } @Nullable @Override public String getName() { return getInputName(); } @Override public boolean replaceAllOccurrences() { return isReplaceAllOccurrences(); } @Nullab...
getSettings
31,094
String () { return PsiModifier.PUBLIC; }
getVisibilityModifier
31,095
String () { return getInputName(); }
getName
31,096
boolean () { return isReplaceAllOccurrences(); }
replaceAllOccurrences
31,097
PsiType () { return GrInplaceConstantIntroducer.this.getSelectedType(); }
getSelectedType
31,098
PsiClass () { return (PsiClass)myContext.getScope(); }
getTargetClass
31,099
PsiElement () { return ((PsiField)getVariable()).getContainingClass(); }
checkLocalScope