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

Side by Side Diff: pkg/analyzer/test/src/dart/analysis/driver_test.dart

Issue 2686843003: Don't re-read files when compute their analysis results. (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 | « pkg/analyzer/lib/src/dart/analysis/driver.dart ('k') | 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 analyzer.test.driver; 5 library analyzer.test.driver;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 1394
1395 { 1395 {
1396 AnalysisResult result = await driver.getResult(a); 1396 AnalysisResult result = await driver.getResult(a);
1397 expect(_getTopLevelVarType(result.unit, 'A1'), 'int'); 1397 expect(_getTopLevelVarType(result.unit, 'A1'), 'int');
1398 expect(_getTopLevelVarType(result.unit, 'A2'), 'int'); 1398 expect(_getTopLevelVarType(result.unit, 'A2'), 'int');
1399 } 1399 }
1400 1400
1401 // Update "a" so that "A1" is now "double". 1401 // Update "a" so that "A1" is now "double".
1402 // Get result for "a". 1402 // Get result for "a".
1403 // 1403 //
1404 // Even though we have not notified the driver about the change, 1404 // We get "double" for "A2", even though "A2" has the type from "b".
1405 // we still get "double" for "A1", because getResult() re-read the content.
1406 //
1407 // We also get "double" for "A2", even though "A2" has the type from "b".
1408 // That's because we check for "a" API signature consistency, and because 1405 // That's because we check for "a" API signature consistency, and because
1409 // it has changed, we invalidated the dependency cache, relinked libraries 1406 // it has changed, we invalidated the dependency cache, relinked libraries
1410 // and recomputed types. 1407 // and recomputed types.
1411 provider.updateFile( 1408 provider.updateFile(
1412 a, 1409 a,
1413 r''' 1410 r'''
1414 import 'b.dart'; 1411 import 'b.dart';
1415 var A1 = 1.2; 1412 var A1 = 1.2;
1416 var A2 = B1; 1413 var A2 = B1;
1417 '''); 1414 ''');
1415 driver.changeFile(a);
1416
1418 { 1417 {
1419 AnalysisResult result = await driver.getResult(a); 1418 AnalysisResult result = await driver.getResult(a);
1420 expect(_getTopLevelVarType(result.unit, 'A1'), 'double'); 1419 expect(_getTopLevelVarType(result.unit, 'A1'), 'double');
1421 expect(_getTopLevelVarType(result.unit, 'A2'), 'double'); 1420 expect(_getTopLevelVarType(result.unit, 'A2'), 'double');
1422 } 1421 }
1423 } 1422 }
1424 1423
1425 test_getResult_thenRemove() async { 1424 test_getResult_thenRemove() async {
1426 addTestFile('main() {}', priority: true); 1425 addTestFile('main() {}', priority: true);
1427 1426
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
2336 * Return the [provider] specific path for the given Posix [path]. 2335 * Return the [provider] specific path for the given Posix [path].
2337 */ 2336 */
2338 String _p(String path) => provider.convertPath(path); 2337 String _p(String path) => provider.convertPath(path);
2339 2338
2340 static String _md5(String content) { 2339 static String _md5(String content) {
2341 return hex.encode(md5.convert(UTF8.encode(content)).bytes); 2340 return hex.encode(md5.convert(UTF8.encode(content)).bytes);
2342 } 2341 }
2343 } 2342 }
2344 2343
2345 class _SourceMock extends TypedMock implements Source {} 2344 class _SourceMock extends TypedMock implements Source {}
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/driver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698