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

Show error when Dart SDK is not set correctly (#636) #637

Closed
wants to merge 2 commits into from
Closed

Show error when Dart SDK is not set correctly (#636) #637

wants to merge 2 commits into from

Conversation

skybrian
Copy link
Contributor

No description provided.

@alexander-doroshko
Copy link
Contributor

Flutter users do not need to use the Dart page in Preferences and to know much about Dart SDK. I'd suggest rephrasing: it is Flutter SDK that is not set, and it is Flutter page in Settings (Linux) or Preferences (Mac) where user should set Flutter SDK.
Yes, under the hood IDE will automatically change Dart SDK as well (to bin/cache/dart-sdk), but this is not something user should care about.
P.S. I believe this check has already been there at some point, @pq should remember better.

@skybrian
Copy link
Contributor Author

skybrian commented Jan 18, 2017

I tested the error message by changing the Dart SDK, so that does work. I guess what you're saying is that modifying the Flutter SDK also works?

If the user sets the Flutter SDK and then the Dart SDK, it seems like that might lead to confusion, if they don't know they're linked? I wonder if there is anything we can do to make this more obvious. Perhaps in a Flutter module, the Dart SDK should appear to be locked down (no edit allowed).

@alexander-doroshko
Copy link
Contributor

alexander-doroshko commented Jan 18, 2017

You are right, there's a field for the Dart SDK in the Dart page and for the Flutter SDK in the Flutter page. And inside the model used by the IDE it is the same setting. Changing one SDK path affects another SDK path and vice versa. It may be not obvious for users.

Indeed, you may be confused if you change both SDKs in one shot. Only one of them wins and the next time you open Preferences you'll see it.

Also you may be confused if you change one SDK path and then move to another page. For example you change Flutter SDK path and open Dart page without closing the Preferences dialog. You'll see that Dart SDK path is not updated at this moment. Only when you press OK and then open Preferences again you'll see the new path in the 2nd page.

I'm afraid I do not know a good fix for this confusion at the moment.

What I'm saying is that Flutter users do not have to care about the Dart page and Dart SDK field. So all messages related to the Flutter settings could mention only Flutter page and Flutter SDK field.

Perhaps in a Flutter module, the Dart SDK should appear to be locked down (no edit allowed).

We may think about some solution like this. The problem is that in IntelliJ IDEA a project may contain a lot of modules of different nature. Three Java modules, five Dart modules, two Flutter modules, etc. Dart/Flutter SDK in 2016.3 is set per the whole IDE - once changed it affects all projects. In 2017.1 it is improved, and SDK is set per project. Different projects may have different SDKs configured. But still not per module.

@pq
Copy link
Contributor

pq commented Jan 18, 2017

P.S. I believe this check has already been there at some point, @pq should remember better.

Right. It was in this commit:

d6b1cd1

Given all the nuances, how do you feel about restoring WrongDartSdkConfigurationNotificationProvider? It seems like the case we really want to flag is where an incompatible Dart SDK is set and this in inspection does just that.

@pq
Copy link
Contributor

pq commented Jan 18, 2017

Ah, wait, it looks like that logic just got moved (see: fcbb090). It's now here:

io.flutter.inspections.SdkConfigurationNotificationProvider#createWrongSdkPanel

this should generate an editor notification in this case. If it's not we should fix that! (Or if that's not the approach we want to take we should remove it.)

@alexander-doroshko
Copy link
Contributor

With the current model I wouldn't say 'wrong Dart SDK'. I would say 'Flutter SDK not specified'. Updating SdkConfigurationNotificationProvider looks good to me. That's exactly the TODO that you added in its createNoFlutterSdkPanel() that Brian suggests to implement. I only mentioned that you can avoid word 'Dart SDK' 'Dart page in Settings', 'bin/cache/dart-sdk'.

Link to open Flutter page would be great for sure as Brian mentioned in the new TODO.

BTW, createWrongSdkPanel() seems to be unreachable with the current model. As well as
// TODO(devoncarew): Recommend to set up with Flutter's dart sdk. - dead branch too.

@alexander-doroshko
Copy link
Contributor

this should generate an editor notification in this case. If it's not we should fix that!

it's a dead branch. And the fix is the TODO that you left in createNoFlutterSdkPanel() - exactly what Brian is suggesting :)

@pq
Copy link
Contributor

pq commented Jan 18, 2017

Clearly I need more coffee... and we have some dead code to cleanup!

@skybrian
Copy link
Contributor Author

Trying this out, if the error tells the user to change the Flutter SDK, it will be confusing because it looks like the Flutter SDK is already set correctly in the UI.

It looks like we populate mySdkCombo in addKnownSDKPathsToCombo() and the first item is selected by default, but this doesn't actually have any effect on the rest of the system. It seems like we need to somehow represent 'Flutter SDK not set' in the preferences UI, so that the user will have something to do, and then when they save it, it will be fixed.

Also, the 'Apply' button is weird. It apparently has no effect (the UI doesn't update right away) but in the debugger I see that it does set the Dart SDK. So we need to fix that too.

@skybrian
Copy link
Contributor Author

Another problem: the device selector does not appear when it should. If you didn't have the Flutter SDK properly configured, and you configure it, doesn't show up.

It looks like it's listening to FlutterSdkManager which doesn't get an event when the Dart SDK changes.

I think FlutterSdkManager.Listener should fire events for this, but that's not what the comment says. It says it should be fired when the "Flutter global library is set".

(Also, I don't understand why FlutterSdkManager uses ApplicationLibraryTable. Is that table even used for Dart?)

Fix combo box to display correctly when no Flutter SDK is configured.
Fire a Flutter SDK changed event when the user changes the Flutter SDK.
Remove dead code.
@skybrian
Copy link
Contributor Author

Please take another look. This doesn't handle everything, but I made enough changes so that it mostly looks right when the user changes the Flutter SDK in response to the error.

But the Apply button still doesn't work, and it's unclear why. Current behavior is that the Flutter Run Configuration gets greyed out when you click Apply, but the device menu doesn't appear until after you close the settings dialog.

Copy link
Contributor

@pq pq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General question: I'm not seeing how the case where the Dart SDK is set to a non-Flutter SDK is handled. This was a BIG source of confusion with users early on and I'd hate to remove the safety net. (But maybe we're not and I'm just not seeing it?)

@@ -47,30 +47,18 @@ public SdkConfigurationNotificationProvider(@NotNull Project project) {
this.project = project;
}

@Nullable
private static EditorNotificationPanel createWrongSdkPanel(@NotNull Project project, @Nullable Module module) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this case being handled?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not possible

@alexander-doroshko
Copy link
Contributor

I'm not seeing how the case where the Dart SDK is set to a non-Flutter SDK is handled.

It is not possible to configure both Dart SDK and Flutter SDK in such a way that they are in conflict. Because under the hood it is ONE setting.
If you change Dart SDK in Preferences to non-Flutter's and press OK - at this moment you loose Flutter SDK setting for this project. This is the case 'Flutter SDK is not specified'. You can fix it in 2 ways: either change Dart SDK in the Dart page or set Flutter SDK in the Flutter page. Under the hood these are absolutely equivalent actions.

@skybrian
Copy link
Contributor Author

There is still an issue that no "Flutter SDK changed" event is sent when the user sets the Dart SDK. But, this error message doesn't rely on events - it does a query each time.

@skybrian skybrian closed this Jan 19, 2017
@skybrian skybrian deleted the check-dart-sdk branch January 19, 2017 21:42
@pq
Copy link
Contributor

pq commented Jan 19, 2017

It is not possible to configure both Dart SDK and Flutter SDK in such a way that they are in conflict. Because under the hood it is ONE setting.

Something is not right then... I just got into this state by setting my Dart SDK preferences.

screen shot 2017-01-19 at 1 55 04 pm

screen shot 2017-01-19 at 1 54 58 pm

@skybrian
Copy link
Contributor Author

Yes, when no Flutter SDK is set, the combo box is displayed wrong. (It displays the first entry.) I fixed that too.

However, I just noticed that the "Version:" text is still wrong. Working on that.

@alexander-doroshko
Copy link
Contributor

Something is not right then...

Notice a 'Reset...' link in the top-right of your 2nd screenshot :). It is a marker of a bug: the page is in the incorrect state right after opening it. 'Reset...' (as well as enabled Apply button) automatically appears when UI doesn't correspond to the stored model. On page opening there must be neither Reset nor Apply,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants