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.24k stars 1.57k forks source link

NPE in CorrectionUtils while trying to service edit.getAvailableRefactorings request #34932

Closed smokytheangel0 closed 3 years ago

smokytheangel0 commented 6 years ago

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

opening flutter sdk folder in visual studio code to read how production organizations write code

Versions

Analyzer Info

The analyzer was launched using the arguments:

C:\Users\Justice\Desktop\SDKs\flutter\bin\cache\dart-sdk\bin\snapshots\analysis_server.dart.snapshot
--client-id=Dart-Code.dart-code
--client-version=2.19.0

Exception (fatal)

Failed to handle request: {id: 8, method: edit.getAvailableRefactorings, params: {file: C:\Users\Justice\Desktop\SDKs\flutter\packages\flutter\lib\material.dart, length: 0, offset: 0}}

NoSuchMethodError: The getter 'declaredElement' was called on null.
Receiver: null
Tried calling: declaredElement
#0      Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
#1      new CorrectionUtils (package:analysis_server/src/services/correction/util.dart:658:47)
#2      new ExtractLocalRefactoringImpl (package:analysis_server/src/services/refactoring/extract_local.dart:59:17)
#3      EditDomainHandler._getAvailableRefactoringsImpl (package:analysis_server/src/edit/edit_domain.dart:617:17)
<asynchronous suspension>
#4      EditDomainHandler._getAvailableRefactorings (package:analysis_server/src/edit/edit_domain.dart:598:5)
#5      EditDomainHandler.handleRequest (package:analysis_server/src/edit/edit_domain.dart:358:16)
#6      AnalysisServer.handleRequest.<anonymous closure>.<anonymous closure> (package:analysis_server/src/analysis_server.dart:645:45)
#7      _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:258:15)
#8      AnalysisServer.handleRequest.<anonymous closure> (package:analysis_server/src/analysis_server.dart:641:50)
#9      _rootRun (dart:async/zone.dart:1124:13)
#10     _CustomZone.run (dart:async/zone.dart:1021:19)
#11     _runZoned (dart:async/zone.dart:1516:10)
#12     runZoned (dart:async/zone.dart:1500:12)
#13     AnalysisServer.handleRequest (package:analysis_server/src/analysis_server.dart:640:5)
#14     ByteStreamServerChannel._readRequest.<anonymous closure> (package:analysis_server/src/channel/byte_stream_channel.dart:174:16)
#15     _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:258:15)
#16     ByteStreamServerChannel._readRequest (package:analysis_server/src/channel/byte_stream_channel.dart:165:47)
#17     ByteStreamServerChannel.listen.<anonymous closure> (package:analysis_server/src/channel/byte_stream_channel.dart:110:26)
#18     _rootRunUnary (dart:async/zone.dart:1132:38)
#19     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#20     _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#21     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#22     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#23     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
#24     _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#25     _StringAdapterSink.add (dart:convert/string_conversion.dart:268:11)
#26     _LineSplitterSink._addLines (dart:convert/line_splitter.dart:154:13)
#27     _LineSplitterSink.addSlice (dart:convert/line_splitter.dart:129:5)
#28     StringConversionSinkMixin.add (dart:convert/string_conversion.dart:189:5)
#29     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
#30     _rootRunUnary (dart:async/zone.dart:1132:38)
#31     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#32     _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#33     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#34     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#35     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
#36     _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#37     _StringAdapterSink.add (dart:convert/string_conversion.dart:268:11)
#38     _StringAdapterSink.addSlice (dart:convert/string_conversion.dart:273:7)
#39     _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:348:20)
#40     _Utf8ConversionSink.add (dart:convert/string_conversion.dart:341:5)
#41     _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:86:18)
#42     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
#43     _rootRunUnary (dart:async/zone.dart:1132:38)
#44     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#45     _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#46     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#47     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#48     _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
#49     _StreamController._add (dart:async/stream_controller.dart:639:7)
#50     _StreamController.add (dart:async/stream_controller.dart:585:5)
#51     _Socket._onData (dart:io/runtime/binsocket_patch.dart:1721:41)
#52     _rootRunUnary (dart:async/zone.dart:1136:13)
#53     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#54     _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#55     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#56     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#57     _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
#58     _StreamController._add (dart:async/stream_controller.dart:639:7)
#59     _StreamController.add (dart:async/stream_controller.dart:585:5)
#60     new _RawSocket.<anonymous closure> (dart:io/runtime/binsocket_patch.dart:1283:33)
#61     _NativeSocket.issueReadEvent.issue (dart:io/runtime/binsocket_patch.dart:826:14)
#62     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#63     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#64     _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#65     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)

