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

Side by Side Diff: pkg/analyzer/lib/src/context/context.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/src/context/cache.dart ('k') | pkg/analyzer/lib/src/context/source.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.context; 5 library analyzer.src.context.context;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 TimestampedData<String> getContents(Source source) { 836 TimestampedData<String> getContents(Source source) {
837 String contents = _contentCache.getContents(source); 837 String contents = _contentCache.getContents(source);
838 if (contents != null) { 838 if (contents != null) {
839 return new TimestampedData<String>( 839 return new TimestampedData<String>(
840 _contentCache.getModificationStamp(source), contents); 840 _contentCache.getModificationStamp(source), contents);
841 } 841 }
842 return source.contents; 842 return source.contents;
843 } 843 }
844 844
845 @override 845 @override
846 InternalAnalysisContext getContextFor(Source source) { 846 InternalAnalysisContext getContextFor(Source source) =>
847 InternalAnalysisContext context = _cache.getContextFor(source); 847 _cache.getContextFor(source) ?? this;
848 return context == null ? this : context;
849 }
850 848
851 @override 849 @override
852 Element getElement(ElementLocation location) { 850 Element getElement(ElementLocation location) {
853 // TODO(brianwilkerson) This should not be a "get" method. 851 // TODO(brianwilkerson) This should not be a "get" method.
854 try { 852 try {
855 List<String> components = location.components; 853 List<String> components = location.components;
856 Source source = _computeSourceFromEncoding(components[0]); 854 Source source = _computeSourceFromEncoding(components[0]);
857 String sourceName = source.shortName; 855 String sourceName = source.shortName;
858 if (AnalysisEngine.isDartFileName(sourceName)) { 856 if (AnalysisEngine.isDartFileName(sourceName)) {
859 ElementImpl element = computeLibraryElement(source) as ElementImpl; 857 ElementImpl element = computeLibraryElement(source) as ElementImpl;
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 } 2193 }
2196 DartSdk sdk = factory.dartSdk; 2194 DartSdk sdk = factory.dartSdk;
2197 if (sdk == null) { 2195 if (sdk == null) {
2198 throw new IllegalArgumentException( 2196 throw new IllegalArgumentException(
2199 "The source factory for an SDK analysis context must have a DartUriRes olver"); 2197 "The source factory for an SDK analysis context must have a DartUriRes olver");
2200 } 2198 }
2201 return new AnalysisCache( 2199 return new AnalysisCache(
2202 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); 2200 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]);
2203 } 2201 }
2204 } 2202 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/context/cache.dart ('k') | pkg/analyzer/lib/src/context/source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698