Search in sources :

Example 1 with ServerInlineMethodRefactoring

use of com.jetbrains.lang.dart.ide.refactoring.ServerInlineMethodRefactoring in project intellij-plugins by JetBrains.

the class DartInlineMethodRefactoringTest method doTest.

private void doTest(String filePath, boolean all) {
    final ServerInlineMethodRefactoring refactoring = createRefactoring(filePath);
    // check initial conditions
    final RefactoringStatus initialConditions = refactoring.checkInitialConditions();
    assertNotNull(initialConditions);
    assertTrue(initialConditions.isOK());
    // all
    if (all) {
        refactoring.setInlineAll(true);
        refactoring.setDeleteSource(true);
    }
    // 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, false);
        } catch (DartSourceEditException e) {
            fail(e.getMessage());
        }
    });
    // validate
    myFixture.checkResultByFile(getTestName(false) + ".after.dart");
}
Also used : RefactoringStatus(com.jetbrains.lang.dart.ide.refactoring.status.RefactoringStatus) SourceChange(org.dartlang.analysis.server.protocol.SourceChange) ServerInlineMethodRefactoring(com.jetbrains.lang.dart.ide.refactoring.ServerInlineMethodRefactoring) DartSourceEditException(com.jetbrains.lang.dart.assists.DartSourceEditException)

Example 2 with ServerInlineMethodRefactoring

use of com.jetbrains.lang.dart.ide.refactoring.ServerInlineMethodRefactoring in project intellij-plugins by JetBrains.

the class DartInlineMethodRefactoringTest method createRefactoring.

@NotNull
private ServerInlineMethodRefactoring createRefactoring(String filePath) {
    ((CodeInsightTestFixtureImpl) myFixture).canChangeDocumentDuringHighlighting(true);
    final PsiFile psiFile = myFixture.configureByFile(filePath);
    // make sure server is warmed up
    myFixture.doHighlighting();
    // find the Element to rename
    final int offset = getEditor().getCaretModel().getOffset();
    return new ServerInlineMethodRefactoring(getProject(), psiFile.getVirtualFile(), offset, 0);
}
Also used : CodeInsightTestFixtureImpl(com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl) PsiFile(com.intellij.psi.PsiFile) ServerInlineMethodRefactoring(com.jetbrains.lang.dart.ide.refactoring.ServerInlineMethodRefactoring) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ServerInlineMethodRefactoring (com.jetbrains.lang.dart.ide.refactoring.ServerInlineMethodRefactoring)2 PsiFile (com.intellij.psi.PsiFile)1 CodeInsightTestFixtureImpl (com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl)1 DartSourceEditException (com.jetbrains.lang.dart.assists.DartSourceEditException)1 RefactoringStatus (com.jetbrains.lang.dart.ide.refactoring.status.RefactoringStatus)1 SourceChange (org.dartlang.analysis.server.protocol.SourceChange)1 NotNull (org.jetbrains.annotations.NotNull)1