simolus3 / drift

Drift is an easy to use, reactive, typesafe persistence library for Dart & Flutter.
https://drift.simonbinder.eu/
MIT License
2.68k stars 377 forks source link

[Bug] Exception from analysis server #322

Closed North101 closed 4 years ago

North101 commented 4 years ago

1st: Please review the below report for any information you do not wish to share and report to https://github.com/dart-lang/sdk/issues/new

Exception from analysis server (running from VSCode / Dart Code)

What I was doing

(please describe what you were doing when this exception occurred)

Versions

Analyzer Info

The analyzer was launched using the arguments:

/usr/local/Caskroom/flutter/latest/flutter/bin/cache/dart-sdk/bin/snapshots/analysis_server.dart.snapshot
--client-id=Dart-Code.dart-code
--client-version=3.7.1

Exception

PLEASE DO NOT REPORT THIS ON dart-lang/sdk! This should be reported via https://github.com/simolus3/moor/issues/new instead. Message was Error while working on file:///Users/alexanderwilde/git/gloomhaven_campaign/lib/sql/lineage.moor, error NoSuchMethodError: The getter 'fullName' was called on null. Receiver: null Tried calling: fullName

#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1      MoorDriver.absolutePath (package:moor_generator/src/backends/common/driver.dart:141:19)
#2      CommonBackend.resolve (package:moor_generator/src/backends/common/backend.dart:15:29)
#3      MoorSession.resolve (package:moor_generator/src/analyzer/session.dart:54:33)
#4      Task._parse (package:moor_generator/src/analyzer/runner/task.dart:92:33)
<asynchronous suspension>
#5      Task.runTask (package:moor_generator/src/analyzer/runner/task.dart:41:26)
<asynchronous suspension>
#6      MoorDriver.performWork (package:moor_generator/src/backends/common/driver.dart:100:18)
#7      AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:1926:24)
<asynchronous suspension>
#8      AnalysisDriverScheduler.start (package:analyzer/src/dart/analysis/driver.dart:1860:5)
#9      new ServerPlugin (package:analyzer_plugin/plugin/plugin.dart:100:29)
#10     new BaseMoorPlugin (package:moor_generator/src/backends/common/base_plugin.dart:16:47)
#11     new _MoorPlugin&BaseMoorPlugin&OutlineMixin (package:moor_generator/src/backends/plugin/plugin.dart)
#12     new _MoorPlugin&BaseMoorPlugin&OutlineMixin&HighlightsMixin (package:moor_generator/src/backends/plugin/plugin.dart)
#13     new _MoorPlugin&BaseMoorPlugin&OutlineMixin&HighlightsMixin&FoldingMixin (package:moor_generator/src/backends/plugin/plugin.dart)
#14     new _MoorPlugin&BaseMoorPlugin&OutlineMixin&HighlightsMixin&FoldingMixin&CompletionMixin (package:moor_generator/src/backends/plugin/plugin.dart)
#15     new _MoorPlugin&BaseMoorPlugin&OutlineMixin&HighlightsMixin&FoldingMixin&CompletionMixin&AssistsMixin (package:moor_generator/src/backends/plugin/plugin.dart)
#16     new _MoorPlugin&BaseMoorPlugin&OutlineMixin&HighlightsMixin&FoldingMixin&CompletionMixin&AssistsMixin&NavigationMixin (package:moor_generator/src/backends/plugin/plugin.dart)
#17     new MoorPlugin (package:moor_generator/src/backends/plugin/plugin.dart:39:43)
#18     new MoorPlugin.forProduction (package:moor_generator/src/backends/plugin/plugin.dart:45:12)
#19     start (package:moor_generator/integrations/plugin.dart:7:34)
#20     main (file:///Users/alexanderwilde/.dartServer/.plugin_manager/2ab450d5be63a0b338bff9f25f027c28/analyzer_plugin/bin/plugin.dart:13:5)
#21     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:303:32)
#22     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)

Diagnostics requested after the error occurred are:

