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;
}
}
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);
}
}
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;
}
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));
}
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()));
}
Aggregations