Search in sources :

Example 16 with AnalysisServer

use of com.google.dart.server.generated.AnalysisServer in project intellij-plugins by JetBrains.

the class DartAnalysisServerService method analysis_getHover.

@NotNull
public List<HoverInformation> analysis_getHover(@NotNull final VirtualFile file, final int _offset) {
    final String filePath = FileUtil.toSystemDependentName(file.getPath());
    final List<HoverInformation> result = Lists.newArrayList();
    final AnalysisServer server = myServer;
    if (server == null) {
        return HoverInformation.EMPTY_LIST;
    }
    final CountDownLatch latch = new CountDownLatch(1);
    final int offset = getOriginalOffset(file, _offset);
    server.analysis_getHover(filePath, offset, new GetHoverConsumer() {

        @Override
        public void computedHovers(HoverInformation[] hovers) {
            Collections.addAll(result, hovers);
            latch.countDown();
        }

        @Override
        public void onError(RequestError error) {
            logError("analysis_getHover()", filePath, error);
            latch.countDown();
        }
    });
    awaitForLatchCheckingCanceled(server, latch, GET_HOVER_TIMEOUT);
    return result;
}
Also used : AnalysisServer(com.google.dart.server.generated.AnalysisServer) CountDownLatch(java.util.concurrent.CountDownLatch) NotNull(org.jetbrains.annotations.NotNull)

Example 17 with AnalysisServer

use of com.google.dart.server.generated.AnalysisServer in project intellij-plugins by JetBrains.

the class DartAnalysisServerService method edit_organizeDirectives.

@Nullable
public SourceFileEdit edit_organizeDirectives(@NotNull final String _filePath) {
    final String filePath = FileUtil.toSystemDependentName(_filePath);
    final Ref<SourceFileEdit> resultRef = new Ref<>();
    final AnalysisServer server = myServer;
    if (server == null)
        return null;
    final CountDownLatch latch = new CountDownLatch(1);
    server.edit_organizeDirectives(filePath, new OrganizeDirectivesConsumer() {

        @Override
        public void computedEdit(final SourceFileEdit edit) {
            resultRef.set(edit);
            latch.countDown();
        }

        @Override
        public void onError(final RequestError error) {
            if (RequestErrorCode.FILE_NOT_ANALYZED.equals(error.getCode()) || RequestErrorCode.ORGANIZE_DIRECTIVES_ERROR.equals(error.getCode())) {
                LOG.info(getShortErrorMessage("edit_organizeDirectives()", filePath, error));
            } else {
                logError("edit_organizeDirectives()", filePath, error);
            }
            latch.countDown();
        }
    });
    awaitForLatchCheckingCanceled(server, latch, EDIT_ORGANIZE_DIRECTIVES_TIMEOUT);
    if (latch.getCount() > 0) {
        LOG.info("edit_organizeDirectives() took too long for file " + filePath);
    }
    return resultRef.get();
}
Also used : Ref(com.intellij.openapi.util.Ref) AnalysisServer(com.google.dart.server.generated.AnalysisServer) CountDownLatch(java.util.concurrent.CountDownLatch) Nullable(org.jetbrains.annotations.Nullable)

Example 18 with AnalysisServer

use of com.google.dart.server.generated.AnalysisServer in project intellij-plugins by JetBrains.

the class DartAnalysisServerService method updateRoots.

public boolean updateRoots(@NotNull final List<String> includedRoots, @NotNull final List<String> excludedRoots) {
    AnalysisServer server = myServer;
    if (server == null) {
        return false;
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("analysis_setAnalysisRoots, included:\n" + StringUtil.join(includedRoots, ",\n") + "\nexcluded:\n" + StringUtil.join(excludedRoots, ",\n"));
    }
    server.analysis_setAnalysisRoots(includedRoots, excludedRoots, null);
    return true;
}
Also used : AnalysisServer(com.google.dart.server.generated.AnalysisServer)

Example 19 with AnalysisServer

use of com.google.dart.server.generated.AnalysisServer in project intellij-plugins by JetBrains.

the class DartAnalysisServerService method waitForAnalysisToComplete_TESTS_ONLY.

public void waitForAnalysisToComplete_TESTS_ONLY(@NotNull final VirtualFile file) {
    assert ApplicationManager.getApplication().isUnitTestMode();
    final AnalysisServer server = myServer;
    if (server == null)
        return;
    final CountDownLatch latch = new CountDownLatch(1);
    server.analysis_getErrors(FileUtil.toSystemDependentName(file.getPath()), new GetErrorsConsumer() {

        @Override
        public void computedErrors(AnalysisError[] errors) {
            latch.countDown();
        }

        @Override
        public void onError(RequestError requestError) {
            latch.countDown();
            LOG.error(requestError.getMessage());
        }
    });
    awaitForLatchCheckingCanceled(server, latch, ANALYSIS_IN_TESTS_TIMEOUT / TESTS_TIMEOUT_COEFF);
    assert latch.getCount() == 0 : "Analysis did't complete in " + ANALYSIS_IN_TESTS_TIMEOUT + "ms.";
}
Also used : AnalysisServer(com.google.dart.server.generated.AnalysisServer) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

AnalysisServer (com.google.dart.server.generated.AnalysisServer)19 CountDownLatch (java.util.concurrent.CountDownLatch)15 Nullable (org.jetbrains.annotations.Nullable)9 Ref (com.intellij.openapi.util.Ref)8 NotNull (org.jetbrains.annotations.NotNull)4 Document (com.intellij.openapi.editor.Document)2 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)2 EvictingQueue (com.google.common.collect.EvictingQueue)1 Lists (com.google.common.collect.Lists)1 Uninterruptibles (com.google.common.util.concurrent.Uninterruptibles)1 com.google.dart.server (com.google.dart.server)1 DebugPrintStream (com.google.dart.server.internal.remote.DebugPrintStream)1 RemoteAnalysisServerImpl (com.google.dart.server.internal.remote.RemoteAnalysisServerImpl)1 StdioServerSocket (com.google.dart.server.internal.remote.StdioServerSocket)1 Logging (com.google.dart.server.utilities.logging.Logging)1 IntentionManager (com.intellij.codeInsight.intention.IntentionManager)1 Disposable (com.intellij.openapi.Disposable)1 ApplicationInfo (com.intellij.openapi.application.ApplicationInfo)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 ApplicationNamesInfo (com.intellij.openapi.application.ApplicationNamesInfo)1