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

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

Issue 1748763002: Move shouldFileBeAnalyzed into ContextManager (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
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 0226b7c561a0676dadc9e034f8901ee0318299c7..2b2b28e2645d37d8916f4911660b594ca8ac8cc7 100644
--- a/pkg/analysis_server/lib/src/context_manager.dart
+++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -31,6 +31,7 @@ import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/source_io.dart';
import 'package:analyzer/src/task/options.dart';
import 'package:analyzer/src/util/absolute_path.dart';
+import 'package:analyzer/src/util/glob.dart';
import 'package:analyzer/src/util/yaml.dart';
import 'package:package_config/packages.dart';
import 'package:package_config/packages_file.dart' as pkgfile show parse;
@@ -336,11 +337,6 @@ abstract class ContextManagerCallbacks {
void removeContext(Folder folder, List<String> flushedFiles);
/**
- * Return `true` if the given [file] should be analyzed.
- */
- bool shouldFileBeAnalyzed(File file);
-
- /**
* Called when the disposition for a context has changed.
*/
void updateContextPackageUriResolver(
@@ -442,15 +438,20 @@ class ContextManagerImpl implements ContextManager {
new AnalysisOptionsProvider();
/**
- * The instrumentation service used to report instrumentation data.
+ * A list of the globs used to determine which files should be analyzed.
*/
- final InstrumentationService _instrumentationService;
+ final List<Glob> analyzedFilesGlobs;
/**
* The default options used to create new analysis contexts.
*/
final AnalysisOptionsImpl defaultContextOptions;
+ /**
+ * The instrumentation service used to report instrumentation data.
+ */
+ final InstrumentationService _instrumentationService;
+
@override
ContextManagerCallbacks callbacks;
@@ -478,6 +479,7 @@ class ContextManagerImpl implements ContextManager {
this.packageResolverProvider,
this.embeddedUriResolverProvider,
this._packageMapProvider,
+ this.analyzedFilesGlobs,
this._instrumentationService,
this.defaultContextOptions) {
absolutePathContext = resourceProvider.absolutePathContext;
@@ -787,7 +789,7 @@ class ContextManagerImpl implements ContextManager {
// add files, recurse into folders
if (child is File) {
// ignore if should not be analyzed at all
- if (!callbacks.shouldFileBeAnalyzed(child)) {
+ if (!_shouldFileBeAnalyzed(child)) {
continue;
}
// ignore if was not excluded
@@ -834,7 +836,7 @@ class ContextManagerImpl implements ContextManager {
}
// add files, recurse into folders
if (child is File) {
- if (callbacks.shouldFileBeAnalyzed(child)) {
+ if (_shouldFileBeAnalyzed(child)) {
Source source = createSourceInContext(info.context, child);
changeSet.addedSource(source);
info.sources[path] = source;
@@ -1308,7 +1310,7 @@ class ContextManagerImpl implements ContextManager {
// that case don't add it.
if (resource is File) {
File file = resource;
- if (callbacks.shouldFileBeAnalyzed(file)) {
+ if (_shouldFileBeAnalyzed(file)) {
ChangeSet changeSet = new ChangeSet();
Source source = createSourceInContext(info.context, file);
changeSet.addedSource(source);
@@ -1492,6 +1494,24 @@ class ContextManagerImpl implements ContextManager {
}
/**
+ * Return `true` if the given [file] should be analyzed.
+ */
+ bool _shouldFileBeAnalyzed(File file) {
+ for (Glob glob in analyzedFilesGlobs) {
+ if (glob.matches(file.path)) {
+ // Emacs creates dummy links to track the fact that a file is open for
+ // editing and has unsaved changes (e.g. having unsaved changes to
+ // 'foo.dart' causes a link '.#foo.dart' to be created, which points to
+ // the non-existent file 'username@hostname.pid'. To avoid these dummy
+ // links causing the analyzer to thrash, just ignore links to
+ // non-existent files.
+ return file.exists;
+ }
+ }
+ return false;
+ }
+
+ /**
* Create and return a source representing the given [file] within the given
* [context].
*/
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analysis_server/test/analysis_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698