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

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

Issue 1521693002: Roll Observatory deps (charted -> ^0.3.0) (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/observatory_pub_packages.git@master
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) 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
11 import 'package:analyzer/src/cancelable_future.dart'; 11 import 'package:analyzer/src/cancelable_future.dart';
12 import 'package:analyzer/src/context/cache.dart' as cache; 12 import 'package:analyzer/src/context/cache.dart' as cache;
13 import 'package:analyzer/src/context/context.dart' as newContext; 13 import 'package:analyzer/src/context/context.dart' as newContext;
14 import 'package:analyzer/src/generated/incremental_resolution_validator.dart'; 14 import 'package:analyzer/src/generated/incremental_resolution_validator.dart';
15 import 'package:analyzer/src/plugin/command_line_plugin.dart'; 15 import 'package:analyzer/src/plugin/command_line_plugin.dart';
16 import 'package:analyzer/src/plugin/engine_plugin.dart'; 16 import 'package:analyzer/src/plugin/engine_plugin.dart';
17 import 'package:analyzer/src/plugin/options_plugin.dart'; 17 import 'package:analyzer/src/plugin/options_plugin.dart';
18 import 'package:analyzer/src/services/lint.dart'; 18 import 'package:analyzer/src/services/lint.dart';
19 import 'package:analyzer/src/task/manager.dart'; 19 import 'package:analyzer/src/task/manager.dart';
20 import 'package:analyzer/task/dart.dart'; 20 import 'package:analyzer/task/dart.dart';
21 import 'package:analyzer/task/model.dart' as newContext;
21 import 'package:analyzer/task/model.dart'; 22 import 'package:analyzer/task/model.dart';
22 import 'package:html/dom.dart' show Document; 23 import 'package:html/dom.dart' show Document;
24 import 'package:path/path.dart' as pathos;
23 import 'package:plugin/manager.dart'; 25 import 'package:plugin/manager.dart';
24 import 'package:plugin/plugin.dart'; 26 import 'package:plugin/plugin.dart';
25 27
26 import '../../instrumentation/instrumentation.dart'; 28 import '../../instrumentation/instrumentation.dart';
27 import 'ast.dart'; 29 import 'ast.dart';
28 import 'constant.dart'; 30 import 'constant.dart';
29 import 'element.dart'; 31 import 'element.dart';
30 import 'error.dart'; 32 import 'error.dart';
31 import 'error_verifier.dart'; 33 import 'error_verifier.dart';
32 import 'html.dart' as ht; 34 import 'html.dart' as ht;
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 /** 584 /**
583 * Return the element model corresponding to the compilation unit defined by 585 * Return the element model corresponding to the compilation unit defined by
584 * the given [unitSource] in the library defined by the given [librarySource], 586 * the given [unitSource] in the library defined by the given [librarySource],
585 * or `null` if the element model does not currently exist or if the library 587 * or `null` if the element model does not currently exist or if the library
586 * cannot be analyzed for some reason. 588 * cannot be analyzed for some reason.
587 */ 589 */
588 CompilationUnitElement getCompilationUnitElement( 590 CompilationUnitElement getCompilationUnitElement(
589 Source unitSource, Source librarySource); 591 Source unitSource, Source librarySource);
590 592
591 /** 593 /**
594 * Return configuration data associated with the given key or `null` if no
595 * state has been associated with the given [key].
596 *
597 * See [setConfigurationData].
598 */
599 Object getConfigurationData(ResultDescriptor key);
600
601 /**
592 * Return the contents and timestamp of the given [source]. 602 * Return the contents and timestamp of the given [source].
593 * 603 *
594 * This method should be used rather than the method [Source.getContents] 604 * This method should be used rather than the method [Source.getContents]
595 * because contexts can have local overrides of the content of a source that 605 * because contexts can have local overrides of the content of a source that
596 * the source is not aware of. 606 * the source is not aware of.
597 */ 607 */
598 TimestampedData<String> getContents(Source source); 608 TimestampedData<String> getContents(Source source);
599 609
600 /** 610 /**
601 * Return the element referenced by the given [location], or `null` if the 611 * Return the element referenced by the given [location], or `null` if the
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 888
879 /** 889 /**
880 * Set the contents of the given [source] to the given [contents] and mark the 890 * Set the contents of the given [source] to the given [contents] and mark the
881 * source as having changed. The additional [offset] and [length] information 891 * source as having changed. The additional [offset] and [length] information
882 * is used by the context to determine what reanalysis is necessary. 892 * is used by the context to determine what reanalysis is necessary.
883 */ 893 */
884 void setChangedContents( 894 void setChangedContents(
885 Source source, String contents, int offset, int oldLength, int newLength); 895 Source source, String contents, int offset, int oldLength, int newLength);
886 896
887 /** 897 /**
898 * Associate this configuration [data] object with the given descriptor [key].
899 *
900 * See [getConfigurationData].
901 */
902 void setConfigurationData(ResultDescriptor key, Object data);
903
904 /**
888 * Set the contents of the given [source] to the given [contents] and mark the 905 * Set the contents of the given [source] to the given [contents] and mark the
889 * source as having changed. This has the effect of overriding the default 906 * source as having changed. This has the effect of overriding the default
890 * contents of the source. If the contents are `null` the override is removed 907 * contents of the source. If the contents are `null` the override is removed
891 * so that the default contents will be returned. 908 * so that the default contents will be returned.
892 */ 909 */
893 void setContents(Source source, String contents); 910 void setContents(Source source, String contents);
894 911
895 /** 912 /**
896 * Check the cache for any invalid entries (entries whose modification time 913 * Check the cache for any invalid entries (entries whose modification time
897 * does not match the modification time of the source associated with the 914 * does not match the modification time of the source associated with the
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 */ 947 */
931 final int _id = _NEXT_ID++; 948 final int _id = _NEXT_ID++;
932 949
933 /** 950 /**
934 * A client-provided name used to identify this context, or `null` if the 951 * A client-provided name used to identify this context, or `null` if the
935 * client has not provided a name. 952 * client has not provided a name.
936 */ 953 */
937 String name; 954 String name;
938 955
939 /** 956 /**
957 * Configuration data associated with this context.
958 */
959 final HashMap<ResultDescriptor, Object> _configurationData =
960 new HashMap<ResultDescriptor, Object>();
961
962 /**
940 * The set of analysis options controlling the behavior of this context. 963 * The set of analysis options controlling the behavior of this context.
941 */ 964 */
942 AnalysisOptionsImpl _options = new AnalysisOptionsImpl(); 965 AnalysisOptionsImpl _options = new AnalysisOptionsImpl();
943 966
944 /** 967 /**
945 * A flag indicating whether errors related to implicitly analyzed sources 968 * A flag indicating whether errors related to implicitly analyzed sources
946 * should be generated and reported. 969 * should be generated and reported.
947 */ 970 */
948 bool _generateImplicitErrors = true; 971 bool _generateImplicitErrors = true;
949 972
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 1584
1562 @override 1585 @override
1563 TypeSystem get typeSystem { 1586 TypeSystem get typeSystem {
1564 if (_typeSystem == null) { 1587 if (_typeSystem == null) {
1565 _typeSystem = TypeSystem.create(this); 1588 _typeSystem = TypeSystem.create(this);
1566 } 1589 }
1567 return _typeSystem; 1590 return _typeSystem;
1568 } 1591 }
1569 1592
1570 @override 1593 @override
1594 List<newContext.WorkManager> get workManagers {
1595 throw new NotImplementedException('In not task-based AnalysisContext.');
1596 }
1597
1598 @override
1571 void addListener(AnalysisListener listener) { 1599 void addListener(AnalysisListener listener) {
1572 if (!_listeners.contains(listener)) { 1600 if (!_listeners.contains(listener)) {
1573 _listeners.add(listener); 1601 _listeners.add(listener);
1574 } 1602 }
1575 } 1603 }
1576 1604
1577 @override 1605 @override
1578 void applyAnalysisDelta(AnalysisDelta delta) { 1606 void applyAnalysisDelta(AnalysisDelta delta) {
1579 ChangeSet changeSet = new ChangeSet(); 1607 ChangeSet changeSet = new ChangeSet();
1580 delta.analysisLevels.forEach((Source source, AnalysisLevel level) { 1608 delta.analysisLevels.forEach((Source source, AnalysisLevel level) {
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 for (CompilationUnitElement partUnit in libraryElement.parts) { 1955 for (CompilationUnitElement partUnit in libraryElement.parts) {
1928 if (partUnit.source == unitSource) { 1956 if (partUnit.source == unitSource) {
1929 return partUnit; 1957 return partUnit;
1930 } 1958 }
1931 } 1959 }
1932 } 1960 }
1933 return null; 1961 return null;
1934 } 1962 }
1935 1963
1936 @override 1964 @override
1965 Object getConfigurationData(ResultDescriptor key) => _configurationData[key];
1966
1967 @override
1937 TimestampedData<String> getContents(Source source) { 1968 TimestampedData<String> getContents(Source source) {
1938 String contents = _contentCache.getContents(source); 1969 String contents = _contentCache.getContents(source);
1939 if (contents != null) { 1970 if (contents != null) {
1940 return new TimestampedData<String>( 1971 return new TimestampedData<String>(
1941 _contentCache.getModificationStamp(source), contents); 1972 _contentCache.getModificationStamp(source), contents);
1942 } 1973 }
1943 return source.contents; 1974 return source.contents;
1944 } 1975 }
1945 1976
1946 @override 1977 @override
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
2623 @override 2654 @override
2624 void setChangedContents(Source source, String contents, int offset, 2655 void setChangedContents(Source source, String contents, int offset,
2625 int oldLength, int newLength) { 2656 int oldLength, int newLength) {
2626 if (_contentRangeChanged(source, contents, offset, oldLength, newLength)) { 2657 if (_contentRangeChanged(source, contents, offset, oldLength, newLength)) {
2627 _onSourcesChangedController.add(new SourcesChangedEvent.changedRange( 2658 _onSourcesChangedController.add(new SourcesChangedEvent.changedRange(
2628 source, contents, offset, oldLength, newLength)); 2659 source, contents, offset, oldLength, newLength));
2629 } 2660 }
2630 } 2661 }
2631 2662
2632 @override 2663 @override
2664 void setConfigurationData(ResultDescriptor key, Object data) {
2665 _configurationData[key] = data;
2666 }
2667
2668 @override
2633 void setContents(Source source, String contents) { 2669 void setContents(Source source, String contents) {
2634 _contentsChanged(source, contents, true); 2670 _contentsChanged(source, contents, true);
2635 } 2671 }
2636 2672
2637 @override 2673 @override
2638 bool shouldErrorsBeAnalyzed(Source source, Object entry) { 2674 bool shouldErrorsBeAnalyzed(Source source, Object entry) {
2639 DartEntry dartEntry = entry; 2675 DartEntry dartEntry = entry;
2640 if (source.isInSystemLibrary) { 2676 if (source.isInSystemLibrary) {
2641 return _generateSdkErrors; 2677 return _generateSdkErrors;
2642 } else if (!dartEntry.explicitlyAdded) { 2678 } else if (!dartEntry.explicitlyAdded) {
(...skipping 3190 matching lines...) Expand 10 before | Expand all | Expand 10 after
5833 * The short suffix used for HTML files. 5869 * The short suffix used for HTML files.
5834 */ 5870 */
5835 static const String SUFFIX_HTM = "htm"; 5871 static const String SUFFIX_HTM = "htm";
5836 5872
5837 /** 5873 /**
5838 * The long suffix used for HTML files. 5874 * The long suffix used for HTML files.
5839 */ 5875 */
5840 static const String SUFFIX_HTML = "html"; 5876 static const String SUFFIX_HTML = "html";
5841 5877
5842 /** 5878 /**
5879 * The file name used for analysis options files.
5880 */
5881 static const String ANALYSIS_OPTIONS_FILE = '.analysis_options';
5882
5883 /**
5843 * The unique instance of this class. 5884 * The unique instance of this class.
5844 */ 5885 */
5845 static final AnalysisEngine instance = new AnalysisEngine._(); 5886 static final AnalysisEngine instance = new AnalysisEngine._();
5846 5887
5847 /** 5888 /**
5848 * The logger that should receive information about errors within the analysis 5889 * The logger that should receive information about errors within the analysis
5849 * engine. 5890 * engine.
5850 */ 5891 */
5851 Logger _logger = Logger.NULL; 5892 Logger _logger = Logger.NULL;
5852 5893
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
6001 * Create and return a new context in which analysis can be performed. 6042 * Create and return a new context in which analysis can be performed.
6002 */ 6043 */
6003 AnalysisContext createAnalysisContext() { 6044 AnalysisContext createAnalysisContext() {
6004 if (useTaskModel) { 6045 if (useTaskModel) {
6005 return new newContext.AnalysisContextImpl(); 6046 return new newContext.AnalysisContextImpl();
6006 } 6047 }
6007 return new AnalysisContextImpl(); 6048 return new AnalysisContextImpl();
6008 } 6049 }
6009 6050
6010 /** 6051 /**
6052 * Return `true` if the given [fileName] is an analysis options file.
6053 */
6054 static bool isAnalysisOptionsFileName(String fileName,
6055 [pathos.Context context]) {
6056 if (fileName == null) {
6057 return false;
6058 }
6059 return (context ?? pathos.posix).basename(fileName) ==
6060 ANALYSIS_OPTIONS_FILE;
6061 }
6062
6063 /**
6011 * Return `true` if the given [fileName] is assumed to contain Dart source 6064 * Return `true` if the given [fileName] is assumed to contain Dart source
6012 * code. 6065 * code.
6013 */ 6066 */
6014 static bool isDartFileName(String fileName) { 6067 static bool isDartFileName(String fileName) {
6015 if (fileName == null) { 6068 if (fileName == null) {
6016 return false; 6069 return false;
6017 } 6070 }
6018 return javaStringEqualsIgnoreCase( 6071 return javaStringEqualsIgnoreCase(
6019 FileNameUtilities.getExtension(fileName), SUFFIX_DART); 6072 FileNameUtilities.getExtension(fileName), SUFFIX_DART);
6020 } 6073 }
(...skipping 3367 matching lines...) Expand 10 before | Expand all | Expand 10 after
9388 * Sets the [TypeProvider] for this context. 9441 * Sets the [TypeProvider] for this context.
9389 */ 9442 */
9390 void set typeProvider(TypeProvider typeProvider); 9443 void set typeProvider(TypeProvider typeProvider);
9391 9444
9392 /** 9445 /**
9393 * A factory to override how [TypeResolverVisitor] is created. 9446 * A factory to override how [TypeResolverVisitor] is created.
9394 */ 9447 */
9395 TypeResolverVisitorFactory get typeResolverVisitorFactory; 9448 TypeResolverVisitorFactory get typeResolverVisitorFactory;
9396 9449
9397 /** 9450 /**
9451 * A list of all [WorkManager]s used by this context.
9452 */
9453 List<newContext.WorkManager> get workManagers;
9454
9455 /**
9398 * Return a list containing the sources of the libraries that are exported by 9456 * Return a list containing the sources of the libraries that are exported by
9399 * the library with the given [source]. The list will be empty if the given 9457 * the library with the given [source]. The list will be empty if the given
9400 * source is invalid, if the given source does not represent a library, or if 9458 * source is invalid, if the given source does not represent a library, or if
9401 * the library does not export any other libraries. 9459 * the library does not export any other libraries.
9402 * 9460 *
9403 * Throws an [AnalysisException] if the exported libraries could not be 9461 * Throws an [AnalysisException] if the exported libraries could not be
9404 * computed. 9462 * computed.
9405 */ 9463 */
9406 List<Source> computeExportedLibraries(Source source); 9464 List<Source> computeExportedLibraries(Source source);
9407 9465
(...skipping 2645 matching lines...) Expand 10 before | Expand all | Expand 10 after
12053 PendingFuture pendingFuture = 12111 PendingFuture pendingFuture =
12054 new PendingFuture<T>(_context, source, computeValue); 12112 new PendingFuture<T>(_context, source, computeValue);
12055 if (!pendingFuture.evaluate(sourceEntry)) { 12113 if (!pendingFuture.evaluate(sourceEntry)) {
12056 _context._pendingFutureSources 12114 _context._pendingFutureSources
12057 .putIfAbsent(source, () => <PendingFuture>[]) 12115 .putIfAbsent(source, () => <PendingFuture>[])
12058 .add(pendingFuture); 12116 .add(pendingFuture);
12059 } 12117 }
12060 return pendingFuture.future; 12118 return pendingFuture.future;
12061 } 12119 }
12062 } 12120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698