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 (myOccurrencesCount > 1) { myCbReplaceAllOccurrences.setSelected(false); myCbReplaceAllOccurrences.setEnabled(true); myCbReplaceAllOccurrences.setText(UIUtil.replaceMnemonicAmpersand( GroovyBundle.message("introduce.variable.replace.all.0.occurrences", myOccurrencesCount) )); } else { myCbReplaceAllOccurrences.setSelected(false); myCbReplaceAllOccurrences.setEnabled(false); } pack(); } | 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("introduce.variable.replace.all.occurrences") )); panel.add(myCbReplaceAllOccurrences); return panel; } | 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().weightx(0).fillCellNone(); namePanel.add(typeLabel, c); myTypeComboBox = GrTypeComboBox.createTypeComboBoxFromExpression(myExpression, GroovyApplicationSettings.getInstance().INTRODUCE_LOCAL_SELECT_DEF); 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); myNameField = setUpNameComboBox(); c.next().weightx(1).fillCellHorizontally(); namePanel.add(myNameField, c); nameLabel.setLabelFor(myNameField); GrTypeComboBox.registerUpDownHint(myNameField, myTypeComboBox); return namePanel; } | 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() { @Override public void actionPerformed(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(myCanBeFinalCb.isSelected(), variable); } }); } }); final JPanel panel = new JPanel(new GridBagLayout()); panel.setBorder(null); if (myCanBeFinalCb != null) { panel.add(myCanBeFinalCb, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); } panel.add(Box.createVerticalBox(), new GridBagConstraints(0, 2, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); return panel; } | 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(myCanBeFinalCb.isSelected(), variable); } }); } | 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 stringPart = context.getStringPart(); GrVariable var = context.getVar(); PsiType type = expression != null ? expression.getType() : var != null ? var.getType() : stringPart != null ? stringPart.getLiteral().getType() : null; myType = type != null && !PsiTypes.nullType().equals(type) ? CanonicalTypes.createTypeWrapper(type) : null; } @Override public boolean isDeclareFinal() { return myCanBeFinalCb != null ? myCanBeFinalCb.isSelected() : false; } @Nullable @Override public String getName() { return names[0]; } @Override public boolean replaceAllOccurrences() { return choice == OccurrencesChooser.ReplaceChoice.ALL; } @Nullable @Override public PsiType getSelectedType() { return myType != null ? myType.getType(context.getPlace()) : null; } }; } | 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()) ? new SupertypeConstraint[]{SupertypeConstraint.create(initializerType)} : TypeConstraint.EMPTY_ARRAY; ChooseTypeExpression typeExpression = new ChooseTypeExpression(constraints, variable.getManager(), variable.getResolveScope(), true, GroovyApplicationSettings.getInstance().INTRODUCE_LOCAL_SELECT_DEF); PsiElement element = getTypeELementOrDef(variable); if (element == null) return; builder.replaceElement(element, "Variable_type", typeExpression, true, true); } | 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() { return isReplaceAllOccurrences(); } @Nullable @Override public PsiType getSelectedType() { return GrInplaceVariableIntroducer.this.getSelectedType(); } }; } | 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.conflicts.with.parameter.0", CommonRefactoringUtil.htmlEmphasize(varName))); } else if (varName.equals(var.getName())) { conflicts.putValue(var, GroovyRefactoringBundle .message("introduced.variable.conflicts.with.variable.0", CommonRefactoringUtil.htmlEmphasize(varName))); } } | 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 replacedExpression = replaced[expressionIndex]; GrStatement anchor = GrIntroduceHandlerBase.getAnchor(replaced, myContext.getScope()); RefactoringUtil.highlightAllOccurrences(myContext.getProject(), replaced, myContext.getEditor()); return insertVariableDefinition(declaration, anchor, replacedExpression); } | 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.getParent()).getElseBranch()); } | 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 IncorrectOperationException("Expression occurrence to be replaced is not instance of GroovyPsiElement"); } final GrExpression replaced = ((GrExpression)occurrence).replaceWithExpression(templateRef, true); result.add(replaced); } return PsiUtilCore.toPsiElementArray(result); } | 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 = psiReference.resolve(); if (resolved != null) { String fieldName = getFieldName(resolved); if (varName.equals(fieldName)) { GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(tempContainer.getProject()); ((GrReferenceExpression)child).replaceWithExpression(factory.createExpressionFromText("this." + child.getText()), true); } } } } else { resolveLocalConflicts(child, varName); } } } | 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 newBlockStatement.getBlock().getStatements()[0]; } | 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 = GrIntroduceHandlerBase.resolveLocalVar(context); if (localVar != null) { assert localVar.getInitializerGroovy() != null : "initializer should exist: " + localVar.getText(); GrIntroduceHandlerBase.deleteLocalVar(localVar); if (settings.replaceAllOccurrences()) { processOccurrences(field); } else { replaceOccurrence(field, localVar.getInitializerGroovy(), isEscalateVisibility()); } } else if (context.getStringPart() != null) { final GrExpression ref = context.getStringPart().replaceLiteralWithConcatenation(field.getName()); final PsiElement element = replaceOccurrence(field, ref, isEscalateVisibility()); updateCaretPosition(element); } else if (context.getExpression() != null) { if (settings.replaceAllOccurrences()) { processOccurrences(field); } else { replaceOccurrence(field, context.getExpression(), isEscalateVisibility()); } } return field; } | 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 = (GrVariableDeclaration)targetClass.addAfter(declaration, enumConstants); } else { added = ((GrVariableDeclaration)targetClass.add(declaration)); } JavaCodeStyleManager.getInstance(added.getProject()).shortenClassReferences(added); return added; } | 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"), message, HelpID.INTRODUCE_CONSTANT, context.getProject()); return true; } PsiField oldField = targetClass.findFieldByName(fieldName, true); if (oldField != null) { String message = RefactoringBundle.message("field.exists", fieldName, oldField.getContainingClass().getQualifiedName()); int answer = Messages .showYesNoDialog(context.getProject(), message, GroovyBundle.message("introduce.constant.title"), Messages.getWarningIcon()); if (answer != Messages.YES) { return true; } } return false; } | 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)occurrence).replaceWithExpression(newExpr, false) : occurrence.replace(newExpr); if (escalateVisibility) { PsiUtil.escalateVisibility(field, replaced); } if (replaced instanceof GrReferenceExpression) { GrReferenceAdjuster.shortenReference((GrReferenceExpression)replaced); } if (isOriginal) { updateCaretPosition(replaced); } return replaced; } | 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.equals(fieldName) ? qname + "." + fieldName : fieldName; return GroovyPsiElementFactory.getInstance(place.getProject()).createReferenceExpressionFromText(refText, place); } | 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 myPanel; } | 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.class"), GlobalSearchScope.projectScope(myContext.getProject()), new ClassFilter() { @Override public boolean isAccepted(PsiClass aClass) { return aClass.getParent() instanceof GroovyFile || aClass.hasModifierProperty(PsiModifier.STATIC); } }, null); if (myTargetClass != null) { chooser.selectDirectory(myTargetClass.getContainingFile().getContainingDirectory()); } chooser.showDialog(); PsiClass aClass = chooser.getSelected(); if (aClass != null) { myTargetClassEditor.setText(aClass.getQualifiedName()); } } }, "", myContext.getProject(), true, RECENTS_KEY); myTargetClassPanel.setLayout(new BorderLayout()); myTargetClassPanel.add(myTargetClassLabel, BorderLayout.NORTH); myTargetClassPanel.add(myTargetClassEditor, BorderLayout.CENTER); Set<String> possibleClassNames = new LinkedHashSet<>(); for (final PsiElement occurrence : myContext.getOccurrences()) { final PsiClass parentClass = getParentClass(occurrence); if (parentClass != null && parentClass.getQualifiedName() != null) { possibleClassNames.add(parentClass.getQualifiedName()); } } for (String possibleClassName : possibleClassNames) { myTargetClassEditor.prependItem(possibleClassName); } if (myDefaultTargetClass != null) { myTargetClassEditor.prependItem(myDefaultTargetClass.getQualifiedName()); } myTargetClassEditor.getChildComponent().addDocumentListener(new DocumentListener() { @Override public void documentChanged(@NotNull DocumentEvent e) { targetClassChanged(); updateOkStatus(); // enableEnumDependant(introduceEnumConstant()); } }); } | 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(PsiClass aClass) { return aClass.getParent() instanceof GroovyFile || aClass.hasModifierProperty(PsiModifier.STATIC); } }, null); if (myTargetClass != null) { chooser.selectDirectory(myTargetClass.getContainingFile().getContainingDirectory()); } chooser.showDialog(); PsiClass aClass = chooser.getSelected(); if (aClass != null) { myTargetClassEditor.setText(aClass.getQualifiedName()); } } | 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(KeyEvent.VK_N, InputEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW); myNameField.addDataChangedListener(() -> updateOkStatus()); } | 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.createTypeComboBoxFromExpression(expression); } else if (stringPart != null) { myTypeCombo = GrTypeComboBox.createTypeComboBoxFromExpression(stringPart.getLiteral()); } else { assert var != null; myTypeCombo = GrTypeComboBox.createTypeComboBoxWithDefType(var.getDeclaredType(), var); } List<String> names = new ArrayList<>(); if (var != null) { names.add(var.getName()); } if (expression != null) { names.addAll(suggestNames()); } myNameField = new NameSuggestionsField(ArrayUtilRt.toStringArray(names), myContext.getProject(), GroovyFileType.GROOVY_FILE_TYPE); GrTypeComboBox.registerUpDownHint(myNameField, myTypeCombo); } | createUIComponents |
31,077 | void () { final String targetClassName = getTargetClassName(); myTargetClass = JavaPsiFacade.getInstance(myContext.getProject()).findClass(targetClassName, GlobalSearchScope.projectScope(myContext.getProject())); updateVisibilityPanel(); // myIntroduceEnumConstantCb.setEnabled(EnumConstantsUtil.isSuitableForEnumConstant(getSelectedType(), myTargetClassEditor)); } | 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); visible.add(PsiModifier.PROTECTED); visible.add(PsiModifier.PACKAGE_LOCAL); visible.add(PsiModifier.PUBLIC); for (PsiElement occurrence : myContext.getOccurrences()) { final PsiManager psiManager = PsiManager.getInstance(myContext.getProject()); for (Iterator<String> iterator = visible.iterator(); iterator.hasNext();) { String modifier = iterator.next(); try { final String modifierText = PsiModifier.PACKAGE_LOCAL.equals(modifier) ? "" : modifier + " "; final PsiField field = JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory().createFieldFromText(modifierText + "int xxx;", myTargetClass); if (!JavaResolveUtil.isAccessible(field, myTargetClass, field.getModifierList(), occurrence, myTargetClass, null)) { iterator.remove(); } } catch (IncorrectOperationException e) { LOG.error(e); } } } if (!visible.contains(getVisibilityModifier())) { if (visible.contains(PsiModifier.PUBLIC)) myJavaVisibilityPanel.setVisibility(PsiModifier.PUBLIC); if (visible.contains(PsiModifier.PACKAGE_LOCAL)) myJavaVisibilityPanel.setVisibility(PsiModifier.PACKAGE_LOCAL); if (visible.contains(PsiModifier.PROTECTED)) myJavaVisibilityPanel.setVisibility(PsiModifier.PROTECTED); if (visible.contains(PsiModifier.PRIVATE)) myJavaVisibilityPanel.setVisibility(PsiModifier.PRIVATE); } } } | 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) { setOKActionEnabled(false); return; } final String trimmed = targetClassName.trim(); if (!PsiNameHelper.getInstance(myContext.getProject()).isQualifiedName(trimmed)) { setOKActionEnabled(false); return; } setOKActionEnabled(true); } | 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 = JavaPsiFacade.getInstance(myContext.getProject()); PsiClass newClass = facade.findClass(targetClassName, GlobalSearchScope.projectScope(myContext.getProject())); if (newClass == null && Messages.showOkCancelDialog(myContext.getProject(), GroovyRefactoringBundle.message("class.does.not.exist.in.the.module"), IntroduceConstantHandler.getRefactoringNameText(), Messages.getErrorIcon()) != Messages.OK) { return; } myTargetClassInfo = new TargetClassInfo(targetClassName, myContext.getPlace().getContainingFile().getContainingDirectory(), module, myContext.getProject()); } else { myTargetClassInfo = new TargetClassInfo(myDefaultTargetClass); } JavaRefactoringSettings.getInstance().INTRODUCE_CONSTANT_VISIBILITY = getVisibilityModifier(); RecentsManager.getInstance(myContext.getProject()).registerRecentEntry(RECENTS_KEY, targetClassName); super.doOKAction(); } | 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 packageName = StringUtil.getPackageName(qualifiedName); PsiPackage psiPackage = JavaPsiFacade.getInstance(project).findPackage(packageName); final PsiDirectory psiDirectory; if (psiPackage != null) { final PsiDirectory[] directories = psiPackage.getDirectories(GlobalSearchScope.allScope(project)); psiDirectory = directories.length > 1 ? DirectoryChooserUtil .chooseDirectory(directories, null, project, new HashMap<>()) : directories[0]; } else { psiDirectory = PackageUtil.findOrCreateDirectoryForPackage(module, packageName, baseDirectory, false); } if (psiDirectory == null) return null; final String shortName = StringUtil.getShortName(qualifiedName); final String fileName = shortName + NewGroovyActionBase.GROOVY_EXTENSION; return WriteAction.compute(() -> { final GroovyFile file = (GroovyFile)GroovyTemplatesFactory.createFromTemplate(psiDirectory, shortName, fileName, GroovyTemplates.GROOVY_CLASS, true); return file.getTypeDefinitions()[0]; }); } | 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(context, settings).addDeclaration(scope instanceof GroovyFileBase ? ((GroovyFileBase)scope).getScriptClass() : (PsiClass)scope).getVariables()[0]; } }); } | 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 getTargetClass() { return (PsiClass)context.getScope(); } @Nullable @Override public String getName() { return names[0]; } @Override public boolean replaceAllOccurrences() { return isReplaceAllOccurrences(); } @Nullable @Override public PsiType getSelectedType() { 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; } }; } | 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(); } @Nullable @Override public PsiType getSelectedType() { return GrInplaceConstantIntroducer.this.getSelectedType(); } @Nullable @Override public PsiClass getTargetClass() { return (PsiClass)myContext.getScope(); } }; } | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.