Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: pkg/analysis_server/lib/src/resource.dart

Issue 345063005: Fix operator== and hashCode for File and Folder objects. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library resource; 5 library resource;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:io' as io; 9 import 'dart:io' as io;
10 10
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 * An in-memory implementation of [Resource]. 109 * An in-memory implementation of [Resource].
110 */ 110 */
111 abstract class _MemoryResource implements Resource { 111 abstract class _MemoryResource implements Resource {
112 final MemoryResourceProvider _provider; 112 final MemoryResourceProvider _provider;
113 final String path; 113 final String path;
114 114
115 _MemoryResource(this._provider, this.path); 115 _MemoryResource(this._provider, this.path);
116 116
117 @override 117 @override
118 bool operator ==(other) { 118 bool operator ==(other) {
119 return identical(this, other); 119 if (runtimeType != other.runtimeType) {
120 return false;
121 }
122 return path == other.path;
120 } 123 }
121 124
122 @override 125 @override
123 bool get exists => _provider._pathToResource.containsKey(path); 126 bool get exists => _provider._pathToResource.containsKey(path);
124 127
125 @override 128 @override
126 get hashCode => path.hashCode; 129 get hashCode => path.hashCode;
127 130
128 @override 131 @override
129 String get shortName => posix.basename(path); 132 String get shortName => posix.basename(path);
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 492
490 _PhysicalResource(this._entry); 493 _PhysicalResource(this._entry);
491 494
492 @override 495 @override
493 bool get exists => _entry.existsSync(); 496 bool get exists => _entry.existsSync();
494 497
495 @override 498 @override
496 String get path => _entry.absolute.path; 499 String get path => _entry.absolute.path;
497 500
498 @override 501 @override
499 get hashCode => _entry.hashCode; 502 get hashCode => path.hashCode;
503
504 @override
505 bool operator==(other) {
506 if (runtimeType != other.runtimeType) {
507 return false;
508 }
509 return path == other.path;
510 }
500 511
501 @override 512 @override
502 String get shortName => basename(path); 513 String get shortName => basename(path);
503 514
504 @override 515 @override
505 String toString() => path; 516 String toString() => path;
506 517
507 @override 518 @override
508 Folder get parent { 519 Folder get parent {
509 String parentPath = dirname(path); 520 String parentPath = dirname(path);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 } 587 }
577 588
578 /** 589 /**
579 * Return `true` if the given URI is a `file` URI. 590 * Return `true` if the given URI is a `file` URI.
580 * 591 *
581 * @param uri the URI being tested 592 * @param uri the URI being tested
582 * @return `true` if the given URI is a `file` URI 593 * @return `true` if the given URI is a `file` URI
583 */ 594 */
584 static bool _isFileUri(Uri uri) => uri.scheme == _FILE_SCHEME; 595 static bool _isFileUri(Uri uri) => uri.scheme == _FILE_SCHEME;
585 } 596 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698