本文整理汇总了Java中com.intellij.refactoring.RefactoringBundle类的典型用法代码示例。如果您正苦于以下问题:Java RefactoringBundle类的具体用法?Java RefactoringBundle怎么用?Java RefactoringBundle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RefactoringBundle类属于com.intellij.refactoring包,在下文中一共展示了RefactoringBundle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processDuplicates
import com.intellij.refactoring.RefactoringBundle; //导入依赖的package包/类
public static void processDuplicates(@NotNull MatchProvider provider, @NotNull Project project, @NotNull Editor editor) {
Boolean hasDuplicates = provider.hasDuplicates();
if (hasDuplicates == null || hasDuplicates.booleanValue()) {
List<Match> duplicates = provider.getDuplicates();
if (duplicates.size() == 1) {
previewMatch(project, duplicates.get(0), editor);
}
final int answer = ApplicationManager.getApplication().isUnitTestMode() || hasDuplicates == null ? Messages.YES : Messages.showYesNoDialog(project,
RefactoringBundle.message("0.has.detected.1.code.fragments.in.this.file.that.can.be.replaced.with.a.call.to.extracted.method",
ApplicationNamesInfo.getInstance().getProductName(), duplicates.size()),
"Process Duplicates", Messages.getQuestionIcon());
if (answer == Messages.YES) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
invoke(project, editor, provider, hasDuplicates != null);
}
}
}
示例2: check
import com.intellij.refactoring.RefactoringBundle; //导入依赖的package包/类
@Nullable
private String check(@NotNull PsiClass targetClass, @Nullable final String fieldName) {
if (!GroovyLanguage.INSTANCE.equals(targetClass.getLanguage())) {
return GroovyRefactoringBundle.message("class.language.is.not.groovy");
}
if (fieldName == null || fieldName.isEmpty()) {
return RefactoringBundle.message("no.field.name.specified");
}
else if (!PsiNameHelper.getInstance(context.getProject()).isIdentifier(fieldName)) {
return RefactoringMessageUtil.getIncorrectIdentifierMessage(fieldName);
}
if (targetClass instanceof GroovyScriptClass) {
return GroovyRefactoringBundle.message("target.class.must.not.be.script");
}
return null;
}
示例3: checkAccessibility
import com.intellij.refactoring.RefactoringBundle; //导入依赖的package包/类
public static void checkAccessibility(PsiMember refMember,
@NotNull PsiElement newContext,
@Nullable PsiClass accessClass,
PsiMember member,
MultiMap<PsiElement, String> conflicts) {
if (!PsiUtil.isAccessible(refMember, newContext, accessClass)) {
String message = RefactoringBundle.message("0.is.1.and.will.not.be.accessible.from.2.in.the.target.class",
RefactoringUIUtil.getDescription(refMember, true),
VisibilityUtil.getVisibilityStringToDisplay(refMember),
RefactoringUIUtil.getDescription(member, false));
message = CommonRefactoringUtil.capitalize(message);
conflicts.putValue(refMember, message);
}
else if (newContext instanceof PsiClass && refMember instanceof PsiField && refMember.getContainingClass() == member.getContainingClass()) {
final PsiField fieldInSubClass = ((PsiClass)newContext).findFieldByName(refMember.getName(), false);
if (fieldInSubClass != null && fieldInSubClass != refMember) {
conflicts.putValue(refMember, CommonRefactoringUtil.capitalize(RefactoringUIUtil.getDescription(fieldInSubClass, true) +
" would hide " + RefactoringUIUtil.getDescription(refMember, true) +
" which is used by moved " + RefactoringUIUtil.getDescription(member, false)));
}
}
}
示例4: CopyClassDialog
import com.intellij.refactoring.RefactoringBundle; //导入依赖的package包/类
public CopyClassDialog(PsiClass aClass, PsiDirectory defaultTargetDirectory, Project project, boolean doClone) {
super(project, true);
myProject = project;
myDefaultTargetDirectory = defaultTargetDirectory;
myDoClone = doClone;
String text = myDoClone ? RefactoringBundle.message("copy.class.clone.0.1", UsageViewUtil.getType(aClass), UsageViewUtil.getLongName(aClass)) :
RefactoringBundle.message("copy.class.copy.0.1", UsageViewUtil.getType(aClass), UsageViewUtil.getLongName(aClass));
myInformationLabel.setText(text);
myInformationLabel.setFont(myInformationLabel.getFont().deriveFont(Font.BOLD));
init();
myDestinationCB.setData(myProject, defaultTargetDirectory,
new Pass<String>() {
@Override
public void pass(String s) {
setErrorText(s);
}
}, myTfPackage.getChildComponent());
myNameField.setText(UsageViewUtil.getShortName(aClass));
myNameField.selectAll();
}
示例5: invoke
import com.intellij.refactoring.RefactoringBundle; //导入依赖的package包/类
private void invoke(final Project project, PsiMethod method, Editor editor) {
if(method.isConstructor()){
CommonRefactoringUtil.showErrorHint(project, editor, RefactorJBundle.message("cannot.perform.the.refactoring") + RefactorJBundle.message("constructor.returns.can.not.be.wrapped"), null,
this.getHelpID());
return;
}
final PsiType returnType = method.getReturnType();
if(PsiType.VOID.equals(returnType)){
CommonRefactoringUtil.showErrorHint(project, editor, RefactorJBundle.message("cannot.perform.the.refactoring") + RefactorJBundle.message("method.selected.returns.void"), null, this.getHelpID());
return;
}
method = SuperMethodWarningUtil.checkSuperMethod(method, RefactoringBundle.message("to.refactor"));
if (method == null) return;
if(method instanceof PsiCompiledElement){
CommonRefactoringUtil.showErrorHint(project, editor, RefactorJBundle.message("cannot.perform.the.refactoring") + RefactorJBundle.message(
"the.selected.method.cannot.be.wrapped.because.it.is.defined.in.a.non.project.class"), null, this.getHelpID());
return;
}
new WrapReturnValueDialog(method).show();
}
示例6: tryToMove
import com.intellij.refactoring.RefactoringBundle; //导入依赖的package包/类
public boolean tryToMove(final PsiElement element, final Project project, final DataContext dataContext, final PsiReference reference,
final Editor editor) {
if (isNonStaticInnerClass(element) && !JavaMoveClassesOrPackagesHandler.isReferenceInAnonymousClass(reference)) {
PsiClass aClass = (PsiClass) element;
FeatureUsageTracker.getInstance().triggerFeatureUsed("refactoring.move.moveInner");
final PsiClass containingClass = aClass.getContainingClass();
if (containingClass instanceof JspClass) {
CommonRefactoringUtil.showErrorHint(project, editor, RefactoringBundle.message("move.nonstatic.class.from.jsp.not.supported"),
RefactoringBundle.message("move.title"), null);
return true;
}
MoveInnerImpl.doMove(project, new PsiElement[]{aClass}, null, LangDataKeys.TARGET_PSI_ELEMENT.getData(dataContext));
return true;
}
return false;
}
示例7: addInaccessibleMemberConflicts
import com.intellij.refactoring.RefactoringBundle; //导入依赖的package包/类
public static void addInaccessibleMemberConflicts(final PsiElement element,
final UsageInfo[] usages,
final ReferencedElementsCollector collector,
final MultiMap<PsiElement, String> conflicts) {
element.accept(collector);
final Map<PsiMember, Set<PsiMember>> containersToReferenced = getInaccessible(collector.myReferencedMembers, usages, element);
final Set<PsiMember> containers = containersToReferenced.keySet();
for (PsiMember container : containers) {
Set<PsiMember> referencedInaccessible = containersToReferenced.get(container);
for (PsiMember referenced : referencedInaccessible) {
final String referencedDescription = RefactoringUIUtil.getDescription(referenced, true);
final String containerDescription = RefactoringUIUtil.getDescription(container, true);
String message = RefactoringBundle.message("0.that.is.used.in.inlined.method.is.not.accessible.from.call.site.s.in.1",
referencedDescription, containerDescription);
conflicts.putValue(container, CommonRefactoringUtil.capitalize(message));
}
}
}
示例8: createNorthPanel
import com.intellij.refactoring.RefactoringBundle; //导入依赖的package包/类
protected JComponent createNorthPanel() {
myNameField = new JTextField(myMigrationMap.getName());
myNameField.getDocument().addDocumentListener(new DocumentAdapter() {
protected void textChanged(DocumentEvent e) {
validateOKButton();
}
});
myDescriptionTextArea = new JTextArea(myMigrationMap.getDescription(), 3, 40) {
@Override
public Dimension getMinimumSize() {
return super.getPreferredSize();
}
};
myDescriptionTextArea.setLineWrap(true);
myDescriptionTextArea.setWrapStyleWord(true);
myDescriptionTextArea.setFont(myNameField.getFont());
myDescriptionTextArea.setBackground(myNameField.getBackground());
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myDescriptionTextArea);
scrollPane.setBorder(myNameField.getBorder());
return FormBuilder.createFormBuilder()
.addLabeledComponent(new JLabel(RefactoringBundle.message("migration.map.name.prompt")), myNameField)
.addLabeledComponent(new JLabel(RefactoringBundle.message("migration.map.description.label")), scrollPane)
.addVerticalGap(UIUtil.LARGE_VGAP).getPanel();
}
示例9: createNorthPanel
import com.intellij.refactoring.RefactoringBundle; //导入依赖的package包/类
protected JComponent createNorthPanel() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints gbConstraints = new GridBagConstraints();
gbConstraints.insets = new Insets(4, 8, 4, 8);
gbConstraints.weighty = 1;
gbConstraints.weightx = 1;
gbConstraints.gridy = 0;
gbConstraints.gridwidth = GridBagConstraints.REMAINDER;
gbConstraints.fill = GridBagConstraints.BOTH;
gbConstraints.anchor = GridBagConstraints.WEST;
panel.add(createDescriptionLabel(), gbConstraints);
gbConstraints.gridy++;
myCbReplaceUsages = new JCheckBox(RefactoringBundle.message("replace.instance.qualifiers.with.class.references"));
panel.add(myCbReplaceUsages, gbConstraints);
myCbReplaceUsages.setSelected(true);
return panel;
}
示例10: ConflictsDialog
import com.intellij.refactoring.RefactoringBundle; //导入依赖的package包/类
public ConflictsDialog(@NotNull Project project,
@NotNull MultiMap<PsiElement, String> conflictDescriptions,
@Nullable Runnable doRefactoringRunnable,
boolean alwaysShowOkButton,
boolean canShowConflictsInView) {
super(project, true);
myProject = project;
myDoRefactoringRunnable = doRefactoringRunnable;
myCanShowConflictsInView = canShowConflictsInView;
final LinkedHashSet<String> conflicts = new LinkedHashSet<String>();
for (String conflict : conflictDescriptions.values()) {
conflicts.add(conflict);
}
myConflictDescriptions = ArrayUtil.toStringArray(conflicts);
myElementConflictDescription = conflictDescriptions;
setTitle(RefactoringBundle.message("problems.detected.title"));
setOKButtonText(RefactoringBundle.message("continue.button"));
setOKActionEnabled(alwaysShowOkButton || getDoRefactoringRunnable(null) != null);
init();
}
示例11: invoke
import com.intellij.refactoring.RefactoringBundle; //导入依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
int offset = editor.getCaretModel().getOffset();
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
PsiElement element = file.findElementAt(offset);
while (true) {
if (element == null || element instanceof PsiFile) {
String message = RefactoringBundle
.getCannotRefactorMessage(RefactoringBundle.message("the.caret.should.be.positioned.inside.a.class.to.pull.members.from"));
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.MEMBERS_PULL_UP);
return;
}
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, element)) return;
if (element instanceof PsiClass || element instanceof PsiField || element instanceof PsiMethod) {
invoke(project, new PsiElement[]{element}, dataContext);
return;
}
element = element.getParent();
}
}
示例12: invoke
import com.intellij.refactoring.RefactoringBundle; //导入依赖的package包/类
public void invoke(@NotNull final Project project, @NotNull PsiElement[] elements, DataContext dataContext) {
if (elements.length != 1) return;
PsiClass subClass = (PsiClass) elements[0];
ArrayList basesList = RefactoringHierarchyUtil.createBasesList(subClass, true, true);
if (basesList.isEmpty()) {
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("interface.does.not.have.base.interfaces", subClass.getQualifiedName()));
Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.TURN_REFS_TO_SUPER);
return;
}
new TurnRefsToSuperDialog(project, subClass, basesList).show();
}
示例13: createParametersPanel
import com.intellij.refactoring.RefactoringBundle; //导入依赖的package包/类
@Nullable
private JPanel createParametersPanel () {
myThisClassesMap = MoveInstanceMembersUtil.getThisClassesToMembers(myMethod);
myOldClassParameterNameFields = new HashMap<PsiClass, EditorTextField>();
if (myThisClassesMap.size() == 0) return null;
JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, true));
for (PsiClass aClass : myThisClassesMap.keySet()) {
final String text = RefactoringBundle.message("move.method.this.parameter.label", aClass.getName());
panel.add(new TitledSeparator(text, null));
String suggestedName = MoveInstanceMethodHandler.suggestParameterNameForThisClass(aClass);
final EditorTextField field = new EditorTextField(suggestedName, getProject(), StdFileTypes.JAVA);
field.setMinimumSize(new Dimension(field.getPreferredSize()));
myOldClassParameterNameFields.put(aClass, field);
panel.add(field);
}
panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
return panel;
}
示例14: invoke
import com.intellij.refactoring.RefactoringBundle; //导入依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
int offset = editor.getCaretModel().getOffset();
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
PsiElement element = file.findElementAt(offset);
while (true) {
if (element == null || element instanceof PsiFile) {
String message = RefactoringBundle
.getCannotRefactorMessage(RefactoringBundle.message("the.caret.should.be.positioned.inside.a.class.to.pull.members.from"));
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.MEMBERS_PULL_UP);
return;
}
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, element)) return;
if (element instanceof GrTypeDefinition || element instanceof GrField || element instanceof GrMethod) {
invoke(project, new PsiElement[]{element}, dataContext);
return;
}
element = element.getParent();
}
}
示例15: doAction
import com.intellij.refactoring.RefactoringBundle; //导入依赖的package包/类
@Override
protected void doAction() {
LOG.assertTrue(myElement.isValid());
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
try {
myTag.setName(getNewName());
}
catch (IncorrectOperationException e) {
LOG.error(e);
}
}
});
}
}, RefactoringBundle.message("rename.title"), null);
close(DialogWrapper.OK_EXIT_CODE);
}