Skip to content

Commit

Permalink
[analysis_server] Fix LSP references on initializing formals
Browse files Browse the repository at this point in the history
Fixes Dart-Code/Dart-Code#4535.

Change-Id: Id2cfc6abba756afc10d8b67bde86c0aae6ae5659
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302786
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
  • Loading branch information
DanTup authored and Commit Queue committed May 11, 2023
1 parent 5cbd939 commit 2d43bc3
Show file tree
Hide file tree
Showing 2 changed files with 166 additions and 179 deletions.
12 changes: 1 addition & 11 deletions pkg/analysis_server/lib/src/lsp/handlers/handler_references.dart
Expand Up @@ -11,7 +11,6 @@ import 'package:analysis_server/src/services/search/search_engine.dart'
show SearchMatch;
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/ast/utilities.dart';
import 'package:analyzer/src/util/performance/operation_performance.dart';
import 'package:analyzer_plugin/src/utilities/navigation/navigation.dart';
Expand Down Expand Up @@ -66,15 +65,6 @@ class ReferencesHandler
OperationPerformanceImpl performance) async {
final node = NodeLocator(offset).searchWithin(result.unit);
var element = server.getElementOfNode(node);
if (element is LibraryImportElement) {
element = element.prefix?.element;
}
if (element is FieldFormalParameterElement) {
element = element.field;
}
if (element is PropertyAccessorElement) {
element = element.variable;
}
if (element == null) {
return success(null);
}
Expand All @@ -84,7 +74,7 @@ class ReferencesHandler
final results = await performance.runAsync(
"computer.compute",
(childPerformance) =>
computer.compute(element!, false, performance: childPerformance));
computer.compute(element, false, performance: childPerformance));

Location? toLocation(SearchMatch result) {
final file = session.getFile(result.file);
Expand Down

0 comments on commit 2d43bc3

Please sign in to comment.