-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
move to file fail on a simple case (4 lines) #59968
Comments
CC @DanTup |
@stephane-archer I wasn't able to reproduce this in a new project using your code above. Is it possible you could capture a log file performing this operation? Could you try capturing debugging logs while reproducing this?
Thanks! |
|
Relevant error is: An error occurred while handling workspace/executeCommand request:
RangeError (length): Invalid value: Not in inclusive range 0..77: -1
#0 _Array.[] (dart:core-patch/array.dart)
#1 _FbGenericList.[] (package:analyzer/src/summary/flat_buffers.dart:742:22)
#2 Search.prefixesUsedInLibrary (package:analyzer/src/dart/analysis/search.dart:333:53)
<asynchronous suspension>
#3 SearchEngineImpl.searchPrefixesUsedInLibrary (package:analysis_server/src/services/search/search_engine_internal.dart:110:12)
<asynchronous suspension>
#4 MoveTopLevelToFile.compute (package:analysis_server/src/services/refactoring/move_top_level_to_file.dart:159:13)
<asynchronous suspension>
#5 RefactorCommandHandler.handle.<anonymous closure> (package:analysis_server/src/lsp/handlers/commands/refactor_command_handler.dart:81:20)
<asynchronous suspension>
#6 ErrorOr.mapResult (package:analysis_server/src/lsp/error_or.dart:94:11)
<asynchronous suspension>
#7 ServerStateMessageHandler.handleMessage (package:analysis_server/src/lsp/handlers/handlers.dart:452:11)
<asynchronous suspension>
#8 LspAnalysisServer._handleRequestMessage (package:analysis_server/src/lsp/lsp_analysis_server.dart:1068:18)
<asynchronous suspension>
#9 LspAnalysisServer.handleMessage.<anonymous closure>.<anonymous closure> (package:analysis_server/src/lsp/lsp_analysis_server.dart:509:15)
<asynchronous suspension>
#10 OperationPerformanceImpl.runAsync (package:analyzer/src/util/performance/operation_performance.dart:174:14)
<asynchronous suspension>
#11 LspAnalysisServer.handleMessage.<anonymous closure> (package:analysis_server/src/lsp/lsp_analysis_server.dart:491:11)
<asynchronous suspension> I'll try following the stack trace here, if I find anything I'll let you know. |
I still could not repro your error on a test but I'll keep trying. Seems like the problem is inside There have been some changes to this file between stable and main so when I reproduce your error on a test, I'll see if this still happens on main. Unless you can test this or similar code (same error) on the Dart main/Flutter master channel for us to be sure it is still occurring. If I it doesn't happen anymore I'll see if I can still find what the error was and to add a test. |
I was able to repro - the problem was that I didn't have a reference to the element being removed. I was able to reduce it to this trivial example (which surprises me, because this seems basic enough that there should be tests covering it): move_error.mp4 |
What about |
At a glance, it doesn't seem like there are any references to the variable being moved there (which is how I tried to repro it initially). My guess is that if there was another file that referenced |
It repros with this: /// https://github.com/dart-lang/sdk/issues/59968#issuecomment-2622191812
@soloTest
Future<void> test_single_variable2() async {
var originalSource = '''
class A {}
int variableT^oMove = 3;
class B {}
''';
var declarationName = 'variableToMove';
var expected = '''
>>>>>>>>>> lib/main.dart
class A {}
class B {}
>>>>>>>>>> lib/variable_to_move.dart created
int variableToMove = 3;
''';
var otherFilePath = '$projectFolderPath/lib/other.dart';
var otherFileContent = '''
import "main.dart";
void f() {
print(variableToMove);
}
''';
await _singleDeclaration(
originalSource: originalSource,
expected: expected,
declarationName: declarationName,
otherFilePath: otherFilePath,
otherFileContent: otherFileContent,
);
} However, I can't easily debug it right now because of #59992. |
An error occurred while handling workspace/executeCommand request
The text was updated successfully, but these errors were encountered: