avoid static BUNDLED_BUNDLES_PATH (easier debug, don't cache)

GitOrigin-RevId: 0841fd48f23c4458cac840f9603d73ab5e0cbd60
This commit is contained in:
Vladimir Krivosheev
2023-03-10 17:11:26 +00:00
committed by intellij-monorepo-bot
parent c5e315cc89
commit 2f023150b3
2 changed files with 14 additions and 10 deletions
@@ -47,7 +47,9 @@ import static org.jetbrains.plugins.textmate.bundles.BundleReaderKt.readTextMate
import static org.jetbrains.plugins.textmate.bundles.VSCBundleReaderKt.readVSCBundle;
public final class TextMateServiceImpl extends TextMateService {
public static final String BUNDLED_BUNDLES_PATH = PluginPathManager.getPluginHome("textmate") + "/lib/bundles";
public static String getBundledBundlePath() {
return PluginPathManager.getPluginHome("textmate") + "/lib/bundles";
}
private boolean ourBuiltinBundlesDisabled;
@@ -88,11 +90,12 @@ public final class TextMateServiceImpl extends TextMateService {
}
Map<TextMateFileNameMatcher, CharSequence> newExtensionsMapping = new HashMap<>();
String bundledBundlePath = getBundledBundlePath();
for (BundleConfigBean bundleConfigBean : settings.getBundles()) {
if (bundleConfigBean.isEnabled()) {
VirtualFile bundleFile = LocalFileSystem.getInstance().findFileByPath(bundleConfigBean.getPath());
boolean result = registerBundle(bundleFile, newExtensionsMapping);
if (!result && (bundleFile != null || !bundleConfigBean.getPath().startsWith(BUNDLED_BUNDLES_PATH))) {
if (!result && (bundleFile != null || !bundleConfigBean.getPath().startsWith(bundledBundlePath))) {
String bundleName = bundleConfigBean.getName();
String errorMessage = bundleFile != null ? TextMateBundle.message("textmate.cant.register.bundle", bundleName)
: TextMateBundle.message("textmate.cant.find.bundle", bundleName);
@@ -133,7 +136,7 @@ public final class TextMateServiceImpl extends TextMateService {
}
private static void loadBuiltinBundles(TextMateSettings settings) {
File bundles = new File(BUNDLED_BUNDLES_PATH);
File bundles = new File(getBundledBundlePath());
File[] files = bundles.listFiles();
if (files == null) {
LOG.warn("Builtin bundles not found at " + bundles);
@@ -146,7 +149,10 @@ public final class TextMateServiceImpl extends TextMateService {
List<BundleConfigBean> oldBundles = state.getBundles();
List<BundleConfigBean> newBundles = new ArrayList<>(oldBundles);
for (File file : files) {
if (file.getName().startsWith(".")) continue;
if (file.getName().startsWith(".")) {
continue;
}
String path = FileUtil.toSystemIndependentName(file.getPath());
BundleConfigBean existing = ContainerUtil.find(oldBundles, (BundleConfigBean bundle) -> bundle.getPath().equals(path));
if (existing != null) {
@@ -21,15 +21,13 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.textmate.TextMateBundle;
import org.jetbrains.plugins.textmate.TextMateService;
import org.jetbrains.plugins.textmate.TextMateServiceImpl;
import org.jetbrains.plugins.textmate.bundles.TextMateBundleReader;
import javax.swing.*;
import java.util.*;
import static com.intellij.ui.ToolbarDecorator.createDecorator;
import static org.jetbrains.plugins.textmate.TextMateServiceImpl.BUNDLED_BUNDLES_PATH;
public class TextMateBundlesListPanel implements Disposable {
public final class TextMateBundlesListPanel implements Disposable {
private static final String TEXTMATE_LAST_ADDED_BUNDLE = "textmate.last.added.bundle";
private final CheckBoxList<BundleConfigBean> myBundlesList;
@@ -58,7 +56,7 @@ public class TextMateBundlesListPanel implements Disposable {
private static boolean isBuiltin(BundleConfigBean bean) {
String path = bean != null ? bean.getPath() : null;
return path != null && path.startsWith(BUNDLED_BUNDLES_PATH);
return path != null && path.startsWith(TextMateServiceImpl.getBundledBundlePath());
}
public @NotNull Collection<BundleConfigBean> getState() {
@@ -77,7 +75,7 @@ public class TextMateBundlesListPanel implements Disposable {
}
public JPanel createMainComponent() {
return createDecorator(myBundlesList)
return ToolbarDecorator.createDecorator(myBundlesList)
.setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {