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

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

Issue 1502213002: Remove deprecated code (Closed) Base URL: https://github.com/dart-lang/sdk.git@analyzer-breaking-0.27
Patch Set: Created 5 years 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.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/instrumentation/instrumentation.dart'; 10 import 'package:analyzer/instrumentation/instrumentation.dart';
11 import 'package:analyzer/plugin/task.dart'; 11 import 'package:analyzer/plugin/task.dart';
12 import 'package:analyzer/source/embedder.dart'; 12 import 'package:analyzer/source/embedder.dart';
13 import 'package:analyzer/src/cancelable_future.dart'; 13 import 'package:analyzer/src/cancelable_future.dart';
14 import 'package:analyzer/src/context/cache.dart'; 14 import 'package:analyzer/src/context/cache.dart';
15 import 'package:analyzer/src/generated/ast.dart'; 15 import 'package:analyzer/src/generated/ast.dart';
16 import 'package:analyzer/src/generated/constant.dart'; 16 import 'package:analyzer/src/generated/constant.dart';
17 import 'package:analyzer/src/generated/element.dart'; 17 import 'package:analyzer/src/generated/element.dart';
18 import 'package:analyzer/src/generated/engine.dart'; 18 import 'package:analyzer/src/generated/engine.dart';
19 import 'package:analyzer/src/generated/error.dart'; 19 import 'package:analyzer/src/generated/error.dart';
20 import 'package:analyzer/src/generated/html.dart' as ht show HtmlUnit;
21 import 'package:analyzer/src/generated/incremental_resolver.dart'; 20 import 'package:analyzer/src/generated/incremental_resolver.dart';
22 import 'package:analyzer/src/generated/java_core.dart'; 21 import 'package:analyzer/src/generated/java_core.dart';
23 import 'package:analyzer/src/generated/java_engine.dart'; 22 import 'package:analyzer/src/generated/java_engine.dart';
24 import 'package:analyzer/src/generated/resolver.dart'; 23 import 'package:analyzer/src/generated/resolver.dart';
25 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; 24 import 'package:analyzer/src/generated/sdk.dart' show DartSdk;
26 import 'package:analyzer/src/generated/source.dart'; 25 import 'package:analyzer/src/generated/source.dart';
27 import 'package:analyzer/src/generated/utilities_collection.dart'; 26 import 'package:analyzer/src/generated/utilities_collection.dart';
28 import 'package:analyzer/src/task/dart.dart'; 27 import 'package:analyzer/src/task/dart.dart';
29 import 'package:analyzer/src/task/dart_work_manager.dart'; 28 import 'package:analyzer/src/task/dart_work_manager.dart';
30 import 'package:analyzer/src/task/driver.dart'; 29 import 'package:analyzer/src/task/driver.dart';
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 */ 197 */
199 Source incrementalResolutionValidation_lastLibrarySource; 198 Source incrementalResolutionValidation_lastLibrarySource;
200 199
201 /** 200 /**
202 * The result of incremental resolution result of 201 * The result of incremental resolution result of
203 * [incrementalResolutionValidation_lastSource]. 202 * [incrementalResolutionValidation_lastSource].
204 */ 203 */
205 CompilationUnit incrementalResolutionValidation_lastUnit; 204 CompilationUnit incrementalResolutionValidation_lastUnit;
206 205
207 /** 206 /**
208 * A factory to override how the [ResolverVisitor] is created.
209 */
210 ResolverVisitorFactory resolverVisitorFactory;
211
212 /**
213 * A factory to override how the [TypeResolverVisitor] is created.
214 */
215 TypeResolverVisitorFactory typeResolverVisitorFactory;
216
217 /**
218 * Initialize a newly created analysis context. 207 * Initialize a newly created analysis context.
219 */ 208 */
220 AnalysisContextImpl() { 209 AnalysisContextImpl() {
221 _privatePartition = new UniversalCachePartition(this); 210 _privatePartition = new UniversalCachePartition(this);
222 _cache = createCacheFromSourceFactory(null); 211 _cache = createCacheFromSourceFactory(null);
223 _taskManager = AnalysisEngine.instance.taskManager; 212 _taskManager = AnalysisEngine.instance.taskManager;
224 for (WorkManagerFactory factory 213 for (WorkManagerFactory factory
225 in AnalysisEngine.instance.enginePlugin.workManagerFactories) { 214 in AnalysisEngine.instance.enginePlugin.workManagerFactories) {
226 WorkManager workManager = factory(this); 215 WorkManager workManager = factory(this);
227 if (workManager != null) { 216 if (workManager != null) {
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 return computeResult(source, HTML_ERRORS); 576 return computeResult(source, HTML_ERRORS);
588 } 577 }
589 return computeResult(source, DART_ERRORS); 578 return computeResult(source, DART_ERRORS);
590 } 579 }
591 580
592 @override 581 @override
593 List<Source> computeExportedLibraries(Source source) => 582 List<Source> computeExportedLibraries(Source source) =>
594 computeResult(source, EXPORTED_LIBRARIES); 583 computeResult(source, EXPORTED_LIBRARIES);
595 584
596 @override 585 @override
597 @deprecated
598 HtmlElement computeHtmlElement(Source source) {
599 // TODO(brianwilkerson) Remove this method after switching to the new task
600 // model.
601 throw new UnimplementedError('Not supported in the new task model');
602 }
603
604 @override
605 List<Source> computeImportedLibraries(Source source) => 586 List<Source> computeImportedLibraries(Source source) =>
606 computeResult(source, EXPLICITLY_IMPORTED_LIBRARIES); 587 computeResult(source, EXPLICITLY_IMPORTED_LIBRARIES);
607 588
608 @override 589 @override
609 SourceKind computeKindOf(Source source) { 590 SourceKind computeKindOf(Source source) {
610 String name = source.shortName; 591 String name = source.shortName;
611 if (AnalysisEngine.isDartFileName(name)) { 592 if (AnalysisEngine.isDartFileName(name)) {
612 return computeResult(source, SOURCE_KIND); 593 return computeResult(source, SOURCE_KIND);
613 } else if (AnalysisEngine.isHtmlFileName(name)) { 594 } else if (AnalysisEngine.isHtmlFileName(name)) {
614 return SourceKind.HTML; 595 return SourceKind.HTML;
615 } 596 }
616 return SourceKind.UNKNOWN; 597 return SourceKind.UNKNOWN;
617 } 598 }
618 599
619 @override 600 @override
620 LibraryElement computeLibraryElement(Source source) { 601 LibraryElement computeLibraryElement(Source source) {
621 //_computeResult(source, HtmlEntry.ELEMENT); 602 //_computeResult(source, HtmlEntry.ELEMENT);
622 return computeResult(source, LIBRARY_ELEMENT); 603 return computeResult(source, LIBRARY_ELEMENT);
623 } 604 }
624 605
625 @override 606 @override
626 LineInfo computeLineInfo(Source source) => computeResult(source, LINE_INFO); 607 LineInfo computeLineInfo(Source source) => computeResult(source, LINE_INFO);
627 608
628 @override 609 @override
629 @deprecated
630 CompilationUnit computeResolvableCompilationUnit(Source source) {
631 return null;
632 }
633
634 @override
635 CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync( 610 CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync(
636 Source unitSource, Source librarySource) { 611 Source unitSource, Source librarySource) {
637 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || 612 if (!AnalysisEngine.isDartFileName(unitSource.shortName) ||
638 !AnalysisEngine.isDartFileName(librarySource.shortName)) { 613 !AnalysisEngine.isDartFileName(librarySource.shortName)) {
639 return new CancelableFuture.error(new AnalysisNotScheduledError()); 614 return new CancelableFuture.error(new AnalysisNotScheduledError());
640 } 615 }
641 return new AnalysisFutureHelper<CompilationUnit>( 616 return new AnalysisFutureHelper<CompilationUnit>(
642 this, 617 this,
643 new LibrarySpecificUnit(librarySource, unitSource), 618 new LibrarySpecificUnit(librarySource, unitSource),
644 RESOLVED_UNIT).computeAsync(); 619 RESOLVED_UNIT).computeAsync();
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 List<AnalysisError> allErrors = <AnalysisError>[]; 783 List<AnalysisError> allErrors = <AnalysisError>[];
809 for (WorkManager workManager in workManagers) { 784 for (WorkManager workManager in workManagers) {
810 List<AnalysisError> errors = workManager.getErrors(source); 785 List<AnalysisError> errors = workManager.getErrors(source);
811 allErrors.addAll(errors); 786 allErrors.addAll(errors);
812 } 787 }
813 LineInfo lineInfo = getLineInfo(source); 788 LineInfo lineInfo = getLineInfo(source);
814 return new AnalysisErrorInfoImpl(allErrors, lineInfo); 789 return new AnalysisErrorInfoImpl(allErrors, lineInfo);
815 } 790 }
816 791
817 @override 792 @override
818 @deprecated
819 HtmlElement getHtmlElement(Source source) {
820 // TODO(brianwilkerson) Remove this method after switching to the new task
821 // model.
822 throw new UnimplementedError('Not supported in the new task model');
823 }
824
825 @override
826 List<Source> getHtmlFilesReferencing(Source source) { 793 List<Source> getHtmlFilesReferencing(Source source) {
827 if (!AnalysisEngine.isDartFileName(source.shortName)) { 794 if (!AnalysisEngine.isDartFileName(source.shortName)) {
828 return Source.EMPTY_LIST; 795 return Source.EMPTY_LIST;
829 } 796 }
830 List<Source> htmlSources = <Source>[]; 797 List<Source> htmlSources = <Source>[];
831 List<Source> librarySources = getLibrariesContaining(source); 798 List<Source> librarySources = getLibrariesContaining(source);
832 for (Source source in _cache.sources) { 799 for (Source source in _cache.sources) {
833 if (AnalysisEngine.isHtmlFileName(source.shortName)) { 800 if (AnalysisEngine.isHtmlFileName(source.shortName)) {
834 List<Source> referencedLibraries = 801 List<Source> referencedLibraries =
835 getResult(source, REFERENCED_LIBRARIES); 802 getResult(source, REFERENCED_LIBRARIES);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 Source unitSource, Source librarySource) { 914 Source unitSource, Source librarySource) {
948 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || 915 if (!AnalysisEngine.isDartFileName(unitSource.shortName) ||
949 !AnalysisEngine.isDartFileName(librarySource.shortName)) { 916 !AnalysisEngine.isDartFileName(librarySource.shortName)) {
950 return null; 917 return null;
951 } 918 }
952 return getResult( 919 return getResult(
953 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT); 920 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT);
954 } 921 }
955 922
956 @override 923 @override
957 @deprecated
958 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) {
959 // TODO(brianwilkerson) Remove this method after switching to the new task
960 // model.
961 throw new UnimplementedError('Not supported in the new task model');
962 }
963
964 @override
965 Object getResult(AnalysisTarget target, ResultDescriptor result) { 924 Object getResult(AnalysisTarget target, ResultDescriptor result) {
966 return _cache.getValue(target, result); 925 return _cache.getValue(target, result);
967 } 926 }
968 927
969 @override 928 @override
970 List<Source> getSourcesWithFullName(String path) { 929 List<Source> getSourcesWithFullName(String path) {
971 return analysisCache.getSourcesWithFullName(path); 930 return analysisCache.getSourcesWithFullName(path);
972 } 931 }
973 932
974 @override 933 @override
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 1035
1077 @override 1036 @override
1078 Document parseHtmlDocument(Source source) { 1037 Document parseHtmlDocument(Source source) {
1079 if (!AnalysisEngine.isHtmlFileName(source.shortName)) { 1038 if (!AnalysisEngine.isHtmlFileName(source.shortName)) {
1080 return null; 1039 return null;
1081 } 1040 }
1082 return computeResult(source, HTML_DOCUMENT); 1041 return computeResult(source, HTML_DOCUMENT);
1083 } 1042 }
1084 1043
1085 @override 1044 @override
1086 @deprecated // use parseHtmlDocument(source)
1087 ht.HtmlUnit parseHtmlUnit(Source source) {
1088 // TODO(brianwilkerson) Remove this method after switching to the new task
1089 // model.
1090 throw new UnimplementedError('Not supported in the new task model');
1091 }
1092
1093 @override
1094 AnalysisResult performAnalysisTask() { 1045 AnalysisResult performAnalysisTask() {
1095 return PerformanceStatistics.performAnaysis.makeCurrentWhile(() { 1046 return PerformanceStatistics.performAnaysis.makeCurrentWhile(() {
1096 _evaluatePendingFutures(); 1047 _evaluatePendingFutures();
1097 bool done = !driver.performAnalysisTask(); 1048 bool done = !driver.performAnalysisTask();
1098 List<ChangeNotice> notices = _getChangeNotices(done); 1049 List<ChangeNotice> notices = _getChangeNotices(done);
1099 if (notices != null) { 1050 if (notices != null) {
1100 int noticeCount = notices.length; 1051 int noticeCount = notices.length;
1101 for (int i = 0; i < noticeCount; i++) { 1052 for (int i = 0; i < noticeCount; i++) {
1102 ChangeNotice notice = notices[i]; 1053 ChangeNotice notice = notices[i];
1103 _notifyErrors(notice.source, notice.errors, notice.lineInfo); 1054 _notifyErrors(notice.source, notice.errors, notice.lineInfo);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 } 1144 }
1194 1145
1195 @override 1146 @override
1196 CompilationUnit resolveCompilationUnit2( 1147 CompilationUnit resolveCompilationUnit2(
1197 Source unitSource, Source librarySource) { 1148 Source unitSource, Source librarySource) {
1198 return computeResult( 1149 return computeResult(
1199 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT); 1150 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT);
1200 } 1151 }
1201 1152
1202 @override 1153 @override
1203 @deprecated
1204 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) {
1205 // TODO(brianwilkerson) Remove this method after switching to the new task
1206 // model.
1207 throw new UnimplementedError('Not supported in the new task model');
1208 }
1209
1210 @override
1211 void setChangedContents(Source source, String contents, int offset, 1154 void setChangedContents(Source source, String contents, int offset,
1212 int oldLength, int newLength) { 1155 int oldLength, int newLength) {
1213 if (_contentRangeChanged(source, contents, offset, oldLength, newLength)) { 1156 if (_contentRangeChanged(source, contents, offset, oldLength, newLength)) {
1214 _onSourcesChangedController.add(new SourcesChangedEvent.changedRange( 1157 _onSourcesChangedController.add(new SourcesChangedEvent.changedRange(
1215 source, contents, offset, oldLength, newLength)); 1158 source, contents, offset, oldLength, newLength));
1216 } 1159 }
1217 } 1160 }
1218 1161
1219 @override 1162 @override
1220 void setConfigurationData(ResultDescriptor key, Object data) { 1163 void setConfigurationData(ResultDescriptor key, Object data) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 buffer.writeln(" removed"); 1243 buffer.writeln(" removed");
1301 for (Source source in missingSources) { 1244 for (Source source in missingSources) {
1302 buffer.write(" "); 1245 buffer.write(" ");
1303 buffer.writeln(source.fullName); 1246 buffer.writeln(source.fullName);
1304 } 1247 }
1305 _logInformation(buffer.toString()); 1248 _logInformation(buffer.toString());
1306 } 1249 }
1307 return changedSources.length > 0; 1250 return changedSources.length > 0;
1308 } 1251 }
1309 1252
1310 @deprecated
1311 @override
1312 void visitCacheItems(void callback(
1313 Source source, dynamic dartEntry, dynamic rowDesc, CacheState state)) {}
1314
1315 @override 1253 @override
1316 void visitContentCache(ContentCacheVisitor visitor) { 1254 void visitContentCache(ContentCacheVisitor visitor) {
1317 _contentCache.accept(visitor); 1255 _contentCache.accept(visitor);
1318 } 1256 }
1319 1257
1320 /** 1258 /**
1321 * Add all of the sources contained in the given source [container] to the 1259 * Add all of the sources contained in the given source [container] to the
1322 * given list of [sources]. 1260 * given list of [sources].
1323 */ 1261 */
1324 void _addSourcesInContainer(List<Source> sources, SourceContainer container) { 1262 void _addSourcesInContainer(List<Source> sources, SourceContainer container) {
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
2074 } 2012 }
2075 DartSdk sdk = factory.dartSdk; 2013 DartSdk sdk = factory.dartSdk;
2076 if (sdk == null) { 2014 if (sdk == null) {
2077 throw new IllegalArgumentException( 2015 throw new IllegalArgumentException(
2078 "The source factory for an SDK analysis context must have a DartUriRes olver"); 2016 "The source factory for an SDK analysis context must have a DartUriRes olver");
2079 } 2017 }
2080 return new AnalysisCache( 2018 return new AnalysisCache(
2081 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); 2019 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]);
2082 } 2020 }
2083 } 2021 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/services/completion/optype_test.dart ('k') | pkg/analyzer/lib/src/generated/ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698