Sdk: Alt+Enter has stopped working

Created on 2 Jul 2019  Â·  14Comments  Â·  Source: dart-lang/sdk

@lukef commented on Jul 2, 2019, 3:38 AM UTC:

Plugin: v37.0.3
OS: Linux (Ubuntu)
Flutter: 1.7.12-pre.40
Channel: master
IntelliJ: 2019.1 (Ultimate)

I'm not really sure why or how to debug it (honestly) but Alt+Enter has stopped working for me on most projects. I've taken a look in the IntelliJ logs and I can't see anything that looks like the likely culprit.

I've tried deleting my .iml files and the .idea directory and recreating the project but no luck.

It's a bit of a bummer because I can't use the Widget re-parenting functions at all.

Quick fixes DO still work for things like the linter though (e.g.: "Suppress 'xx' warning", etc).

Let me know how I can help diagnose.

This issue was moved by stevemessick from flutter/flutter-intellij#3637.

P2 analyzer-completion area-analyzer

Most helpful comment

Ok. I'll try to explain it one more time in case I messed up:

I have dart code in <project_dir>/lib and in <project_dir>/example/lib. I have ONE analysis_options.yaml file at <project_dir>/analysis_options.yaml.

If I add the following to the analysis_options.yaml then the alt+enter functionality in IntelliJ will stop working for all code in the project and not just the code in the (excluded) example folder:

exclude:
  - 'example/**'

I would think the problem would manifest for the example source files but not the library files. In any case, I am now not excluding that folder and it works.

I also noticed if i do a clean pull (to a different location) then the problem isn't present. Is it possible it is a cache issue somewhere?

All 14 comments

@stevemessick commented on Jul 2, 2019, 3:38 PM UTC:

Are you getting analysis errors reported in the console? Does code completion work?

My first thought is there is something wrong with the Dart analysis server. You might try looking for rogue java processes that have dart in the name: ps xa | grep [Dd]art
Kill them and restart the analysis server in IntelliJ. To be more sure, shut down IJ, kill the processes, and restart IJ. If you're still having trouble after that, and everything else works, then maybe something changed in your keymap.

You can check that by adding "Show Intention Actions" to an existing menu. I added it to Help, just to see if it works. After adding it, select the name of some widget and choose that item from the menu. If the server is working you'll see the normal widget-editing fixes, and that suggests your keymap for alt-enter is not working.

@lukef commented on Jul 2, 2019, 4:06 PM UTC:

I found the issue while checking what you asked. Let me know how to debug it for you because the IntelliJ logs, the Event Log and System logs aren't showing any errors. It might be user error also.

Here is the setup:

  1. I'm working on a Flutter library project (https://github.com/lukef/qr.flutter). It has the library at the root level and an example folder with a Flutter app inside there.
  2. I have two analysis_options.yaml files: one at the root level and one in example. Not sure if it matters, but putting that out there.
  3. The root level analysis_options.yaml file has an exclude section that excludes the example directory (along with others) like:
  exclude:
    - '.idea/**'
    - 'android/**'
    - 'assets/**'
    - 'build/**'
    - 'ios/**'
    - 'res/**'
    - 'example/**'

If I remove the - 'example/**' line then it all works. 😕

I've tried removing the example/analysis_options.yaml file and various other combinations but it seems like if I exclude example from the main analysis file then the whole thing will stop working.

Any ideas?

@stevemessick commented on Jul 2, 2019, 4:58 PM UTC:

IIUC the alt-enter problem only occurs for code in the example directory? Everything works as expected for the library code?

Here is the analysis options doc:
https://dart.dev/guides/language/analysis-options

