use of com.jetbrains.lang.dart.ide.refactoring.ServerExtractLocalVariableRefactoring in project intellij-plugins by JetBrains.
the class DartExtractLocalVariableRefactoringTest method doTest.
private void doTest(String filePath, boolean all) {
final ServerExtractLocalVariableRefactoring refactoring = createRefactoring(filePath);
// check initial conditions
final RefactoringStatus initialConditions = refactoring.checkInitialConditions();
assertNotNull(initialConditions);
assertTrue(initialConditions.isOK());
// configure
//refactoring.setName("test");
refactoring.setExtractAll(all);
// check final conditions
final RefactoringStatus finalConditions = refactoring.checkFinalConditions();
assertNotNull(finalConditions);
assertTrue(finalConditions.isOK());
// apply the SourceChange
final SourceChange change = refactoring.getChange();
assertNotNull(change);
ApplicationManager.getApplication().runWriteAction(() -> {
try {
AssistUtils.applySourceChange(myFixture.getProject(), change, true);
} catch (DartSourceEditException e) {
fail(e.getMessage());
}
});
// validate
myFixture.checkResultByFile(getTestName(false) + ".after.dart");
}
use of com.jetbrains.lang.dart.ide.refactoring.ServerExtractLocalVariableRefactoring in project intellij-plugins by JetBrains.
the class DartExtractLocalVariableRefactoringTest method createRefactoring.
@NotNull
private ServerExtractLocalVariableRefactoring createRefactoring(String filePath) {
((CodeInsightTestFixtureImpl) myFixture).canChangeDocumentDuringHighlighting(true);
final PsiFile psiFile = myFixture.configureByFile(filePath);
ApplicationManager.getApplication().runWriteAction(() -> {
try {
VfsUtil.saveText(psiFile.getVirtualFile(), StringUtil.convertLineSeparators(psiFile.getText(), "\r\n"));
} catch (IOException e) {
throw new RuntimeException(e);
}
});
// make sure server is warmed up
myFixture.doHighlighting();
// find the Element to rename
final SelectionModel selectionModel = getEditor().getSelectionModel();
int offset = selectionModel.getSelectionStart();
final int length = selectionModel.getSelectionEnd() - offset;
return new ServerExtractLocalVariableRefactoring(getProject(), psiFile.getVirtualFile(), offset, length);
}
use of com.jetbrains.lang.dart.ide.refactoring.ServerExtractLocalVariableRefactoring in project intellij-plugins by JetBrains.
the class DartServerExtractLocalVariableDialog method createRefactoring.
private void createRefactoring(int offset, int length) {
refactoring = new ServerExtractLocalVariableRefactoring(project, file.getVirtualFile(), offset, length);
final RefactoringStatus initialStatus = refactoring.checkInitialConditions();
if (showMessageIfError(initialStatus)) {
refactoring = null;
}
}
Aggregations