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

Side by Side Diff: pkg/analyzer/lib/src/task/model.dart

Issue 1152063004: Use artificial hashCode values. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 analyzer.src.task.model; 5 library analyzer.src.task.model;
6 6
7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; 7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask;
8 import 'package:analyzer/src/task/inputs.dart'; 8 import 'package:analyzer/src/task/inputs.dart';
9 import 'package:analyzer/task/model.dart'; 9 import 'package:analyzer/task/model.dart';
10 10
(...skipping 19 matching lines...) Expand all
30 30
31 @override 31 @override
32 ListTaskInput<E> of(AnalysisTarget target) => 32 ListTaskInput<E> of(AnalysisTarget target) =>
33 new ListTaskInputImpl<E>(target, this); 33 new ListTaskInputImpl<E>(target, this);
34 } 34 }
35 35
36 /** 36 /**
37 * A concrete implementation of a [ResultDescriptor]. 37 * A concrete implementation of a [ResultDescriptor].
38 */ 38 */
39 class ResultDescriptorImpl<V> implements ResultDescriptor<V> { 39 class ResultDescriptorImpl<V> implements ResultDescriptor<V> {
40 static int _NEXT_HASH = 0;
41
42 @override
43 final hashCode = _NEXT_HASH++;
44
40 /** 45 /**
41 * The name of the result, used for debugging. 46 * The name of the result, used for debugging.
42 */ 47 */
43 final String name; 48 final String name;
44 49
45 /** 50 /**
46 * Return the default value for results described by this descriptor. 51 * Return the default value for results described by this descriptor.
47 */ 52 */
48 final V defaultValue; 53 final V defaultValue;
49 54
50 /** 55 /**
51 * The caching policy for results described by this descriptor. 56 * The caching policy for results described by this descriptor.
52 */ 57 */
53 final ResultCachingPolicy<V> cachingPolicy; 58 final ResultCachingPolicy<V> cachingPolicy;
54 59
55 /** 60 /**
56 * Initialize a newly created analysis result to have the given [name] and 61 * Initialize a newly created analysis result to have the given [name] and
57 * [defaultValue]. If a [cachingPolicy] is provided, it will control how long 62 * [defaultValue]. If a [cachingPolicy] is provided, it will control how long
58 * values associated with this result will remain in the cache. 63 * values associated with this result will remain in the cache.
59 */ 64 */
60 ResultDescriptorImpl(this.name, this.defaultValue, 65 ResultDescriptorImpl(this.name, this.defaultValue,
61 {this.cachingPolicy: DEFAULT_CACHING_POLICY}); 66 {this.cachingPolicy: DEFAULT_CACHING_POLICY});
62 67
63 @override 68 @override
69 bool operator ==(Object other) {
70 return other is ResultDescriptorImpl && other.hashCode == hashCode;
71 }
72
73 @override
64 TaskInput<V> of(AnalysisTarget target) => 74 TaskInput<V> of(AnalysisTarget target) =>
65 new SimpleTaskInput<V>(target, this); 75 new SimpleTaskInput<V>(target, this);
66 76
67 @override 77 @override
68 String toString() => name; 78 String toString() => name;
69 } 79 }
70 80
71 /** 81 /**
72 * A simple [ResultCachingPolicy] implementation that consider all the objects 82 * A simple [ResultCachingPolicy] implementation that consider all the objects
73 * to be of the size `1`. 83 * to be of the size `1`.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 AnalysisTask createTask(AnalysisContext context, AnalysisTarget target, 134 AnalysisTask createTask(AnalysisContext context, AnalysisTarget target,
125 Map<String, dynamic> inputs) { 135 Map<String, dynamic> inputs) {
126 AnalysisTask task = buildTask(context, target); 136 AnalysisTask task = buildTask(context, target);
127 task.inputs = inputs; 137 task.inputs = inputs;
128 return task; 138 return task;
129 } 139 }
130 140
131 @override 141 @override
132 String toString() => name; 142 String toString() => name;
133 } 143 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698