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

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

Issue 1200913002: Deprecate old HTML support (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | pkg/analyzer/lib/src/generated/engine.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/instrumentation/instrumentation.dart'; 10 import 'package:analyzer/instrumentation/instrumentation.dart';
11 import 'package:analyzer/src/cancelable_future.dart'; 11 import 'package:analyzer/src/cancelable_future.dart';
12 import 'package:analyzer/src/context/cache.dart'; 12 import 'package:analyzer/src/context/cache.dart';
13 import 'package:analyzer/src/generated/ast.dart'; 13 import 'package:analyzer/src/generated/ast.dart';
14 import 'package:analyzer/src/generated/constant.dart'; 14 import 'package:analyzer/src/generated/constant.dart';
15 import 'package:analyzer/src/generated/element.dart'; 15 import 'package:analyzer/src/generated/element.dart';
16 import 'package:analyzer/src/generated/engine.dart' 16 import 'package:analyzer/src/generated/engine.dart'
17 hide 17 hide
18 AnalysisCache, 18 AnalysisCache,
19 CachePartition, 19 CachePartition,
20 SdkCachePartition, 20 SdkCachePartition,
21 UniversalCachePartition, 21 UniversalCachePartition,
22 WorkManager; 22 WorkManager;
23 import 'package:analyzer/src/generated/error.dart'; 23 import 'package:analyzer/src/generated/error.dart';
24 import 'package:analyzer/src/generated/html.dart' as ht; 24 import 'package:analyzer/src/generated/html.dart' as ht show HtmlUnit;
25 import 'package:analyzer/src/generated/incremental_resolver.dart'; 25 import 'package:analyzer/src/generated/incremental_resolver.dart';
26 import 'package:analyzer/src/generated/java_core.dart'; 26 import 'package:analyzer/src/generated/java_core.dart';
27 import 'package:analyzer/src/generated/java_engine.dart'; 27 import 'package:analyzer/src/generated/java_engine.dart';
28 import 'package:analyzer/src/generated/resolver.dart'; 28 import 'package:analyzer/src/generated/resolver.dart';
29 import 'package:analyzer/src/generated/scanner.dart'; 29 import 'package:analyzer/src/generated/scanner.dart';
30 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; 30 import 'package:analyzer/src/generated/sdk.dart' show DartSdk;
31 import 'package:analyzer/src/generated/source.dart'; 31 import 'package:analyzer/src/generated/source.dart';
32 import 'package:analyzer/src/generated/utilities_collection.dart'; 32 import 'package:analyzer/src/generated/utilities_collection.dart';
33 import 'package:analyzer/src/task/dart.dart'; 33 import 'package:analyzer/src/task/dart.dart';
34 import 'package:analyzer/src/task/dart_work_manager.dart'; 34 import 'package:analyzer/src/task/dart_work_manager.dart';
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 return _computeResult(source, HTML_ERRORS); 570 return _computeResult(source, HTML_ERRORS);
571 } 571 }
572 return AnalysisError.NO_ERRORS; 572 return AnalysisError.NO_ERRORS;
573 } 573 }
574 574
575 @override 575 @override
576 List<Source> computeExportedLibraries(Source source) => 576 List<Source> computeExportedLibraries(Source source) =>
577 _computeResult(source, EXPORTED_LIBRARIES); 577 _computeResult(source, EXPORTED_LIBRARIES);
578 578
579 @override 579 @override
580 @deprecated
580 HtmlElement computeHtmlElement(Source source) { 581 HtmlElement computeHtmlElement(Source source) {
581 // TODO(brianwilkerson) Implement this. For the time being, we compute the 582 // TODO(brianwilkerson) Remove this method after switching to the new task
582 // data that will implicitly be computed by creating an element. 583 // model.
583 _computeResult(source, REFERENCED_LIBRARIES); 584 throw new UnimplementedError('Not supported in the new task model');
584 return null;
585 } 585 }
586 586
587 @override 587 @override
588 List<Source> computeImportedLibraries(Source source) => 588 List<Source> computeImportedLibraries(Source source) =>
589 _computeResult(source, EXPLICITLY_IMPORTED_LIBRARIES); 589 _computeResult(source, EXPLICITLY_IMPORTED_LIBRARIES);
590 590
591 @override 591 @override
592 SourceKind computeKindOf(Source source) { 592 SourceKind computeKindOf(Source source) {
593 String name = source.shortName; 593 String name = source.shortName;
594 if (AnalysisEngine.isDartFileName(name)) { 594 if (AnalysisEngine.isDartFileName(name)) {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 if (AnalysisEngine.isDartFileName(sourceName)) { 751 if (AnalysisEngine.isDartFileName(sourceName)) {
752 ElementImpl element = computeLibraryElement(source) as ElementImpl; 752 ElementImpl element = computeLibraryElement(source) as ElementImpl;
753 for (int i = 1; i < components.length; i++) { 753 for (int i = 1; i < components.length; i++) {
754 if (element == null) { 754 if (element == null) {
755 return null; 755 return null;
756 } 756 }
757 element = element.getChild(components[i]); 757 element = element.getChild(components[i]);
758 } 758 }
759 return element; 759 return element;
760 } 760 }
761 if (AnalysisEngine.isHtmlFileName(sourceName)) {
762 return computeHtmlElement(source);
763 }
764 } catch (exception) { 761 } catch (exception) {
765 // If the location cannot be decoded for some reason then the underlying 762 // If the location cannot be decoded for some reason then the underlying
766 // cause should have been logged already and we can fall though to return 763 // cause should have been logged already and we can fall though to return
767 // null. 764 // null.
768 } 765 }
769 return null; 766 return null;
770 } 767 }
771 768
772 @override 769 @override
773 AnalysisErrorInfo getErrors(Source source) { 770 AnalysisErrorInfo getErrors(Source source) {
774 String name = source.shortName; 771 String name = source.shortName;
775 if (AnalysisEngine.isDartFileName(name)) { 772 if (AnalysisEngine.isDartFileName(name)) {
776 return dartWorkManager.getErrors(source); 773 return dartWorkManager.getErrors(source);
777 } else if (AnalysisEngine.isHtmlFileName(name)) { 774 } else if (AnalysisEngine.isHtmlFileName(name)) {
778 List<AnalysisError> errors = analysisCache.getValue(source, HTML_ERRORS); 775 List<AnalysisError> errors = analysisCache.getValue(source, HTML_ERRORS);
779 // TODO(brianwilkerson) We don't currently have line info for HTML files. 776 // TODO(brianwilkerson) We don't currently have line info for HTML files.
780 return new AnalysisErrorInfoImpl(errors, null); 777 return new AnalysisErrorInfoImpl(errors, null);
781 } 778 }
782 return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, null); 779 return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, null);
783 } 780 }
784 781
785 @override 782 @override
783 @deprecated
786 HtmlElement getHtmlElement(Source source) { 784 HtmlElement getHtmlElement(Source source) {
787 // TODO(brianwilkerson) Implement this. 785 // TODO(brianwilkerson) Remove this method after switching to the new task
788 // SourceEntry sourceEntry = getReadableSourceEntryOrNull(source); 786 // model.
789 // if (sourceEntry is HtmlEntry) { 787 throw new UnimplementedError('Not supported in the new task model');
790 // return sourceEntry.getValue(HtmlEntry.ELEMENT);
791 // }
792 return null;
793 } 788 }
794 789
795 @override 790 @override
796 List<Source> getHtmlFilesReferencing(Source source) { 791 List<Source> getHtmlFilesReferencing(Source source) {
797 if (!AnalysisEngine.isDartFileName(source.shortName)) { 792 if (!AnalysisEngine.isDartFileName(source.shortName)) {
798 return Source.EMPTY_LIST; 793 return Source.EMPTY_LIST;
799 } 794 }
800 List<Source> htmlSources = <Source>[]; 795 List<Source> htmlSources = <Source>[];
801 List<Source> librarySources = getLibrariesContaining(source); 796 List<Source> librarySources = getLibrariesContaining(source);
802 for (Source source in _cache.sources) { 797 for (Source source in _cache.sources) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 Source unitSource, Source librarySource) { 912 Source unitSource, Source librarySource) {
918 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || 913 if (!AnalysisEngine.isDartFileName(unitSource.shortName) ||
919 !AnalysisEngine.isDartFileName(librarySource.shortName)) { 914 !AnalysisEngine.isDartFileName(librarySource.shortName)) {
920 return null; 915 return null;
921 } 916 }
922 return _cache.getValue( 917 return _cache.getValue(
923 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT); 918 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT);
924 } 919 }
925 920
926 @override 921 @override
922 @deprecated
927 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { 923 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) {
928 // TODO(brianwilkerson) Implement this. 924 // TODO(brianwilkerson) Remove this method after switching to the new task
929 // SourceEntry sourceEntry = getReadableSourceEntryOrNull(htmlSource); 925 // model.
930 // if (sourceEntry is HtmlEntry) { 926 throw new UnimplementedError('Not supported in the new task model');
931 // HtmlEntry htmlEntry = sourceEntry;
932 // return htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT);
933 // }
934 return null;
935 } 927 }
936 928
937 @override 929 @override
938 List<Source> getSourcesWithFullName(String path) { 930 List<Source> getSourcesWithFullName(String path) {
939 return analysisCache.getSourcesWithFullName(path); 931 return analysisCache.getSourcesWithFullName(path);
940 } 932 }
941 933
942 @override 934 @override
943 bool handleContentsChanged( 935 bool handleContentsChanged(
944 Source source, String originalContents, String newContents, bool notify) { 936 Source source, String originalContents, String newContents, bool notify) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 return null; 1027 return null;
1036 } 1028 }
1037 return _computeResult(source, HTML_DOCUMENT); 1029 return _computeResult(source, HTML_DOCUMENT);
1038 } 1030 }
1039 1031
1040 @override 1032 @override
1041 @deprecated // use parseHtmlDocument(source) 1033 @deprecated // use parseHtmlDocument(source)
1042 ht.HtmlUnit parseHtmlUnit(Source source) { 1034 ht.HtmlUnit parseHtmlUnit(Source source) {
1043 // TODO(brianwilkerson) Remove this method after switching to the new task 1035 // TODO(brianwilkerson) Remove this method after switching to the new task
1044 // model. 1036 // model.
1045 throw new UnimplementedError( 1037 throw new UnimplementedError('Not supported in the new task model');
1046 'Not supported in the new task model; use parseHtmlDocument instead.');
1047 } 1038 }
1048 1039
1049 @override 1040 @override
1050 AnalysisResult performAnalysisTask() { 1041 AnalysisResult performAnalysisTask() {
1051 return PerformanceStatistics.performAnaysis.makeCurrentWhile(() { 1042 return PerformanceStatistics.performAnaysis.makeCurrentWhile(() {
1052 _evaluatePendingFutures(); 1043 _evaluatePendingFutures();
1053 bool done = !driver.performAnalysisTask(); 1044 bool done = !driver.performAnalysisTask();
1054 List<ChangeNotice> notices = _getChangeNotices(done); 1045 List<ChangeNotice> notices = _getChangeNotices(done);
1055 if (notices != null) { 1046 if (notices != null) {
1056 int noticeCount = notices.length; 1047 int noticeCount = notices.length;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 !AnalysisEngine.isDartFileName(librarySource.shortName)) { 1138 !AnalysisEngine.isDartFileName(librarySource.shortName)) {
1148 return null; 1139 return null;
1149 } 1140 }
1150 return _computeResult( 1141 return _computeResult(
1151 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT); 1142 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT);
1152 } 1143 }
1153 1144
1154 @override 1145 @override
1155 @deprecated 1146 @deprecated
1156 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { 1147 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) {
1157 computeHtmlElement(htmlSource); 1148 // TODO(brianwilkerson) Remove this method after switching to the new task
1149 // model.
1158 throw new UnimplementedError('Not supported in the new task model'); 1150 throw new UnimplementedError('Not supported in the new task model');
1159 } 1151 }
1160 1152
1161 @override 1153 @override
1162 void setChangedContents(Source source, String contents, int offset, 1154 void setChangedContents(Source source, String contents, int offset,
1163 int oldLength, int newLength) { 1155 int oldLength, int newLength) {
1164 if (_contentRangeChanged(source, contents, offset, oldLength, newLength)) { 1156 if (_contentRangeChanged(source, contents, offset, oldLength, newLength)) {
1165 _onSourcesChangedController.add(new SourcesChangedEvent.changedRange( 1157 _onSourcesChangedController.add(new SourcesChangedEvent.changedRange(
1166 source, contents, offset, oldLength, newLength)); 1158 source, contents, offset, oldLength, newLength));
1167 } 1159 }
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
2000 new PendingFuture<T>(_context, target, computeValue); 1992 new PendingFuture<T>(_context, target, computeValue);
2001 if (!pendingFuture.evaluate(entry)) { 1993 if (!pendingFuture.evaluate(entry)) {
2002 _context._pendingFutureTargets 1994 _context._pendingFutureTargets
2003 .putIfAbsent(target, () => <PendingFuture>[]) 1995 .putIfAbsent(target, () => <PendingFuture>[])
2004 .add(pendingFuture); 1996 .add(pendingFuture);
2005 scheduleComputation(); 1997 scheduleComputation();
2006 } 1998 }
2007 return pendingFuture.future; 1999 return pendingFuture.future;
2008 } 2000 }
2009 } 2001 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698