| OLD | NEW |
| 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 context.directory.manager; | 5 library context.directory.manager; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:convert'; | 9 import 'dart:convert'; |
| 10 import 'dart:core'; | 10 import 'dart:core'; |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 * folder is or contains the given path. ("innermost" refers to the nesting | 283 * folder is or contains the given path. ("innermost" refers to the nesting |
| 284 * of contexts, so if there is a context for path /foo and a context for | 284 * of contexts, so if there is a context for path /foo and a context for |
| 285 * path /foo/bar, then the innermost context containing /foo/bar/baz.dart is | 285 * path /foo/bar, then the innermost context containing /foo/bar/baz.dart is |
| 286 * the context for /foo/bar.) | 286 * the context for /foo/bar.) |
| 287 * | 287 * |
| 288 * If no context contains the given path, `null` is returned. | 288 * If no context contains the given path, `null` is returned. |
| 289 */ | 289 */ |
| 290 AnalysisContext getContextFor(String path); | 290 AnalysisContext getContextFor(String path); |
| 291 | 291 |
| 292 /** | 292 /** |
| 293 * Return a list of all of the analysis drivers reachable from the given |
| 294 * [analysisRoot] (the driver associated with [analysisRoot] and all of its |
| 295 * descendants). |
| 296 */ |
| 297 List<AnalysisDriver> getDriversInAnalysisRoot(Folder analysisRoot); |
| 298 |
| 299 /** |
| 293 * Return `true` if the given [path] is ignored by a [ContextInfo] whose | 300 * Return `true` if the given [path] is ignored by a [ContextInfo] whose |
| 294 * folder contains it. | 301 * folder contains it. |
| 295 */ | 302 */ |
| 296 bool isIgnored(String path); | 303 bool isIgnored(String path); |
| 297 | 304 |
| 298 /** | 305 /** |
| 299 * Return `true` if the given absolute [path] is in one of the current | 306 * Return `true` if the given absolute [path] is in one of the current |
| 300 * root folders and is not excluded. | 307 * root folders and is not excluded. |
| 301 */ | 308 */ |
| 302 bool isInAnalysisRoot(String path); | 309 bool isInAnalysisRoot(String path); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 */ | 592 */ |
| 586 ContextInfo getContextInfoFor(Folder folder) { | 593 ContextInfo getContextInfoFor(Folder folder) { |
| 587 ContextInfo info = _getInnermostContextInfoFor(folder.path); | 594 ContextInfo info = _getInnermostContextInfoFor(folder.path); |
| 588 if (info != null && folder == info.folder) { | 595 if (info != null && folder == info.folder) { |
| 589 return info; | 596 return info; |
| 590 } | 597 } |
| 591 return null; | 598 return null; |
| 592 } | 599 } |
| 593 | 600 |
| 594 @override | 601 @override |
| 602 List<AnalysisDriver> getDriversInAnalysisRoot(Folder analysisRoot) { |
| 603 List<AnalysisDriver> drivers = <AnalysisDriver>[]; |
| 604 void addContextAndDescendants(ContextInfo info) { |
| 605 drivers.add(info.analysisDriver); |
| 606 info.children.forEach(addContextAndDescendants); |
| 607 } |
| 608 |
| 609 ContextInfo innermostContainingInfo = |
| 610 _getInnermostContextInfoFor(analysisRoot.path); |
| 611 if (innermostContainingInfo != null) { |
| 612 if (analysisRoot == innermostContainingInfo.folder) { |
| 613 addContextAndDescendants(innermostContainingInfo); |
| 614 } else { |
| 615 for (ContextInfo info in innermostContainingInfo.children) { |
| 616 if (analysisRoot.isOrContains(info.folder.path)) { |
| 617 addContextAndDescendants(info); |
| 618 } |
| 619 } |
| 620 } |
| 621 } |
| 622 return drivers; |
| 623 } |
| 624 |
| 625 @override |
| 595 bool isIgnored(String path) { | 626 bool isIgnored(String path) { |
| 596 ContextInfo info = rootInfo; | 627 ContextInfo info = rootInfo; |
| 597 do { | 628 do { |
| 598 info = info.findChildInfoFor(path); | 629 info = info.findChildInfoFor(path); |
| 599 if (info == null) { | 630 if (info == null) { |
| 600 return false; | 631 return false; |
| 601 } | 632 } |
| 602 if (info.ignored(path)) { | 633 if (info.ignored(path)) { |
| 603 return true; | 634 return true; |
| 604 } | 635 } |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 continue; | 980 continue; |
| 950 } | 981 } |
| 951 _addSourceFiles(changeSet, child, info); | 982 _addSourceFiles(changeSet, child, info); |
| 952 } | 983 } |
| 953 } | 984 } |
| 954 } | 985 } |
| 955 | 986 |
| 956 void _checkForAnalysisOptionsUpdate( | 987 void _checkForAnalysisOptionsUpdate( |
| 957 String path, ContextInfo info, ChangeType changeType) { | 988 String path, ContextInfo info, ChangeType changeType) { |
| 958 if (AnalysisEngine.isAnalysisOptionsFileName(path, pathContext)) { | 989 if (AnalysisEngine.isAnalysisOptionsFileName(path, pathContext)) { |
| 959 var analysisContext = info.context; | 990 if (enableNewAnalysisDriver) { |
| 960 if (analysisContext is context.AnalysisContextImpl) { | 991 // TODO(brianwilkerson) Implement this. |
| 961 Map<String, Object> options = | 992 // AnalysisDriver driver = info.analysisDriver; |
| 962 readOptions(info.folder, info.disposition.packages); | 993 // String contextRoot = info.folder.path; |
| 963 processOptionsForContext(info, options, | 994 // ContextBuilder builder = |
| 964 optionsRemoved: changeType == ChangeType.REMOVE); | 995 // callbacks.createContextBuilder(info.folder, defaultContextOptions); |
| 965 analysisContext.sourceFactory = _createSourceFactory( | 996 // AnalysisOptions options = builder.getAnalysisOptions(contextRoot); |
| 966 analysisContext, analysisContext.analysisOptions, info.folder); | 997 // driver.analysisOptions = options; |
| 967 callbacks.applyChangesToContext(info.folder, new ChangeSet()); | 998 // driver.sourceFactory = builder.createSourceFactory(contextRoot, option
s); |
| 999 // TODO(brianwilkerson) Set exclusion patterns. |
| 1000 } else { |
| 1001 var analysisContext = info.context; |
| 1002 if (analysisContext is context.AnalysisContextImpl) { |
| 1003 Map<String, Object> options = |
| 1004 readOptions(info.folder, info.disposition.packages); |
| 1005 processOptionsForContext(info, options, |
| 1006 optionsRemoved: changeType == ChangeType.REMOVE); |
| 1007 analysisContext.sourceFactory = _createSourceFactory( |
| 1008 analysisContext, analysisContext.analysisOptions, info.folder); |
| 1009 callbacks.applyChangesToContext(info.folder, new ChangeSet()); |
| 1010 } |
| 968 } | 1011 } |
| 969 } | 1012 } |
| 970 } | 1013 } |
| 971 | 1014 |
| 972 void _checkForPackagespecUpdate( | 1015 void _checkForPackagespecUpdate( |
| 973 String path, ContextInfo info, Folder folder) { | 1016 String path, ContextInfo info, Folder folder) { |
| 974 // Check to see if this is the .packages file for this context and if so, | 1017 // Check to see if this is the .packages file for this context and if so, |
| 975 // update the context's source factory. | 1018 // update the context's source factory. |
| 976 if (absolutePathContext.basename(path) == PACKAGE_SPEC_NAME) { | 1019 if (absolutePathContext.basename(path) == PACKAGE_SPEC_NAME) { |
| 977 String contextRoot = info.folder.path; | 1020 String contextRoot = info.folder.path; |
| (...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1903 } | 1946 } |
| 1904 return _embedderLocator; | 1947 return _embedderLocator; |
| 1905 } | 1948 } |
| 1906 | 1949 |
| 1907 @override | 1950 @override |
| 1908 SdkExtensionFinder getSdkExtensionFinder(ResourceProvider resourceProvider) { | 1951 SdkExtensionFinder getSdkExtensionFinder(ResourceProvider resourceProvider) { |
| 1909 return _sdkExtensionFinder ??= | 1952 return _sdkExtensionFinder ??= |
| 1910 new SdkExtensionFinder(buildPackageMap(resourceProvider)); | 1953 new SdkExtensionFinder(buildPackageMap(resourceProvider)); |
| 1911 } | 1954 } |
| 1912 } | 1955 } |
| OLD | NEW |