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

Unified Diff: pkg/analysis_server/lib/src/context_manager.dart

Issue 1238173003: Add a PathFilter to each context in analysis_server (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/context_manager.dart
diff --git a/pkg/analysis_server/lib/src/context_manager.dart b/pkg/analysis_server/lib/src/context_manager.dart
index fc93e96ec3b5d302ee074d6c356ed0a982353e09..241b9f16b9716373d7952893ceb73eff5f24a697 100644
--- a/pkg/analysis_server/lib/src/context_manager.dart
+++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -14,6 +14,7 @@ import 'package:analysis_server/uri/resolver_provider.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/instrumentation/instrumentation.dart';
import 'package:analyzer/source/package_map_resolver.dart';
+import 'package:analyzer/source/path_filter.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/java_io.dart';
import 'package:analyzer/src/generated/source.dart';
@@ -163,6 +164,16 @@ abstract class AbstractContextManager implements ContextManager {
// Do nothing.
}
+ // Sets the [ignorePatterns] for the context [folder].
+ void setIgnorePatternsForContext(Folder folder, List<String> ignorePatterns) {
+ _ContextInfo info = _contexts[folder];
+ if (info == null) {
+ return;
+ }
+ var pathFilter = info.pathFilter;
+ pathFilter.setIgnorePatterns(ignorePatterns);
+ }
+
@override
bool isInAnalysisRoot(String path) {
// check if excluded
@@ -318,6 +329,10 @@ abstract class AbstractContextManager implements ContextManager {
}
for (Resource child in children) {
String path = child.path;
+ // Path is being ignored.
+ if (info.ignored(path)) {
+ continue;
+ }
// add files, recurse into folders
if (child is File) {
// ignore if should not be analyzed at all
@@ -361,7 +376,7 @@ abstract class AbstractContextManager implements ContextManager {
for (Resource child in children) {
String path = child.path;
// ignore excluded files or folders
- if (_isExcluded(path) || info.excludes(path)) {
+ if (_isExcluded(path) || info.excludes(path) || info.ignored(path)) {
continue;
}
// add files, recurse into folders
@@ -606,6 +621,9 @@ abstract class AbstractContextManager implements ContextManager {
if (info.excludes(path)) {
return;
}
+ if (info.ignored(path)) {
+ return;
+ }
// handle the change
switch (event.type) {
case ChangeType.ADD:
@@ -859,6 +877,9 @@ class _ContextInfo {
*/
final Folder folder;
+ /// The [PathFilter] used to filter sources from being analyzed.
+ final PathFilter pathFilter;
+
/**
* The enclosed pubspec-based contexts.
*/
@@ -910,7 +931,9 @@ class _ContextInfo {
*/
OptimizingPubPackageMapInfo packageMapInfo;
- _ContextInfo(this.folder, File pubspecFile, this.children, this.packageRoot) {
+ _ContextInfo(Folder folder, File pubspecFile, this.children, this.packageRoot)
+ : folder = folder,
+ pathFilter = new PathFilter(folder.path, null) {
pubspecPath = pubspecFile.path;
for (_ContextInfo child in children) {
child.parent = this;
@@ -931,6 +954,9 @@ class _ContextInfo {
});
}
+ /// Returns `true` if [path] should be ignored.
+ bool ignored(String path) => pathFilter.ignored(path);
+
/**
* Returns `true` if [resource] is excluded, as it is in one of the children.
*/
« no previous file with comments | « no previous file | pkg/analysis_server/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698