| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /** | 5 /** |
| 6 * Support for client code that extends the set of files being analyzed by the | 6 * Support for client code that extends the set of files being analyzed by the |
| 7 * analysis server. | 7 * analysis server. |
| 8 * | 8 * |
| 9 * Plugins can register a function that takes a [File] and returns a [bool] | 9 * Plugins can contribute a list of file patterns. Any file whose path matches |
| 10 * indicating whether the plugin is interested in having that file be analyzed. | 10 * one or more of the contributed patterns will be analyzed. The file patterns |
| 11 * The analysis server will invoke the contributed functions and analyze the | 11 * are interpreted as glob patterns as defined by the 'glob' package. |
| 12 * file if at least one of the functions returns `true`. (The server is not | |
| 13 * required to invoke every function with every file.) | |
| 14 * | 12 * |
| 15 * If a plugin is interested in analyzing a certain kind of files, it needs to | 13 * If a plugin is interested in analyzing a certain kind of file, it needs to |
| 16 * ensure that files of that kind will be analyzed. It should register a | 14 * ensure that files of that kind will be analyzed. It should register a list of |
| 17 * function by including code like the following in the plugin's | 15 * file patterns by including code like the following in the plugin's |
| 18 * registerExtensions method: | 16 * registerExtensions method: |
| 19 * | 17 * |
| 20 * @override | 18 * @override |
| 21 * void registerExtensions(RegisterExtension registerExtension) { | 19 * void registerExtensions(RegisterExtension registerExtension) { |
| 22 * ... | 20 * ... |
| 23 * registerExtension( | 21 * registerExtension( |
| 24 * ANALYZE_FILE_EXTENSION_POINT_ID, | 22 * ANALYZED_FILE_PATTERNS_EXTENSION_POINT_ID, |
| 25 * (File file) => file.path.endsWith(...)); | 23 * ['*.yaml']); |
| 26 * ... | 24 * ... |
| 27 * } | 25 * } |
| 28 */ | 26 */ |
| 29 library analysis_server.plugin.analysis.analyzed_files; | 27 library analysis_server.plugin.analysis.analyzed_files; |
| 30 | 28 |
| 31 import 'package:analysis_server/src/plugin/server_plugin.dart'; | 29 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
| 32 import 'package:analyzer/file_system/file_system.dart'; | |
| 33 import 'package:plugin/plugin.dart'; | 30 import 'package:plugin/plugin.dart'; |
| 34 | 31 |
| 35 /** | 32 /** |
| 36 * The identifier of the extension point that allows plugins to register | 33 * The identifier of the extension point that allows plugins to cause certain |
| 37 * functions that can cause files to be analyzed. The object used as an | 34 * kinds of files to be analyzed. The object used as an extension must be a list |
| 38 * extension must be a [ShouldAnalyzeFile] function. | 35 * of strings. The strings are interpreted as glob patterns as defined by the |
| 36 * 'glob' package. |
| 39 */ | 37 */ |
| 40 final String ANALYZE_FILE_EXTENSION_POINT_ID = Plugin.join( | 38 final String ANALYZED_FILE_PATTERNS_EXTENSION_POINT_ID = Plugin.join( |
| 41 ServerPlugin.UNIQUE_IDENTIFIER, ServerPlugin.ANALYZE_FILE_EXTENSION_POINT); | 39 ServerPlugin.UNIQUE_IDENTIFIER, |
| 42 | 40 ServerPlugin.ANALYZED_FILE_PATTERNS_EXTENSION_POINT); |
| 43 /** | |
| 44 * A function that returns `true` if the given [file] should be analyzed. | |
| 45 */ | |
| 46 typedef bool ShouldAnalyzeFile(File file); | |
| OLD | NEW |