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

Side by Side Diff: pkg/analysis_server/test/abstract_context.dart

Issue 2681733007: When addSource() in tests, call both addFile() and changeFile(). (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 testing.abstract_context; 5 library testing.abstract_context;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 Source addPackageSource(String packageName, String filePath, String content) { 79 Source addPackageSource(String packageName, String filePath, String content) {
80 packageMap[packageName] = [(newFolder('/pubcache/$packageName'))]; 80 packageMap[packageName] = [(newFolder('/pubcache/$packageName'))];
81 File file = newFile('/pubcache/$packageName/$filePath', content); 81 File file = newFile('/pubcache/$packageName/$filePath', content);
82 return file.createSource(); 82 return file.createSource();
83 } 83 }
84 84
85 Source addSource(String path, String content, [Uri uri]) { 85 Source addSource(String path, String content, [Uri uri]) {
86 File file = newFile(path, content); 86 File file = newFile(path, content);
87 if (enableNewAnalysisDriver) { 87 if (enableNewAnalysisDriver) {
88 driver.addFile(path); 88 driver.addFile(path);
89 driver.changeFile(path);
Brian Wilkerson 2017/02/09 16:43:54 Should `addFile` be extended to also always do the
scheglov 2017/02/09 16:48:03 In general - no. We just allow us to be a bit slop
89 _fileContentOverlay[path] = content; 90 _fileContentOverlay[path] = content;
90 return null; 91 return null;
91 } else { 92 } else {
92 Source source = file.createSource(uri); 93 Source source = file.createSource(uri);
93 ChangeSet changeSet = new ChangeSet(); 94 ChangeSet changeSet = new ChangeSet();
94 changeSet.addedSource(source); 95 changeSet.addedSource(source);
95 context.applyChanges(changeSet); 96 context.applyChanges(changeSet);
96 context.setContents(source, content); 97 context.setContents(source, content);
97 return source; 98 return source;
98 } 99 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 * [engine.GeneralizingElementVisitor]. 202 * [engine.GeneralizingElementVisitor].
202 */ 203 */
203 class _ElementVisitorFunctionWrapper extends GeneralizingElementVisitor { 204 class _ElementVisitorFunctionWrapper extends GeneralizingElementVisitor {
204 final _ElementVisitorFunction function; 205 final _ElementVisitorFunction function;
205 _ElementVisitorFunctionWrapper(this.function); 206 _ElementVisitorFunctionWrapper(this.function);
206 visitElement(Element element) { 207 visitElement(Element element) {
207 function(element); 208 function(element);
208 super.visitElement(element); 209 super.visitElement(element);
209 } 210 }
210 } 211 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698