flutter-intellij
flutter-intellij copied to clipboard
Dart / Flutter thrown exception location opens in read-only ("Preview") mode
Steps to Reproduce
- Install the Flutter IntelliJ plugin
- Create a new Flutter project
- Introduce a thrown exception (e.g. put
throw "test";anywhere inside the_incrementCounter()method) - Run the app on any target (e.g. macOS)
- 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).
This means code analysis doesn't work in the file:
(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":
The one workaround is to find the same file in the Project toolbar and open it, then find the same location manually.
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
I originally reported this issue on IntelliJ's YouTrack, but they say it's a plugin issue: https://youtrack.jetbrains.com/issue/WEB-68867
I have been unsuccessful in reproing this issue, Flutter SDK version 3.24.4 and Flutter plugin for IJ version 83.x.
@filiph is there any additional information that you haven't shared that might help. I have tried different apps, different platform targets, etc. Can you still reproduce this yourself?
Thanks for looking into it!
I noticed I'm getting notifications in IntelliJ that look like the following:
## Dart analysis issue
Invalid argument (uri): URI is not a valid file:// URI: "/Users/filiph/dev/bug_intellij_dart/lib/main.dart"
## Version information
- Dart SDK 3.6.0
- Dart IntelliJ 233.15271
- IntelliJ IDEA 2023.3.2
- Mac OS X 14.7
## Details
Invalid argument (uri): URI is not a valid file:// URI: "/Users/filiph/dev/bug_intellij_dart/lib/main.dart"
#0 _VirtualFileClientUriConverter.fromClientUri (package:analyzer_plugin/src/utilities/client_uri_converter.dart:98:7)
#1 _VirtualFileClientUriConverter.fromClientFilePath (package:analyzer_plugin/src/utilities/client_uri_converter.dart:91:7)
#2 new FlutterSetSubscriptionsParams.fromJson.<anonymous closure>.<anonymous closure> (package:analysis_server/protocol/protocol_generated.dart:10959:45)
#3 JsonDecoder.decodeList (package:analyzer_plugin/src/protocol/protocol_internal.dart:351:27)
#4 new FlutterSetSubscriptionsParams.fromJson.<anonymous closure> (package:analysis_server/protocol/protocol_generated.dart:10955:29)
#5 JsonDecoder.decodeMap.<anonymous closure> (package:analyzer_plugin/src/protocol/protocol_internal.dart:377:31)
#6 _LinkedHashMapMixin.forEach (dart:_compact_hash:726:13)
#7 JsonDecoder.decodeMap (package:analyzer_plugin/src/protocol/protocol_internal.dart:369:16)
#8 new FlutterSetSubscriptionsParams.fromJson (package:analysis_server/protocol/protocol_generated.dart:10949:37)
#9 new FlutterSetSubscriptionsParams.fromRequest (package:analysis_server/protocol/protocol_generated.dart:10974:42)
#10 FlutterSetSubscriptionsHandler.handle (package:analysis_server/src/handler/legacy/flutter_set_subscriptions.dart:20:48)
#11 LegacyAnalysisServer.handleRequest.<anonymous closure>.<anonymous closure> (package:analysis_server/src/legacy_analysis_server.dart:569:25)
#12 OperationPerformanceImpl.runAsync (package:analyzer/src/util/performance/operation_performance.dart:174:29)
#13 LegacyAnalysisServer.handleRequest.<anonymous closure> (package:analysis_server/src/legacy_analysis_server.dart:550:29)
#14 _rootRun (dart:async/zone.dart:1414:13)
#15 _CustomZone.run (dart:async/zone.dart:1317:19)
#16 _runZoned (dart:async/zone.dart:1838:10)
#17 runZonedGuarded (dart:async/zone.dart:1826:12)
#18 LegacyAnalysisServer.handleRequest (package:analysis_server/src/legacy_analysis_server.dart:546:5)
#19 MessageScheduler.processMessages (package:analysis_server/src/server/message_scheduler.dart:81:42)
#20 MessageScheduler.notify (package:analysis_server/src/server/message_scheduler.dart:66:5)
#21 LegacyAnalysisServer.handleRequestOrResponse (package:analysis_server/src/legacy_analysis_server.dart:611:24)
#22 _rootRunUnary (dart:async/zone.dart:1422:47)
#23 _CustomZone.runUnary (dart:async/zone.dart:1324:19)
#24 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1233:7)
#25 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:366:11)
#26 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:297:7)
#27 _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11)
#28 _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11)
#29 new _DebounceRequests.<anonymous closure>.<anonymous closure> (package:analysis_server/src/server/debounce_requests.dart:50:20)
#30 _rootRun (dart:async/zone.dart:1406:47)
#31 _CustomZone.run (dart:async/zone.dart:1317:19)
#32 _CustomZone.runGuarded (dart:async/zone.dart:1225:7)
#33 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1265:23)
#34 _rootRun (dart:async/zone.dart:1414:13)
#35 _CustomZone.run (dart:async/zone.dart:1317:19)
#36 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1249:23)
#37 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
#38 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
#39 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
#40 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
Debug log
1735898036217 started analysis server:
/Users/filiph/dev/giant_robot/.fvm/flutter_sdk/bin/cache/dart-sdk/bin/dart language-server --client-id=IntelliJ-IDEA --client-version=IU-233.13135.103 --protocol=analyzer
1735898036686 <= {"event":"server.connected","params":{"version":"1.38.0","pid":49088}}
1735898036707 <= {"id":"0","result":{"version":"1.38.0"}}
1735898036707 => {"id":"1","method":"server.setSubscriptions","params":{"subscriptions":["STATUS"]},"clientRequestTime":1735898036222}
1735898036707 => {"id":"2","method":"analysis.updateOptions","params":{"options":{"enableAsync":true,"enableDeferredLoading":true,"enableEnums":true,"enableNullAwareOperators":true,"generateDart2jsHin...
1735898036707 => {"id":"3","method":"server.setClientCapabilities","params":{"requests":["openUrlRequest","showMessageRequest"],"supportsUris":true},"clientRequestTime":1735898036222}
1735898036707 => {"id":"4","method":"analysis.setAnalysisRoots","params":{"included":["file:///Users/filiph/dev/bug_intellij_dart"],"excluded":["file:///Users/filiph/dev/bug_intellij_dart/.idea","file...
1735898036711 <= {"id":"1"}
1735898036715 <= {"id":"2"}
1735898036719 <= {"id":"3"}
1735898036803 => {"id":"5","method":"analysis.setPriorityFiles","params":{"files":["file:///Users/filiph/dev/bug_intellij_dart/lib/main.dart"]},"clientRequestTime":1735898036803}
1735898036803 => {"id":"6","method":"analysis.setSubscriptions","params":{"subscriptions":{"OVERRIDES":["file:///Users/filiph/dev/bug_intellij_dart/lib/main.dart"],"OUTLINE":["file:///Users/filiph/dev...
1735898036879 <= {"id":"5"}
1735898036884 <= {"id":"6"}
1735898036890 => {"id":"7","method":"flutter.setSubscriptions","params":{"subscriptions":{"OUTLINE":["/Users/filiph/dev/bug_intellij_dart/lib/main.dart"]}}}
1735898036909 <= {"event":"server.error","params":{"isFatal":true,"message":"Internal error: Failed to handle request: flutter.setSubscriptions\nInvalid argument (uri): URI is not a valid file:// URI:...
1735898036916 <= {"id":"7","error":{"code":"SERVER_ERROR","message":"Invalid argument (uri): URI is not a valid file:// URI: \"/Users/filiph/dev/bug_intellij_dart/lib/main.dart\"","stackTrace":"#0 ...
Could this be related?
Meanwhile, I'll try to "un-reproduce" the issue by uninstalling plugins and such.
Whoa, turns out that the problems was that I'm an idiot! As I was trying to check this bug in Android Studio (instead of my daily driver, IntelliJ IDEA), I realized that all my IntelliJ IDEs are out of date . I probably disabled the JetBrains Toolbox app at some point and never re-enabled it. That app is the only way IntelliJ IDEs check for updates to themselves (as opposed to plugin updates).
After upgrading to the latest IntelliJ IDEA (2023.3.2 -> 2024.3.1.1), the issue is gone.
Sorry for wasting y'all's time! I'm going to spread the information so that, hopefully, no one else makes the same mistake. (UPDATE: Here.)