To me, it seems you are trying to do something that isn't supported, although I may be mistaken about that. I'd place the example program in a separate project if it needed to be totally separate. The Flutter plugin template does create an example project as a subdir of the Flutter plugin project, but it uses the analysis options of the main plugin. By adding the example/** exclude you are telling the analyzer to ignore your example. If you want it to have separate options it will need to be in a different project.

If you think every directory that has a pubspec should also allow analysis options then you should discuss that with the Dart SDK engineers: https://github.com/dart-lang/sdk/issues

@stevemessick commented on Jul 2, 2019, 5:00 PM UTC:

Oh, there is another option. You could open your example in its own project window. Then the analyzer would see the example analysis options.

@lukef commented on Jul 2, 2019, 5:03 PM UTC:

Actually, the issue is for both. I can't use alt+enter in the library project at all.

The issue is still there if i delete the second analysis_options.yaml file in the example folder.

So long as there is that exclude line for the example folder, the alt+enter functions wont work anywhere in the project. I think if i opened the example folder independently then it would work but i haven't tried.

If i remove that single line the everything works. To me that seems like a bug. Maybe its just an analysis server bug.

I'm happy to remove the example out also, but I don't think that's the issue.

@stevemessick commented on Jul 2, 2019, 5:08 PM UTC:

It does sound like something odd is happening. I think it is an analyzer issue so I'm moving it to the Dart SDK. Maybe @bwilkerson can help.

Sorry, but I don't know what the issue is.

When you tell analyzer to exclude a directory, then it won't analyze any of the files in that directory unless (a) they are referenced by files outside the directory that are being analyzed or (b) you explicitly open the file. But that wouldn't explain the behavior you're seeing.

We have been getting reports of some slowness in server related to quick assists that we are investigating, and IntelliJ has a timeout that prevents it from displaying any assists if they are not returned quickly enough, but that wouldn't explain why excluding or not excluding the directory would make a difference.

I'm at a loss. Ideally we'd be able to reproduce the behavior on our end so that we could have a starting point for tracking down the issue, but I assume we've tried and failed.

Ok. I'll try to explain it one more time in case I messed up:

I have dart code in <project_dir>/lib and in <project_dir>/example/lib. I have ONE analysis_options.yaml file at <project_dir>/analysis_options.yaml.

If I add the following to the analysis_options.yaml then the alt+enter functionality in IntelliJ will stop working for all code in the project and not just the code in the (excluded) example folder:

exclude:
  - 'example/**'

I would think the problem would manifest for the example source files but not the library files. In any case, I am now not excluding that folder and it works.

I also noticed if i do a clean pull (to a different location) then the problem isn't present. Is it possible it is a cache issue somewhere?

As a side: @stevemessick - maybe Flutter libraries shouldn't have the example projects in the template? :smile:

@a-siva, I'm not sure area-intellij is the right label here, AFAIU no actions needed on the IntelliJ end.

Moving to area-analyzer based on some of the comments above.

I'm developing a Flutter app using Android Studio. I have the same issue currently. Even in the most basic flutter app (created via flutter create myApp), alt+enter does not work for dart code. There is no analysis_options.yaml anywhere in the project.

flutter doctor:

[✓] Flutter (Channel master, v1.10.7-pre.51, on Linux, locale en_US.UTF-8)
    • Flutter version 1.10.7-pre.51 at /opt/flutter
    • Framework revision 957d839775 (85 minutes ago), 2019-09-26 22:45:21 -0700
    • Engine revision a206557f8f
    • Dart version 2.6.0 (build 2.6.0-dev.3.0 327bc451f8)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /home/ren/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /home/ren/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.5791312/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Android Studio (version 3.5)
    • Android Studio at /home/ren/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.5791312
    • Flutter plugin version 37.1.3
    • Dart plugin version 191.7830
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] Connected device (1 available)
    • SM T510 • R52M400PMFN • android-arm • Android 9 (API 28)

EDIT: As you can see on the flutter doctor output, I noticed that it was reporting the wrong flutter plugin version, so I went ahead and uninstalled Android Studio and all configuration files (all .AndroidStudio* folders). This fixed my issue with Alt + Enter not working.

Ok. I'll try to explain it one more time in case I messed up:

I have dart code in <project_dir>/lib and in <project_dir>/example/lib. I have ONE analysis_options.yaml file at <project_dir>/analysis_options.yaml.

If I add the following to the analysis_options.yaml then the alt+enter functionality in IntelliJ will stop working for all code in the project and not just the code in the (excluded) example folder:

exclude:
  - 'example/**'

I would think the problem would manifest for the example source files but not the library files. In any case, I am now not excluding that folder and it works.

I also noticed if i do a clean pull (to a different location) then the problem isn't present. Is it possible it is a cache issue somewhere?

Faced the same issue today. Removed exclude block from analysis_options.yaml and got my options+return hotkey working back again.

[✓] Flutter (Channel dev, 1.19.0-4.0.pre, on Mac OS X 10.15.4 19E287, locale ru-RU)
• Flutter version 1.19.0-4.0.pre at /Users/saturov/Library/flutter
• Framework revision 2f7a59a8da (3 days ago), 2020-06-05 03:44:02 -0700
• Engine revision d17c84e7af
• Dart version 2.9.0 (build 2.9.0-13.0.dev 02915ec5ce)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/saturov/Library/Android/sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.5, Build version 11E608c
• CocoaPods version 1.9.1

[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 45.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.45.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.11.0

[✓] Connected device (1 available)
• SM G973F • RF8M31ADENP • android-arm64 • Android 10 (API 29)

/cc @devoncarew - Devon do you know if this is something we are planning to fix?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Hixie picture Hixie  Â·  3Comments

xster picture xster  Â·  3Comments

brooth picture brooth  Â·  3Comments

55555Mohit55555 picture 55555Mohit55555  Â·  3Comments

gspencergoog picture gspencergoog  Â·  3Comments