dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.23k stars 1.58k forks source link

Dart / Flutter thrown exception location opens in read-only ("Preview") mode in IntelliJ #57025

Open filiph opened 12 hours ago

filiph commented 12 hours ago

Note: The following issue was first filed in IntelliJ's YouTrack bug tracker, but there it was rejected with "Flutter is a third-party plugin maintained by Google, please try reporting the issue to the plugin vendor." I then filed the bug over at https://github.com/flutter/flutter-intellij/issues/7646 but since realized the bug is probably not specific to Flutter. Also, that bug was not touched since it was filed on September 11 and the tracker seems half-abandoned.

If you think I'm just filing a duplicate, feel free to close it as such, and I'm sorry for wasting your time. But I was seeing a bunch of label:area-intellij issues on this repo issue tracker so I thought maybe it belongs here. The original issue follows, and I'm happy to elaborate.

Steps to Reproduce

  1. Install the Flutter IntelliJ plugin
  2. Create a new Flutter project
  3. Introduce a thrown exception (e.g. put throw "test"; anywhere inside the _incrementCounter() method)
  4. Run the app on any target (e.g. macOS)
  5. Hit the exception (e.g. press the + button)

Expected

The code location (e.g. lib/main.dart) is opened in the editor.

Actual

The location is open, BUT it's open in Preview mode (filename in italics).

Screenshot 2024-08-19 at 10 18 49-1

This means code analysis doesn't work in the file:

Screenshot 2024-08-19 at 10 21 17-1

(Note the "No usages found" callout, although the method is clearly used in the code.)

Therefore, there's no "Go to definition", which is incredibly frustrating. There's also no syntax highlighting beyond the basics.

And when one wants to change the file where the problem happened (a common occurrence), the IDE refuses with "Failed to make ___ writable":

Screenshot 2024-08-19 at 10 24 00-1

The one workaround is to find the same file in the Project toolbar and open it, then find the same location manually.

It looks as though the file that the IDE opens on exception is some temp/memory copy of the real file, and the linkage to the original file is lost on the IDE. I hypothesize that this might be an analyzer issue?

Version info

flutter doctor --verbose
[✓] Flutter (Channel stable, 3.24.2, on macOS 14.4.1 23E224 darwin-arm64, locale en-US)
    • Flutter version 3.24.2 on channel stable at /Users/filiph/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4cf269e36d (7 days ago), 2024-09-03 14:30:00 -0700
    • Engine revision a6bd3f1de1
    • Dart version 3.5.2
    • DevTools version 2.37.2

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/filiph/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.3.2)
    • IntelliJ at /Users/filiph/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 78.4.2
    • Dart plugin version 233.15271

[✓] VS Code (version 1.92.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.84.0
dart-github-bot commented 12 hours ago

Summary: The issue reports that when an exception is thrown in a Dart/Flutter application running in IntelliJ, the code location is opened in read-only "Preview" mode, preventing code analysis, "Go to definition", and editing.