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

Side by Side Diff: pkg/analyzer/lib/src/context/cache.dart

Issue 1933763002: Use null-aware operators to clean up the code (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Additional clean-up Created 4 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
« no previous file with comments | « pkg/analyzer/lib/source/path_filter.dart ('k') | pkg/analyzer/lib/src/context/context.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.context.cache; 5 library analyzer.src.context.cache;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/src/dart/element/element.dart' 10 import 'package:analyzer/src/dart/element/element.dart'
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 // 'setValue $descriptor for $target value=$valueStr $dependedOn=$depen dedOn'); 507 // 'setValue $descriptor for $target value=$valueStr $dependedOn=$depen dedOn');
508 // } 508 // }
509 _validateStateChange(descriptor, CacheState.VALID); 509 _validateStateChange(descriptor, CacheState.VALID);
510 TargetedResult thisResult = new TargetedResult(target, descriptor); 510 TargetedResult thisResult = new TargetedResult(target, descriptor);
511 if (_partition != null) { 511 if (_partition != null) {
512 _partition.resultStored(thisResult, value); 512 _partition.resultStored(thisResult, value);
513 } 513 }
514 ResultData data = getResultData(descriptor); 514 ResultData data = getResultData(descriptor);
515 _setDependedOnResults(data, thisResult, dependedOn); 515 _setDependedOnResults(data, thisResult, dependedOn);
516 data.state = CacheState.VALID; 516 data.state = CacheState.VALID;
517 data.value = value == null ? descriptor.defaultValue : value; 517 data.value = value ?? descriptor.defaultValue;
518 } 518 }
519 519
520 /** 520 /**
521 * If the result represented by the given [descriptor] is valid, set 521 * If the result represented by the given [descriptor] is valid, set
522 * it to the given [value], keep its dependency, and if [invalidateDependent] 522 * it to the given [value], keep its dependency, and if [invalidateDependent]
523 * invalidate all the dependent result. 523 * invalidate all the dependent result.
524 */ 524 */
525 void setValueIncremental( 525 void setValueIncremental(
526 ResultDescriptor descriptor, dynamic value, bool invalidateDependent) { 526 ResultDescriptor descriptor, dynamic value, bool invalidateDependent) {
527 ResultData data = getResultData(descriptor); 527 ResultData data = getResultData(descriptor);
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 * Return the entry associated with the given [target]. 915 * Return the entry associated with the given [target].
916 */ 916 */
917 CacheEntry get(AnalysisTarget target) => entryMap[target]; 917 CacheEntry get(AnalysisTarget target) => entryMap[target];
918 918
919 /** 919 /**
920 * Return [Source]s whose full path is equal to the given [path]. 920 * Return [Source]s whose full path is equal to the given [path].
921 * Maybe empty, but not `null`. 921 * Maybe empty, but not `null`.
922 */ 922 */
923 List<Source> getSourcesWithFullName(String path) { 923 List<Source> getSourcesWithFullName(String path) {
924 List<Source> sources = pathToSource[path]; 924 List<Source> sources = pathToSource[path];
925 return sources != null ? sources : Source.EMPTY_LIST; 925 return sources ?? Source.EMPTY_LIST;
926 } 926 }
927 927
928 /** 928 /**
929 * Return `true` if this partition is responsible for the given [target]. 929 * Return `true` if this partition is responsible for the given [target].
930 */ 930 */
931 bool isResponsibleFor(AnalysisTarget target); 931 bool isResponsibleFor(AnalysisTarget target);
932 932
933 /** 933 /**
934 * Return an iterator returning all of the map entries mapping targets to 934 * Return an iterator returning all of the map entries mapping targets to
935 * cache entries. 935 * cache entries.
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 void resultAccessed(TargetedResult result) {} 1279 void resultAccessed(TargetedResult result) {}
1280 1280
1281 @override 1281 @override
1282 List<TargetedResult> resultStored(TargetedResult newResult, newValue) { 1282 List<TargetedResult> resultStored(TargetedResult newResult, newValue) {
1283 return TargetedResult.EMPTY_LIST; 1283 return TargetedResult.EMPTY_LIST;
1284 } 1284 }
1285 1285
1286 @override 1286 @override
1287 void targetRemoved(AnalysisTarget target) {} 1287 void targetRemoved(AnalysisTarget target) {}
1288 } 1288 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/source/path_filter.dart ('k') | pkg/analyzer/lib/src/context/context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698