[
    {
        "name": "/Users/alexanderwilde/git/gloomhaven_campaign",
        "explicitFileCount": 29,
        "implicitFileCount": 864,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    }
]

2nd: Please review the below report for any information you do not wish to share and report to https://github.com/dart-lang/sdk/issues/new

Exception from analysis server (running from VSCode / Dart Code)

What I was doing

(please describe what you were doing when this exception occurred)

Versions

Analyzer Info

The analyzer was launched using the arguments:

/usr/local/Caskroom/flutter/latest/flutter/bin/cache/dart-sdk/bin/snapshots/analysis_server.dart.snapshot
--client-id=Dart-Code.dart-code
--client-version=3.7.1

Exception

NoSuchMethodError: The method 'firstWhere' was called on null. Receiver: null Tried calling: firstWhere(Closure: (SqlQuery) => bool, orElse: Closure: () => Null)

#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1      _OutlineVisitor.visitMoorDeclaredStatement (package:moor_generator/src/backends/plugin/services/outline.dart:78:10)
#2      DeclaredStatement.accept (package:sqlparser/src/ast/moor/declared_statement.dart:20:15)
#3      RecursiveVisitor.visitChildren (package:sqlparser/src/ast/ast.dart:344:13)
#4      _OutlineVisitor.visitMoorFile (package:moor_generator/src/backends/plugin/services/outline.dart:62:11)
#5      MoorFile.accept (package:sqlparser/src/ast/moor/moor_file.dart:16:49)
#6      MoorOutlineContributor.computeOutline (package:moor_generator/src/backends/plugin/services/outline.dart:19:41)
#7      OutlineGenerator.generateOutlineNotification (package:analyzer_plugin/utilities/outline/outline.dart:87:21)
#8      OutlineMixin.sendOutlineNotification (package:analyzer_plugin/plugin/outline_mixin.dart:66:21)
<asynchronous suspension>
#9      ServerPlugin._sendNotificationForFile (package:analyzer_plugin/plugin/plugin.dart:753:9)
#10     ServerPlugin.sendNotificationsForSubscriptions.<anonymous closure> (package:analyzer_plugin/plugin/plugin.dart:581:9)
#11     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
#12     ServerPlugin.sendNotificationsForSubscriptions (package:analyzer_plugin/plugin/plugin.dart:579:19)
#13     ServerPlugin.handleAnalysisSetSubscriptions (package:analyzer_plugin/plugin/plugin.dart:355:5)
<asynchronous suspension>
#14     ServerPlugin._getResponse (package:analyzer_plugin/plugin/plugin.dart:660:24)
<asynchronous suspension>
#15     ServerPlugin._onRequest (package:analyzer_plugin/plugin/plugin.dart:720:24)
<asynchronous suspension>
#16     PluginIsolateChannel.listen.onData (package:analyzer_plugin/src/channel/isolate_channel.dart:127:18)
#17     _RootZone.runUnaryGuarded (dart:async/zone.dart:1316:10)
#18     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#19     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
#20     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:773:19)
#21     _StreamController._add (dart:async/stream_controller.dart:649:7)
#22     _StreamController.add (dart:async/stream_controller.dart:595:5)
#23     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)

Diagnostics requested after the error occurred are:

[
    {
        "name": "/Users/alexanderwilde/git/gloomhaven_campaign",
        "explicitFileCount": 29,
        "implicitFileCount": 864,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    }
]
North101 commented 4 years ago

The exception happens on a different file each time so I don't believe its specific to a file

simolus3 commented 4 years ago

Thanks for the reports!

I think the first error indicates an invalid url somewhere (invalid as in can't be parsed), the stack trace indicates it happened while resolving imports in a moor file. I've changed the resolver to just report an "invalid import" error and move on (debf8b30f43e9154ac846b7d5f46ce984c90659a).

The second error happens when reporting outline information on a file that isn't fully analyzed. The plugin should be able to handle this, I just forgot one case (done with a6e4a3669ce55cbbee1f81479f14aac223e0afd3).