mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 19:02:13 +07:00
tests for forthcoming functionality, cleanup and refactoring
This commit is contained in:
+2
@@ -320,5 +320,7 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
|
||||
void renameElementAtCaret(String newName) throws Exception;
|
||||
|
||||
void renameElement(PsiElement element, String newName) throws Exception;
|
||||
|
||||
void allowTreeAccessForFile(VirtualFile file);
|
||||
}
|
||||
|
||||
+8
-2
@@ -501,10 +501,16 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
|
||||
public void renameElementAtCaret(final String newName) throws Exception {
|
||||
assertInitialized();
|
||||
final PsiElement element = TargetElementUtilBase.findTargetElement(getCompletionEditor(), TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED |
|
||||
TargetElementUtilBase.ELEMENT_NAME_ACCEPTED);
|
||||
assert element != null : "element not found in file " + myFile.getName() + " at caret position, offset " +
|
||||
myEditor.getCaretModel().getOffset();
|
||||
renameElement(element, newName);
|
||||
}
|
||||
|
||||
public void renameElement(final PsiElement element, final String newName) throws Exception {
|
||||
new WriteCommandAction.Simple(myProjectFixture.getProject()) {
|
||||
protected void run() throws Exception {
|
||||
PsiElement element = TargetElementUtilBase.findTargetElement(getCompletionEditor(), TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED | TargetElementUtilBase.ELEMENT_NAME_ACCEPTED);
|
||||
assert element != null: "element not found in file " + myFile.getName() + " at caret position, offset " + myEditor.getCaretModel().getOffset();
|
||||
final PsiElement substitution = RenamePsiElementProcessor.forElement(element).substituteElementToRename(element, myEditor);
|
||||
new RenameProcessor(myProjectFixture.getProject(), substitution, newName, false, false).run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user