Compatibility verification
This commit is contained in:
@@ -1,8 +1,5 @@
|
|||||||
package io.github.linwancen.plugin.show.ext.conf;
|
package io.github.linwancen.plugin.show.ext.conf;
|
||||||
|
|
||||||
import com.intellij.notification.NotificationDisplayType;
|
|
||||||
import com.intellij.notification.NotificationGroup;
|
|
||||||
import com.intellij.notification.NotificationType;
|
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
import com.intellij.openapi.project.DumbService;
|
import com.intellij.openapi.project.DumbService;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
@@ -10,6 +7,8 @@ import com.intellij.openapi.vfs.VirtualFile;
|
|||||||
import com.intellij.psi.search.FilenameIndex;
|
import com.intellij.psi.search.FilenameIndex;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -20,6 +19,7 @@ import java.util.regex.Pattern;
|
|||||||
* call ConfFactory, ConfCacheGetUtils
|
* call ConfFactory, ConfCacheGetUtils
|
||||||
*/
|
*/
|
||||||
public class ConfCache {
|
public class ConfCache {
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(ConfCache.class);
|
||||||
|
|
||||||
static final String KEY_MID_EXT = ".key";
|
static final String KEY_MID_EXT = ".key";
|
||||||
static final String DOC_MID_EXT = ".doc";
|
static final String DOC_MID_EXT = ".doc";
|
||||||
@@ -116,9 +116,6 @@ public class ConfCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final NotificationGroup LOAD_ALL_LOG =
|
|
||||||
new NotificationGroup("Ext Doc Conf Load All", NotificationDisplayType.BALLOON, true);
|
|
||||||
|
|
||||||
static void loadAll(@NotNull Project project) {
|
static void loadAll(@NotNull Project project) {
|
||||||
DumbService.getInstance(project).runReadActionInSmartMode(() ->
|
DumbService.getInstance(project).runReadActionInSmartMode(() ->
|
||||||
ApplicationManager.getApplication().runReadAction(() -> {
|
ApplicationManager.getApplication().runReadAction(() -> {
|
||||||
@@ -131,8 +128,7 @@ public class ConfCache {
|
|||||||
if (files.isEmpty()) {
|
if (files.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOAD_ALL_LOG.createNotification("Ext doc conf load all complete", files.size() + " files",
|
LOG.info("Ext doc conf load all complete {} files\n{}", files.size(), sb);
|
||||||
sb.toString(), NotificationType.INFORMATION).notify(project);
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package io.github.linwancen.plugin.show.ext.conf;
|
package io.github.linwancen.plugin.show.ext.conf;
|
||||||
|
|
||||||
import com.intellij.notification.NotificationDisplayType;
|
|
||||||
import com.intellij.notification.NotificationGroup;
|
|
||||||
import com.intellij.notification.NotificationType;
|
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.twelvemonkeys.util.LinkedSet;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -15,18 +14,16 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
class ConfFactory {
|
class ConfFactory {
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(ConfFactory.class);
|
||||||
|
|
||||||
private static final Pattern EMPTY_PATTERN = Pattern.compile("");
|
private static final Pattern EMPTY_PATTERN = Pattern.compile("");
|
||||||
private static final Map<String, Pattern> PATTERN_CACHE = new ConcurrentHashMap<>();
|
private static final Map<String, Pattern> PATTERN_CACHE = new ConcurrentHashMap<>();
|
||||||
private static final NotificationGroup REGEXP_LOG =
|
|
||||||
new NotificationGroup("Ext Doc Keyword Regexp Compile", NotificationDisplayType.TOOL_WINDOW, true);
|
|
||||||
|
|
||||||
private ConfFactory() {}
|
private ConfFactory() {}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
static Pattern buildPattern(@Nullable Project project, @NotNull String path,
|
static Pattern buildPattern(@SuppressWarnings("unused") @Nullable Project project, @NotNull String path,
|
||||||
@NotNull Map<String, Map<String, List<String>>> map) {
|
@NotNull Map<String, Map<String, List<String>>> map) {
|
||||||
@NotNull Set<String> exclude = new LinkedSet<>();
|
@NotNull Set<String> exclude = new LinkedHashSet<>();
|
||||||
@NotNull StringBuilder sb = new StringBuilder();
|
@NotNull StringBuilder sb = new StringBuilder();
|
||||||
for (@NotNull Map<String, List<String>> keyMap : map.values()) {
|
for (@NotNull Map<String, List<String>> keyMap : map.values()) {
|
||||||
// key() is escape
|
// key() is escape
|
||||||
@@ -53,15 +50,13 @@ class ConfFactory {
|
|||||||
try {
|
try {
|
||||||
@NotNull Pattern compile = Pattern.compile(regex);
|
@NotNull Pattern compile = Pattern.compile(regex);
|
||||||
PATTERN_CACHE.put(regex, compile);
|
PATTERN_CACHE.put(regex, compile);
|
||||||
REGEXP_LOG.createNotification("Ext doc keyword regexp compile success", regex.length() + " chars",
|
LOG.info("Ext doc keyword regexp compile success {} chars\n{}", regex.length(), sb);
|
||||||
sb.toString(), NotificationType.INFORMATION).notify(project);
|
|
||||||
return compile;
|
return compile;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sb.insert(0, "\n");
|
sb.insert(0, "\n");
|
||||||
sb.insert(0, e.getLocalizedMessage());
|
sb.insert(0, e.getLocalizedMessage());
|
||||||
PATTERN_CACHE.put(regex, EMPTY_PATTERN);
|
PATTERN_CACHE.put(regex, EMPTY_PATTERN);
|
||||||
REGEXP_LOG.createNotification("Ext doc keyword regexp compile fail", regex.length() + " chars",
|
LOG.warn("Ext doc keyword regexp compile fail {} chars\n{}", regex.length(), sb);
|
||||||
sb.toString(), NotificationType.ERROR).notify(project);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user