Search in sources :

Example 1 with FlutterDoctorAction

use of io.flutter.actions.FlutterDoctorAction in project flutter-intellij by flutter.

the class FlutterModuleBuilder method commitModule.

@Nullable
@Override
public Module commitModule(@NotNull Project project, @Nullable ModifiableModuleModel model) {
    final String basePath = getModuleFileDirectory();
    if (basePath == null) {
        Messages.showErrorDialog("Module path not set", "Internal Error");
        return null;
    }
    final VirtualFile baseDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(basePath);
    if (baseDir == null) {
        Messages.showErrorDialog("Unable to determine Flutter project directory", "Internal Error");
        return null;
    }
    final FlutterSdk sdk = getFlutterSdk();
    if (sdk == null) {
        Messages.showErrorDialog("Flutter SDK not found", "Error");
        return null;
    }
    final OutputListener listener = new OutputListener();
    final PubRoot root = runFlutterCreateWithProgress(baseDir, sdk, project, listener, getAdditionalSettings());
    if (root == null) {
        final String stderr = listener.getOutput().getStderr();
        final String msg = stderr.isEmpty() ? "Flutter create command was unsuccessful" : stderr;
        final int code = FlutterMessages.showDialog(project, msg, "Project Creation Error", new String[] { "Run Flutter Doctor", "Cancel" }, 0);
        if (code == 0) {
            new FlutterDoctorAction().startCommand(project, sdk, null);
        }
        return null;
    }
    FlutterSdkUtil.updateKnownSdkPaths(sdk.getHomePath());
    // Create the Flutter module. This indirectly calls setupRootModule, etc.
    final Module flutter = super.commitModule(project, model);
    if (flutter == null) {
        return null;
    }
    FlutterModuleUtils.autoShowMain(project, root);
    addAndroidModule(project, model, basePath, flutter.getName());
    return flutter;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FlutterDoctorAction(io.flutter.actions.FlutterDoctorAction) FlutterSdk(io.flutter.sdk.FlutterSdk) PubRoot(io.flutter.pub.PubRoot) OutputListener(com.intellij.execution.OutputListener) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

OutputListener (com.intellij.execution.OutputListener)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 FlutterDoctorAction (io.flutter.actions.FlutterDoctorAction)1 PubRoot (io.flutter.pub.PubRoot)1 FlutterSdk (io.flutter.sdk.FlutterSdk)1 Nullable (org.jetbrains.annotations.Nullable)1