Remove dead code for an unused (old) task

R=scheglov@google.com

Review URL: https://codereview.chromium.org//1215433008.
This commit is contained in:
Brian Wilkerson
2015-06-29 13:23:38 -07:00
parent 508e6ca49b
commit e575dfe1d8
6 changed files with 0 additions and 264 deletions
@@ -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('<rethrow>', 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<E> {
/**
* 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.
-87
View File
@@ -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);
}
}
@@ -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<E> implements AnalysisTaskVisitor<E> {
@override
E visitBuildUnitElementTask(BuildUnitElementTask task) {
fail("Unexpectedly invoked visitGenerateDartErrorsTask");
return null;
}
@override
E visitGenerateDartErrorsTask(GenerateDartErrorsTask task) {
fail("Unexpectedly invoked visitGenerateDartErrorsTask");
-118
View File
@@ -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<bool> {
@override
bool visitBuildUnitElementTask(BuildUnitElementTask task) => true;
}
class BuildUnitElementTaskTV_perform_exception extends TestTaskVisitor<bool> {
@override
bool visitBuildUnitElementTask(BuildUnitElementTask task) {
expect(task.exception, isNotNull);
return true;
}
}
class BuildUnitElementTaskTV_perform_valid extends TestTaskVisitor<bool> {
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;
}
}
-17
View File
@@ -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();
});
}
-2
View File
@@ -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();
});
}