Skip to content

Commit

Permalink
Remove more unused classes from engine.dart
Browse files Browse the repository at this point in the history
R=brianwilkerson@google.com

Change-Id: I8d660025e201ef8a79d377c1923fe9a87bbc80ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116750
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
scheglov authored and commit-bot@chromium.org committed Sep 11, 2019
1 parent e35408d commit d39b67d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 197 deletions.
156 changes: 0 additions & 156 deletions pkg/analyzer/lib/src/generated/engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,70 +107,6 @@ abstract class AnalysisContext {
void applyChanges(ChangeSet changeSet);
}

/// A representation of changes to the types of analysis that should be
/// performed.
class AnalysisDelta {
/// A mapping from source to what type of analysis should be performed on that
/// source.
Map<Source, AnalysisLevel> _analysisMap =
new HashMap<Source, AnalysisLevel>();

/// Return a collection of the sources that have been added. This is equivalent
/// to calling [getAnalysisLevels] and collecting all sources that do not have
/// an analysis level of [AnalysisLevel.NONE].
List<Source> get addedSources {
List<Source> result = new List<Source>();
_analysisMap.forEach((Source source, AnalysisLevel level) {
if (level != AnalysisLevel.NONE) {
result.add(source);
}
});
return result;
}

/// Return a mapping of sources to the level of analysis that should be
/// performed.
Map<Source, AnalysisLevel> get analysisLevels => _analysisMap;

/// Record that the given [source] should be analyzed at the given [level].
void setAnalysisLevel(Source source, AnalysisLevel level) {
_analysisMap[source] = level;
}

@override
String toString() {
StringBuffer buffer = new StringBuffer();
bool needsSeparator = _appendSources(buffer, false, AnalysisLevel.ALL);
needsSeparator =
_appendSources(buffer, needsSeparator, AnalysisLevel.RESOLVED);
_appendSources(buffer, needsSeparator, AnalysisLevel.NONE);
return buffer.toString();
}

/// Append to the given [buffer] all sources with the given analysis [level],
/// prefixed with a label and a separator if [needsSeparator] is `true`.
bool _appendSources(
StringBuffer buffer, bool needsSeparator, AnalysisLevel level) {
bool first = true;
_analysisMap.forEach((Source source, AnalysisLevel sourceLevel) {
if (sourceLevel == level) {
if (first) {
first = false;
if (needsSeparator) {
buffer.write("; ");
}
buffer.write(level);
buffer.write(" ");
} else {
buffer.write(", ");
}
buffer.write(source.fullName);
}
});
return needsSeparator || !first;
}
}

