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

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

Issue 1413643006: Rework analyzed files support to use globs (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address comments Created 5 years, 1 month 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/analysis_server.dart
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index cdf1561b0f9fbdf3f3b4da66e7fc87cbf53bef33..458cdd727cbe31e76842fc509844b9dc89ddaec2 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -29,10 +29,12 @@ import 'package:analyzer/src/generated/ast.dart';
import 'package:analyzer/src/generated/element.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/java_engine.dart';
+import 'package:analyzer/src/generated/java_io.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/source_io.dart';
import 'package:analyzer/src/generated/utilities_general.dart';
+import 'package:glob/glob.dart';
import 'package:plugin/plugin.dart';
typedef void OptionUpdater(AnalysisOptionsImpl options);
@@ -1404,8 +1406,35 @@ class ServerContextManagerCallbacks extends ContextManagerCallbacks {
*/
final ResourceProvider resourceProvider;
+ /**
+ * A list of the globs used to determine which files should be analyzed. The
+ * list is lazily created and should be accessed using [analyzedFilesGlobs].
+ */
+ List<Glob> _analyzedFilesGlobs = null;
+
ServerContextManagerCallbacks(this.analysisServer, this.resourceProvider);
+ /**
+ * Return a list of the globs used to determine which files should be analyzed.
+ */
+ List<Glob> get analyzedFilesGlobs {
+ if (_analyzedFilesGlobs == null) {
+ _analyzedFilesGlobs = <Glob>[];
+ List<String> patterns = analysisServer.serverPlugin.analyzedFilePatterns;
+ for (String pattern in patterns) {
+ try {
+ _analyzedFilesGlobs
+ .add(new Glob(pattern, context: JavaFile.pathContext));
+ } catch (exception, stackTrace) {
+ AnalysisEngine.instance.logger.logError(
+ 'Invalid glob pattern: "$pattern"',
+ new CaughtException(exception, stackTrace));
+ }
+ }
+ }
+ return _analyzedFilesGlobs;
+ }
+
@override
AnalysisContext addContext(Folder folder, FolderDisposition disposition) {
InternalAnalysisContext context =
@@ -1463,10 +1492,8 @@ class ServerContextManagerCallbacks extends ContextManagerCallbacks {
@override
bool shouldFileBeAnalyzed(File file) {
- List<ShouldAnalyzeFile> functions =
- analysisServer.serverPlugin.analyzeFileFunctions;
- for (ShouldAnalyzeFile shouldAnalyzeFile in functions) {
- if (shouldAnalyzeFile(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
« no previous file with comments | « pkg/analysis_server/lib/plugin/analysis/analyzed_files.dart ('k') | pkg/analysis_server/lib/src/plugin/server_plugin.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698