Search in sources :

Example 1 with RunMode

use of io.flutter.run.daemon.RunMode in project flutter-intellij by flutter.

the class SdkRunConfig method getState.

@NotNull
@Override
public LaunchState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
    final SdkFields launchFields = fields.copy();
    try {
        launchFields.checkRunnable(env.getProject());
    } catch (RuntimeConfigurationError e) {
        throw new ExecutionException(e);
    }
    final MainFile mainFile = MainFile.verify(launchFields.getFilePath(), env.getProject()).get();
    final Project project = env.getProject();
    final RunMode mode = RunMode.fromEnv(env);
    final Module module = ModuleUtil.findModuleForFile(mainFile.getFile(), env.getProject());
    final LaunchState.Callback callback = (device) -> {
        if (device == null)
            return null;
        final GeneralCommandLine command = fields.createFlutterSdkRunCommand(project, device, mode);
        final FlutterApp app = FlutterApp.start(env, project, module, mode, device, command, StringUtil.capitalize(mode.mode()) + "App", "StopApp");
        // Stop the app if the Flutter SDK changes.
        final FlutterSdkManager.Listener sdkListener = new FlutterSdkManager.Listener() {

            @Override
            public void flutterSdkRemoved() {
                app.shutdownAsync();
            }
        };
        FlutterSdkManager.getInstance(project).addListener(sdkListener);
        Disposer.register(project, () -> FlutterSdkManager.getInstance(project).removeListener(sdkListener));
        return app;
    };
    final LaunchState launcher = new LaunchState(env, mainFile.getAppDir(), mainFile.getFile(), this, callback);
    // Set up additional console filters.
    final TextConsoleBuilder builder = launcher.getConsoleBuilder();
    builder.addFilter(new DartConsoleFilter(env.getProject(), mainFile.getFile()));
    if (module != null) {
        builder.addFilter(new FlutterConsoleFilter(module));
    }
    return launcher;
}
Also used : XmlSerializer(com.intellij.util.xmlb.XmlSerializer) RunConfigurationWithSuppressedDefaultRunAction(com.intellij.execution.runners.RunConfigurationWithSuppressedDefaultRunAction) ExecutionException(com.intellij.execution.ExecutionException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) RefactoringElementListener(com.intellij.refactoring.listeners.RefactoringElementListener) InvalidDataException(com.intellij.openapi.util.InvalidDataException) com.intellij.execution.configurations(com.intellij.execution.configurations) UndoRefactoringElementAdapter(com.intellij.refactoring.listeners.UndoRefactoringElementAdapter) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) ModuleUtil(com.intellij.openapi.module.ModuleUtil) DartConsoleFilter(com.jetbrains.lang.dart.ide.runner.DartConsoleFilter) Disposer(com.intellij.openapi.util.Disposer) PsiElement(com.intellij.psi.PsiElement) SkipDefaultValuesSerializationFilters(com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) Module(com.intellij.openapi.module.Module) SettingsEditor(com.intellij.openapi.options.SettingsEditor) FlutterApp(io.flutter.run.daemon.FlutterApp) FlutterSdkManager(io.flutter.sdk.FlutterSdkManager) RunMode(io.flutter.run.daemon.RunMode) TextConsoleBuilder(com.intellij.execution.filters.TextConsoleBuilder) StringUtil(com.intellij.openapi.util.text.StringUtil) Executor(com.intellij.execution.Executor) Nullable(org.jetbrains.annotations.Nullable) PsiDirectory(com.intellij.psi.PsiDirectory) PathUtil(com.intellij.util.PathUtil) WriteExternalException(com.intellij.openapi.util.WriteExternalException) FlutterConsoleFilter(io.flutter.console.FlutterConsoleFilter) NotNull(org.jetbrains.annotations.NotNull) PsiFileSystemItem(com.intellij.psi.PsiFileSystemItem) Element(org.jdom.Element) FlutterApp(io.flutter.run.daemon.FlutterApp) RefactoringElementListener(com.intellij.refactoring.listeners.RefactoringElementListener) FlutterConsoleFilter(io.flutter.console.FlutterConsoleFilter) DartConsoleFilter(com.jetbrains.lang.dart.ide.runner.DartConsoleFilter) Project(com.intellij.openapi.project.Project) TextConsoleBuilder(com.intellij.execution.filters.TextConsoleBuilder) FlutterSdkManager(io.flutter.sdk.FlutterSdkManager) RunMode(io.flutter.run.daemon.RunMode) ExecutionException(com.intellij.execution.ExecutionException) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with RunMode

