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

Side by Side Diff: pkg/analyzer/lib/src/generated/engine.dart

Issue 1403033002: State-carrying context API. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fixes and tests. Created 5 years, 2 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/context.dart ('k') | pkg/analyzer/test/generated/engine_test.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 engine; 5 library engine;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:math' as math; 9 import 'dart:math' as math;
10 10
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 /** 583 /**
584 * Return the element model corresponding to the compilation unit defined by 584 * Return the element model corresponding to the compilation unit defined by
585 * the given [unitSource] in the library defined by the given [librarySource], 585 * the given [unitSource] in the library defined by the given [librarySource],
586 * or `null` if the element model does not currently exist or if the library 586 * or `null` if the element model does not currently exist or if the library
587 * cannot be analyzed for some reason. 587 * cannot be analyzed for some reason.
588 */ 588 */
589 CompilationUnitElement getCompilationUnitElement( 589 CompilationUnitElement getCompilationUnitElement(
590 Source unitSource, Source librarySource); 590 Source unitSource, Source librarySource);
591 591
592 /** 592 /**
593 * Return configuration data associated with the given key or `null` if no
594 * state has been associated with the given [key].
595 *
596 * See [setConfigurationData].
597 */
598 Object getConfigurationData(ResultDescriptor key);
599
600 /**
593 * Return the contents and timestamp of the given [source]. 601 * Return the contents and timestamp of the given [source].
594 * 602 *
595 * This method should be used rather than the method [Source.getContents] 603 * This method should be used rather than the method [Source.getContents]
596 * because contexts can have local overrides of the content of a source that 604 * because contexts can have local overrides of the content of a source that
597 * the source is not aware of. 605 * the source is not aware of.
598 */ 606 */
599 TimestampedData<String> getContents(Source source); 607 TimestampedData<String> getContents(Source source);
600 608
601 /** 609 /**
602 * Return the element referenced by the given [location], or `null` if the 610 * Return the element referenced by the given [location], or `null` if the
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 887
880 /** 888 /**
881 * Set the contents of the given [source] to the given [contents] and mark the 889 * Set the contents of the given [source] to the given [contents] and mark the
882 * source as having changed. The additional [offset] and [length] information 890 * source as having changed. The additional [offset] and [length] information
883 * is used by the context to determine what reanalysis is necessary. 891 * is used by the context to determine what reanalysis is necessary.
884 */ 892 */
885 void setChangedContents( 893 void setChangedContents(
886 Source source, String contents, int offset, int oldLength, int newLength); 894 Source source, String contents, int offset, int oldLength, int newLength);
887 895
888 /** 896 /**
897 * Associate this configuration [data] object with the given descriptor [key].
898 *
899 * See [getConfigurationData].
900 */
901 void setConfigurationData(ResultDescriptor key, Object data);
902
903 /**
889 * Set the contents of the given [source] to the given [contents] and mark the 904 * Set the contents of the given [source] to the given [contents] and mark the
890 * source as having changed. This has the effect of overriding the default 905 * source as having changed. This has the effect of overriding the default
891 * contents of the source. If the contents are `null` the override is removed 906 * contents of the source. If the contents are `null` the override is removed
892 * so that the default contents will be returned. 907 * so that the default contents will be returned.
893 */ 908 */
894 void setContents(Source source, String contents); 909 void setContents(Source source, String contents);
895 910
896 /** 911 /**
897 * Check the cache for any invalid entries (entries whose modification time 912 * Check the cache for any invalid entries (entries whose modification time
898 * does not match the modification time of the source associated with the 913 * does not match the modification time of the source associated with the
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 */ 946 */
932 final int _id = _NEXT_ID++; 947 final int _id = _NEXT_ID++;
933 948
934 /** 949 /**
935 * A client-provided name used to identify this context, or `null` if the 950 * A client-provided name used to identify this context, or `null` if the
936 * client has not provided a name. 951 * client has not provided a name.
937 */ 952 */
938 String name; 953 String name;
939 954
940 /** 955 /**
956 * Configuration data associated with this context.
957 */
958 final HashMap<ResultDescriptor, Object> _configurationData =
959 new HashMap<ResultDescriptor, Object>();
960
961 /**
941 * The set of analysis options controlling the behavior of this context. 962 * The set of analysis options controlling the behavior of this context.
942 */ 963 */
943 AnalysisOptionsImpl _options = new AnalysisOptionsImpl(); 964 AnalysisOptionsImpl _options = new AnalysisOptionsImpl();
944 965
945 /** 966 /**
946 * A flag indicating whether errors related to implicitly analyzed sources 967 * A flag indicating whether errors related to implicitly analyzed sources
947 * should be generated and reported. 968 * should be generated and reported.
948 */ 969 */
949 bool _generateImplicitErrors = true; 970 bool _generateImplicitErrors = true;
950 971
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 for (CompilationUnitElement partUnit in libraryElement.parts) { 1954 for (CompilationUnitElement partUnit in libraryElement.parts) {
1934 if (partUnit.source == unitSource) { 1955 if (partUnit.source == unitSource) {
1935 return partUnit; 1956 return partUnit;
1936 } 1957 }
1937 } 1958 }
1938 } 1959 }
1939 return null; 1960 return null;
1940 } 1961 }
1941 1962
1942 @override 1963 @override
1964 Object getConfigurationData(ResultDescriptor key) => _configurationData[key];
1965
1966 @override
1943 TimestampedData<String> getContents(Source source) { 1967 TimestampedData<String> getContents(Source source) {
1944 String contents = _contentCache.getContents(source); 1968 String contents = _contentCache.getContents(source);
1945 if (contents != null) { 1969 if (contents != null) {
1946 return new TimestampedData<String>( 1970 return new TimestampedData<String>(
1947 _contentCache.getModificationStamp(source), contents); 1971 _contentCache.getModificationStamp(source), contents);
1948 } 1972 }
1949 return source.contents; 1973 return source.contents;
1950 } 1974 }
1951 1975
1952 @override 1976 @override
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
2629 @override 2653 @override
2630 void setChangedContents(Source source, String contents, int offset, 2654 void setChangedContents(Source source, String contents, int offset,
2631 int oldLength, int newLength) { 2655 int oldLength, int newLength) {
2632 if (_contentRangeChanged(source, contents, offset, oldLength, newLength)) { 2656 if (_contentRangeChanged(source, contents, offset, oldLength, newLength)) {
2633 _onSourcesChangedController.add(new SourcesChangedEvent.changedRange( 2657 _onSourcesChangedController.add(new SourcesChangedEvent.changedRange(
2634 source, contents, offset, oldLength, newLength)); 2658 source, contents, offset, oldLength, newLength));
2635 } 2659 }
2636 } 2660 }
2637 2661
2638 @override 2662 @override
2663 void setConfigurationData(ResultDescriptor key, Object data) {
2664 _configurationData[key] = data;
2665 }
2666
2667 @override
2639 void setContents(Source source, String contents) { 2668 void setContents(Source source, String contents) {
2640 _contentsChanged(source, contents, true); 2669 _contentsChanged(source, contents, true);
2641 } 2670 }
2642 2671
2643 @override 2672 @override
2644 bool shouldErrorsBeAnalyzed(Source source, Object entry) { 2673 bool shouldErrorsBeAnalyzed(Source source, Object entry) {
2645 DartEntry dartEntry = entry; 2674 DartEntry dartEntry = entry;
2646 if (source.isInSystemLibrary) { 2675 if (source.isInSystemLibrary) {
2647 return _generateSdkErrors; 2676 return _generateSdkErrors;
2648 } else if (!dartEntry.explicitlyAdded) { 2677 } else if (!dartEntry.explicitlyAdded) {
(...skipping 9415 matching lines...) Expand 10 before | Expand all | Expand 10 after
12064 PendingFuture pendingFuture = 12093 PendingFuture pendingFuture =
12065 new PendingFuture<T>(_context, source, computeValue); 12094 new PendingFuture<T>(_context, source, computeValue);
12066 if (!pendingFuture.evaluate(sourceEntry)) { 12095 if (!pendingFuture.evaluate(sourceEntry)) {
12067 _context._pendingFutureSources 12096 _context._pendingFutureSources
12068 .putIfAbsent(source, () => <PendingFuture>[]) 12097 .putIfAbsent(source, () => <PendingFuture>[])
12069 .add(pendingFuture); 12098 .add(pendingFuture);
12070 } 12099 }
12071 return pendingFuture.future; 12100 return pendingFuture.future;
12072 } 12101 }
12073 } 12102 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/context/context.dart ('k') | pkg/analyzer/test/generated/engine_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698