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

Exception from analysis server (running from VSCode / Dart Code): misplaced '<' operator #39577

Closed pauek closed 2 years ago

pauek commented 4 years ago

What I was doing

I accidentally typed the '<' operator after the print in the last instruction in the program below and that produced the exception.

import 'dart:io';

main() {
  print("---> inicio");
  File file = File('futures.dart');
  file.readAsString().then((content) {
    print(content);
  });
  print("---> fin");<
}

Versions

Analyzer Info

The analyzer was launched using the arguments:

/opt-fast/flutter/bin/cache/dart-sdk/bin/snapshots/analysis_server.dart.snapshot
--client-id=Dart-Code.dart-code
--client-version=3.6.0

Exception (fatal)

Failed to handle request: {id: 1056, method: edit.getAvailableRefactorings, params: {file: /home/minidosis/dart/futures.dart, length: 0, offset: 175}, clientRequestTime: 1575022534013}

RangeError: Value not in range: 178
#0      _StringBase.substring (dart:core-patch/string_patch.dart:389:7)
#1      StatementAnalyzer._hasTokens (package:analysis_server/src/services/correction/statement_analyzer.dart:228:33)
#2      StatementAnalyzer._checkSelectedNodes (package:analysis_server/src/services/correction/statement_analyzer.dart:214:11)
#3      StatementAnalyzer.visitCompilationUnit (package:analysis_server/src/services/correction/statement_analyzer.dart:93:7)
#4      CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:2140:49)
#5      StatementAnalyzer.analyze (package:analysis_server/src/services/correction/statement_analyzer.dart:58:24)
#6      ExtractMethodRefactoringImpl._isExtractable (package:analysis_server/src/services/refactoring/extract_method.dart:847:14)
#7      ExtractMethodRefactoringImpl._checkSelection (package:analysis_server/src/services/refactoring/extract_method.dart:511:35)
#8      ExtractMethodRefactoringImpl.isAvailable (package:analysis_server/src/services/refactoring/extract_method.dart:409:13)
#9      EditDomainHandler._getAvailableRefactoringsImpl (package:analysis_server/src/edit/edit_domain.dart:798:14)
<asynchronous suspension>
#10     EditDomainHandler._getAvailableRefactorings (package:analysis_server/src/edit/edit_domain.dart:770:5)
#11     EditDomainHandler.handleRequest (package:analysis_server/src/edit/edit_domain.dart:379:16)
#12     AnalysisServer.handleRequest.<anonymous closure>.<anonymous closure> (package:analysis_server/src/analysis_server.dart:325:45)
#13     _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:258:15)
#14     AnalysisServer.handleRequest.<anonymous closure> (package:analysis_server/src/analysis_server.dart:321:50)
#15     _rootRun (dart:async/zone.dart:1124:13)
#16     _CustomZone.run (dart:async/zone.dart:1021:19)
#17     _runZoned (dart:async/zone.dart:1516:10)
#18     runZoned (dart:async/zone.dart:1500:12)
#19     AnalysisServer.handleRequest (package:analysis_server/src/analysis_server.dart:320:5)
#20     ByteStreamServerChannel._readRequest.<anonymous closure> (package:analysis_server/src/channel/byte_stream_channel.dart:174:16)
#21     _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:258:15)
#22     ByteStreamServerChannel._readRequest (package:analysis_server/src/channel/byte_stream_channel.dart:165:47)
#23     ByteStreamServerChannel.listen.<anonymous closure> (package:analysis_server/src/channel/byte_stream_channel.dart:110:26)
#24     _rootRunUnary (dart:async/zone.dart:1132:38)
#25     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#26     _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#27     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#28     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#29     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
#30     _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#31     _StringAdapterSink.add (dart:convert/string_conversion.dart:236:11)
#32     _LineSplitterSink._addLines (dart:convert/line_splitter.dart:150:13)
#33     _LineSplitterSink.addSlice (dart:convert/line_splitter.dart:125:5)
#34     StringConversionSinkMixin.add (dart:convert/string_conversion.dart:163:5)
#35     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
#36     _rootRunUnary (dart:async/zone.dart:1132:38)
#37     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#38     _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#39     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#40     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#41     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
#42     _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#43     _StringAdapterSink.add (dart:convert/string_conversion.dart:236:11)
#44     _StringAdapterSink.addSlice (dart:convert/string_conversion.dart:241:7)
#45     _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:312:20)
#46     _Utf8ConversionSink.add (dart:convert/string_conversion.dart:305:5)
#47     _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:72:18)
#48     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
#49     _rootRunUnary (dart:async/zone.dart:1132:38)
#50     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#51     _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#52     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#53     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#54     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:764:19)
#55     _StreamController._add (dart:async/stream_controller.dart:640:7)
#56     _StreamController.add (dart:async/stream_controller.dart:586:5)
#57     _Socket._onData (dart:io-patch/socket_patch.dart:1791:41)
#58     _rootRunUnary (dart:async/zone.dart:1136:13)
#59     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#60     _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#61     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#62     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#63     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:764:19)
#64     _StreamController._add (dart:async/stream_controller.dart:640:7)
#65     _StreamController.add (dart:async/stream_controller.dart:586:5)
#66     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1339:33)
#67     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:860:14)
#68     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#69     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#70     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:116:13)
#71     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:173:5)

Diagnostics requested after the error occurred are:

[
    {
        "name": "/home/minidosis/dart",
        "explicitFileCount": 7,
        "implicitFileCount": 192,
        "workItemQueueLength": 0,
        "cacheEntryExceptions": []
    }
]
DanTup commented 2 years ago

This appears to have been fixed. I can reproduce in Flutter 1.9.1+hotfix.6 using the code above (and putting my cursor around the semicolon, triggering a call for what refactors are available), but not in Flutter 3.0.3 using the same code and the same steps.