Skip to content

Commit

Permalink
Add @OVERRIDES to (a lot of) analyzer.
Browse files Browse the repository at this point in the history
This gets us roughly half+ way there.  We should defintely consider automating this to speed up the rest.  (Even with the quick-fix it's VERY tedious and slow going.)

Once we've done this in bulk, I'd like to add the  `annotate_overrides` lint to analyzer and server `.analysis_options`.

BUG=
[email protected], [email protected]

Review URL: https://codereview.chromium.org/1749143003 .
  • Loading branch information
pq committed Mar 2, 2016
1 parent d9e426e commit 9ea1718
Show file tree
Hide file tree
Showing 24 changed files with 228 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/analyzer/.analysis_options
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
linter:
rules:
- unnecessary_brace_in_string_interp
- annotate_overrides
- empty_constructor_bodies
- unnecessary_brace_in_string_interp
2 changes: 2 additions & 0 deletions pkg/analyzer/example/parser_driver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ _parse(File file) {
}

class _ASTVisitor extends GeneralizingAstVisitor {
@override
visitNode(AstNode node) {
print('${node.runtimeType} : <"$node">');
return super.visitNode(node);
Expand All @@ -52,5 +53,6 @@ class _ASTVisitor extends GeneralizingAstVisitor {
class _ErrorCollector extends AnalysisErrorListener {
List<AnalysisError> errors;
_ErrorCollector() : errors = new List<AnalysisError>();
@override
onError(error) => errors.add(error);
}
1 change: 1 addition & 0 deletions pkg/analyzer/example/resolver_driver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const _usage =
'Usage: resolve_driver <path_to_sdk> <file_to_resolve> [<packages_root>]';

class _ASTVisitor extends GeneralizingAstVisitor {
@override
visitNode(AstNode node) {
var lines = <String>['${node.runtimeType} : <"$node">'];
if (node is SimpleIdentifier) {
Expand Down
1 change: 1 addition & 0 deletions pkg/analyzer/lib/analyzer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,6 @@ class _ErrorCollector extends AnalysisErrorListener {
/// Whether any errors where collected.
bool get hasErrors => !_errors.isEmpty;

@override
void onError(AnalysisError error) => _errors.add(error);
}
11 changes: 11 additions & 0 deletions pkg/analyzer/lib/dart/ast/ast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4020,6 +4020,7 @@ abstract class FunctionExpressionInvocation extends InvocationExpression {
/**
* Return the expression producing the function being invoked.
*/
@override
Expression get function;

/**
Expand Down Expand Up @@ -4050,12 +4051,14 @@ abstract class FunctionExpressionInvocation extends InvocationExpression {
* [InterfaceType] with a `call` method, `dynamic`, `Function`, or a `@proxy`
* interface type that implements `Function`.
*/
@override
DartType get propagatedInvokeType;

/**
* Set the function type of the method invocation based on the propagated type
* information to the given [type].
*/
@override
void set propagatedInvokeType(DartType type);

/**
Expand All @@ -4080,12 +4083,14 @@ abstract class FunctionExpressionInvocation extends InvocationExpression {
* [InterfaceType] with a `call` method, `dynamic`, `Function`, or a `@proxy`
* interface type that implements `Function`.
*/
@override
DartType get staticInvokeType;

/**
* Set the function type of the method invocation based on the static type
* information to the given [type].
*/
@override
void set staticInvokeType(DartType type);

/**
Expand Down Expand Up @@ -5632,12 +5637,14 @@ abstract class MethodInvocation extends InvocationExpression {
* [InterfaceType] with a `call` method, `dynamic`, `Function`, or a `@proxy`
* interface type that implements `Function`.
*/
@override
DartType get propagatedInvokeType;

/**
* Set the function type of the method invocation based on the propagated type
* information to the given [type].
*/
@override
void set propagatedInvokeType(DartType type);

/**
Expand All @@ -5657,12 +5664,14 @@ abstract class MethodInvocation extends InvocationExpression {
* [InterfaceType] with a `call` method, `dynamic`, `Function`, or a `@proxy`
* interface type that implements `Function`.
*/
@override
DartType get staticInvokeType;

/**
* Set the function type of the method invocation based on the static type
* information to the given [type].
*/
@override
void set staticInvokeType(DartType type);

/**
Expand Down Expand Up @@ -5920,12 +5929,14 @@ abstract class NodeList<E extends AstNode> implements List<E> {
* Return the node at the given [index] in the list or throw a [RangeError] if
* [index] is out of bounds.
*/
@override
E operator [](int index);

/**
* Set the node at the given [index] in the list to the given [node] or throw
* a [RangeError] if [index] is out of bounds.
*/
@override
void operator []=(int index, E node);

/**
Expand Down
1 change: 1 addition & 0 deletions pkg/analyzer/lib/file_system/file_system.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class FileSystemException implements Exception {

FileSystemException(this.path, this.message);

@override
String toString() => 'FileSystemException(path=$path; message=$message)';
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/analyzer/lib/file_system/memory_file_system.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class MemoryResourceProvider implements ResourceProvider {
int nextStamp = 0;

final Context _pathContext;
@override
final AbsolutePathContext absolutePathContext;

MemoryResourceProvider({bool isWindows: false})
Expand Down Expand Up @@ -211,6 +212,7 @@ class _MemoryDummyLink extends _MemoryResource implements File {
@override
bool get exists => false;

@override
int get modificationStamp {
int stamp = _provider._pathToTimestamp[path];
if (stamp == null) {
Expand Down Expand Up @@ -249,6 +251,7 @@ class _MemoryFile extends _MemoryResource implements File {
@override
bool get exists => _provider._pathToResource[path] is _MemoryFile;

@override
int get modificationStamp {
int stamp = _provider._pathToTimestamp[path];
if (stamp == null) {
Expand Down Expand Up @@ -303,6 +306,7 @@ class _MemoryFileSource extends Source {

final _MemoryFile file;

@override
final Uri uri;

/**
Expand Down Expand Up @@ -453,6 +457,7 @@ class _MemoryFolder extends _MemoryResource implements Folder {
*/
abstract class _MemoryResource implements Resource {
final MemoryResourceProvider _provider;
@override
final String path;

_MemoryResource(this._provider, this.path);
Expand Down
1 change: 1 addition & 0 deletions pkg/analyzer/lib/file_system/physical_file_system.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class PhysicalResourceProvider implements ResourceProvider {
*/
static final String SERVER_DIR = ".dartServer";

@override
final AbsolutePathContext absolutePathContext =
new AbsolutePathContext(io.Platform.isWindows);

Expand Down
1 change: 1 addition & 0 deletions pkg/analyzer/lib/source/path_filter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class PathFilter {
}
}

@override
String toString() {
StringBuffer sb = new StringBuffer();
for (Glob pattern in _ignorePatterns) {
Expand Down
3 changes: 3 additions & 0 deletions pkg/analyzer/lib/src/context/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class AnalysisContextImpl implements InternalAnalysisContext {
* A client-provided name used to identify this context, or `null` if the
* client has not provided a name.
*/
@override
String name;

/**
Expand Down Expand Up @@ -129,6 +130,7 @@ class AnalysisContextImpl implements InternalAnalysisContext {
/**
* A list of all [WorkManager]s used by this context.
*/
@override
final List<WorkManager> workManagers = <WorkManager>[];

/**
Expand Down Expand Up @@ -490,6 +492,7 @@ class AnalysisContextImpl implements InternalAnalysisContext {
/**
* Sets the [TypeProvider] for this context.
*/
@override
void set typeProvider(TypeProvider typeProvider) {
_typeProvider = typeProvider;
}
Expand Down
11 changes: 11 additions & 0 deletions pkg/analyzer/lib/src/context/source.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class SourceFactoryImpl implements SourceFactory {
/**
* The analysis context that this source factory is associated with.
*/
@override
AnalysisContext context;

/**
Expand Down Expand Up @@ -63,6 +64,7 @@ class SourceFactoryImpl implements SourceFactory {
* @return the [DartSdk] associated with this [SourceFactory], or `null` if
* there is no such SDK
*/
@override
DartSdk get dartSdk {
for (UriResolver resolver in resolvers) {
if (resolver is DartUriResolver) {
Expand All @@ -78,12 +80,14 @@ class SourceFactoryImpl implements SourceFactory {
*
* @param localSourcePredicate the predicate to determine is [Source] is local
*/
@override
void set localSourcePredicate(LocalSourcePredicate localSourcePredicate) {
this._localSourcePredicate = localSourcePredicate;
}

/// A table mapping package names to paths of directories containing
/// the package (or [null] if there is no registered package URI resolver).
@override
Map<String, List<Folder>> get packageMap {
// Start by looking in .packages.
if (_packages != null) {
Expand All @@ -108,6 +112,7 @@ class SourceFactoryImpl implements SourceFactory {
* Return a source factory that will resolve URI's in the same way that this
* source factory does.
*/
@override
SourceFactory clone() {
SourceFactory factory =
new SourceFactory(resolvers, _packages, _resourceProvider);
Expand All @@ -122,6 +127,7 @@ class SourceFactoryImpl implements SourceFactory {
* @param absoluteUri the absolute URI to be resolved
* @return a source object representing the absolute URI
*/
@override
Source forUri(String absoluteUri) {
try {
Uri uri = parseUriWithException(absoluteUri);
Expand All @@ -143,6 +149,7 @@ class SourceFactoryImpl implements SourceFactory {
* @param absoluteUri the absolute URI to be resolved
* @return a source object representing the absolute URI
*/
@override
Source forUri2(Uri absoluteUri) {
if (absoluteUri.isAbsolute) {
try {
Expand All @@ -165,6 +172,7 @@ class SourceFactoryImpl implements SourceFactory {
* @throws IllegalArgumentException if the argument is not a valid encoding
* See [Source.encoding].
*/
@override
Source fromEncoding(String encoding) {
Source source = forUri(encoding);
if (source == null) {
Expand All @@ -180,6 +188,7 @@ class SourceFactoryImpl implements SourceFactory {
* @param source the [Source] to analyze
* @return `true` if the given [Source] is local
*/
@override
bool isLocalSource(Source source) => _localSourcePredicate.isLocal(source);

/**
Expand All @@ -189,6 +198,7 @@ class SourceFactoryImpl implements SourceFactory {
* if either the [containedUri] is invalid or if it cannot be resolved against
* the [containingSource]'s URI.
*/
@override
Source resolveUri(Source containingSource, String containedUri) {
if (containedUri == null || containedUri.isEmpty) {
return null;
Expand Down Expand Up @@ -217,6 +227,7 @@ class SourceFactoryImpl implements SourceFactory {
* @param source the source to get URI for
* @return the absolute URI representing the given source
*/
@override
Uri restoreUri(Source source) {
// First see if a resolver can restore the URI.
for (UriResolver resolver in resolvers) {
Expand Down
Loading

0 comments on commit 9ea1718

Please sign in to comment.