Search in sources :

Example 26 with DartSdk

use of com.jetbrains.lang.dart.sdk.DartSdk in project intellij-plugins by JetBrains.

the class DartAnalysisServerService method serverReadyForRequest.

public boolean serverReadyForRequest(@NotNull final Project project) {
    final DartSdk sdk = DartSdk.getDartSdk(project);
    if (sdk == null || !isDartSdkVersionSufficient(sdk)) {
        stopServer();
        return false;
    }
    ApplicationManager.getApplication().assertReadAccessAllowed();
    synchronized (myLock) {
        if (myServer == null || !sdk.getHomePath().equals(mySdkHome) || !sdk.getVersion().equals(mySdkVersion) || !myServer.isSocketOpen()) {
            stopServer();
            startServer(sdk);
            if (myServer != null) {
                myRootsHandler.ensureProjectServed();
            }
        }
        return myServer != null;
    }
}
Also used : DartSdk(com.jetbrains.lang.dart.sdk.DartSdk)

Example 27 with DartSdk

use of com.jetbrains.lang.dart.sdk.DartSdk in project intellij-plugins by JetBrains.

the class PubServerManager method send.

public void send(@NotNull Channel clientChannel, @NotNull FullHttpRequest clientRequest, @NotNull HttpHeaders extraHeaders, @NotNull VirtualFile servedDir, @NotNull String pathForPubServer) {
    final DartSdk sdk = DartSdk.getDartSdk(project);
    if (sdk != null && !sdk.getVersion().equals(myServedSdkVersion)) {
        stopAllPubServerProcesses();
        myServedSdkVersion = sdk.getVersion();
    }
    try {
        // servedDir - web or test, direct child of directory containing pubspec.yaml
        myServedDirToPubService.get(servedDir).sendToPubServer(clientChannel, clientRequest, extraHeaders, servedDir, pathForPubServer);
    } catch (ExecutionException e) {
        LOG.error(e);
    }
}
Also used : DartSdk(com.jetbrains.lang.dart.sdk.DartSdk) ExecutionException(java.util.concurrent.ExecutionException)

Example 28 with DartSdk

use of com.jetbrains.lang.dart.sdk.DartSdk in project intellij-plugins by JetBrains.

the class PubServerService method createProcessHandler.

@Override
@Nullable
protected OSProcessHandler createProcessHandler(@NotNull final Project project, final int port) throws ExecutionException {
    final DartSdk dartSdk = DartSdk.getDartSdk(project);
    if (dartSdk == null)
        return null;
    final GeneralCommandLine commandLine = new GeneralCommandLine().withWorkDirectory(firstServedDir.getParent().getPath());
    commandLine.setExePath(FileUtil.toSystemDependentName(DartSdkUtil.getPubPath(dartSdk)));
    commandLine.addParameter("serve");
    commandLine.addParameter(firstServedDir.getName());
    commandLine.addParameter("--port=" + String.valueOf(port));
    commandLine.withEnvironment(DartPubActionBase.PUB_ENV_VAR_NAME, DartPubActionBase.getPubEnvValue());
    final OSProcessHandler processHandler = new OSProcessHandler(commandLine);
    processHandler.addProcessListener(new PubServeOutputListener(project));
    return processHandler;
}
Also used : DartSdk(com.jetbrains.lang.dart.sdk.DartSdk) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) Nullable(org.jetbrains.annotations.Nullable)

Example 29 with DartSdk

use of com.jetbrains.lang.dart.sdk.DartSdk in project intellij-plugins by JetBrains.

the class DartTestRunningState method startProcess.