Diagnostics requested after the error occurred are:

[
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\packages\\flutter_test",
        "explicitFileCount": 34,
        "implicitFileCount": 6,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\examples\\hello_world",
        "explicitFileCount": 3,
        "implicitFileCount": 1,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\integration_tests\\ui",
        "explicitFileCount": 16,
        "implicitFileCount": 2,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\integration_tests\\platform_interaction",
        "explicitFileCount": 4,
        "implicitFileCount": 2,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter",
        "explicitFileCount": 0,
        "implicitFileCount": 0,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\examples\\platform_view",
        "explicitFileCount": 1,
        "implicitFileCount": 3,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\packages\\flutter_localizations",
        "explicitFileCount": 12,
        "implicitFileCount": 3,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\integration_tests\\android_views",
        "explicitFileCount": 3,
        "implicitFileCount": 4,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\packages\\flutter_test\\test\\test_config\\project_root",
        "explicitFileCount": 1,
        "implicitFileCount": 3,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\examples\\layers",
        "explicitFileCount": 46,
        "implicitFileCount": 5,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\snippets",
        "explicitFileCount": 5,
        "implicitFileCount": 3,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\devicelab",
        "explicitFileCount": 102,
        "implicitFileCount": 7,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\tools\\vitool",
        "explicitFileCount": 3,
        "implicitFileCount": 3,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\examples\\catalog",
        "explicitFileCount": 15,
        "implicitFileCount": 2,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\integration_tests\\flavors",
        "explicitFileCount": 2,
        "implicitFileCount": 1,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\manual_tests",
        "explicitFileCount": 14,
        "implicitFileCount": 5,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\benchmarks\\microbenchmarks",
        "explicitFileCount": 6,
        "implicitFileCount": 3,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\packages\\flutter_driver",
        "explicitFileCount": 26,
        "implicitFileCount": 5,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\packages\\flutter",
        "explicitFileCount": 908,
        "implicitFileCount": 11,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\bots",
        "explicitFileCount": 11,
        "implicitFileCount": 6,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\integration_tests\\android_semantics_testing",
        "explicitFileCount": 13,
        "implicitFileCount": 4,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\examples\\stocks",
        "explicitFileCount": 15,
        "implicitFileCount": 7,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\packages\\flutter_goldens",
        "explicitFileCount": 2,
        "implicitFileCount": 4,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\docs\\platform_integration",
        "explicitFileCount": 0,
        "implicitFileCount": 0,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\missing_dependency_tests",
        "explicitFileCount": 0,
        "implicitFileCount": 0,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\examples\\platform_channel",
        "explicitFileCount": 3,
        "implicitFileCount": 2,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\integration_tests\\channels",
        "explicitFileCount": 6,
        "implicitFileCount": 3,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\tools",
        "explicitFileCount": 9,
        "implicitFileCount": 4,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\automated_tests",
        "explicitFileCount": 14,
        "implicitFileCount": 2,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\examples\\platform_channel_swift",
        "explicitFileCount": 3,
        "implicitFileCount": 2,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\examples\\flutter_view",
        "explicitFileCount": 1,
        "implicitFileCount": 2,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\packages\\flutter_goldens_client",
        "explicitFileCount": 1,
        "implicitFileCount": 3,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\integration_tests\\named_isolates",
        "explicitFileCount": 1,
        "implicitFileCount": 1,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\benchmarks\\complex_layout",
        "explicitFileCount": 6,
        "implicitFileCount": 4,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\examples\\flutter_gallery",
        "explicitFileCount": 107,
        "implicitFileCount": 7,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    },
    {
        "name": "C:\\Users\\Justice\\Desktop\\SDKs\\flutter\\dev\\integration_tests\\external_ui",
        "explicitFileCount": 2,
        "implicitFileCount": 2,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    }
]
srawlins commented 3 years ago

This has not been reported again since Dart 2.5; please re-open if you see this in a recent version of Dart/Flutter.