Search in sources :

Example 1 with RequestError

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

the class AnalysisServerDiagnosticsAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getProject();
    if (project == null)
        return;
    // Get the current analysis server.
    DartAnalysisServerService server = DartAnalysisServerService.getInstance(project);
    // Ask it for the diagnostics port.
    server.diagnostic_getServerPort(new GetServerPortConsumer() {

        @Override
        public void computedServerPort(int port) {
            // Open a new browser page.
            final String url = "http://localhost:" + port + "/status";
            OpenDartObservatoryUrlAction.openUrlInChromeFamilyBrowser(url);
        }

        @Override
        public void onError(RequestError requestError) {
            Notification notification = new Notification(GROUP_DISPLAY_ID, DartBundle.message("analysis.server.show.diagnostics.error"), requestError.getMessage(), NotificationType.ERROR);
            Notifications.Bus.notify(notification);
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) GetServerPortConsumer(com.google.dart.server.GetServerPortConsumer) RequestError(org.dartlang.analysis.server.protocol.RequestError) DartAnalysisServerService(com.jetbrains.lang.dart.analyzer.DartAnalysisServerService) Notification(com.intellij.notification.Notification)

Example 2 with RequestError

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

the class RemoteAnalysisServerImpl method processResponse.

private void processResponse(JsonObject response) throws Exception {
    // handle notification
    if (processNotification(response)) {
        return;
    }
    // prepare ID
    JsonPrimitive idJsonPrimitive = (JsonPrimitive) response.get("id");
    if (idJsonPrimitive == null) {
        return;
    }
    String idString = idJsonPrimitive.getAsString();
    // prepare consumer
    Consumer consumer;
    synchronized (consumerMapLock) {
        consumer = consumerMap.get(idString);
    }
    JsonObject errorObject = (JsonObject) response.get("error");
    RequestError requestError = null;
    if (errorObject != null) {
        requestError = processErrorResponse(errorObject);
        listener.requestError(requestError);
    }
    // handle result
    JsonObject resultObject = (JsonObject) response.get("result");
    //
    if (consumer instanceof UpdateContentConsumer) {
        ((UpdateContentConsumer) consumer).onResponse();
    } else //
    if (consumer instanceof GetSuggestionsConsumer) {
        new CompletionIdProcessor((GetSuggestionsConsumer) consumer).process(resultObject, requestError);
    } else //
    if (consumer instanceof FindElementReferencesConsumer) {
        new FindElementReferencesProcessor((FindElementReferencesConsumer) consumer).process(resultObject, requestError);
    } else if (consumer instanceof FindMemberDeclarationsConsumer) {
        new FindMemberDeclarationsProcessor((FindMemberDeclarationsConsumer) consumer).process(resultObject, requestError);
    } else if (consumer instanceof FindMemberReferencesConsumer) {
        new FindMemberReferencesProcessor((FindMemberReferencesConsumer) consumer).process(resultObject, requestError);
    } else if (consumer instanceof FindTopLevelDeclarationsConsumer) {
        new FindTopLevelDeclarationsProcessor((FindTopLevelDeclarationsConsumer) consumer).process(resultObject, requestError);
    } else if (consumer instanceof GetTypeHierarchyConsumer) {
        new TypeHierarchyProcessor((GetTypeHierarchyConsumer) consumer).process(resultObject, requestError);
    } else //
    if (consumer instanceof FormatConsumer) {
        new FormatProcessor((FormatConsumer) consumer).process(resultObject, requestError);
    } else if (consumer instanceof GetHoverConsumer) {
        new HoverProcessor((GetHoverConsumer) consumer).process(resultObject, requestError);
    } else if (consumer instanceof GetRefactoringConsumer) {
        new GetRefactoringProcessor(requestToRefactoringKindMap, (GetRefactoringConsumer) consumer).process(idString, resultObject, requestError);
    } else if (consumer instanceof GetAssistsConsumer) {
        new AssistsProcessor((GetAssistsConsumer) consumer).process(resultObject, requestError);
    } else if (consumer instanceof GetFixesConsumer) {
        new FixesProcessor((GetFixesConsumer) consumer).process(resultObject, requestError);
    } else if (consumer instanceof GetStatementCompletionConsumer) {
        new StatementCompletionProcessor((GetStatementCompletionConsumer) consumer).process(resultObject, requestError);
    } else if (consumer instanceof GetLibraryDependenciesConsumer) {
        new LibraryDependenciesProcessor((GetLibraryDependenciesConsumer) consumer).process(resultObject, requestError);
    } else if (consumer instanceof GetNavigationConsumer) {
        new GetNavigationProcessor((GetNavigationConsumer) consumer).process(resultObject, requestError);
    } else if (consumer instanceof GetAvailableRefactoringsConsumer) {
        new RefactoringGetAvailableProcessor((GetAvailableRefactoringsConsumer) consumer).process(resultObject, requestError);
    } else if (consumer instanceof GetErrorsConsumer) {
        new AnalysisErrorsProcessor((GetErrorsConsumer) consumer).process(resultObject, requestError);
    } else if (consumer instanceof OrganizeDirectivesConsumer) {
        new OrganizeDirectivesProcessor((OrganizeDirectivesConsumer) consumer).process(resultObject, requestError);
    } else if (consumer instanceof SortMembersConsumer) {
        new SortMembersProcessor((SortMembersConsumer) consumer).process(resultObject, requestError);
    } else //
    if (consumer instanceof CreateContextConsumer) {
        new CreateContextProcessor((CreateContextConsumer) consumer).process(resultObject, requestError);
    } else if (consumer instanceof MapUriConsumer) {
        new MapUriProcessor((MapUriConsumer) consumer).process(resultObject, requestError);
    } else //
    if (consumer instanceof GetServerPortConsumer) {
        new GetServerPortProcessor((GetServerPortConsumer) consumer).process(resultObject, requestError);
    } else //
    if (consumer instanceof GetVersionConsumer) {
        new VersionProcessor((GetVersionConsumer) consumer).process(resultObject, requestError);
    } else if (consumer instanceof BasicConsumer) {
        ((BasicConsumer) consumer).received();
    }
    synchronized (consumerMapLock) {
        consumerMap.remove(idString);
    }
}
Also used : JsonObject(com.google.gson.JsonObject) JsonPrimitive(com.google.gson.JsonPrimitive) RequestError(org.dartlang.analysis.server.protocol.RequestError)

Aggregations

RequestError (org.dartlang.analysis.server.protocol.RequestError)2 GetServerPortConsumer (com.google.dart.server.GetServerPortConsumer)1 JsonObject (com.google.gson.JsonObject)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 Notification (com.intellij.notification.Notification)1 Project (com.intellij.openapi.project.Project)1 DartAnalysisServerService (com.jetbrains.lang.dart.analyzer.DartAnalysisServerService)1