mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 02:27:39 +00:00
Remove many explicit references to AnalysisContextImpl and enable testing of the new task model
R=scheglov@google.com Review URL: https://codereview.chromium.org//1150863007
This commit is contained in:
parent
da0363172a
commit
add5a6910d
|
@ -926,7 +926,7 @@ class TestContextManager extends ContextManager {
|
|||
/**
|
||||
* The analysis context that was created.
|
||||
*/
|
||||
AnalysisContextImpl currentContext;
|
||||
AnalysisContext currentContext;
|
||||
|
||||
/**
|
||||
* Map from context to the timestamp when the context was created.
|
||||
|
@ -970,7 +970,7 @@ class TestContextManager extends ContextManager {
|
|||
currentContextFilePaths[path] = <String, int>{};
|
||||
currentContextSources[path] = new HashSet<Source>();
|
||||
currentContextPackageUriResolvers[path] = packageUriResolver;
|
||||
currentContext = new AnalysisContextImpl();
|
||||
currentContext = AnalysisEngine.instance.createAnalysisContext();
|
||||
currentContext.sourceFactory = new SourceFactory(
|
||||
packageUriResolver == null ? [] : [packageUriResolver]);
|
||||
return currentContext;
|
||||
|
|
|
@ -7881,7 +7881,7 @@ class HtmlTagInfoBuilderTest extends HtmlParserTest {
|
|||
|
||||
@reflectiveTest
|
||||
class HtmlUnitBuilderTest extends EngineTestCase {
|
||||
AnalysisContextImpl _context;
|
||||
InternalAnalysisContext _context;
|
||||
@override
|
||||
void setUp() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
|
@ -8009,15 +8009,10 @@ class HtmlUnitBuilderTest_ExpectedVariable {
|
|||
*/
|
||||
@reflectiveTest
|
||||
class HtmlWarningCodeTest extends EngineTestCase {
|
||||
/**
|
||||
* The source factory used to create the sources to be resolved.
|
||||
*/
|
||||
SourceFactory _sourceFactory;
|
||||
|
||||
/**
|
||||
* The analysis context used to resolve the HTML files.
|
||||
*/
|
||||
AnalysisContextImpl _context;
|
||||
InternalAnalysisContext _context;
|
||||
|
||||
/**
|
||||
* The contents of the 'test.html' file.
|
||||
|
@ -8030,14 +8025,11 @@ class HtmlWarningCodeTest extends EngineTestCase {
|
|||
List<AnalysisError> _errors;
|
||||
@override
|
||||
void setUp() {
|
||||
_sourceFactory = new SourceFactory([new FileUriResolver()]);
|
||||
_context = new AnalysisContextImpl();
|
||||
_context.sourceFactory = _sourceFactory;
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
}
|
||||
|
||||
@override
|
||||
void tearDown() {
|
||||
_sourceFactory = null;
|
||||
_context = null;
|
||||
_contents = null;
|
||||
_errors = null;
|
||||
|
|
|
@ -10,7 +10,7 @@ library engine.element_test;
|
|||
import 'package:analyzer/src/generated/ast.dart';
|
||||
import 'package:analyzer/src/generated/element.dart';
|
||||
import 'package:analyzer/src/generated/engine.dart'
|
||||
show AnalysisContext, AnalysisContextImpl, AnalysisOptionsImpl;
|
||||
show AnalysisContext, AnalysisOptionsImpl;
|
||||
import 'package:analyzer/src/generated/java_core.dart';
|
||||
import 'package:analyzer/src/generated/source_io.dart';
|
||||
import 'package:analyzer/src/generated/testing/ast_factory.dart';
|
||||
|
@ -1064,7 +1064,7 @@ class ElementImplTest extends EngineTestCase {
|
|||
}
|
||||
|
||||
void test_isAccessibleIn_private_differentLibrary() {
|
||||
AnalysisContextImpl context = createAnalysisContext();
|
||||
AnalysisContext context = createAnalysisContext();
|
||||
LibraryElementImpl library1 = ElementFactory.library(context, "lib1");
|
||||
ClassElement classElement = ElementFactory.classElement2("_C");
|
||||
(library1.definingCompilationUnit as CompilationUnitElementImpl).types =
|
||||
|
@ -1083,7 +1083,7 @@ class ElementImplTest extends EngineTestCase {
|
|||
}
|
||||
|
||||
void test_isAccessibleIn_public_differentLibrary() {
|
||||
AnalysisContextImpl context = createAnalysisContext();
|
||||
AnalysisContext context = createAnalysisContext();
|
||||
LibraryElementImpl library1 = ElementFactory.library(context, "lib1");
|
||||
ClassElement classElement = ElementFactory.classElement2("C");
|
||||
(library1.definingCompilationUnit as CompilationUnitElementImpl).types =
|
||||
|
@ -1960,27 +1960,27 @@ class FunctionTypeImplTest extends EngineTestCase {
|
|||
@reflectiveTest
|
||||
class HtmlElementImplTest extends EngineTestCase {
|
||||
void test_equals_differentSource() {
|
||||
AnalysisContextImpl context = createAnalysisContext();
|
||||
AnalysisContext context = createAnalysisContext();
|
||||
HtmlElementImpl elementA = ElementFactory.htmlUnit(context, "indexA.html");
|
||||
HtmlElementImpl elementB = ElementFactory.htmlUnit(context, "indexB.html");
|
||||
expect(elementA == elementB, isFalse);
|
||||
}
|
||||
|
||||
void test_equals_null() {
|
||||
AnalysisContextImpl context = createAnalysisContext();
|
||||
AnalysisContext context = createAnalysisContext();
|
||||
HtmlElementImpl element = ElementFactory.htmlUnit(context, "index.html");
|
||||
expect(element == null, isFalse);
|
||||
}
|
||||
|
||||
void test_equals_sameSource() {
|
||||
AnalysisContextImpl context = createAnalysisContext();
|
||||
AnalysisContext context = createAnalysisContext();
|
||||
HtmlElementImpl elementA = ElementFactory.htmlUnit(context, "index.html");
|
||||
HtmlElementImpl elementB = ElementFactory.htmlUnit(context, "index.html");
|
||||
expect(elementA == elementB, isTrue);
|
||||
}
|
||||
|
||||
void test_equals_self() {
|
||||
AnalysisContextImpl context = createAnalysisContext();
|
||||
AnalysisContext context = createAnalysisContext();
|
||||
HtmlElementImpl element = ElementFactory.htmlUnit(context, "index.html");
|
||||
expect(element == element, isTrue);
|
||||
}
|
||||
|
|
|
@ -311,7 +311,7 @@ class AnalysisContextImplTest extends EngineTestCase {
|
|||
}
|
||||
|
||||
void test_applyChanges_change_flush_element() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source librarySource = _addSource("/lib.dart", r'''
|
||||
library lib;
|
||||
|
@ -324,7 +324,7 @@ int aa = 0;''');
|
|||
}
|
||||
|
||||
Future test_applyChanges_change_multiple() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
SourcesChangedListener listener = new SourcesChangedListener();
|
||||
_context.onSourcesChanged.listen(listener.onData);
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
|
@ -416,7 +416,7 @@ int b = aa;''';
|
|||
}
|
||||
|
||||
Future test_applyChanges_remove() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
SourcesChangedListener listener = new SourcesChangedListener();
|
||||
_context.onSourcesChanged.listen(listener.onData);
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
|
@ -452,7 +452,7 @@ import 'libB.dart';''';
|
|||
}
|
||||
|
||||
Future test_applyChanges_removeContainer() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
SourcesChangedListener listener = new SourcesChangedListener();
|
||||
_context.onSourcesChanged.listen(listener.onData);
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
|
@ -485,7 +485,7 @@ import 'libB.dart';''';
|
|||
}
|
||||
|
||||
void test_computeDocumentationComment_block() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
String comment = "/** Comment */";
|
||||
Source source = _addSource("/test.dart", """
|
||||
|
@ -499,7 +499,7 @@ class A {}""");
|
|||
}
|
||||
|
||||
void test_computeDocumentationComment_none() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source source = _addSource("/test.dart", "class A {}");
|
||||
LibraryElement libraryElement = _context.computeLibraryElement(source);
|
||||
|
@ -514,7 +514,7 @@ class A {}""");
|
|||
}
|
||||
|
||||
void test_computeDocumentationComment_singleLine_multiple_EOL_n() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
String comment = "/// line 1\n/// line 2\n/// line 3\n";
|
||||
Source source = _addSource("/test.dart", "${comment}class A {}");
|
||||
|
@ -527,7 +527,7 @@ class A {}""");
|
|||
}
|
||||
|
||||
void test_computeDocumentationComment_singleLine_multiple_EOL_rn() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
String comment = "/// line 1\r\n/// line 2\r\n/// line 3\r\n";
|
||||
Source source = _addSource("/test.dart", "${comment}class A {}");
|
||||
|
@ -627,7 +627,7 @@ class A {}""");
|
|||
}
|
||||
|
||||
void test_computeLibraryElement() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source source = _addSource("/test.dart", "library lib;");
|
||||
LibraryElement element = _context.computeLibraryElement(source);
|
||||
|
@ -685,7 +685,7 @@ main() {}''');
|
|||
}
|
||||
|
||||
Future test_computeResolvedCompilationUnitAsync() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source source = _addSource("/lib.dart", "library lib;");
|
||||
// Complete all pending analysis tasks and flush the AST so that it won't
|
||||
|
@ -709,7 +709,7 @@ main() {}''');
|
|||
}
|
||||
|
||||
Future test_computeResolvedCompilationUnitAsync_afterDispose() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source source = _addSource("/lib.dart", "library lib;");
|
||||
// Complete all pending analysis tasks and flush the AST so that it won't
|
||||
|
@ -736,7 +736,7 @@ main() {}''');
|
|||
}
|
||||
|
||||
Future test_computeResolvedCompilationUnitAsync_cancel() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source source = _addSource("/lib.dart", "library lib;");
|
||||
// Complete all pending analysis tasks and flush the AST so that it won't
|
||||
|
@ -764,7 +764,7 @@ main() {}''');
|
|||
}
|
||||
|
||||
Future test_computeResolvedCompilationUnitAsync_dispose() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source source = _addSource("/lib.dart", "library lib;");
|
||||
// Complete all pending analysis tasks and flush the AST so that it won't
|
||||
|
@ -794,7 +794,7 @@ main() {}''');
|
|||
}
|
||||
|
||||
Future test_computeResolvedCompilationUnitAsync_unrelatedLibrary() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source librarySource = _addSource("/lib.dart", "library lib;");
|
||||
Source partSource = _addSource("/part.dart", "part of foo;");
|
||||
|
@ -871,12 +871,12 @@ main() {}''');
|
|||
}
|
||||
|
||||
void test_getDeclaredVariables() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
expect(_context.declaredVariables, isNotNull);
|
||||
}
|
||||
|
||||
void test_getElement() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
LibraryElement core =
|
||||
_context.computeLibraryElement(_sourceFactory.forUri("dart:core"));
|
||||
|
@ -983,7 +983,7 @@ class A {
|
|||
}
|
||||
|
||||
void test_getHtmlFilesReferencing_html() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source htmlSource = _addSource("/test.html", r'''
|
||||
<html><head>
|
||||
|
@ -1016,7 +1016,7 @@ class A {
|
|||
}
|
||||
|
||||
void test_getHtmlFilesReferencing_part() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source htmlSource = _addSource("/test.html", r'''
|
||||
<html><head>
|
||||
|
@ -1070,7 +1070,7 @@ class A {
|
|||
}
|
||||
|
||||
void test_getLaunchableClientLibrarySources() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
List<Source> sources = _context.launchableClientLibrarySources;
|
||||
expect(sources, hasLength(0));
|
||||
|
@ -1083,7 +1083,7 @@ main() {}''');
|
|||
}
|
||||
|
||||
void test_getLaunchableServerLibrarySources() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
List<Source> sources = _context.launchableServerLibrarySources;
|
||||
expect(sources, hasLength(0));
|
||||
|
@ -1094,7 +1094,7 @@ main() {}''');
|
|||
}
|
||||
|
||||
void test_getLibrariesContaining() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source librarySource = _addSource("/lib.dart", r'''
|
||||
library lib;
|
||||
|
@ -1110,7 +1110,7 @@ part 'part.dart';''');
|
|||
}
|
||||
|
||||
void test_getLibrariesDependingOn() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source libASource = _addSource("/libA.dart", "library libA;");
|
||||
_addSource("/libB.dart", "library libB;");
|
||||
|
@ -1129,7 +1129,7 @@ export 'libA.dart';''');
|
|||
}
|
||||
|
||||
void test_getLibrariesReferencedFromHtml() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source htmlSource = _addSource("/test.html", r'''
|
||||
<html><head>
|
||||
|
@ -1145,7 +1145,7 @@ export 'libA.dart';''');
|
|||
}
|
||||
|
||||
void test_getLibrariesReferencedFromHtml_no() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source htmlSource = _addSource("/test.html", r'''
|
||||
<html><head>
|
||||
|
@ -1158,7 +1158,7 @@ export 'libA.dart';''');
|
|||
}
|
||||
|
||||
void test_getLibraryElement() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source source = _addSource("/test.dart", "library lib;");
|
||||
LibraryElement element = _context.getLibraryElement(source);
|
||||
|
@ -1212,7 +1212,7 @@ main() {}''');
|
|||
}
|
||||
|
||||
void test_getPublicNamespace_element() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source source = _addSource("/test.dart", "class A {}");
|
||||
LibraryElement library = _context.computeLibraryElement(source);
|
||||
|
@ -1223,7 +1223,7 @@ main() {}''');
|
|||
}
|
||||
|
||||
void test_getResolvedCompilationUnit_library() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source source = _addSource("/lib.dart", "library libb;");
|
||||
LibraryElement library = _context.computeLibraryElement(source);
|
||||
|
@ -1233,14 +1233,14 @@ main() {}''');
|
|||
}
|
||||
|
||||
void test_getResolvedCompilationUnit_library_null() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source source = _addSource("/lib.dart", "library lib;");
|
||||
expect(_context.getResolvedCompilationUnit(source, null), isNull);
|
||||
}
|
||||
|
||||
void test_getResolvedCompilationUnit_source_dart() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source source = _addSource("/lib.dart", "library lib;");
|
||||
expect(_context.getResolvedCompilationUnit2(source, source), isNull);
|
||||
|
@ -1249,7 +1249,7 @@ main() {}''');
|
|||
}
|
||||
|
||||
void test_getResolvedCompilationUnit_source_html() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source source = _addSource("/test.html", "<html></html>");
|
||||
expect(_context.getResolvedCompilationUnit2(source, source), isNull);
|
||||
|
@ -1258,7 +1258,7 @@ main() {}''');
|
|||
}
|
||||
|
||||
void test_getResolvedHtmlUnit() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source source = _addSource("/test.html", "<html></html>");
|
||||
expect(_context.getResolvedHtmlUnit(source), isNull);
|
||||
|
@ -1301,7 +1301,7 @@ main() {}''');
|
|||
}
|
||||
|
||||
void test_isClientLibrary_dart() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source source = _addSource("/test.dart", r'''
|
||||
import 'dart:html';
|
||||
|
@ -1320,7 +1320,7 @@ main() {}''');
|
|||
}
|
||||
|
||||
void test_isServerLibrary_dart() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source source = _addSource("/test.dart", r'''
|
||||
library lib;
|
||||
|
@ -1751,7 +1751,7 @@ void g() { f(null); }''');
|
|||
}
|
||||
|
||||
void test_resolveCompilationUnit_import_relative() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
Source sourceA =
|
||||
_addSource("/libA.dart", "library libA; import 'libB.dart'; class A{}");
|
||||
_addSource("/libB.dart", "library libB; class B{}");
|
||||
|
@ -1765,7 +1765,7 @@ void g() { f(null); }''');
|
|||
}
|
||||
|
||||
void test_resolveCompilationUnit_import_relative_cyclic() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
Source sourceA =
|
||||
_addSource("/libA.dart", "library libA; import 'libB.dart'; class A{}");
|
||||
_addSource("/libB.dart", "library libB; import 'libA.dart'; class B{}");
|
||||
|
@ -1779,7 +1779,7 @@ void g() { f(null); }''');
|
|||
}
|
||||
|
||||
void test_resolveCompilationUnit_library() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source source = _addSource("/lib.dart", "library lib;");
|
||||
LibraryElement library = _context.computeLibraryElement(source);
|
||||
|
@ -1790,7 +1790,7 @@ void g() { f(null); }''');
|
|||
}
|
||||
|
||||
void test_resolveCompilationUnit_source() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source source = _addSource("/lib.dart", "library lib;");
|
||||
CompilationUnit compilationUnit =
|
||||
|
@ -1864,7 +1864,7 @@ void g() { f(null); }''');
|
|||
Future test_setChangedContents_libraryWithPart() {
|
||||
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
|
||||
options.incremental = true;
|
||||
_context = AnalysisContextFactory.contextWithCoreAndOptions(options);
|
||||
_context = AnalysisContextFactory.oldContextWithCoreAndOptions(options);
|
||||
SourcesChangedListener listener = new SourcesChangedListener();
|
||||
_context.onSourcesChanged.listen(listener.onData);
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
|
@ -1907,7 +1907,7 @@ int ya = 0;''';
|
|||
}
|
||||
|
||||
void test_setChangedContents_notResolved() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
AnalysisOptionsImpl options =
|
||||
new AnalysisOptionsImpl.from(_context.analysisOptions);
|
||||
options.incremental = true;
|
||||
|
@ -1927,7 +1927,7 @@ int ya = 0;''';
|
|||
}
|
||||
|
||||
Future test_setContents_libraryWithPart() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
SourcesChangedListener listener = new SourcesChangedListener();
|
||||
_context.onSourcesChanged.listen(listener.onData);
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
|
@ -1964,7 +1964,7 @@ int aa = 0;''';
|
|||
}
|
||||
|
||||
void test_setContents_null() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source librarySource = _addSource("/lib.dart", r'''
|
||||
library lib;
|
||||
|
@ -2005,7 +2005,7 @@ int a = 0;''');
|
|||
}
|
||||
|
||||
void test_unreadableSource() {
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
_context = AnalysisContextFactory.oldContextWithCore();
|
||||
_sourceFactory = _context.sourceFactory;
|
||||
Source test1 = _addSource("/test1.dart", r'''
|
||||
import 'test2.dart';
|
||||
|
@ -2306,8 +2306,7 @@ class AnalysisTask_test_perform_exception extends AnalysisTask {
|
|||
@reflectiveTest
|
||||
class AnalysisTaskTest extends EngineTestCase {
|
||||
void test_perform_exception() {
|
||||
InternalAnalysisContext context = new AnalysisContextImpl();
|
||||
context.sourceFactory = new SourceFactory([new FileUriResolver()]);
|
||||
InternalAnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
AnalysisTask task = new AnalysisTask_test_perform_exception(context);
|
||||
task.perform(new TestTaskVisitor<Object>());
|
||||
}
|
||||
|
@ -3884,8 +3883,7 @@ class GetContentTaskTest extends EngineTestCase {
|
|||
|
||||
void test_perform_valid() {
|
||||
Source source = new TestSource('/test.dart', 'class A {}');
|
||||
InternalAnalysisContext context = new AnalysisContextImpl();
|
||||
context.sourceFactory = new SourceFactory([new FileUriResolver()]);
|
||||
InternalAnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
GetContentTask task = new GetContentTask(context, source);
|
||||
task.perform(new GetContentTaskTestTV_perform_valid(context, source));
|
||||
}
|
||||
|
@ -4577,8 +4575,7 @@ class ParseDartTaskTest extends EngineTestCase {
|
|||
void test_perform_exception() {
|
||||
TestSource source = new TestSource();
|
||||
source.generateExceptionOnRead = true;
|
||||
InternalAnalysisContext context = new AnalysisContextImpl();
|
||||
context.sourceFactory = new SourceFactory([new FileUriResolver()]);
|
||||
InternalAnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
ParseDartTask task = new ParseDartTask(context, source, null, null);
|
||||
task.perform(new ParseDartTaskTestTV_perform_exception());
|
||||
}
|
||||
|
@ -4591,8 +4588,7 @@ export 'lib3.dart';
|
|||
part 'part.dart';
|
||||
class A {''';
|
||||
Source source = new TestSource('/test.dart', content);
|
||||
InternalAnalysisContext context = new AnalysisContextImpl();
|
||||
context.sourceFactory = new SourceFactory([new FileUriResolver()]);
|
||||
InternalAnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
ParseDartTask task = _createParseTask(context, source, content);
|
||||
task.perform(new ParseDartTaskTestTV_perform_library(context, source));
|
||||
}
|
||||
|
@ -4602,8 +4598,7 @@ class A {''';
|
|||
part of lib;
|
||||
class B {}''';
|
||||
Source source = new TestSource('/test.dart', content);
|
||||
InternalAnalysisContext context = new AnalysisContextImpl();
|
||||
context.sourceFactory = new SourceFactory([new FileUriResolver()]);
|
||||
InternalAnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
ParseDartTask task = _createParseTask(context, source, content);
|
||||
task.perform(new ParseDartTaskTestTV_perform_part(context, source));
|
||||
}
|
||||
|
@ -4617,8 +4612,7 @@ export '${a}lib3.dart';
|
|||
part 'part.dart';
|
||||
class A {}''';
|
||||
Source source = new TestSource('/test.dart', content);
|
||||
InternalAnalysisContext context = new AnalysisContextImpl();
|
||||
context.sourceFactory = new SourceFactory([new FileUriResolver()]);
|
||||
InternalAnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
ParseDartTask task = _createParseTask(context, source, content);
|
||||
task.perform(
|
||||
new ParseDartTaskTestTV_perform_validateDirectives(context, source));
|
||||
|
@ -4636,7 +4630,7 @@ class A {}''';
|
|||
void test_resolveDirective_exception() {
|
||||
GatheringErrorListener listener = new GatheringErrorListener();
|
||||
ImportDirective directive = AstFactory.importDirective3('dart:core', null);
|
||||
AnalysisContext context = new AnalysisContextImpl();
|
||||
AnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
context.sourceFactory = new MockSourceFactory();
|
||||
Source source =
|
||||
ParseDartTask.resolveDirective(context, null, directive, listener);
|
||||
|
@ -4753,9 +4747,8 @@ class ParseHtmlTaskTest extends EngineTestCase {
|
|||
|
||||
ParseHtmlTask parseSource(
|
||||
Source source, String contents, TestLogger testLogger) {
|
||||
InternalAnalysisContext context = new AnalysisContextImpl();
|
||||
InternalAnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
context.setContents(source, contents);
|
||||
context.sourceFactory = new SourceFactory([new FileUriResolver()]);
|
||||
ParseHtmlTask task = new ParseHtmlTask(context, source, contents);
|
||||
Logger oldLogger = AnalysisEngine.instance.logger;
|
||||
try {
|
||||
|
@ -4979,8 +4972,7 @@ class ResolveDartLibraryTaskTest extends EngineTestCase {
|
|||
void test_perform_exception() {
|
||||
TestSource source = new TestSource();
|
||||
source.generateExceptionOnRead = true;
|
||||
InternalAnalysisContext context = new AnalysisContextImpl();
|
||||
context.sourceFactory = new SourceFactory([new FileUriResolver()]);
|
||||
InternalAnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
ResolveDartLibraryTask task =
|
||||
new ResolveDartLibraryTask(context, source, source);
|
||||
task.perform(new ResolveDartLibraryTaskTestTV_perform_exception());
|
||||
|
@ -5154,8 +5146,7 @@ class ResolveHtmlTaskTest extends EngineTestCase {
|
|||
|
||||
void test_perform_exception() {
|
||||
Source source = new TestSource();
|
||||
InternalAnalysisContext context = new AnalysisContextImpl();
|
||||
context.sourceFactory = new SourceFactory([new FileUriResolver()]);
|
||||
InternalAnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
ResolveHtmlTask task = new ResolveHtmlTask(context, source, 0, null);
|
||||
task.perform(new ResolveHtmlTaskTestTV_perform_exception());
|
||||
}
|
||||
|
@ -5249,8 +5240,7 @@ class ScanDartTaskTest extends EngineTestCase {
|
|||
void test_perform_valid() {
|
||||
String content = 'class A {}';
|
||||
Source source = new TestSource('test.dart', content);
|
||||
InternalAnalysisContext context = new AnalysisContextImpl();
|
||||
context.sourceFactory = new SourceFactory([new FileUriResolver()]);
|
||||
InternalAnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
ScanDartTask task = new ScanDartTask(context, source, content);
|
||||
task.perform(new ScanDartTaskTestTV_perform_valid(context, source));
|
||||
}
|
||||
|
|
|
@ -2471,6 +2471,17 @@ class IncrementalResolverTest extends ResolverTestCase {
|
|||
LibraryElement library;
|
||||
CompilationUnit unit;
|
||||
|
||||
@override
|
||||
void reset() {
|
||||
analysisContext2 = AnalysisContextFactory.oldContextWithCore();
|
||||
}
|
||||
|
||||
@override
|
||||
void resetWithOptions(AnalysisOptions options) {
|
||||
analysisContext2 =
|
||||
AnalysisContextFactory.oldContextWithCoreAndOptions(options);
|
||||
}
|
||||
|
||||
void setUp() {
|
||||
super.setUp();
|
||||
test_resolveApiChanges = true;
|
||||
|
@ -2802,8 +2813,9 @@ class B {
|
|||
int updateEndOld = updateOffset + edit.length;
|
||||
int updateOldNew = updateOffset + edit.replacement.length;
|
||||
IncrementalResolver resolver = new IncrementalResolver(
|
||||
analysisContext2.getReadableSourceEntryOrNull(source), null, null,
|
||||
unit.element, updateOffset, updateEndOld, updateOldNew);
|
||||
(analysisContext2 as AnalysisContextImpl)
|
||||
.getReadableSourceEntryOrNull(source), null, null, unit.element,
|
||||
updateOffset, updateEndOld, updateOldNew);
|
||||
bool success = resolver.resolve(newNode);
|
||||
expect(success, isTrue);
|
||||
List<AnalysisError> newErrors = analysisContext.computeErrors(source);
|
||||
|
|
|
@ -6,6 +6,7 @@ library engine.resolver_test;
|
|||
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:analyzer/src/context/context.dart' as newContext;
|
||||
import 'package:analyzer/src/generated/ast.dart';
|
||||
import 'package:analyzer/src/generated/element.dart';
|
||||
import 'package:analyzer/src/generated/element_resolver.dart';
|
||||
|
@ -75,23 +76,28 @@ class AnalysisContextFactory {
|
|||
|
||||
/**
|
||||
* Create an analysis context that has a fake core library already resolved.
|
||||
*
|
||||
* @return the analysis context that was created
|
||||
* Return the context that was created.
|
||||
*/
|
||||
static AnalysisContextImpl contextWithCore() {
|
||||
static InternalAnalysisContext contextWithCore() {
|
||||
if (AnalysisEngine.instance.useTaskModel) {
|
||||
NewAnalysisContextForTests context = new NewAnalysisContextForTests();
|
||||
return initContextWithCore(context);
|
||||
}
|
||||
AnalysisContextForTests context = new AnalysisContextForTests();
|
||||
return initContextWithCore(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an analysis context that uses the given options and has a fake core library already
|
||||
* resolved.
|
||||
*
|
||||
* @param options the options to be applied to the context
|
||||
* @return the analysis context that was created
|
||||
* Create an analysis context that uses the given [options] and has a fake
|
||||
* core library already resolved. Return the context that was created.
|
||||
*/
|
||||
static AnalysisContextImpl contextWithCoreAndOptions(
|
||||
static InternalAnalysisContext contextWithCoreAndOptions(
|
||||
AnalysisOptions options) {
|
||||
if (AnalysisEngine.instance.useTaskModel) {
|
||||
NewAnalysisContextForTests context = new NewAnalysisContextForTests();
|
||||
context._internalSetAnalysisOptions(options);
|
||||
return initContextWithCore(context);
|
||||
}
|
||||
AnalysisContextForTests context = new AnalysisContextForTests();
|
||||
context._internalSetAnalysisOptions(options);
|
||||
return initContextWithCore(context);
|
||||
|
@ -103,7 +109,8 @@ class AnalysisContextFactory {
|
|||
* @param context the context to be initialized (not `null`)
|
||||
* @return the analysis context that was created
|
||||
*/
|
||||
static AnalysisContextImpl initContextWithCore(AnalysisContextImpl context) {
|
||||
static InternalAnalysisContext initContextWithCore(
|
||||
InternalAnalysisContext context) {
|
||||
DirectoryBasedDartSdk sdk = new _AnalysisContextFactory_initContextWithCore(
|
||||
new JavaFile("/fake/sdk"));
|
||||
SourceFactory sourceFactory =
|
||||
|
@ -346,6 +353,26 @@ class AnalysisContextFactory {
|
|||
context.recordLibraryElements(elementMap);
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an analysis context that has a fake core library already resolved.
|
||||
* Return the context that was created.
|
||||
*/
|
||||
static AnalysisContextImpl oldContextWithCore() {
|
||||
AnalysisContextForTests context = new AnalysisContextForTests();
|
||||
return initContextWithCore(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an analysis context that uses the given [options] and has a fake
|
||||
* core library already resolved. Return the context that was created.
|
||||
*/
|
||||
static AnalysisContextImpl oldContextWithCoreAndOptions(
|
||||
AnalysisOptions options) {
|
||||
AnalysisContextForTests context = new AnalysisContextForTests();
|
||||
context._internalSetAnalysisOptions(options);
|
||||
return initContextWithCore(context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -412,7 +439,7 @@ class AnalysisContextHelper {
|
|||
AnalysisContext context;
|
||||
|
||||
/**
|
||||
* Creates new [AnalysisContext] using [AnalysisContextFactory.contextWithCore].
|
||||
* Creates new [AnalysisContext] using [AnalysisContextFactory].
|
||||
*/
|
||||
AnalysisContextHelper([AnalysisOptionsImpl options]) {
|
||||
if (options == null) {
|
||||
|
@ -1888,10 +1915,7 @@ class ElementResolverTest extends EngineTestCase {
|
|||
* @return the resolver that was created
|
||||
*/
|
||||
ElementResolver _createResolver() {
|
||||
AnalysisContextImpl context = new AnalysisContextImpl();
|
||||
SourceFactory sourceFactory = new SourceFactory(
|
||||
[new DartUriResolver(DirectoryBasedDartSdk.defaultSdk)]);
|
||||
context.sourceFactory = sourceFactory;
|
||||
InternalAnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
FileBasedSource source =
|
||||
new FileBasedSource(FileUtilities2.createFile("/test.dart"));
|
||||
CompilationUnitElementImpl definingCompilationUnit =
|
||||
|
@ -5709,7 +5733,7 @@ class InheritanceManagerTest extends EngineTestCase {
|
|||
* @return the inheritance manager that was created
|
||||
*/
|
||||
InheritanceManager _createInheritanceManager() {
|
||||
AnalysisContextImpl context = AnalysisContextFactory.contextWithCore();
|
||||
AnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
FileBasedSource source =
|
||||
new FileBasedSource(FileUtilities2.createFile("/test.dart"));
|
||||
CompilationUnitElementImpl definingCompilationUnit =
|
||||
|
@ -5727,7 +5751,7 @@ class LibraryElementBuilderTest extends EngineTestCase {
|
|||
/**
|
||||
* The analysis context used to analyze sources.
|
||||
*/
|
||||
AnalysisContextImpl _context;
|
||||
InternalAnalysisContext _context;
|
||||
|
||||
/**
|
||||
* Add a source file to the content provider. The file path should be absolute.
|
||||
|
@ -5744,12 +5768,7 @@ class LibraryElementBuilderTest extends EngineTestCase {
|
|||
|
||||
@override
|
||||
void setUp() {
|
||||
SourceFactory sourceFactory = new SourceFactory([
|
||||
new DartUriResolver(DirectoryBasedDartSdk.defaultSdk),
|
||||
new FileUriResolver()
|
||||
]);
|
||||
_context = new AnalysisContextImpl();
|
||||
_context.sourceFactory = sourceFactory;
|
||||
_context = AnalysisContextFactory.contextWithCore();
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -5909,8 +5928,7 @@ class A {}''');
|
|||
@reflectiveTest
|
||||
class LibraryImportScopeTest extends ResolverTestCase {
|
||||
void test_conflictingImports() {
|
||||
AnalysisContext context = new AnalysisContextImpl();
|
||||
context.sourceFactory = new SourceFactory([]);
|
||||
AnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
String typeNameA = "A";
|
||||
String typeNameB = "B";
|
||||
String typeNameC = "C";
|
||||
|
@ -5976,8 +5994,7 @@ class LibraryImportScopeTest extends ResolverTestCase {
|
|||
}
|
||||
|
||||
void test_creation_nonEmpty() {
|
||||
AnalysisContext context = new AnalysisContextImpl();
|
||||
context.sourceFactory = new SourceFactory([]);
|
||||
AnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
String importedTypeName = "A";
|
||||
ClassElement importedType =
|
||||
new ClassElementImpl.forNode(AstFactory.identifier3(importedTypeName));
|
||||
|
@ -6028,8 +6045,7 @@ class LibraryImportScopeTest extends ResolverTestCase {
|
|||
}
|
||||
|
||||
void test_nonConflictingImports_sameElement() {
|
||||
AnalysisContext context = new AnalysisContextImpl();
|
||||
context.sourceFactory = new SourceFactory([]);
|
||||
AnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
String typeNameA = "A";
|
||||
String typeNameB = "B";
|
||||
ClassElement typeA = ElementFactory.classElement2(typeNameA);
|
||||
|
@ -6053,8 +6069,7 @@ class LibraryImportScopeTest extends ResolverTestCase {
|
|||
}
|
||||
|
||||
void test_prefixedAndNonPrefixed() {
|
||||
AnalysisContext context = new AnalysisContextImpl();
|
||||
context.sourceFactory = new SourceFactory([]);
|
||||
AnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
String typeName = "C";
|
||||
String prefixName = "p";
|
||||
ClassElement prefixedType = ElementFactory.classElement2(typeName);
|
||||
|
@ -6195,8 +6210,7 @@ class LibraryScopeTest extends ResolverTestCase {
|
|||
}
|
||||
|
||||
void test_creation_nonEmpty() {
|
||||
AnalysisContext context = new AnalysisContextImpl();
|
||||
context.sourceFactory = new SourceFactory([]);
|
||||
AnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
String importedTypeName = "A";
|
||||
ClassElement importedType =
|
||||
new ClassElementImpl.forNode(AstFactory.identifier3(importedTypeName));
|
||||
|
@ -6230,15 +6244,10 @@ class LibraryTest extends EngineTestCase {
|
|||
*/
|
||||
GatheringErrorListener _errorListener;
|
||||
|
||||
/**
|
||||
* The source factory used to create libraries.
|
||||
*/
|
||||
SourceFactory _sourceFactory;
|
||||
|
||||
/**
|
||||
* The analysis context to pass in to all libraries created by the tests.
|
||||
*/
|
||||
AnalysisContextImpl _analysisContext;
|
||||
InternalAnalysisContext _analysisContext;
|
||||
|
||||
/**
|
||||
* The library used by the tests.
|
||||
|
@ -6247,9 +6256,7 @@ class LibraryTest extends EngineTestCase {
|
|||
|
||||
@override
|
||||
void setUp() {
|
||||
_sourceFactory = new SourceFactory([new FileUriResolver()]);
|
||||
_analysisContext = new AnalysisContextImpl();
|
||||
_analysisContext.sourceFactory = _sourceFactory;
|
||||
_analysisContext = AnalysisContextFactory.contextWithCore();
|
||||
_errorListener = new GatheringErrorListener();
|
||||
_library = _createLibrary("/lib.dart");
|
||||
}
|
||||
|
@ -6257,7 +6264,6 @@ class LibraryTest extends EngineTestCase {
|
|||
@override
|
||||
void tearDown() {
|
||||
_errorListener = null;
|
||||
_sourceFactory = null;
|
||||
_analysisContext = null;
|
||||
_library = null;
|
||||
super.tearDown();
|
||||
|
@ -6381,6 +6387,63 @@ class MemberMapTest {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An analysis context that has a fake SDK that is much smaller and faster for
|
||||
* testing purposes.
|
||||
*/
|
||||
class NewAnalysisContextForTests extends newContext.AnalysisContextImpl {
|
||||
@override
|
||||
void set analysisOptions(AnalysisOptions options) {
|
||||
AnalysisOptions currentOptions = analysisOptions;
|
||||
bool needsRecompute = currentOptions.analyzeFunctionBodiesPredicate !=
|
||||
options.analyzeFunctionBodiesPredicate ||
|
||||
currentOptions.generateImplicitErrors !=
|
||||
options.generateImplicitErrors ||
|
||||
currentOptions.generateSdkErrors != options.generateSdkErrors ||
|
||||
currentOptions.dart2jsHint != options.dart2jsHint ||
|
||||
(currentOptions.hint && !options.hint) ||
|
||||
currentOptions.preserveComments != options.preserveComments ||
|
||||
currentOptions.enableNullAwareOperators !=
|
||||
options.enableNullAwareOperators ||
|
||||
currentOptions.enableStrictCallChecks != options.enableStrictCallChecks;
|
||||
if (needsRecompute) {
|
||||
fail(
|
||||
"Cannot set options that cause the sources to be reanalyzed in a test context");
|
||||
}
|
||||
super.analysisOptions = options;
|
||||
}
|
||||
|
||||
@override
|
||||
bool exists(Source source) =>
|
||||
super.exists(source) || sourceFactory.dartSdk.context.exists(source);
|
||||
|
||||
@override
|
||||
TimestampedData<String> getContents(Source source) {
|
||||
if (source.isInSystemLibrary) {
|
||||
return sourceFactory.dartSdk.context.getContents(source);
|
||||
}
|
||||
return super.getContents(source);
|
||||
}
|
||||
|
||||
@override
|
||||
int getModificationStamp(Source source) {
|
||||
if (source.isInSystemLibrary) {
|
||||
return sourceFactory.dartSdk.context.getModificationStamp(source);
|
||||
}
|
||||
return super.getModificationStamp(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the analysis options, even if they would force re-analysis. This method should only be
|
||||
* invoked before the fake SDK is initialized.
|
||||
*
|
||||
* @param options the analysis options to be set
|
||||
*/
|
||||
void _internalSetAnalysisOptions(AnalysisOptions options) {
|
||||
super.analysisOptions = options;
|
||||
}
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class NonHintCodeTest extends ResolverTestCase {
|
||||
void test_deadCode_deadBlock_conditionalElse_debugConst() {
|
||||
|
@ -7661,7 +7724,7 @@ class ResolverTestCase extends EngineTestCase {
|
|||
/**
|
||||
* The analysis context used to parse the compilation units being resolved.
|
||||
*/
|
||||
AnalysisContextImpl analysisContext2;
|
||||
InternalAnalysisContext analysisContext2;
|
||||
|
||||
/**
|
||||
* Specifies if [assertErrors] should check for [HintCode.UNUSED_ELEMENT] and
|
||||
|
@ -7771,7 +7834,7 @@ class ResolverTestCase extends EngineTestCase {
|
|||
* @return the library element that was created
|
||||
*/
|
||||
LibraryElementImpl createDefaultTestLibrary() =>
|
||||
createTestLibrary(new AnalysisContextImpl(), "test");
|
||||
createTestLibrary(AnalysisContextFactory.contextWithCore(), "test");
|
||||
|
||||
/**
|
||||
* Create a library element that represents a library with the given name containing a single
|
||||
|
@ -10994,10 +11057,7 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|||
* @return the analyzer to be used by the tests
|
||||
*/
|
||||
StaticTypeAnalyzer _createAnalyzer() {
|
||||
AnalysisContextImpl context = new AnalysisContextImpl();
|
||||
SourceFactory sourceFactory = new SourceFactory(
|
||||
[new DartUriResolver(DirectoryBasedDartSdk.defaultSdk)]);
|
||||
context.sourceFactory = sourceFactory;
|
||||
InternalAnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
FileBasedSource source =
|
||||
new FileBasedSource(FileUtilities2.createFile("/lib.dart"));
|
||||
CompilationUnitElementImpl definingCompilationUnit =
|
||||
|
@ -11502,7 +11562,7 @@ class SubtypeManagerTest extends EngineTestCase {
|
|||
@override
|
||||
void setUp() {
|
||||
super.setUp();
|
||||
AnalysisContextImpl context = AnalysisContextFactory.contextWithCore();
|
||||
AnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
FileBasedSource source =
|
||||
new FileBasedSource(FileUtilities2.createFile("/test.dart"));
|
||||
_definingCompilationUnit = new CompilationUnitElementImpl("test.dart");
|
||||
|
@ -13210,7 +13270,7 @@ class TypeProviderImplTest extends EngineTestCase {
|
|||
CompilationUnitElementImpl asyncUnit =
|
||||
new CompilationUnitElementImpl("async.dart");
|
||||
asyncUnit.types = <ClassElement>[futureType.element, streamType.element];
|
||||
AnalysisContextImpl context = new AnalysisContextImpl();
|
||||
AnalysisContext context = AnalysisEngine.instance.createAnalysisContext();
|
||||
LibraryElementImpl coreLibrary = new LibraryElementImpl.forNode(
|
||||
context, AstFactory.libraryIdentifier2(["dart.core"]));
|
||||
coreLibrary.definingCompilationUnit = coreUnit;
|
||||
|
@ -13333,9 +13393,7 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
|||
@override
|
||||
void setUp() {
|
||||
_listener = new GatheringErrorListener();
|
||||
SourceFactory factory = new SourceFactory([new FileUriResolver()]);
|
||||
AnalysisContextImpl context = new AnalysisContextImpl();
|
||||
context.sourceFactory = factory;
|
||||
InternalAnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
Source librarySource =
|
||||
new FileBasedSource(FileUtilities2.createFile("/lib.dart"));
|
||||
_library = new Library(context, _listener, librarySource);
|
||||
|
|
|
@ -18,6 +18,8 @@ import 'package:analyzer/src/generated/java_engine.dart';
|
|||
import 'package:analyzer/src/generated/source.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import 'resolver_test.dart';
|
||||
|
||||
/**
|
||||
* The class `EngineTestCase` defines utility methods for making assertions.
|
||||
*/
|
||||
|
@ -54,10 +56,8 @@ class EngineTestCase {
|
|||
expect(elements, hasLength(names.length));
|
||||
}
|
||||
|
||||
AnalysisContextImpl createAnalysisContext() {
|
||||
AnalysisContextImpl context = new AnalysisContextImpl();
|
||||
context.sourceFactory = new SourceFactory([]);
|
||||
return context;
|
||||
AnalysisContext createAnalysisContext() {
|
||||
return AnalysisContextFactory.contextWithCore();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -594,8 +594,6 @@ class TestSource extends Source {
|
|||
UriKind get uriKind {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@override
|
||||
String toString() => '$_name';
|
||||
bool operator ==(Object other) {
|
||||
if (other is TestSource) {
|
||||
return other._name == _name;
|
||||
|
@ -616,6 +614,8 @@ class TestSource extends Source {
|
|||
modificationStamp = new DateTime.now().millisecondsSinceEpoch;
|
||||
_contents = value;
|
||||
}
|
||||
@override
|
||||
String toString() => '$_name';
|
||||
}
|
||||
|
||||
class TestSourceWithUri extends TestSource {
|
||||
|
|
|
@ -63,8 +63,7 @@ class BuildUnitElementTaskTest extends EngineTestCase {
|
|||
void test_perform_exception() {
|
||||
TestSource source = new TestSource();
|
||||
source.generateExceptionOnRead = true;
|
||||
InternalAnalysisContext context = new AnalysisContextImpl();
|
||||
context.sourceFactory = new SourceFactory([new FileUriResolver()]);
|
||||
InternalAnalysisContext context = AnalysisContextFactory.contextWithCore();
|
||||
CompilationUnit unit = parseUnit(context, source, "");
|
||||
BuildUnitElementTask task =
|
||||
new BuildUnitElementTask(context, null, source, unit);
|
||||
|
|
Loading…
Reference in a new issue