@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
    Project project = getEnvironment().getProject();
    DartSdk sdk = DartSdk.getDartSdk(project);
    // can't happen, already checked
    if (sdk == null)
        throw new ExecutionException("Dart SDK cannot be found");
    DartTestRunnerParameters params = getParameters();
    StringBuilder builder = new StringBuilder();
    builder.append(RUN_COMMAND);
    final boolean projectWithoutPubspec = Registry.is("dart.projects.without.pubspec", false);
    final String targetName = params.getTargetName();
    final String testRunnerOptions = params.getTestRunnerOptions();
    if (projectWithoutPubspec && params.getScope() == DartTestRunnerParameters.Scope.FOLDER && targetName != null && !targetName.isEmpty()) {
        builder.append(" ").append(":").append(targetName).append(" ").append(EXPANDED_REPORTER_OPTION);
        if (testRunnerOptions != null && !testRunnerOptions.isEmpty()) {
            builder.append(" ").append(testRunnerOptions);
        }
    } else {
        builder.append(' ').append(TEST_PACKAGE_SPEC);
        builder.append(' ').append(EXPANDED_REPORTER_OPTION);
        if (testRunnerOptions != null && !testRunnerOptions.isEmpty()) {
            builder.append(" ").append(testRunnerOptions);
        }
        builder.append(' ').append(params.getFilePath());
        if (params.getScope() == DartTestRunnerParameters.Scope.GROUP_OR_TEST_BY_NAME) {
            builder.append(" -N \"").append(StringUtil.notNullize(params.getTestName())).append("\"");
        }
        if (params.getScope() == DartTestRunnerParameters.Scope.MULTIPLE_NAMES) {
            final String regex = StringUtil.notNullize(params.getTestName());
            // may be empty only in case of Rerun Failed Tests when there are no failed ones yet
            if (regex.isEmpty()) {
                throw new ExecutionException("No tests to run");
            }
            builder.append(" -n \"").append(regex).append("\"");
        }
    }
    params.setArguments(builder.toString());
    params.setCheckedMode(false);
    // working directory is not configurable in UI because there's only one valid value that we calculate ourselves
    params.setWorkingDirectory(params.computeProcessWorkingDirectory(project));
    return doStartProcess(DartSdkUtil.getPubSnapshotPath(sdk));
}
Also used : Project(com.intellij.openapi.project.Project) DartSdk(com.jetbrains.lang.dart.sdk.DartSdk) ExecutionException(com.intellij.execution.ExecutionException) NotNull(org.jetbrains.annotations.NotNull)

Example 30 with DartSdk

use of com.jetbrains.lang.dart.sdk.DartSdk in project intellij-plugins by JetBrains.

the class DartTestUtils method letAnalyzerSmellCoreFile.

public static void letAnalyzerSmellCoreFile(@NotNull final CodeInsightTestFixture fixture, @NotNull final String fileName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    final DartSdk sdk = DartSdk.getDartSdk(fixture.getProject());
    final VirtualFile iterableFile = LocalFileSystem.getInstance().findFileByPath(sdk.getHomePath() + "/lib/core/" + fileName);
    TestCase.assertNotNull(iterableFile);
    fixture.openFileInEditor(iterableFile);
    // let's keep updateVisibleFiles() method package-local, but here we need to invoke it because FileEditorManagerListener is not notified in test environment
    final Method method = DartAnalysisServerService.class.getDeclaredMethod("updateVisibleFiles");
    method.setAccessible(true);
    method.invoke(DartAnalysisServerService.getInstance(fixture.getProject()));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DartSdk(com.jetbrains.lang.dart.sdk.DartSdk) Method(java.lang.reflect.Method)

Aggregations

DartSdk (com.jetbrains.lang.dart.sdk.DartSdk)30 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 Module (com.intellij.openapi.module.Module)8 Nullable (org.jetbrains.annotations.Nullable)8 Project (com.intellij.openapi.project.Project)6 NotNull (org.jetbrains.annotations.NotNull)6 ExecutionException (com.intellij.execution.ExecutionException)4 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)3 EvictingQueue (com.google.common.collect.EvictingQueue)2 Lists (com.google.common.collect.Lists)2 Uninterruptibles (com.google.common.util.concurrent.Uninterruptibles)2 com.google.dart.server (com.google.dart.server)2 AnalysisServer (com.google.dart.server.generated.AnalysisServer)2 DebugPrintStream (com.google.dart.server.internal.remote.DebugPrintStream)2 RemoteAnalysisServerImpl (com.google.dart.server.internal.remote.RemoteAnalysisServerImpl)2 StdioServerSocket (com.google.dart.server.internal.remote.StdioServerSocket)2 Logging (com.google.dart.server.utilities.logging.Logging)2 IntentionManager (com.intellij.codeInsight.intention.IntentionManager)2 RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)2 Disposable (com.intellij.openapi.Disposable)2