/// The entry point for the functionality provided by the analysis engine. There
/// is a single instance of this class.
class AnalysisEngine {
Expand Down Expand Up @@ -311,79 +247,6 @@ class AnalysisErrorInfoImpl implements AnalysisErrorInfo {
AnalysisErrorInfoImpl(this.errors, this.lineInfo);
}

/// The levels at which a source can be analyzed.
class AnalysisLevel implements Comparable<AnalysisLevel> {
/// Indicates a source should be fully analyzed.
static const AnalysisLevel ALL = const AnalysisLevel('ALL', 0);

/// Indicates a source should be resolved and that errors, warnings and hints
/// are needed.
static const AnalysisLevel ERRORS = const AnalysisLevel('ERRORS', 1);

/// Indicates a source should be resolved, but that errors, warnings and hints
/// are not needed.
static const AnalysisLevel RESOLVED = const AnalysisLevel('RESOLVED', 2);

/// Indicates a source is not of interest to the client.
static const AnalysisLevel NONE = const AnalysisLevel('NONE', 3);

static const List<AnalysisLevel> values = const [ALL, ERRORS, RESOLVED, NONE];

/// The name of this analysis level.
final String name;

/// The ordinal value of the analysis level.
final int ordinal;

const AnalysisLevel(this.name, this.ordinal);

@override
int get hashCode => ordinal;

@override
int compareTo(AnalysisLevel other) => ordinal - other.ordinal;

@override
String toString() => name;
}

/// An object that is listening for results being produced by an analysis
/// context.
abstract class AnalysisListener {
/// Reports that a task, described by the given [taskDescription] is about to
/// be performed by the given [context].
void aboutToPerformTask(AnalysisContext context, String taskDescription);

/// Reports that the [errors] associated with the given [source] in the given
/// [context] has been updated to the given errors. The [lineInfo] is the line
/// information associated with the source.
void computedErrors(AnalysisContext context, Source source,
List<AnalysisError> errors, LineInfo lineInfo);

/// Reports that the given [source] is no longer included in the set of sources
/// that are being analyzed by the given analysis [context].
void excludedSource(AnalysisContext context, Source source);

/// Reports that the given [source] is now included in the set of sources that
/// are being analyzed by the given analysis [context].
void includedSource(AnalysisContext context, Source source);

/// Reports that the given Dart [source] was parsed in the given [context],
/// producing the given [unit].
void parsedDart(AnalysisContext context, Source source, CompilationUnit unit);

/// Reports that the given Dart [source] was resolved in the given [context].
void resolvedDart(
AnalysisContext context, Source source, CompilationUnit unit);
}

/// Futures returned by [AnalysisContext] for pending analysis results will
/// complete with this error if it is determined that analysis results will
/// never become available (e.g. because the requested source is not subject to
/// analysis, or because the requested source is a part file which is not a part
/// of any known library).
class AnalysisNotScheduledError implements Exception {}

/// A set of analysis options used to control the behavior of an analysis
/// context.
abstract class AnalysisOptions {
Expand Down Expand Up @@ -1238,25 +1101,6 @@ class NullLogger implements Logger {
void logInformation(String message, [CaughtException exception]) {}
}

/// An exception created when an analysis attempt fails because a source was
/// deleted between the time the analysis started and the time the results of the
/// analysis were ready to be recorded.
class ObsoleteSourceAnalysisException extends AnalysisException {
/// The source that was removed while it was being analyzed.
Source _source;

/// Initialize a newly created exception to represent the removal of the given
/// [source].
ObsoleteSourceAnalysisException(Source source)
: super(
"The source '${source.fullName}' was removed while it was being analyzed") {
this._source = source;
}

/// Return the source that was removed while it was being analyzed.
Source get source => _source;
}

/// Container with global [AnalysisContext] performance statistics.
class PerformanceStatistics {
/// The [PerformanceTag] for `package:analyzer`.
Expand Down
41 changes: 0 additions & 41 deletions pkg/analyzer/test/generated/resolver_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import 'test_support.dart';

main() {
defineReflectiveSuite(() {
defineReflectiveTests(AnalysisDeltaTest);
defineReflectiveTests(ChangeSetTest);
defineReflectiveTests(EnclosedScopeTest);
defineReflectiveTests(ErrorResolverTest);
Expand All @@ -62,46 +61,6 @@ void _fail(String message) {
fail(message);
}

@reflectiveTest
class AnalysisDeltaTest extends EngineTestCase {
TestSource source1 = new TestSource('/1.dart');
TestSource source2 = new TestSource('/2.dart');
TestSource source3 = new TestSource('/3.dart');

void test_getAddedSources() {
AnalysisDelta delta = new AnalysisDelta();
delta.setAnalysisLevel(source1, AnalysisLevel.ALL);
delta.setAnalysisLevel(source2, AnalysisLevel.ERRORS);
delta.setAnalysisLevel(source3, AnalysisLevel.NONE);
List<Source> addedSources = delta.addedSources;
expect(addedSources, hasLength(2));
expect(addedSources, unorderedEquals([source1, source2]));
}

void test_getAnalysisLevels() {
AnalysisDelta delta = new AnalysisDelta();
expect(delta.analysisLevels.length, 0);
}

void test_setAnalysisLevel() {
AnalysisDelta delta = new AnalysisDelta();
delta.setAnalysisLevel(source1, AnalysisLevel.ALL);
delta.setAnalysisLevel(source2, AnalysisLevel.ERRORS);
Map<Source, AnalysisLevel> levels = delta.analysisLevels;
expect(levels.length, 2);
expect(levels[source1], AnalysisLevel.ALL);
expect(levels[source2], AnalysisLevel.ERRORS);
}

void test_toString() {
AnalysisDelta delta = new AnalysisDelta();
delta.setAnalysisLevel(new TestSource(), AnalysisLevel.ALL);
String result = delta.toString();
expect(result, isNotNull);
expect(result.isNotEmpty, isTrue);
}
}

@reflectiveTest
class ChangeSetTest extends EngineTestCase {
void test_changedContent() {
Expand Down

0 comments on commit d39b67d

Please sign in to comment.