Search in sources :

Example 11 with SourceChange

use of org.dartlang.analysis.server.protocol.SourceChange in project intellij-plugins by JetBrains.

the class DartInlineLocalRefactoringTest method doTest.

private void doTest(String filePath) {
    final ServerInlineLocalRefactoring refactoring = createInlineLocalRefactoring(filePath);
    // check initial conditions
    final RefactoringStatus initialConditions = refactoring.checkInitialConditions();
    assertNotNull(initialConditions);
    assertTrue(initialConditions.isOK());
    // 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 : ServerInlineLocalRefactoring(com.jetbrains.lang.dart.ide.refactoring.ServerInlineLocalRefactoring) RefactoringStatus(com.jetbrains.lang.dart.ide.refactoring.status.RefactoringStatus) SourceChange(org.dartlang.analysis.server.protocol.SourceChange) DartSourceEditException(com.jetbrains.lang.dart.assists.DartSourceEditException)

Example 12 with SourceChange

use of org.dartlang.analysis.server.protocol.SourceChange in project intellij-plugins by JetBrains.

the class StatementCompletionProcessor method process.

public void process(JsonObject resultObject, RequestError requestError) {
    if (resultObject != null) {
        try {
            SourceChange sourceChange = SourceChange.fromJson(resultObject.get("change").getAsJsonObject());
            consumer.computedSourceChange(sourceChange);
        } catch (Exception exception) {
            // catch any exceptions in the formatting of this response
            requestError = generateRequestError(exception);
        }
    }
}
Also used : SourceChange(org.dartlang.analysis.server.protocol.SourceChange)

Aggregations

SourceChange (org.dartlang.analysis.server.protocol.SourceChange)12 DartSourceEditException (com.jetbrains.lang.dart.assists.DartSourceEditException)8 RefactoringStatus (com.jetbrains.lang.dart.ide.refactoring.status.RefactoringStatus)7 DartAnalysisServerService (com.jetbrains.lang.dart.analyzer.DartAnalysisServerService)2 JsonObject (com.google.gson.JsonObject)1 PsiElement2UsageTargetAdapter (com.intellij.find.findUsages.PsiElement2UsageTargetAdapter)1 TextRange (com.intellij.openapi.util.TextRange)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 PsiManager (com.intellij.psi.PsiManager)1 UsageInfo (com.intellij.usageView.UsageInfo)1 SmartList (com.intellij.util.SmartList)1 ServerExtractLocalVariableRefactoring (com.jetbrains.lang.dart.ide.refactoring.ServerExtractLocalVariableRefactoring)1 ServerExtractMethodRefactoring (com.jetbrains.lang.dart.ide.refactoring.ServerExtractMethodRefactoring)1 ServerInlineLocalRefactoring (com.jetbrains.lang.dart.ide.refactoring.ServerInlineLocalRefactoring)1 ServerInlineMethodRefactoring (com.jetbrains.lang.dart.ide.refactoring.ServerInlineMethodRefactoring)1 THashMap (gnu.trove.THashMap)1 Position (org.dartlang.analysis.server.protocol.Position)1 RefactoringFeedback (org.dartlang.analysis.server.protocol.RefactoringFeedback)1