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

Side by Side Diff: pkg/analyzer2dart/lib/src/driver.dart

Issue 516463007: Create unit tests for analyzer2dart/driver. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer2dart.driver; 5 library analyzer2dart.driver;
6 6
7 import 'package:analyzer/src/generated/element.dart'; 7 import 'package:analyzer/src/generated/element.dart';
8 import 'package:analyzer/src/generated/engine.dart'; 8 import 'package:analyzer/src/generated/engine.dart';
9 import 'package:analyzer/src/generated/java_io.dart'; 9 import 'package:analyzer/src/generated/java_io.dart';
10 import 'package:analyzer/src/generated/sdk_io.dart'; 10 import 'package:analyzer/src/generated/sdk_io.dart';
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 /** 57 /**
58 * Add the given file as the root of analysis, and return the corresponding 58 * Add the given file as the root of analysis, and return the corresponding
59 * source. 59 * source.
60 */ 60 */
61 Source setRealRoot(String path) { 61 Source setRealRoot(String path) {
62 // Tell the analysis server about the root 62 // Tell the analysis server about the root
63 ChangeSet changeSet = new ChangeSet(); 63 ChangeSet changeSet = new ChangeSet();
64 JavaFile javaFile = new JavaFile(path); 64 JavaFile javaFile = new JavaFile(path);
65 Source source = new FileBasedSource.con1(javaFile); 65 Source source = new FileBasedSource.con1(javaFile);
66 changeSet.addedSources.add(source); 66 changeSet.addedSource(source);
67 context.applyChanges(changeSet); 67 context.applyChanges(changeSet);
68 return source; 68 return source;
69 } 69 }
70
71 /**
72 * Add the given file contents as the root of analysis. For unit testing.
73 */
74 Source setFakeRoot(String contents) {
75 String path = 'root.dart';
76 // Tell the analysis server about the root
77 ChangeSet changeSet = new ChangeSet();
78 JavaFile javaFile = new JavaFile(path);
79 Source source = new FileBasedSource.con1(javaFile);
80 changeSet.addedSource(source);
81 changeSet.changedContent(source, contents);
82 context.applyChanges(changeSet);
83 return source;
84 }
70 } 85 }
71 86
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer2dart/test/driver_test.dart » ('j') | pkg/analyzer2dart/test/driver_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698