use of com.jetbrains.lang.dart.sdk.DartSdk in project intellij-plugins by JetBrains.
the class DartSdkConfigurationTest method testSdkRootsUsingBlacklist.
public void testSdkRootsUsingBlacklist() throws Exception {
final DartSdk sdk = DartSdk.getDartSdk(getProject());
assertNotNull(sdk);
final String[] actualRoots = ArrayUtil.toStringArray(DartSdkLibUtil.getRootUrlsFailover(sdk.getHomePath()));
checkSdkRoots(sdk.getHomePath(), actualRoots);
}
use of com.jetbrains.lang.dart.sdk.DartSdk in project intellij-plugins by JetBrains.
the class AbstractDartFileProcessingAction method update.
@Override
public void update(final AnActionEvent event) {
final Presentation presentation = event.getPresentation();
final Project project = event.getProject();
if (project == null) {
presentation.setEnabledAndVisible(false);
return;
}
final DartSdk sdk = DartSdk.getDartSdk(project);
if (sdk == null || !DartAnalysisServerService.isDartSdkVersionSufficient(sdk)) {
presentation.setEnabledAndVisible(false);
return;
}
final Editor editor = event.getData(CommonDataKeys.EDITOR);
if (editor != null) {
final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
// visible for any Dart file, but enabled for applicable only
presentation.setVisible(psiFile != null && psiFile.getFileType() == DartFileType.INSTANCE);
presentation.setEnabled(isApplicableFile(psiFile));
presentation.setText(getActionTextForEditor());
return;
}
final VirtualFile[] filesAndDirs = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(event.getDataContext());
if (filesAndDirs == null) {
presentation.setEnabledAndVisible(false);
return;
}
presentation.setEnabledAndVisible(mayHaveApplicableDartFiles(project, filesAndDirs));
presentation.setText(getActionTextForFiles());
}
use of com.jetbrains.lang.dart.sdk.DartSdk in project intellij-plugins by JetBrains.
the class DartCoverageProgramRunner method doExecute.
@Nullable
@Override
protected RunContentDescriptor doExecute(@NotNull final RunProfileState state, @NotNull final ExecutionEnvironment env) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
final DartCommandLineRunConfiguration runConfiguration = (DartCommandLineRunConfiguration) env.getRunProfile();
final DartSdk sdk = DartSdk.getDartSdk(runConfiguration.getProject());
if (sdk == null) {
throw new ExecutionException(DartBundle.message("dart.sdk.is.not.configured"));
}
final String dartPubPath = DartSdkUtil.getPubPath(sdk);
final RunContentDescriptor result = DefaultProgramRunnerKt.executeState(state, env, this);
if (result == null) {
return null;
}
if (!myCoveragePackageActivated && !activateCoverage(runConfiguration.getProject(), dartPubPath)) {
throw new ExecutionException("Cannot activate pub package 'coverage'.");
}
final ProcessHandler dartAppProcessHandler = result.getProcessHandler();
if (dartAppProcessHandler != null) {
((DartCommandLineRunningState) state).addObservatoryUrlConsumer(observatoryUrl -> startCollectingCoverage(env, dartAppProcessHandler, observatoryUrl));
}
return result;
}
use of com.jetbrains.lang.dart.sdk.DartSdk in project intellij-plugins by JetBrains.
the class AbstractDartFileProcessingAction method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent event) {
final Project project = event.getProject();
if (project == null)
return;
final DartSdk sdk = DartSdk.getDartSdk(project);
if (sdk == null || !DartAnalysisServerService.isDartSdkVersionSufficient(sdk))
return;
PsiDocumentManager.getInstance(project).commitAllDocuments();
final Editor editor = event.getData(CommonDataKeys.EDITOR);
if (editor != null) {
final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
if (!isApplicableFile(psiFile))
return;
runOverEditor(project, editor, psiFile);
} else {
final VirtualFile[] filesAndDirs = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(event.getDataContext());
if (filesAndDirs != null && DartAnalysisServerService.getInstance(project).serverReadyForRequest(project)) {
final List<VirtualFile> files = getApplicableVirtualFiles(project, filesAndDirs);
runOverFiles(project, files);
}
}
}
use of com.jetbrains.lang.dart.sdk.DartSdk in project intellij-plugins by JetBrains.
the class DartPubActionBase method performPubAction.
public void performPubAction(@NotNull final Module module, @NotNull final VirtualFile pubspecYamlFile, final boolean allowModalDialogs) {
DartSdk sdk = DartSdk.getDartSdk(module.getProject());
if (sdk == null && allowModalDialogs) {
final int answer = Messages.showDialog(module.getProject(), DartBundle.message("dart.sdk.is.not.configured"), getTitle(pubspecYamlFile), new String[] { DartBundle.message("setup.dart.sdk"), CommonBundle.getCancelButtonText() }, Messages.OK, Messages.getErrorIcon());
if (answer != Messages.OK)
return;
DartConfigurable.openDartSettings(module.getProject());
sdk = DartSdk.getDartSdk(module.getProject());
}
if (sdk == null)
return;
File pubFile = new File(DartSdkUtil.getPubPath(sdk));
if (!pubFile.isFile() && allowModalDialogs) {
final int answer = Messages.showDialog(module.getProject(), DartBundle.message("dart.sdk.bad.dartpub.path", pubFile.getPath()), getTitle(pubspecYamlFile), new String[] { DartBundle.message("setup.dart.sdk"), CommonBundle.getCancelButtonText() }, Messages.OK, Messages.getErrorIcon());
if (answer != Messages.OK)
return;
DartConfigurable.openDartSettings(module.getProject());
sdk = DartSdk.getDartSdk(module.getProject());
if (sdk == null)
return;
pubFile = new File(DartSdkUtil.getPubPath(sdk));
}
if (!pubFile.isFile())
return;
final String[] pubParameters = calculatePubParameters(module.getProject(), pubspecYamlFile);
if (pubParameters != null) {
final GeneralCommandLine command = new GeneralCommandLine().withWorkDirectory(pubspecYamlFile.getParent().getPath());
if (FlutterUtil.isFlutterModule(module)) {
final String flutterRoot = FlutterUtil.getFlutterRoot(sdk.getHomePath());
if (flutterRoot != null) {
command.getEnvironment().put("FLUTTER_ROOT", FileUtil.toSystemDependentName(flutterRoot));
}
}
command.setExePath(pubFile.getPath());
command.addParameters(pubParameters);
doPerformPubAction(module, pubspecYamlFile, command, getTitle(pubspecYamlFile));
}
}
Aggregations