Search in sources :

Example 1 with RenameWrongRefHandler

use of com.intellij.refactoring.rename.RenameWrongRefHandler in project intellij-community by JetBrains.

the class RenameLocalTest method doRenameWrongRef.

private void doRenameWrongRef(final String newName) throws Exception {
    final String name = getTestName(false);
    configureByFile(BASE_PATH + name + ".java");
    TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
    new RenameWrongRefHandler().invoke(getProject(), getEditor(), getFile(), null);
    final TemplateState state = TemplateManagerImpl.getTemplateState(getEditor());
    assert state != null;
    final TextRange range = state.getCurrentVariableRange();
    assert range != null;
    new WriteCommandAction.Simple(getProject()) {

        @Override
        protected void run() throws Throwable {
            getEditor().getDocument().replaceString(range.getStartOffset(), range.getEndOffset(), newName);
        }
    }.execute().throwException();
    state.gotoEnd(false);
    checkResultByFile(BASE_PATH + name + "_after.java");
}
Also used : RenameWrongRefHandler(com.intellij.refactoring.rename.RenameWrongRefHandler) TextRange(com.intellij.openapi.util.TextRange) TemplateState(com.intellij.codeInsight.template.impl.TemplateState)

Aggregations

TemplateState (com.intellij.codeInsight.template.impl.TemplateState)1 TextRange (com.intellij.openapi.util.TextRange)1 RenameWrongRefHandler (com.intellij.refactoring.rename.RenameWrongRefHandler)1