本文整理汇总了Java中com.intellij.refactoring.RefactoringBundle.getCannotRefactorMessage方法的典型用法代码示例。如果您正苦于以下问题:Java RefactoringBundle.getCannotRefactorMessage方法的具体用法?Java RefactoringBundle.getCannotRefactorMessage怎么用?Java RefactoringBundle.getCannotRefactorMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.refactoring.RefactoringBundle
的用法示例。
在下文中一共展示了RefactoringBundle.getCannotRefactorMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invoke
import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
int offset = editor.getCaretModel().getOffset();
PsiElement element = file.findElementAt(offset);
while (true) {
if (element == null || element instanceof PsiFile) {
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.class"));
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.EXTRACT_SUPERCLASS);
return;
}
if (element instanceof PsiClass) {
invoke(project, new PsiElement[]{element}, dataContext);
return;
}
element = element.getParent();
}
}
示例2: 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();
}
}
示例3: invoke
import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
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("error.wrong.caret.position.class"));
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.TURN_REFS_TO_SUPER);
return;
}
if (element instanceof PsiClass && !(element instanceof PsiAnonymousClass)) {
invoke(project, new PsiElement[]{element}, dataContext);
return;
}
element = element.getParent();
}
}
示例4: invoke
import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
private static void invoke(final PsiClass aClass, Editor editor) {
final PsiTypeParameterList typeParameterList = aClass.getTypeParameterList();
Project project = aClass.getProject();
if (typeParameterList == null) {
final String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("changeClassSignature.no.type.parameters"));
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.CHANGE_CLASS_SIGNATURE);
return;
}
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, aClass)) return;
ChangeClassSignatureDialog dialog = new ChangeClassSignatureDialog(aClass, true);
//if (!ApplicationManager.getApplication().isUnitTestMode()){
dialog.show();
//}else {
// dialog.showAndGetOk()
//}
}
示例5: invokeOnElements
import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
private static void invokeOnElements(@NotNull final Project project,
@NotNull final Editor editor,
@NotNull PsiFile file,
@NotNull PsiElement[] elements) {
if (elements.length == 0) {
String message = RefactoringBundle
.getCannotRefactorMessage(RefactoringBundle.message("selected.block.should.represent.a.set.of.statements.or.an.expression"));
CommonRefactoringUtil.showErrorHint(project, editor, message, ExtractMethodObjectProcessor.REFACTORING_NAME, HelpID.EXTRACT_METHOD_OBJECT);
return;
}
try {
extractMethodObject(project, editor, new ExtractMethodObjectProcessor(project, editor, elements, ""));
}
catch (PrepareFailedException e) {
CommonRefactoringUtil.showErrorHint(project, editor, e.getMessage(), ExtractMethodObjectProcessor.REFACTORING_NAME, HelpID.EXTRACT_METHOD_OBJECT);
ExtractMethodHandler.highlightPrepareError(e, file, editor, project);
}
}
示例6: invoke
import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
int offset = editor.getCaretModel().getOffset();
PsiElement element = file.findElementAt(offset);
while (true) {
if (element == null || element instanceof PsiFile) {
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.class"));
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.INHERITANCE_TO_DELEGATION);
return;
}
if (element instanceof PsiClass && !(element instanceof PsiAnonymousClass)) {
invoke(project, new PsiElement[]{element}, dataContext);
return;
}
element = element.getParent();
}
}
示例7: invokeImpl
import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
protected boolean invokeImpl(final Project project, final PsiLocalVariable localVariable, final Editor editor) {
final PsiElement parent = localVariable.getParent();
if (!(parent instanceof PsiDeclarationStatement)) {
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.local.or.expression.name"));
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, getHelpID());
return false;
}
final LocalToFieldHandler localToFieldHandler = new LocalToFieldHandler(project, true){
@Override
protected Settings showRefactoringDialog(PsiClass aClass,
PsiLocalVariable local,
PsiExpression[] occurences,
boolean isStatic) {
return IntroduceConstantHandler.this.showRefactoringDialog(project, editor, aClass, local.getInitializer(), local.getType(), occurences, local, null);
}
};
return localToFieldHandler.convertLocalToField(localVariable, editor);
}
示例8: validateTarget
import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
@Nullable
public static String validateTarget(final PsiTypeParameterListOwner member) {
final PsiClass containingClass = member.getContainingClass();
// Checking various preconditions
if(member instanceof PsiMethod && ((PsiMethod)member).isConstructor()) {
return RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("constructor.cannot.be.made.static"));
}
if(member.getContainingClass() == null) {
return RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("this.member.does.not.seem.to.belong.to.any.class"));
}
if(member.hasModifierProperty(PsiModifier.STATIC)) {
return RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("member.is.already.static"));
}
if(member instanceof PsiMethod && member.hasModifierProperty(PsiModifier.ABSTRACT)) {
return RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("cannot.make.abstract.method.static"));
}
if(containingClass instanceof PsiAnonymousClass ||
(containingClass.getContainingClass() != null && !containingClass.hasModifierProperty(PsiModifier.STATIC))) {
return RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("inner.classes.cannot.have.static.members"));
}
return null;
}
示例9: checkAbstractClassOrInterfaceMessage
import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
private boolean checkAbstractClassOrInterfaceMessage(PsiClass aClass, Editor editor) {
if (!aClass.hasModifierProperty(PsiModifier.ABSTRACT)) return true;
String message = RefactoringBundle.getCannotRefactorMessage(aClass.isInterface() ?
RefactoringBundle.message("class.is.interface", aClass.getQualifiedName()) :
RefactoringBundle.message("class.is.abstract", aClass.getQualifiedName()));
CommonRefactoringUtil.showErrorHint(myProject, editor, message, REFACTORING_NAME, HelpID.REPLACE_CONSTRUCTOR_WITH_FACTORY);
return false;
}
示例10: invoke
import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
/**
* called by an Action in AtomicAction when refactoring is invoked from Editor
*/
@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);
if (element == null) {
element = file;
}
while(true){
if (element == null) {
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("the.caret.should.be.positioned.at.the.class.method.or.field.to.be.refactored"));
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, null);
return;
}
if (tryToMoveElement(element, project, dataContext, null, editor)) {
return;
}
final TextRange range = element.getTextRange();
if (range != null) {
int relative = offset - range.getStartOffset();
final PsiReference reference = element.findReferenceAt(relative);
if (reference != null) {
final PsiElement refElement = reference.resolve();
if (refElement != null && tryToMoveElement(refElement, project, dataContext, reference, editor)) return;
}
}
element = element.getParent();
}
}
示例11: invoke
import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull final Project project, final Editor editor, PsiFile file, DataContext dataContext) {
final int offset = editor.getCaretModel().getOffset();
final PsiElement element = file.findElementAt(offset);
final PsiMember member = PsiTreeUtil.getParentOfType(element, PsiMember.class);
final String cannotRefactorMessage = getCannotRefactorMessage(member);
if (cannotRefactorMessage != null) {
String message = RefactoringBundle.getCannotRefactorMessage(cannotRefactorMessage);
showErrorMessage(message, project, editor);
return;
}
final AnalysisScope scope = new AnalysisScope(file);
final Module module = ModuleUtilCore.findModuleForPsiElement(file);
final BaseAnalysisActionDialog dlg =
new BaseAnalysisActionDialog(RefactoringBundle.message("replace.method.duplicates.scope.chooser.title", REFACTORING_NAME),
RefactoringBundle.message("replace.method.duplicates.scope.chooser.message"),
project, scope, module != null ? module.getName() : null, false,
AnalysisUIOptions.getInstance(project), element);
if (dlg.showAndGet()) {
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Locate duplicates", true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
indicator.setIndeterminate(true);
invokeOnScope(project, member, dlg.getScope(AnalysisUIOptions.getInstance(project), scope, project, module));
}
});
}
}
示例12: invoke
import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
public void invoke(@NotNull final Project project, final Editor editor, PsiFile file, DataContext dataContext) {
PsiElement element = TargetElementUtil.findTargetElement(editor, TargetElementUtil
.ELEMENT_NAME_ACCEPTED |
TargetElementUtil
.LOOKUP_ITEM_ACCEPTED |
TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED);
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
if (!(element instanceof PsiLocalVariable)) {
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.local.name"));
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.REPLACE_TEMP_WITH_QUERY);
return;
}
invokeOnVariable(file, project, (PsiLocalVariable)element, editor);
}
示例13: invokeOnElement
import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
private static void invokeOnElement(Project project, Editor editor, PsiElement element) {
if (element instanceof PsiMethod) {
invoke((PsiMethod)element, project);
}
else {
String message =
RefactoringBundle.getCannotRefactorMessage(GroovyRefactoringBundle.message("error.wrong.caret.position.method.name"));
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.CHANGE_SIGNATURE);
}
}
示例14: testAugmentedAssignment
import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
public void testAugmentedAssignment() throws Exception {
String exception = null;
try {
doTest(false);
}
catch(RuntimeException ex) {
exception = ex.getMessage();
}
String error = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("variable.is.accessed.for.writing", "text"));
assertEquals(error, exception);
}
示例15: showMultipleExitPointsMessage
import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
private void showMultipleExitPointsMessage() {
if (myShowErrorDialogs) {
HighlightManager highlightManager = HighlightManager.getInstance(myProject);
PsiStatement[] exitStatementsArray = myExitStatements.toArray(new PsiStatement[myExitStatements.size()]);
EditorColorsManager manager = EditorColorsManager.getInstance();
TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
highlightManager.addOccurrenceHighlights(myEditor, exitStatementsArray, attributes, true, null);
String message = RefactoringBundle
.getCannotRefactorMessage(RefactoringBundle.message("there.are.multiple.exit.points.in.the.selected.code.fragment"));
CommonRefactoringUtil.showErrorHint(myProject, myEditor, message, myRefactoringName, myHelpId);
WindowManager.getInstance().getStatusBar(myProject).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting"));
}
}