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

Side by Side Diff: pkg/analysis_server/lib/src/plugin/plugin_locator.dart

Issue 2952583003: Rename the plugin location key and directory name (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/test/src/plugin/plugin_locator_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'package:analyzer/file_system/file_system.dart'; 5 import 'package:analyzer/file_system/file_system.dart';
6 import 'package:yaml/yaml.dart'; 6 import 'package:yaml/yaml.dart';
7 7
8 /** 8 /**
9 * An object used to locate a plugin within a package. 9 * An object used to locate a plugin within a package.
10 */ 10 */
11 class PluginLocator { 11 class PluginLocator {
12 /** 12 /**
13 * The key used in the `pubspec.yaml` file to specify the location of the 13 * The key used in the `pubspec.yaml` file to specify the location of the
14 * analysis plugin. 14 * analysis plugin.
15 */ 15 */
16 static const String analysisPluginKey = 'analysis_plugin'; 16 static const String analyzerPluginKey = 'analyzer_plugin';
17 17
18 /** 18 /**
19 * The name of the default plugin directory, located within the `tools` 19 * The name of the default plugin directory, located within the `tools`
20 * directory. 20 * directory.
21 */ 21 */
22 static const String defaultPluginFolderName = 'analysis_plugin'; 22 static const String defaultPluginFolderName = 'analyzer_plugin';
23 23
24 /** 24 /**
25 * The name of the `pubspec.yaml` file. 25 * The name of the `pubspec.yaml` file.
26 */ 26 */
27 static const String pubspecFileName = 'pubspec.yaml'; 27 static const String pubspecFileName = 'pubspec.yaml';
28 28
29 /** 29 /**
30 * The name of the `tools` directory, in which the default plugin directory is 30 * The name of the `tools` directory, in which the default plugin directory is
31 * located. 31 * located.
32 */ 32 */
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 */ 72 */
73 String _findPlugin(String packageRoot) { 73 String _findPlugin(String packageRoot) {
74 Folder packageFolder = resourceProvider.getFolder(packageRoot); 74 Folder packageFolder = resourceProvider.getFolder(packageRoot);
75 File pubspecFile = packageFolder.getChildAssumingFile(pubspecFileName); 75 File pubspecFile = packageFolder.getChildAssumingFile(pubspecFileName);
76 if (pubspecFile.exists) { 76 if (pubspecFile.exists) {
77 try { 77 try {
78 YamlDocument document = loadYamlDocument(pubspecFile.readAsStringSync(), 78 YamlDocument document = loadYamlDocument(pubspecFile.readAsStringSync(),
79 sourceUrl: pubspecFile.toUri()); 79 sourceUrl: pubspecFile.toUri());
80 YamlNode contents = document.contents; 80 YamlNode contents = document.contents;
81 if (contents is YamlMap) { 81 if (contents is YamlMap) {
82 String pluginPath = contents[analysisPluginKey]; 82 String pluginPath = contents[analyzerPluginKey];
83 if (pluginPath != null) { 83 if (pluginPath != null) {
84 Folder pluginFolder = 84 Folder pluginFolder =
85 packageFolder.getChildAssumingFolder(pluginPath); 85 packageFolder.getChildAssumingFolder(pluginPath);
86 if (pluginFolder.exists) { 86 if (pluginFolder.exists) {
87 return pluginFolder.path; 87 return pluginFolder.path;
88 } 88 }
89 } 89 }
90 } 90 }
91 } catch (exception) { 91 } catch (exception) {
92 // If we can't read the file, or if it isn't valid YAML, then ignore it. 92 // If we can't read the file, or if it isn't valid YAML, then ignore it.
93 } 93 }
94 } 94 }
95 Folder pluginFolder = packageFolder 95 Folder pluginFolder = packageFolder
96 .getChildAssumingFolder(toolsFolderName) 96 .getChildAssumingFolder(toolsFolderName)
97 .getChildAssumingFolder(defaultPluginFolderName); 97 .getChildAssumingFolder(defaultPluginFolderName);
98 if (pluginFolder.exists) { 98 if (pluginFolder.exists) {
99 return pluginFolder.path; 99 return pluginFolder.path;
100 } 100 }
101 return null; 101 return null;
102 } 102 }
103 } 103 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/src/plugin/plugin_locator_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698