diff --git a/pkg/analyzer/lib/src/generated/engine.dart b/pkg/analyzer/lib/src/generated/engine.dart index 8139b167616..7d3f7e68aad 100644 --- a/pkg/analyzer/lib/src/generated/engine.dart +++ b/pkg/analyzer/lib/src/generated/engine.dart @@ -20,7 +20,6 @@ import 'package:analyzer/src/plugin/engine_plugin.dart'; import 'package:analyzer/src/plugin/options_plugin.dart'; import 'package:analyzer/src/services/lint.dart'; import 'package:analyzer/src/task/manager.dart'; -import 'package:analyzer/src/task/task_dart.dart'; import 'package:analyzer/task/dart.dart'; import 'package:analyzer/task/model.dart'; import 'package:html/dom.dart' show Document; @@ -4246,28 +4245,6 @@ class AnalysisContextImpl implements InternalAnalysisContext { } } - /** - * Record the results produced by performing a [task] and return the cache - * entry associated with the results. - */ - DartEntry _recordBuildUnitElementTask(BuildUnitElementTask task) { - Source source = task.source; - Source library = task.library; - DartEntry dartEntry = _cache.get(source); - CaughtException thrownException = task.exception; - if (thrownException != null) { - dartEntry.recordBuildElementErrorInLibrary(library, thrownException); - throw new AnalysisException('', thrownException); - } - dartEntry.setValueInLibrary(DartEntry.BUILT_UNIT, library, task.unit); - dartEntry.setValueInLibrary( - DartEntry.BUILT_ELEMENT, library, task.unitElement); - ChangeNoticeImpl notice = getNotice(source); - LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO); - notice.setErrors(dartEntry.allErrors, lineInfo); - return dartEntry; - } - /** * Given a [dartEntry] and a [library] element, record the library element and * other information gleaned from the element in the cache entry. @@ -4839,10 +4816,6 @@ class AnalysisContextImpl_AnalysisTaskResultRecorder AnalysisContextImpl_AnalysisTaskResultRecorder(this.AnalysisContextImpl_this); - @override - DartEntry visitBuildUnitElementTask(BuildUnitElementTask task) => - AnalysisContextImpl_this._recordBuildUnitElementTask(task); - @override DartEntry visitGenerateDartErrorsTask(GenerateDartErrorsTask task) => AnalysisContextImpl_this._recordGenerateDartErrorsTask(task); @@ -6539,12 +6512,6 @@ abstract class AnalysisTask { * appropriate method. */ abstract class AnalysisTaskVisitor { - /** - * Visit the given [task], returning the result of the visit. This method will - * throw an AnalysisException if the visitor throws an exception. - */ - E visitBuildUnitElementTask(BuildUnitElementTask task); - /** * Visit the given [task], returning the result of the visit. This method will * throw an AnalysisException if the visitor throws an exception. diff --git a/pkg/analyzer/lib/src/task/task_dart.dart b/pkg/analyzer/lib/src/task/task_dart.dart deleted file mode 100644 index 91929705153..00000000000 --- a/pkg/analyzer/lib/src/task/task_dart.dart +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -library engine.task.dart; - -import 'package:analyzer/src/generated/ast.dart'; -import 'package:analyzer/src/generated/element.dart'; -import 'package:analyzer/src/generated/engine.dart'; -import 'package:analyzer/src/generated/resolver.dart'; -import 'package:analyzer/src/generated/source.dart'; - -/** - * A `BuildUnitElementTask` builds a compilation unit element for a single - * compilation unit. - */ -class BuildUnitElementTask extends AnalysisTask { - /** - * The source for which an element model will be built. - */ - final Source source; - - /** - * The source of the library in which an element model will be built. - */ - final Source library; - - /** - * The compilation unit from which an element model will be built. - */ - final CompilationUnit unit; - - /** - * The element model that was built. - */ - CompilationUnitElement unitElement; - - /** - * Initialize a newly created task to build a compilation unit element for - * the given [source] in the given [library] based on the compilation [unit] - * that was parsed. - */ - BuildUnitElementTask( - InternalAnalysisContext context, this.source, this.library, this.unit) - : super(context); - - @override - String get taskDescription { - if (source == null) { - return "build the unit element model for null source"; - } - return "build the unit element model for " + source.fullName; - } - - @override - accept(AnalysisTaskVisitor visitor) { - return visitor.visitBuildUnitElementTask(this); - } - - /** - * Return the compilation unit from which the element model was built. - */ - CompilationUnit getCompilationUnit() { - return unit; - } - - /** - * Return the source that is to be parsed. - */ - Source getSource() { - return source; - } - - /** - * Return the compilation unit element that was produced, or `null` if the - * task has not yet been performed or if an exception occurred. - */ - CompilationUnitElement getUnitElement() { - return unitElement; - } - - @override - void internalPerform() { - CompilationUnitBuilder builder = new CompilationUnitBuilder(); - unitElement = builder.buildCompilationUnit(source, unit, library); - } -} diff --git a/pkg/analyzer/test/generated/engine_test.dart b/pkg/analyzer/test/generated/engine_test.dart index f5a4c016165..eb87ea7897f 100644 --- a/pkg/analyzer/test/generated/engine_test.dart +++ b/pkg/analyzer/test/generated/engine_test.dart @@ -33,7 +33,6 @@ import 'package:analyzer/src/generated/testing/element_factory.dart'; import 'package:analyzer/src/generated/utilities_collection.dart'; import 'package:analyzer/src/services/lint.dart'; import 'package:analyzer/src/string_source.dart'; -import 'package:analyzer/src/task/task_dart.dart'; import 'package:analyzer/task/model.dart' hide AnalysisTask; import 'package:html/dom.dart' show Document; import 'package:path/path.dart' as pathos; @@ -6381,12 +6380,6 @@ class TestAnalysisContext_test_setSourceFactory extends TestAnalysisContext { * failure. */ class TestTaskVisitor implements AnalysisTaskVisitor { - @override - E visitBuildUnitElementTask(BuildUnitElementTask task) { - fail("Unexpectedly invoked visitGenerateDartErrorsTask"); - return null; - } - @override E visitGenerateDartErrorsTask(GenerateDartErrorsTask task) { fail("Unexpectedly invoked visitGenerateDartErrorsTask"); diff --git a/pkg/analyzer/test/task/task_dart_test.dart b/pkg/analyzer/test/task/task_dart_test.dart deleted file mode 100644 index e7c03bec5bd..00000000000 --- a/pkg/analyzer/test/task/task_dart_test.dart +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -library test.engine.task.dart; - -import 'package:analyzer/src/generated/ast.dart'; -import 'package:analyzer/src/generated/engine.dart'; -import 'package:analyzer/src/generated/java_engine.dart'; -import 'package:analyzer/src/generated/source.dart'; -import 'package:analyzer/src/generated/source_io.dart'; -import 'package:analyzer/src/task/task_dart.dart'; -import 'package:unittest/unittest.dart'; - -import '../generated/engine_test.dart'; -import '../generated/resolver_test.dart'; -import '../generated/test_support.dart'; - -main() { - groupSep = ' | '; -// runReflectiveTests(BuildUnitElementTaskTest); -} - -class BuildUnitElementTaskTest extends EngineTestCase { - CompilationUnit parseUnit( - InternalAnalysisContext context, Source source, String content) { - ScanDartTask scanTask = new ScanDartTask(context, source, content); - scanTask.perform(new ScanDartTaskTestTV_accept()); - ParseDartTask parseTask = new ParseDartTask( - context, source, scanTask.tokenStream, scanTask.lineInfo); - parseTask.perform(new ParseDartTaskTestTV_accept()); - return parseTask.compilationUnit; - } - - void test_accept() { - BuildUnitElementTask task = - new BuildUnitElementTask(null, null, null, null); - expect(task.accept(new BuildUnitElementTaskTV_accept()), isTrue); - } - - void test_getException() { - BuildUnitElementTask task = - new BuildUnitElementTask(null, null, null, null); - expect(task.exception, isNull); - } - - void test_getLibrarySource() { - Source source = new TestSource('/part.dart'); - Source library = new TestSource('/lib.dart'); - BuildUnitElementTask task = - new BuildUnitElementTask(null, source, library, null); - expect(task.library, equals(library)); - } - - void test_getUnitSource() { - Source source = new TestSource('/part.dart'); - Source library = new TestSource('/lib.dart'); - BuildUnitElementTask task = - new BuildUnitElementTask(null, source, library, null); - expect(task.source, equals(source)); - } - - void test_perform_exception() { - TestSource source = new TestSource(); - source.generateExceptionOnRead = true; - InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); - CompilationUnit unit = parseUnit(context, source, ""); - BuildUnitElementTask task = - new BuildUnitElementTask(context, null, source, unit); - task.perform(new BuildUnitElementTaskTV_perform_exception()); - } - - void test_perform_valid() { - var content = """ -library lib; -class A {}"""; - Source source = new TestSource('/test.dart', content); - InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); - CompilationUnit unit = parseUnit(context, source, content); - BuildUnitElementTask task = - new BuildUnitElementTask(context, source, source, unit); - task.perform(new BuildUnitElementTaskTV_perform_valid(source, unit)); - } -} - -class BuildUnitElementTaskTV_accept extends TestTaskVisitor { - @override - bool visitBuildUnitElementTask(BuildUnitElementTask task) => true; -} - -class BuildUnitElementTaskTV_perform_exception extends TestTaskVisitor { - @override - bool visitBuildUnitElementTask(BuildUnitElementTask task) { - expect(task.exception, isNotNull); - return true; - } -} - -class BuildUnitElementTaskTV_perform_valid extends TestTaskVisitor { - Source source; - - CompilationUnit unit; - - BuildUnitElementTaskTV_perform_valid(this.source, this.unit); - - @override - bool visitBuildUnitElementTask(BuildUnitElementTask task) { - CaughtException exception = task.exception; - if (exception != null) { - throw exception; - } - expect(task.source, equals(source)); - expect(task.library, equals(source)); - expect(task.unit, equals(unit)); - expect(task.unitElement, isNotNull); - return true; - } -} diff --git a/pkg/analyzer/test/task/test_all.dart b/pkg/analyzer/test/task/test_all.dart deleted file mode 100644 index 9ecd16215ff..00000000000 --- a/pkg/analyzer/test/task/test_all.dart +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -library test.task; - -import 'package:unittest/unittest.dart'; - -import 'task_dart_test.dart' as task_dart_test; - -/// Utility for manually running all tests. -main() { - groupSep = ' | '; - group('generated tests', () { - task_dart_test.main(); - }); -} diff --git a/pkg/analyzer/test/test_all.dart b/pkg/analyzer/test/test_all.dart index 222beb809bf..cde1f38234c 100644 --- a/pkg/analyzer/test/test_all.dart +++ b/pkg/analyzer/test/test_all.dart @@ -14,7 +14,6 @@ import 'instrumentation/test_all.dart' as instrumentation; import 'parse_compilation_unit_test.dart' as parse_compilation_unit; import 'source/test_all.dart' as source; import 'src/test_all.dart' as src; -import 'task/test_all.dart' as task; /// Utility for manually running all tests. main() { @@ -28,6 +27,5 @@ main() { parse_compilation_unit.main(); source.main(); src.main(); - task.main(); }); }