Java Code Examples for com.intellij.refactoring.RefactoringBundle#getCannotRefactorMessage()
The following examples show how to use
com.intellij.refactoring.RefactoringBundle#getCannotRefactorMessage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExtractSuperclassHandler.java From intellij-haxe with Apache License 2.0 | 6 votes |
@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(); } }
Example 2
Source File: HaxePushDownHandler.java From intellij-haxe with Apache License 2.0 | 6 votes |
@Override public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext context) { 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.push.members.from")); CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.MEMBERS_PUSH_DOWN); return; } if (element instanceof HaxeClassDeclaration || element instanceof HaxeFieldDeclaration || element instanceof HaxeMethod) { //if (element instanceof JspClass) { // RefactoringMessageUtil.showNotSupportedForJspClassesError(project, editor, REFACTORING_NAME, HelpID.MEMBERS_PUSH_DOWN); // return; //} invoke(project, new PsiElement[]{element}, context); return; } element = element.getParent(); } }
Example 3
Source File: ExtractInterfaceHandler.java From intellij-haxe with Apache License 2.0 | 6 votes |
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.EXTRACT_INTERFACE); return; } if (element instanceof PsiClass && !(element instanceof PsiAnonymousClass)) { invoke(project, new PsiElement[]{element}, dataContext); return; } element = element.getParent(); } }
Example 4
Source File: InlineRefactoringActionHandler.java From consulo with Apache License 2.0 | 6 votes |
@Override public void invoke(@Nonnull final Project project, Editor editor, PsiFile file, DataContext dataContext) { editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); PsiElement element = dataContext.getData(LangDataKeys.PSI_ELEMENT); if (element == null) { element = BaseRefactoringAction.getElementAtCaret(editor, file); } if (element != null) { for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) { if (handler.canInlineElementInEditor(element, editor)) { handler.inlineElement(project, editor, element); return; } } if (invokeInliner(editor, element)) return; String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.method.or.local.name")); CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, null); } }
Example 5
Source File: HaxePullUpHandler.java From intellij-haxe with Apache License 2.0 | 5 votes |
@Override public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext context) { int offset = editor.getCaretModel().getOffset(); editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); PsiElement element = file.findElementAt(offset); //HaxeClassDeclaration classDeclaration; //PsiElement parentElement; 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; /*classDeclaration = PsiTreeUtil.getParentOfType(element, HaxeClassDeclaration.class, false); parentElement = null; parentElement = PsiTreeUtil.getParentOfType(element, HaxeVarDeclaration.class, false); if (parentElement == null) { parentElement = PsiTreeUtil.getParentOfType(element, HaxeFunctionDeclarationWithAttributes.class, false); }*/ if (element instanceof HaxeClassDeclaration || element instanceof HaxeInterfaceDeclaration || element instanceof PsiField || element instanceof PsiMethod) { invoke(project, new PsiElement[]{element}, context); return; } //if (classDeclaration != null) { // invoke(project, context, classDeclaration, parentElement); // return; //} element = element.getParent(); } }
Example 6
Source File: MoveHandler.java From consulo with Apache License 2.0 | 5 votes |
/** * called by an Action in AtomicAction when refactoring is invoked from Editor */ @Override public void invoke(@Nonnull 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) { 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(); } }
Example 7
Source File: SafeDeleteHandler.java From consulo with Apache License 2.0 | 5 votes |
@Override public void invoke(@Nonnull Project project, Editor editor, PsiFile file, DataContext dataContext) { PsiElement element = dataContext.getData(CommonDataKeys.PSI_ELEMENT); editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); if (element == null || !SafeDeleteProcessor.validElement(element)) { String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("is.not.supported.in.the.current.context", REFACTORING_NAME)); CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, "refactoring.safeDelete"); return; } invoke(project, new PsiElement[]{element}, dataContext); }