use of io.flutter.run.daemon.RunMode in project flutter-intellij by flutter.

the class BazelRunConfig method getState.

@NotNull
@Override
public LaunchState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
    final BazelFields launchFields = fields.copy();
    try {
        launchFields.checkRunnable(env.getProject());
    } catch (RuntimeConfigurationError e) {
        throw new ExecutionException(e);
    }
    final MainFile main = MainFile.verify(launchFields.getEntryFile(), env.getProject()).get();
    final RunMode mode = RunMode.fromEnv(env);
    final Module module = ModuleUtil.findModuleForFile(main.getFile(), env.getProject());
    final LaunchState.Callback callback = (device) -> {
        if (device == null)
            return null;
        final GeneralCommandLine command = launchFields.getLaunchCommand(env.getProject(), device, mode);
        return FlutterApp.start(env, env.getProject(), module, mode, device, command, StringUtil.capitalize(mode.mode()) + "BazelApp", "StopBazelApp");
    };
    return new LaunchState(env, main.getAppDir(), main.getFile(), this, callback);
}
Also used : RunMode(io.flutter.run.daemon.RunMode) XmlSerializer(com.intellij.util.xmlb.XmlSerializer) RunConfigurationWithSuppressedDefaultRunAction(com.intellij.execution.runners.RunConfigurationWithSuppressedDefaultRunAction) ExecutionException(com.intellij.execution.ExecutionException) StringUtil(com.intellij.openapi.util.text.StringUtil) MainFile(io.flutter.run.MainFile) Executor(com.intellij.execution.Executor) InvalidDataException(com.intellij.openapi.util.InvalidDataException) com.intellij.execution.configurations(com.intellij.execution.configurations) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) ModuleUtil(com.intellij.openapi.module.ModuleUtil) SkipDefaultValuesSerializationFilters(com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters) LaunchState(io.flutter.run.LaunchState) Project(com.intellij.openapi.project.Project) Module(com.intellij.openapi.module.Module) WriteExternalException(com.intellij.openapi.util.WriteExternalException) NotNull(org.jetbrains.annotations.NotNull) Element(org.jdom.Element) SettingsEditor(com.intellij.openapi.options.SettingsEditor) FlutterApp(io.flutter.run.daemon.FlutterApp) MainFile(io.flutter.run.MainFile) RunMode(io.flutter.run.daemon.RunMode) LaunchState(io.flutter.run.LaunchState) ExecutionException(com.intellij.execution.ExecutionException) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ExecutionException (com.intellij.execution.ExecutionException)2 Executor (com.intellij.execution.Executor)2 com.intellij.execution.configurations (com.intellij.execution.configurations)2 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)2 RunConfigurationWithSuppressedDefaultRunAction (com.intellij.execution.runners.RunConfigurationWithSuppressedDefaultRunAction)2 Module (com.intellij.openapi.module.Module)2 ModuleUtil (com.intellij.openapi.module.ModuleUtil)2 SettingsEditor (com.intellij.openapi.options.SettingsEditor)2 Project (com.intellij.openapi.project.Project)2 InvalidDataException (com.intellij.openapi.util.InvalidDataException)2 WriteExternalException (com.intellij.openapi.util.WriteExternalException)2 StringUtil (com.intellij.openapi.util.text.StringUtil)2 SkipDefaultValuesSerializationFilters (com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters)2 XmlSerializer (com.intellij.util.xmlb.XmlSerializer)2 FlutterApp (io.flutter.run.daemon.FlutterApp)2 RunMode (io.flutter.run.daemon.RunMode)2 Element (org.jdom.Element)2 NotNull (org.jetbrains.annotations.NotNull)2 TextConsoleBuilder (com.intellij.execution.filters.TextConsoleBuilder)1 Disposer (com.intellij.openapi.util.Disposer)1