Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: pkg/analysis_server/test/integration/analysis/package_root.dart

Issue 679763002: Add package root support to analysis server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.integration.analysis.packageRoot;
6
7 import 'package:analysis_server/src/protocol.dart';
8 import 'package:path/path.dart';
9 import 'package:unittest/unittest.dart';
10
11 import '../../reflective_tests.dart';
12 import '../integration_tests.dart';
13
14 @ReflectiveTestCase()
15 class Test extends AbstractAnalysisServerIntegrationTest {
16 test_package_root() {
17 String projPath = sourcePath('project');
18 String mainPath = join(projPath, 'main.dart');
19 String packagesPath = sourcePath('packages');
20 String fooBarPath = join(packagesPath, 'foo', 'bar.dart');
21 String mainText = """
22 library main;
23
24 import 'package:foo/bar.dart'
25
26 main() {
27 f();
28 }
29 """;
30 String fooBarText = """
31 library foo.bar;
32
33 f() {}
34 """;
35 writeFile(mainPath, mainText);
36 String normalizedFooBarPath = writeFile(fooBarPath, fooBarText);
37 sendServerSetSubscriptions([ServerService.STATUS]);
38 sendAnalysisSetSubscriptions({AnalysisService.NAVIGATION: [mainPath]});
39 List<NavigationRegion> navigationRegions;
40 onAnalysisNavigation.listen((AnalysisNavigationParams params) {
41 expect(params.file, equals(mainPath));
42 navigationRegions = params.regions;
43 });
44 sendAnalysisSetAnalysisRoots([projPath], [],
45 packageRoots: {projPath: packagesPath});
46 return analysisFinished.then((_) {
47 // Verify that fooBarPath was properly resolved by checking that f()
48 // refers to it.
49 bool found = false;
50 for (NavigationRegion region in navigationRegions) {
51 String navigationSource =
52 mainText.substring(region.offset, region.offset + region.length);
53 if (navigationSource == 'f') {
54 found = true;
55 expect(region.targets, hasLength(1));
56 Location location = region.targets[0].location;
57 expect(location.file, equals(normalizedFooBarPath));
58 }
59 }
60 expect(found, isTrue);
61 });
62 }
63 }
64
65 main() {
66 runReflectiveTests(Test);
67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698