Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for old Flutter SDKs #7883

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flutter-idea/src/io/flutter/FlutterInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ private void checkSdkVersionNotification(@NotNull Project project) {
final FlutterSdkVersion version = sdk.getVersion();

// See FlutterSdkVersion.MIN_SDK_SUPPORTED.
if (version.isValid() && !version.sdkIsSupported()) {
if (version.isValid() && !version.isSDKSupported()) {
final FlutterSettings settings = FlutterSettings.getInstance();
if (settings == null || settings.isSdkVersionOutdatedWarningAcknowledged(version.getVersionText())) return;

Expand Down
26 changes: 9 additions & 17 deletions flutter-idea/src/io/flutter/actions/OpenInXcodeAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ private static void openFile(@NotNull VirtualFile file) {
final ProgressHelper progressHelper = new ProgressHelper(project);
progressHelper.start("Building for iOS");

String buildArg = "--config-only";
if (!sdk.getVersion().isXcodeConfigOnlySupported()) {
buildArg = "--simulator";
}
String buildArg = "--simulator";
// TODO(pq): consider a popup explaining why we're doing a build.
// Note: we build only for the simulator to bypass device provisioning issues.
final ColoredProcessHandler processHandler = sdk.flutterBuild(pubRoot, "ios", buildArg).startInConsole(project);
Expand Down Expand Up @@ -106,19 +103,14 @@ public void processTerminated(@NotNull ProcessEvent event) {
}

private static boolean hasBeenBuilt(@NotNull PubRoot pubRoot, @NotNull FlutterSdk sdk) {
if (sdk.getVersion().isXcodeConfigOnlySupported()) {
// Derived from packages/flutter_tools/test/integration.shard/build_ios_config_only_test.dart
final VirtualFile ios = pubRoot.getRoot().findChild("ios");
if (ios == null || !ios.isDirectory()) return false;
final VirtualFile flutter = ios.findChild("Flutter");
if (flutter == null || !flutter.isDirectory()) return false;
final VirtualFile gen = flutter.findChild("Generated.xcconfig");
if (gen == null || gen.isDirectory()) return false;
return sdk.isOlderThanToolsStamp(gen);
} else {
final VirtualFile buildDir = pubRoot.getRoot().findChild("build");
return buildDir != null && buildDir.isDirectory() && buildDir.findChild("ios") != null;
}
// Derived from packages/flutter_tools/test/integration.shard/build_ios_config_only_test.dart
final VirtualFile ios = pubRoot.getRoot().findChild("ios");
if (ios == null || !ios.isDirectory()) return false;
final VirtualFile flutter = ios.findChild("Flutter");
if (flutter == null || !flutter.isDirectory()) return false;
final VirtualFile gen = flutter.findChild("Generated.xcconfig");
if (gen == null || gen.isDirectory()) return false;
return sdk.isOlderThanToolsStamp(gen);
}

private static void openWithXcode(@Nullable Project project, String path) {
Expand Down
6 changes: 0 additions & 6 deletions flutter-idea/src/io/flutter/dart/DartPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@
*/
public class DartPlugin {

/**
* Tracks the minimum required Dart Plugin version.
*/
@NotNull
private static final Version MINIMUM_VERSION = Objects.requireNonNull(Version.parseVersion("171.3780.79"));

@NotNull
private static final DartPlugin INSTANCE = new DartPlugin();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,27 +177,10 @@ else if (parentNode.getElementType() == DartTokenTypes.SIMPLE_TYPE) {
final String selector = AstBufferUtil.getTextSkippingWhitespaceComments(selectorNode.getNode());
final Icon icon;
if (name.equals("Icons")) {
if (sdk.getVersion().canUseDistributedIcons()) {
icon = FlutterMaterialIcons.getIconForName(selector);
}
else {
final IconInfo iconDef = findStandardDefinition(name, selector, element.getProject(), knownPath, sdk);
if (iconDef == null) return null;
// <flutter-sdk>/bin/cache/artifacts/material_fonts/MaterialIcons-Regular.otf
icon = findStandardIconFromDef(name, iconDef, sdk.getHomePath() + MaterialRelativeAssetPath);
}
icon = FlutterMaterialIcons.getIconForName(selector);
}
else if (name.equals("CupertinoIcons")) {
if (sdk.getVersion().canUseDistributedIcons()) {
icon = FlutterCupertinoIcons.getIconForName(selector);
}
else {
final IconInfo iconDef = findStandardDefinition(name, selector, element.getProject(), knownPath, sdk);
if (iconDef == null) return null;
final String path = FlutterSdkUtil.getPathToCupertinoIconsPackage(element.getProject());
// <pub_cache>/hosted/pub.dartlang.org/cupertino_icons-v.m.n/assets/CupertinoIcons.ttf
icon = findStandardIconFromDef(name, iconDef, path + CupertinoRelativeAssetPath);
}
icon = FlutterCupertinoIcons.getIconForName(selector);
}
else {
// Note: I want to keep this code until I'm sure we won't use pubspec.yaml.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,9 @@ static class FlutterPubspecActionsPanel extends EditorNotificationPanel {
label = createActionLabel("Pub upgrade", () -> runPubGet(true));
label.setToolTipText("Upgrade referenced packages to the latest versions");

// If the SDK is the right version, add a 'flutter pub outdated' command.
if (myFlutterSdk.getVersion().isPubOutdatedSupported()) {
// "flutter.pub.outdated"
label = createActionLabel("Pub outdated", this::runPubOutdated);
label.setToolTipText("Analyze packages to determine which ones can be upgraded");
}
// "flutter.pub.outdated"
label = createActionLabel("Pub outdated", this::runPubOutdated);
label.setToolTipText("Analyze packages to determine which ones can be upgraded");

if (myLinksPanel != null) {
myLinksPanel.add(new JSeparator(SwingConstants.VERTICAL));
Expand Down
22 changes: 3 additions & 19 deletions flutter-idea/src/io/flutter/module/settings/ProjectType.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,25 +135,9 @@ public void addListener(ItemListener listener) {
}

public void updateProjectTypes() {
FlutterSdkVersion version = getSdk.get().getVersion();
ProjectTypeComboBoxModel model = (ProjectTypeComboBoxModel)projectTypeCombo.getModel();
if (version.isSkeletonTemplateAvailable()) {
model.addSkeleton();
}
else {
model.removeSkeleton();
}
if (version.isPluginFfiTemplateAvailable()) {
model.addPluginFfi();
}
else {
model.removePluginFfi();
}
if (version.isEmptyProjectAvailable()) {
model.addEmptyProject();
}
else {
model.removeEmptyProject();
}
model.addSkeleton();
model.addPluginFfi();
model.addEmptyProject();
}
}
60 changes: 29 additions & 31 deletions flutter-idea/src/io/flutter/run/SdkFields.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,44 +195,42 @@ public GeneralCommandLine createFlutterSdkRunCommand(
if (buildFlavor != null) {
args = ArrayUtil.append(args, "--flavor=" + buildFlavor);
}
if (FlutterSettings.getInstance().isShowStructuredErrors() && flutterSdk.getVersion().isDartDefineSupported()) {
if (FlutterSettings.getInstance().isShowStructuredErrors()) {
args = ArrayUtil.append(args, "--dart-define=flutter.inspector.structuredErrors=true");
}

if (flutterSdk.getVersion().flutterRunSupportsDevToolsUrl()) {
try {
final ProgressManager progress = ProgressManager.getInstance();

final CompletableFuture<DevToolsInstance> devToolsFuture = new CompletableFuture<>();
progress.runProcessWithProgressSynchronously(() -> {
progress.getProgressIndicator().setIndeterminate(true);
try {
final CompletableFuture<DevToolsInstance> futureInstance = DevToolsService.getInstance(project).getDevToolsInstance();
if (firstRun) {
devToolsFuture.complete(futureInstance.get(30, TimeUnit.SECONDS));
try {
final ProgressManager progress = ProgressManager.getInstance();

final CompletableFuture<DevToolsInstance> devToolsFuture = new CompletableFuture<>();
progress.runProcessWithProgressSynchronously(() -> {
progress.getProgressIndicator().setIndeterminate(true);
try {
final CompletableFuture<DevToolsInstance> futureInstance = DevToolsService.getInstance(project).getDevToolsInstance();
if (firstRun) {
devToolsFuture.complete(futureInstance.get(30, TimeUnit.SECONDS));
}
else {
// Skip waiting if this isn't the first time running this project. If DevTools isn't available by now, there's likely to be
// something wrong that won't be fixed by restarting, so we don't want to keep delaying run.
final DevToolsInstance instance = futureInstance.getNow(null);
if (instance == null) {
devToolsFuture.completeExceptionally(new Exception("DevTools instance not available after first run."));
}
else {
// Skip waiting if this isn't the first time running this project. If DevTools isn't available by now, there's likely to be
// something wrong that won't be fixed by restarting, so we don't want to keep delaying run.
final DevToolsInstance instance = futureInstance.getNow(null);
if (instance == null) {
devToolsFuture.completeExceptionally(new Exception("DevTools instance not available after first run."));
}
else {
devToolsFuture.complete(instance);
}
devToolsFuture.complete(instance);
}
}
catch (Exception e) {
devToolsFuture.completeExceptionally(e);
}
}, "Starting DevTools", false, project);
final DevToolsInstance instance = devToolsFuture.get();
args = ArrayUtil.append(args, "--devtools-server-address=http://" + instance.host + ":" + instance.port);
}
catch (Exception e) {
LOG.info(e);
}
}
catch (Exception e) {
devToolsFuture.completeExceptionally(e);
}
}, "Starting DevTools", false, project);
final DevToolsInstance instance = devToolsFuture.get();
args = ArrayUtil.append(args, "--devtools-server-address=http://" + instance.host + ":" + instance.port);
}
catch (Exception e) {
LOG.info(e);
}
command = flutterSdk.flutterRun(root, main.getFile(), device, runMode, flutterLaunchMode, project, args);
final GeneralCommandLine commandLine = command.createGeneralCommandLine(project);
Expand Down
83 changes: 6 additions & 77 deletions flutter-idea/src/io/flutter/run/daemon/DevToolsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@
import com.google.gson.JsonSyntaxException;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.process.*;
import com.intellij.execution.process.ProcessAdapter;
import com.intellij.execution.process.ProcessEvent;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.process.ProcessOutput;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ProjectManagerListener;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.Version;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.registry.Registry;
import com.jetbrains.lang.dart.ide.devtools.DartDevToolsService;
import com.jetbrains.lang.dart.ide.toolingDaemon.DartToolingDaemonService;
import com.jetbrains.lang.dart.sdk.DartSdk;
Expand Down Expand Up @@ -185,12 +188,8 @@ private void startServer() {
ImmutableList.of("devtools", "--machine")));
}
}
else if (sdk != null && sdk.getVersion().useDaemonForDevTools()) {
setUpWithDaemon();
}
else {
// For earlier flutter versions we need to use pub directly to run the latest DevTools server.
setUpWithPub();
setUpWithDaemon();
}
});
}
Expand Down Expand Up @@ -310,76 +309,6 @@ public void projectClosing(@NotNull Project project) {
});
}

private void setUpWithPub() {
final FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
if (sdk == null) {
logExceptionAndComplete("Flutter SDK is null");
return;
}

pubActivateDevTools(sdk).thenAccept(success -> {
if (success) {
pubRunDevTools(sdk);
}
else {
logExceptionAndComplete("pub activate of DevTools failed");
}
});
}

private void pubRunDevTools(FlutterSdk sdk) {
final FlutterCommand command = sdk.flutterPub(null, "global", "run", "devtools", "--machine", "--port=0");

final ColoredProcessHandler handler = command.startProcessOrShowError(project);
if (handler == null) {
logExceptionAndComplete("Handler was null for pub global run command");
return;
}

handler.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) {
final String text = event.getText().trim();

if (text.startsWith("{") && text.endsWith("}")) {
// {"event":"server.started","params":{"host":"127.0.0.1","port":9100}}

try {
final JsonElement element = JsonUtils.parseString(text);

// params.port
final JsonObject obj = element.getAsJsonObject();
final JsonObject params = obj.getAsJsonObject("params");
final String host = JsonUtils.getStringMember(params, "host");
final int port = JsonUtils.getIntMember(params, "port");

if (port != -1) {
devToolsFutureRef.get().complete(new DevToolsInstance(host, port));
}
else {
logExceptionAndComplete("DevTools port was invalid");
handler.destroyProcess();
}
}
catch (JsonSyntaxException e) {
logExceptionAndComplete(e);
handler.destroyProcess();
}
}
}
});

handler.startNotify();

ProjectManager.getInstance().addProjectManagerListener(project, new ProjectManagerListener() {
@Override
public void projectClosing(@NotNull Project project) {
devToolsFutureRef.set(null);
handler.destroyProcess();
}
});
}

private CompletableFuture<Boolean> pubActivateDevTools(FlutterSdk sdk) {
final FlutterCommand command = sdk.flutterPub(null, "global", "activate", "devtools");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,15 @@ protected boolean setupConfigurationFromContext(@NotNull TestConfig config,
return false;
}

if (supportsFiltering(config.getSdk())) {
final String testName = testConfigUtils.findTestName(elt);
if (testName != null && elt != null) {
final boolean hasVariant = "testWidgets".equals(elt.getText());
return setupForSingleTest(config, context, file, testName, hasVariant);
}
final String testName = testConfigUtils.findTestName(elt);
if (testName != null && elt != null) {
final boolean hasVariant = "testWidgets".equals(elt.getText());
return setupForSingleTest(config, context, file, testName, hasVariant);
}

return setupForDartFile(config, context, file);
}

private boolean supportsFiltering(@Nullable FlutterSdk sdk) {
return sdk != null && sdk.getVersion().flutterTestSupportsFiltering();
}

private boolean setupForSingleTest(TestConfig config, ConfigurationContext context, DartFile file, String testName, boolean hasVariant) {
final VirtualFile testFile = verifyFlutterTestFile(config, context, file);
if (testFile == null) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
}

final FlutterSdk sdk = FlutterSdk.getFlutterSdk(((TestConfig)profile).getProject());
if (sdk == null || !sdk.getVersion().flutterTestSupportsMachineMode()) {
if (sdk == null) {
return false;
}

Expand Down
4 changes: 1 addition & 3 deletions flutter-idea/src/io/flutter/run/test/TestFields.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,7 @@ public enum Scope {
@Override
public void checkRunnable(@NotNull TestFields fields, @NotNull Project project) throws RuntimeConfigurationError {
final FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
if (sdk != null && !sdk.getVersion().flutterTestSupportsFiltering()) {
throw new RuntimeConfigurationError("Flutter SDK is too old to filter tests by name");
}
assert sdk != null;
FILE.checkRunnable(fields, project);
}
},
Expand Down
3 changes: 1 addition & 2 deletions flutter-idea/src/io/flutter/run/test/TestLaunchState.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ static TestLaunchState create(@NotNull ExecutionEnvironment env, @NotNull TestCo

final FlutterSdk sdk = FlutterSdk.getFlutterSdk(env.getProject());
assert (sdk != null);
final boolean testConsoleEnabled = sdk.getVersion().flutterTestSupportsMachineMode();

final TestLaunchState launcher = new TestLaunchState(env, config, fileOrDir, pubRoot, testConsoleEnabled);
final TestLaunchState launcher = new TestLaunchState(env, config, fileOrDir, pubRoot, true);
DaemonConsoleView.install(launcher, env, pubRoot.getRoot());
return launcher;
}
Expand Down
Loading
Loading