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

Side by Side Diff: pkg/analyzer/test/src/context/context_test.dart

Issue 2256623005: We need a CompilationUnit with element.library set. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Use RESOLVED_UNIT_RESULTS. Created 4 years, 4 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/context/context.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) 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 analyzer.test.src.context.context_test; 5 library analyzer.test.src.context.context_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 4606 matching lines...) Expand 10 before | Expand all | Expand 10 after
4617 context.setContents( 4617 context.setContents(
4618 a, 4618 a,
4619 r''' 4619 r'''
4620 class A {} 4620 class A {}
4621 class B2 {} 4621 class B2 {}
4622 '''); 4622 ''');
4623 _assertValidAllLibraryUnitResults(b); 4623 _assertValidAllLibraryUnitResults(b);
4624 _assertValid(b, LIBRARY_ERRORS_READY); 4624 _assertValid(b, LIBRARY_ERRORS_READY);
4625 } 4625 }
4626 4626
4627 void test_sequence_useAnyResolvedUnit_needsLibraryElement() {
4628 Source a = addSource(
4629 '/a.dart',
4630 r'''
4631 class A {}
4632 class B {}
4633 ''');
4634 // Perform analysis until we get RESOLVED_UNIT1.
4635 // But it does not have 'library' set, so `unitElement.context` is `null`.
4636 LibrarySpecificUnit aUnitTarget = new LibrarySpecificUnit(a, a);
4637 while (context.getResult(aUnitTarget, RESOLVED_UNIT1) == null) {
4638 context.performAnalysisTask();
4639 }
4640 // There was a bug with exception in incremental element builder.
4641 // We should not attempt to use `unitElement.context`.
4642 // It calls `unitElement.library`, which might be not set yet.
4643 context.setContents(
4644 a,
4645 r'''
4646 class A {}
4647 class B2 {}
4648 ''');
4649 // OK, no exceptions.
4650 }
4651
4627 void test_unusedName_class_add() { 4652 void test_unusedName_class_add() {
4628 Source a = addSource( 4653 Source a = addSource(
4629 '/a.dart', 4654 '/a.dart',
4630 r''' 4655 r'''
4631 class A {} 4656 class A {}
4632 class B {} 4657 class B {}
4633 class C {} 4658 class C {}
4634 '''); 4659 ''');
4635 Source b = addSource( 4660 Source b = addSource(
4636 '/b.dart', 4661 '/b.dart',
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
5225 * Initialize the visitor. 5250 * Initialize the visitor.
5226 */ 5251 */
5227 _ElementGatherer(); 5252 _ElementGatherer();
5228 5253
5229 @override 5254 @override
5230 void visitElement(Element element) { 5255 void visitElement(Element element) {
5231 elements[element] = element; 5256 elements[element] = element;
5232 super.visitElement(element); 5257 super.visitElement(element);
5233 } 5258 }
5234 } 5259 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/context/context.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698