|
54 | 54 | final class FormatterProvider {
|
55 | 55 | private static final Logger log = LoggerFactory.getLogger(FormatterProvider.class);
|
56 | 56 |
|
57 |
| - private static final String PLUGIN_ID = "palantir-java-format"; |
| 57 | + static final String PLUGIN_ID = "palantir-java-format"; |
58 | 58 |
|
59 | 59 | // Cache to avoid creating a URLClassloader every time we want to format from IntelliJ
|
60 | 60 | private final LoadingCache<FormatterCacheKey, Optional<FormatterService>> implementationCache =
|
61 | 61 | Caffeine.newBuilder().maximumSize(1).build(FormatterProvider::createFormatter);
|
62 | 62 |
|
| 63 | + static IdeaPluginDescriptor getPluginDescriptor() { |
| 64 | + return Preconditions.checkNotNull( |
| 65 | + PluginManager.getPlugin(PluginId.getId(PLUGIN_ID)), "Couldn't find our own plugin: %s", PLUGIN_ID); |
| 66 | + } |
| 67 | + |
63 | 68 | Optional<FormatterService> get(Project project, PalantirJavaFormatSettings settings) {
|
64 | 69 | return implementationCache.get(new FormatterCacheKey(
|
65 | 70 | project,
|
@@ -117,8 +122,7 @@ private static List<Path> getProvidedImplementationUrls(List<URI> implementation
|
117 | 122 | @SuppressWarnings("for-rollout:Slf4jLogsafeArgs")
|
118 | 123 | private static List<Path> getBundledImplementationUrls() {
|
119 | 124 | // Load from the jars bundled with the plugin.
|
120 |
| - IdeaPluginDescriptor ourPlugin = Preconditions.checkNotNull( |
121 |
| - PluginManager.getPlugin(PluginId.getId(PLUGIN_ID)), "Couldn't find our own plugin: %s", PLUGIN_ID); |
| 125 | + IdeaPluginDescriptor ourPlugin = getPluginDescriptor(); |
122 | 126 | Path implDir = ourPlugin.getPath().toPath().resolve("impl");
|
123 | 127 | log.debug("Using palantir-java-format implementation bundled with plugin: {}", implDir);
|
124 | 128 | return listDirAsUrlsUnchecked(implDir);
|
|
0 commit comments