Skip to content

Commit e9d2f73

Browse files
committed
More tweaks in attempt to debug the reason of failing getNavigation() tests.
[email protected] BUG= Review URL: https://codereview.chromium.org//1284933002 .
1 parent b30a7a1 commit e9d2f73

File tree

3 files changed

+49
-34
lines changed

3 files changed

+49
-34
lines changed

pkg/analysis_server/lib/src/domain_analysis.dart

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -118,38 +118,46 @@ class AnalysisDomainHandler implements RequestHandler {
118118
return new Response.getNavigationInvalidFile(request);
119119
}
120120
analysisFuture.then((AnalysisDoneReason reason) {
121-
switch (reason) {
122-
case AnalysisDoneReason.COMPLETE:
123-
print('AnalysisDoneReason.COMPLETE');
124-
List<CompilationUnit> units =
125-
server.getResolvedCompilationUnits(file);
126-
print('units: $units');
127-
if (units.isEmpty) {
128-
server.sendResponse(new Response.getNavigationInvalidFile(request));
129-
} else {
130-
DartUnitNavigationComputer computer =
131-
new DartUnitNavigationComputer();
132-
_GetNavigationAstVisitor visitor = new _GetNavigationAstVisitor(
133-
params.offset, params.offset + params.length, computer);
134-
for (CompilationUnit unit in units) {
135-
unit.accept(visitor);
121+
print(' reason: $reason');
122+
try {
123+
switch (reason) {
124+
case AnalysisDoneReason.COMPLETE:
125+
print(' AnalysisDoneReason.COMPLETE');
126+
List<CompilationUnit> units =
127+
server.getResolvedCompilationUnits(file);
128+
print(' units: $units');
129+
if (units.isEmpty) {
130+
server
131+
.sendResponse(new Response.getNavigationInvalidFile(request));
132+
} else {
133+
DartUnitNavigationComputer computer =
134+
new DartUnitNavigationComputer();
135+
_GetNavigationAstVisitor visitor = new _GetNavigationAstVisitor(
136+
params.offset, params.offset + params.length, computer);
137+
for (CompilationUnit unit in units) {
138+
unit.accept(visitor);
139+
}
140+
server.sendResponse(new AnalysisGetNavigationResult(
141+
computer.files, computer.targets, computer.regions)
142+
.toResponse(request.id));
136143
}
137-
server.sendResponse(new AnalysisGetNavigationResult(
138-
computer.files, computer.targets, computer.regions)
139-
.toResponse(request.id));
140-
}
141-
break;
142-
case AnalysisDoneReason.CONTEXT_REMOVED:
143-
print('AnalysisDoneReason.CONTEXT_REMOVED');
144-
// The active contexts have changed, so try again.
145-
Response response = getNavigation(request);
146-
if (response != Response.DELAYED_RESPONSE) {
147-
server.sendResponse(response);
148-
}
149-
break;
144+
break;
145+
case AnalysisDoneReason.CONTEXT_REMOVED:
146+
print(' AnalysisDoneReason.CONTEXT_REMOVED');
147+
// The active contexts have changed, so try again.
148+
Response response = getNavigation(request);
149+
if (response != Response.DELAYED_RESPONSE) {
150+
server.sendResponse(response);
151+
}
152+
break;
153+
}
154+
} on Exception catch (e, st) {
155+
print('Exception1 in AnalysisDomainHandler.getNavigation()');
156+
print(e);
157+
print(st);
150158
}
151159
}).catchError((e, st) {
152-
print('Exception in AnalysisDomainHandler.getNavigation()');
160+
print('Exception2 in AnalysisDomainHandler.getNavigation()');
153161
print(e);
154162
print(st);
155163
});

pkg/analysis_server/test/analysis/get_navigation_test.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class GetNavigationTest extends AbstractNavigationTest {
3030
}
3131

3232
test_beforeAnalysisComplete() async {
33+
print('+++test_beforeAnalysisComplete');
3334
addTestFile('''
3435
main() {
3536
var test = 0;
@@ -42,11 +43,13 @@ main() {
4243
}
4344

4445
test_fileDoesNotExist() {
46+
print('+++test_fileDoesNotExist');
4547
String file = '$projectPath/doesNotExist.dart';
4648
return _checkInvalid(file, -1, -1);
4749
}
4850

4951
test_fileWithoutContext() {
52+
print('+++test_fileWithoutContext');
5053
String file = '/outside.dart';
5154
addFile(
5255
file,
@@ -59,6 +62,7 @@ main() {
5962
}
6063

6164
test_multipleRegions() async {
65+
print('+++test_multipleRegions');
6266
addTestFile('''
6367
main() {
6468
var aaa = 1;
@@ -89,6 +93,7 @@ main() {
8993
}
9094

9195
test_removeContextAfterRequest() async {
96+
print('+++test_removeContextAfterRequest');
9297
addTestFile('''
9398
main() {
9499
var test = 0;
@@ -111,6 +116,7 @@ main() {
111116
}
112117

113118
test_zeroLength_end() async {
119+
print('+++test_zeroLength_end');
114120
addTestFile('''
115121
main() {
116122
var test = 0;
@@ -124,6 +130,7 @@ main() {
124130
}
125131

126132
test_zeroLength_start() async {
133+
print('+++test_zeroLength_start');
127134
addTestFile('''
128135
main() {
129136
var test = 0;

pkg/analysis_server/test/mocks.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Matcher isResponseSuccess(String id) => new _IsResponseSuccess(id);
5858
* times. By default, this should pump the event queue enough times to allow
5959
* any code to run, as long as it's not waiting on some external event.
6060
*/
61-
Future pumpEventQueue([int times = 500]) {
61+
Future pumpEventQueue([int times = 5000]) {
6262
if (times == 0) return new Future.value();
6363
// We use a delayed future to allow microtask events to finish. The
6464
// Future.value or Future() constructors use scheduleMicrotask themselves and
@@ -229,8 +229,8 @@ class MockServerChannel implements ServerCommunicationChannel {
229229
@override
230230
void listen(void onRequest(Request request),
231231
{Function onError, void onDone()}) {
232-
requestController.stream.listen(onRequest,
233-
onError: onError, onDone: onDone);
232+
requestController.stream
233+
.listen(onRequest, onError: onError, onDone: onDone);
234234
}
235235

236236
@override
@@ -330,8 +330,8 @@ class MockSocket<T> implements WebSocket {
330330
controller.close().then((_) => twin.controller.close());
331331

332332
StreamSubscription<T> listen(void onData(T event),
333-
{Function onError, void onDone(), bool cancelOnError}) => stream.listen(
334-
onData,
333+
{Function onError, void onDone(), bool cancelOnError}) =>
334+
stream.listen(onData,
335335
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
336336

337337
noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);

0 commit comments

Comments
 (0)