mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
avoid loading too many class on startup (IDEA-CR-55624)
GitOrigin-RevId: f143b86b0330fcb091e5daf4bc88a8f4b6ccc43d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e342ce6bd1
commit
da4d18ee22
@@ -26,7 +26,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
class BuildMessageDispatcher extends SimpleChannelInboundHandlerAdapter<CmdlineRemoteProto.Message> {
|
||||
private static final Logger LOG = Logger.getInstance(BuildMessageDispatcher.class);
|
||||
|
||||
private static final AttributeKey<SessionData> SESSION_DATA = AttributeKey.valueOf("BuildMessageDispatcher.sessionData");
|
||||
private static class Holder {
|
||||
private static final AttributeKey<SessionData> SESSION_DATA = AttributeKey.valueOf("BuildMessageDispatcher.sessionData");
|
||||
}
|
||||
|
||||
private final Map<UUID, SessionData> mySessionDescriptors = new ConcurrentHashMap<>(16, 0.75f, 1);
|
||||
private final Set<UUID> myCanceledSessions = ContainerUtil.newConcurrentSet();
|
||||
@@ -62,7 +64,7 @@ class BuildMessageDispatcher extends SimpleChannelInboundHandlerAdapter<CmdlineR
|
||||
final Channel channel = data.channel;
|
||||
if (channel != null) {
|
||||
// cleanup the attribute so that session data is not leaked
|
||||
channel.attr(SESSION_DATA).set(null);
|
||||
channel.attr(Holder.SESSION_DATA).set(null);
|
||||
}
|
||||
return data.handler;
|
||||
}
|
||||
@@ -116,7 +118,7 @@ class BuildMessageDispatcher extends SimpleChannelInboundHandlerAdapter<CmdlineR
|
||||
|
||||
@Override
|
||||
protected void messageReceived(ChannelHandlerContext context, CmdlineRemoteProto.Message message) {
|
||||
SessionData sessionData = context.channel().attr(SESSION_DATA).get();
|
||||
SessionData sessionData = context.channel().attr(Holder.SESSION_DATA).get();
|
||||
final boolean isFirstMessage = sessionData == null;
|
||||
final UUID sessionId;
|
||||
if (isFirstMessage) {
|
||||
@@ -127,7 +129,7 @@ class BuildMessageDispatcher extends SimpleChannelInboundHandlerAdapter<CmdlineR
|
||||
sessionData = mySessionDescriptors.get(sessionId);
|
||||
if (sessionData != null) {
|
||||
sessionData.channel = context.channel();
|
||||
context.channel().attr(SESSION_DATA).set(sessionData);
|
||||
context.channel().attr(Holder.SESSION_DATA).set(sessionData);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -204,7 +206,7 @@ class BuildMessageDispatcher extends SimpleChannelInboundHandlerAdapter<CmdlineR
|
||||
super.channelInactive(context);
|
||||
}
|
||||
finally {
|
||||
final SessionData sessionData = context.channel().attr(SESSION_DATA).get();
|
||||
final SessionData sessionData = context.channel().attr(Holder.SESSION_DATA).get();
|
||||
if (sessionData != null) {
|
||||
final BuilderMessageHandler handler = unregisterBuildMessageHandler(sessionData.sessionId);
|
||||
if (handler != null) {
|
||||
|
||||
+2
-2
@@ -31,8 +31,8 @@ public class JavaReflectionCompletionConfidence extends CompletionConfidence {
|
||||
public ThreeState shouldSkipAutopopup(@NotNull PsiElement contextElement, @NotNull PsiFile psiFile, int offset) {
|
||||
final PsiElement literal = contextElement.getParent();
|
||||
if (literal != null &&
|
||||
(JavaReflectionReferenceContributor.PATTERN.accepts(literal) ||
|
||||
JavaReflectionReferenceContributor.CLASS_PATTERN.accepts(literal))) {
|
||||
(JavaReflectionReferenceContributor.Holder.PATTERN.accepts(literal) ||
|
||||
JavaReflectionReferenceContributor.Holder.CLASS_PATTERN.accepts(literal))) {
|
||||
return ThreeState.NO;
|
||||
}
|
||||
return super.shouldSkipAutopopup(contextElement, psiFile, offset);
|
||||
|
||||
+26
-24
@@ -37,33 +37,35 @@ import static com.intellij.psi.impl.source.resolve.reference.impl.JavaReflection
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class JavaReflectionReferenceContributor extends PsiReferenceContributor {
|
||||
public static final PsiJavaElementPattern.Capture<PsiLiteral> PATTERN =
|
||||
psiLiteral().methodCallParameter(psiMethod().withName(GET_FIELD, GET_DECLARED_FIELD, GET_METHOD, GET_DECLARED_METHOD)
|
||||
.definedInClass(JAVA_LANG_CLASS));
|
||||
static class Holder {
|
||||
public static final PsiJavaElementPattern.Capture<PsiLiteral> PATTERN =
|
||||
psiLiteral().methodCallParameter(psiMethod().withName(GET_FIELD, GET_DECLARED_FIELD, GET_METHOD, GET_DECLARED_METHOD)
|
||||
.definedInClass(JAVA_LANG_CLASS));
|
||||
|
||||
public static final PsiJavaElementPattern.Capture<PsiLiteral> CLASS_PATTERN =
|
||||
psiLiteral().methodCallParameter(0, or(
|
||||
psiMethod().withName(FOR_NAME).definedInClass(JAVA_LANG_CLASS),
|
||||
psiMethod().withName(LOAD_CLASS).definedInClass(JAVA_LANG_CLASS_LOADER),
|
||||
psiMethod().withName(FIND_CLASS).definedInClass(JAVA_LANG_INVOKE_METHOD_HANDLES_LOOKUP)));
|
||||
static final PsiJavaElementPattern.Capture<PsiLiteral> CLASS_PATTERN =
|
||||
psiLiteral().methodCallParameter(0, or(
|
||||
psiMethod().withName(FOR_NAME).definedInClass(JAVA_LANG_CLASS),
|
||||
psiMethod().withName(LOAD_CLASS).definedInClass(JAVA_LANG_CLASS_LOADER),
|
||||
psiMethod().withName(FIND_CLASS).definedInClass(JAVA_LANG_INVOKE_METHOD_HANDLES_LOOKUP)));
|
||||
|
||||
private static final ElementPattern<? extends PsiElement> METHOD_HANDLE_PATTERN = psiLiteral()
|
||||
.methodCallParameter(1, psiMethod()
|
||||
.withName(HANDLE_FACTORY_METHOD_NAMES)
|
||||
.definedInClass(JAVA_LANG_INVOKE_METHOD_HANDLES_LOOKUP));
|
||||
private static final ElementPattern<? extends PsiElement> METHOD_HANDLE_PATTERN = psiLiteral()
|
||||
.methodCallParameter(1, psiMethod()
|
||||
.withName(HANDLE_FACTORY_METHOD_NAMES)
|
||||
.definedInClass(JAVA_LANG_INVOKE_METHOD_HANDLES_LOOKUP));
|
||||
|
||||
public static final PsiJavaElementPattern.Capture<PsiLiteral> ATOMIC_NUMERIC_PATTERN =
|
||||
psiLiteral().methodCallParameter(1, psiMethod().withName(NEW_UPDATER)
|
||||
.definedInClass(PsiJavaPatterns.psiClass().withQualifiedName(string().oneOf(ATOMIC_LONG_FIELD_UPDATER,
|
||||
ATOMIC_INTEGER_FIELD_UPDATER))));
|
||||
public static final PsiJavaElementPattern.Capture<PsiLiteral> ATOMIC_NUMERIC_PATTERN =
|
||||
psiLiteral().methodCallParameter(1, psiMethod().withName(NEW_UPDATER)
|
||||
.definedInClass(PsiJavaPatterns.psiClass().withQualifiedName(string().oneOf(ATOMIC_LONG_FIELD_UPDATER,
|
||||
ATOMIC_INTEGER_FIELD_UPDATER))));
|
||||
|
||||
public static final PsiJavaElementPattern.Capture<PsiLiteral> ATOMIC_REFERENCE_PATTERN =
|
||||
psiLiteral().methodCallParameter(2, psiMethod().withName(NEW_UPDATER)
|
||||
.definedInClass(PsiJavaPatterns.psiClass().withQualifiedName(ATOMIC_REFERENCE_FIELD_UPDATER)));
|
||||
public static final PsiJavaElementPattern.Capture<PsiLiteral> ATOMIC_REFERENCE_PATTERN =
|
||||
psiLiteral().methodCallParameter(2, psiMethod().withName(NEW_UPDATER)
|
||||
.definedInClass(PsiJavaPatterns.psiClass().withQualifiedName(ATOMIC_REFERENCE_FIELD_UPDATER)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
|
||||
registrar.registerReferenceProvider(PATTERN, new JavaReflectionReferenceProvider() {
|
||||
registrar.registerReferenceProvider(Holder.PATTERN, new JavaReflectionReferenceProvider() {
|
||||
@Nullable
|
||||
@Override
|
||||
protected PsiReference[] getReferencesByMethod(@NotNull PsiLiteralExpression literalArgument,
|
||||
@@ -75,9 +77,9 @@ public class JavaReflectionReferenceContributor extends PsiReferenceContributor
|
||||
}
|
||||
});
|
||||
|
||||
registrar.registerReferenceProvider(CLASS_PATTERN, new ReflectionClassNameReferenceProvider());
|
||||
registrar.registerReferenceProvider(Holder.CLASS_PATTERN, new ReflectionClassNameReferenceProvider());
|
||||
|
||||
registrar.registerReferenceProvider(METHOD_HANDLE_PATTERN, new JavaLangInvokeHandleReference.JavaLangInvokeHandleReferenceProvider());
|
||||
registrar.registerReferenceProvider(Holder.METHOD_HANDLE_PATTERN, new JavaLangInvokeHandleReference.JavaLangInvokeHandleReferenceProvider());
|
||||
|
||||
JavaReflectionReferenceProvider atomicProvider = new JavaReflectionReferenceProvider() {
|
||||
@Override
|
||||
@@ -92,8 +94,8 @@ public class JavaReflectionReferenceContributor extends PsiReferenceContributor
|
||||
return PsiReference.EMPTY_ARRAY;
|
||||
}
|
||||
};
|
||||
registrar.registerReferenceProvider(ATOMIC_NUMERIC_PATTERN, atomicProvider);
|
||||
registrar.registerReferenceProvider(ATOMIC_REFERENCE_PATTERN, atomicProvider);
|
||||
registrar.registerReferenceProvider(Holder.ATOMIC_NUMERIC_PATTERN, atomicProvider);
|
||||
registrar.registerReferenceProvider(Holder.ATOMIC_REFERENCE_PATTERN, atomicProvider);
|
||||
}
|
||||
|
||||
private static class ReflectionClassNameReferenceProvider extends JavaClassReferenceProvider {
|
||||
|
||||
@@ -16,17 +16,19 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class JsonRainbowVisitor extends RainbowVisitor {
|
||||
private static final Map<String, Set<String>> blacklist = createBlacklist();
|
||||
private static class Holder {
|
||||
private static final Map<String, Set<String>> blacklist = createBlacklist();
|
||||
|
||||
private static Map<String, Set<String>> createBlacklist() {
|
||||
Map<String, Set<String>> blacklist = new HashMap<>();
|
||||
blacklist.put("package.json", ContainerUtil.set("/dependencies",
|
||||
"/devDependencies",
|
||||
"/peerDependencies",
|
||||
"/scripts",
|
||||
"/directories",
|
||||
"/optionalDependencies"));
|
||||
return blacklist;
|
||||
private static Map<String, Set<String>> createBlacklist() {
|
||||
Map<String, Set<String>> blacklist = new HashMap<>();
|
||||
blacklist.put("package.json", ContainerUtil.set("/dependencies",
|
||||
"/devDependencies",
|
||||
"/peerDependencies",
|
||||
"/scripts",
|
||||
"/directories",
|
||||
"/optionalDependencies"));
|
||||
return blacklist;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,9 +41,9 @@ public class JsonRainbowVisitor extends RainbowVisitor {
|
||||
if (element instanceof JsonProperty) {
|
||||
PsiFile file = element.getContainingFile();
|
||||
String fileName = file.getName();
|
||||
if (blacklist.containsKey(fileName)) {
|
||||
if (Holder.blacklist.containsKey(fileName)) {
|
||||
JsonPointerPosition position = JsonOriginalPsiWalker.INSTANCE.findPosition(element, false);
|
||||
if (position != null && blacklist.get(fileName).contains(position.toJsonPointer())) return;
|
||||
if (position != null && Holder.blacklist.get(fileName).contains(position.toJsonPointer())) return;
|
||||
}
|
||||
String name = ((JsonProperty)element).getName();
|
||||
addInfo(getInfo(file, ((JsonProperty)element).getNameElement(), name, JsonSyntaxHighlighterFactory.JSON_PROPERTY_KEY));
|
||||
|
||||
@@ -34,17 +34,18 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @author Irina.Chernushina on 3/31/2016.
|
||||
*/
|
||||
public class JsonSchemaReferenceContributor extends PsiReferenceContributor {
|
||||
private static final PsiElementPattern.Capture<JsonValue> REF_PATTERN = createPropertyValuePattern("$ref", true, false);
|
||||
private static final PsiElementPattern.Capture<JsonValue> REC_REF_PATTERN = createPropertyValuePattern("$recursiveRef", true, false);
|
||||
private static final PsiElementPattern.Capture<JsonValue> SCHEMA_PATTERN = createPropertyValuePattern("$schema", false, true);
|
||||
private static final PsiElementPattern.Capture<JsonStringLiteral> REQUIRED_PROP_PATTERN = createRequiredPropPattern();
|
||||
|
||||
private static class Holder {
|
||||
private static final PsiElementPattern.Capture<JsonValue> REF_PATTERN = createPropertyValuePattern("$ref", true, false);
|
||||
private static final PsiElementPattern.Capture<JsonValue> REC_REF_PATTERN = createPropertyValuePattern("$recursiveRef", true, false);
|
||||
private static final PsiElementPattern.Capture<JsonValue> SCHEMA_PATTERN = createPropertyValuePattern("$schema", false, true);
|
||||
private static final PsiElementPattern.Capture<JsonStringLiteral> REQUIRED_PROP_PATTERN = createRequiredPropPattern();
|
||||
}
|
||||
@Override
|
||||
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
|
||||
registrar.registerReferenceProvider(REF_PATTERN, new JsonPointerReferenceProvider(false));
|
||||
registrar.registerReferenceProvider(REC_REF_PATTERN, new JsonPointerReferenceProvider(false));
|
||||
registrar.registerReferenceProvider(SCHEMA_PATTERN, new JsonPointerReferenceProvider(true));
|
||||
registrar.registerReferenceProvider(REQUIRED_PROP_PATTERN, new JsonRequiredPropsReferenceProvider());
|
||||
registrar.registerReferenceProvider(Holder.REF_PATTERN, new JsonPointerReferenceProvider(false));
|
||||
registrar.registerReferenceProvider(Holder.REC_REF_PATTERN, new JsonPointerReferenceProvider(false));
|
||||
registrar.registerReferenceProvider(Holder.SCHEMA_PATTERN, new JsonPointerReferenceProvider(true));
|
||||
registrar.registerReferenceProvider(Holder.REQUIRED_PROP_PATTERN, new JsonRequiredPropsReferenceProvider());
|
||||
}
|
||||
|
||||
private static PsiElementPattern.Capture<JsonValue> createPropertyValuePattern(
|
||||
|
||||
@@ -465,19 +465,16 @@ public final class DaemonListeners implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
private static class Holder {
|
||||
private static final String myCutActionName = ActionManager.getInstance().getAction(IdeActions.ACTION_EDITOR_CUT).getTemplatePresentation().getText();
|
||||
}
|
||||
private class MyCommandListener implements CommandListener {
|
||||
private final String myCutActionName;
|
||||
|
||||
private MyCommandListener() {
|
||||
myCutActionName = ActionManager.getInstance().getAction(IdeActions.ACTION_EDITOR_CUT).getTemplatePresentation().getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commandStarted(@NotNull CommandEvent event) {
|
||||
Document affectedDocument = extractDocumentFromCommand(event);
|
||||
if (!worthBothering(affectedDocument, event.getProject())) return;
|
||||
|
||||
cutOperationJustHappened = myCutActionName.equals(event.getCommandName());
|
||||
cutOperationJustHappened = Comparing.strEqual(Holder.myCutActionName, event.getCommandName());
|
||||
if (!myDaemonCodeAnalyzer.isRunning()) return;
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("cancelling code highlighting by command:" + event.getCommand());
|
||||
|
||||
@@ -35,10 +35,12 @@ public class I18nReferenceContributor extends PsiReferenceContributor {
|
||||
private static final String INTENTION_ACTION_TAG = "intentionAction";
|
||||
private static final String INTENTION_ACTION_BUNDLE_TAG = "bundleName";
|
||||
|
||||
private static final String CONFIGURABLE_EP = ConfigurableEP.class.getName();
|
||||
private static final String INSPECTION_EP = InspectionEP.class.getName();
|
||||
private static class Holder {
|
||||
private static final String CONFIGURABLE_EP = ConfigurableEP.class.getName();
|
||||
private static final String INSPECTION_EP = InspectionEP.class.getName();
|
||||
|
||||
private static final String TYPE_NAME_EP = TypeNameEP.class.getName();
|
||||
private static final String TYPE_NAME_EP = TypeNameEP.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
|
||||
@@ -49,11 +51,11 @@ public class I18nReferenceContributor extends PsiReferenceContributor {
|
||||
|
||||
private static void registerKeyProviders(PsiReferenceRegistrar registrar) {
|
||||
registrar.registerReferenceProvider(extensionAttributePattern(new String[]{"key", "groupKey"},
|
||||
CONFIGURABLE_EP, INSPECTION_EP),
|
||||
Holder.CONFIGURABLE_EP, Holder.INSPECTION_EP),
|
||||
new PropertyKeyReferenceProvider(false, "groupKey", "groupBundle"));
|
||||
|
||||
registrar.registerReferenceProvider(extensionAttributePattern(new String[]{"resourceKey"},
|
||||
TYPE_NAME_EP),
|
||||
Holder.TYPE_NAME_EP),
|
||||
new PropertyKeyReferenceProvider(false, "resourceKey", "resourceBundle"));
|
||||
|
||||
final XmlTagPattern.Capture intentionActionKeyTagPattern =
|
||||
@@ -78,11 +80,11 @@ public class I18nReferenceContributor extends PsiReferenceContributor {
|
||||
registrar.registerReferenceProvider(resourceBundleTagPattern, bundleReferenceProvider);
|
||||
|
||||
registrar.registerReferenceProvider(extensionAttributePattern(new String[]{"bundle"}, "groupBundle",
|
||||
CONFIGURABLE_EP, INSPECTION_EP),
|
||||
Holder.CONFIGURABLE_EP, Holder.INSPECTION_EP),
|
||||
bundleReferenceProvider);
|
||||
|
||||
registrar.registerReferenceProvider(extensionAttributePattern(new String[]{"resourceBundle"},
|
||||
TYPE_NAME_EP),
|
||||
Holder.TYPE_NAME_EP),
|
||||
bundleReferenceProvider);
|
||||
|
||||
final XmlTagPattern.Capture intentionActionBundleTagPattern =
|
||||
|
||||
+9
-7
@@ -40,12 +40,14 @@ import java.util.List;
|
||||
public class PropertiesReferenceContributor extends PsiReferenceContributor{
|
||||
private static final Logger LOG = Logger.getInstance(PropertiesReferenceContributor.class);
|
||||
|
||||
private static final JavaClassReferenceProvider CLASS_REFERENCE_PROVIDER = new JavaClassReferenceProvider() {
|
||||
@Override
|
||||
public boolean isSoft() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
private static class Holder {
|
||||
private static final JavaClassReferenceProvider CLASS_REFERENCE_PROVIDER = new JavaClassReferenceProvider() {
|
||||
@Override
|
||||
public boolean isSoft() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -117,7 +119,7 @@ public class PropertiesReferenceContributor extends PsiReferenceContributor{
|
||||
String text = element.getText();
|
||||
String[] words = text.split("\\s");
|
||||
if (words.length != 1) return PsiReference.EMPTY_ARRAY;
|
||||
return CLASS_REFERENCE_PROVIDER.getReferencesByString(words[0], element, 0);
|
||||
return Holder.CLASS_REFERENCE_PROVIDER.getReferencesByString(words[0], element, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+30
-27
@@ -25,43 +25,46 @@ import org.jetbrains.annotations.NotNull;
|
||||
import static com.intellij.patterns.XmlPatterns.*;
|
||||
|
||||
public class TestNGSuiteReferenceContributor extends PsiReferenceContributor {
|
||||
private static final XmlAttributeValuePattern ourTestClassPattern =
|
||||
xmlAttributeValue(xmlAttribute("name").withParent(xmlTag().withName("class")
|
||||
.withParent(xmlTag().withName("classes")
|
||||
.withParent(xmlTag().withName("test").withParent(xmlTag().withName("suite"))))));
|
||||
private static class Holder {
|
||||
private static final XmlAttributeValuePattern ourTestClassPattern =
|
||||
xmlAttributeValue(xmlAttribute("name").withParent(xmlTag().withName("class")
|
||||
.withParent(xmlTag().withName("classes")
|
||||
.withParent(xmlTag().withName("test")
|
||||
.withParent(xmlTag().withName("suite"))))));
|
||||
|
||||
private static final XmlAttributeValuePattern ourListenerClassPattern =
|
||||
xmlAttributeValue(xmlAttribute("class-name").withParent(xmlTag().withName("listener")
|
||||
.withParent(xmlTag().withName("listeners")
|
||||
.withParent(xmlTag().withName("suite")))));
|
||||
private static final XmlAttributeValuePattern ourListenerClassPattern =
|
||||
xmlAttributeValue(xmlAttribute("class-name").withParent(xmlTag().withName("listener")
|
||||
.withParent(xmlTag().withName("listeners")
|
||||
.withParent(xmlTag().withName("suite")))));
|
||||
|
||||
private static final XmlAttributeValuePattern ourMethodSelectorPattern =
|
||||
xmlAttributeValue(xmlAttribute("name").withParent(xmlTag().withName("selector-class")
|
||||
.withParent(xmlTag().withName("method-selector")
|
||||
.withParent(xmlTag().withName("method-selectors")
|
||||
.withParent(
|
||||
xmlTag().withName(string().oneOf("suite", "test")))))));
|
||||
private static final XmlAttributeValuePattern ourMethodSelectorPattern =
|
||||
xmlAttributeValue(xmlAttribute("name").withParent(xmlTag().withName("selector-class")
|
||||
.withParent(xmlTag().withName("method-selector")
|
||||
.withParent(xmlTag().withName("method-selectors")
|
||||
.withParent(
|
||||
xmlTag()
|
||||
.withName(string().oneOf("suite", "test")))))));
|
||||
|
||||
private static final XmlAttributeValuePattern ourPackagePattern =
|
||||
xmlAttributeValue(xmlAttribute("name").withParent(xmlTag().withName("package")
|
||||
.withParent(xmlTag().withName("packages")
|
||||
.withParent(xmlTag().withName("suite")))));
|
||||
|
||||
private static final XmlAttributeValuePattern ourSuiteFilePattern =
|
||||
xmlAttributeValue(xmlAttribute("path").withParent(xmlTag().withName("suite-file")
|
||||
.withParent(xmlTag().withName("suite-files")
|
||||
.withParent(xmlTag().withName("suite")))));
|
||||
private static final XmlAttributeValuePattern ourPackagePattern =
|
||||
xmlAttributeValue(xmlAttribute("name").withParent(xmlTag().withName("package")
|
||||
.withParent(xmlTag().withName("packages")
|
||||
.withParent(xmlTag().withName("suite")))));
|
||||
|
||||
private static final XmlAttributeValuePattern ourSuiteFilePattern =
|
||||
xmlAttributeValue(xmlAttribute("path").withParent(xmlTag().withName("suite-file")
|
||||
.withParent(xmlTag().withName("suite-files")
|
||||
.withParent(xmlTag().withName("suite")))));
|
||||
}
|
||||
@Override
|
||||
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
|
||||
registrar.registerReferenceProvider(ourTestClassPattern, new JavaClassReferenceProvider());
|
||||
registrar.registerReferenceProvider(ourListenerClassPattern, new JavaClassReferenceProvider());
|
||||
registrar.registerReferenceProvider(Holder.ourTestClassPattern, new JavaClassReferenceProvider());
|
||||
registrar.registerReferenceProvider(Holder.ourListenerClassPattern, new JavaClassReferenceProvider());
|
||||
|
||||
final JavaClassReferenceProvider methodSelectorProvider = new JavaClassReferenceProvider();
|
||||
methodSelectorProvider.setOption(JavaClassReferenceProvider.EXTEND_CLASS_NAMES, new String[]{"org.testng.IMethodSelector"});
|
||||
registrar.registerReferenceProvider(ourMethodSelectorPattern, methodSelectorProvider);
|
||||
registrar.registerReferenceProvider(Holder.ourMethodSelectorPattern, methodSelectorProvider);
|
||||
|
||||
registrar.registerReferenceProvider(ourSuiteFilePattern, new PathListReferenceProvider(){
|
||||
registrar.registerReferenceProvider(Holder.ourSuiteFilePattern, new PathListReferenceProvider(){
|
||||
@Override
|
||||
protected boolean disableNonSlashedPaths() {
|
||||
return false;
|
||||
|
||||
@@ -19,17 +19,19 @@ import javax.swing.*;
|
||||
* @author oleg
|
||||
*/
|
||||
public class YAMLLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettingsProvider {
|
||||
public static final int[] ALIGN_VALUES = new int[]{
|
||||
YAMLCodeStyleSettings.DO_NOT_ALIGN,
|
||||
YAMLCodeStyleSettings.ALIGN_ON_COLON,
|
||||
YAMLCodeStyleSettings.ALIGN_ON_VALUE
|
||||
};
|
||||
private static class Holder {
|
||||
private static final int[] ALIGN_VALUES = new int[]{
|
||||
YAMLCodeStyleSettings.DO_NOT_ALIGN,
|
||||
YAMLCodeStyleSettings.ALIGN_ON_COLON,
|
||||
YAMLCodeStyleSettings.ALIGN_ON_VALUE
|
||||
};
|
||||
|
||||
public static final String[] ALIGN_OPTIONS = new String[]{
|
||||
YAMLBundle.message("YAMLLanguageCodeStyleSettingsProvider.align.options.no"),
|
||||
YAMLBundle.message("YAMLLanguageCodeStyleSettingsProvider.align.options.colon"),
|
||||
YAMLBundle.message("YAMLLanguageCodeStyleSettingsProvider.align.options.value")
|
||||
};
|
||||
private static final String[] ALIGN_OPTIONS = new String[]{
|
||||
YAMLBundle.message("YAMLLanguageCodeStyleSettingsProvider.align.options.no"),
|
||||
YAMLBundle.message("YAMLLanguageCodeStyleSettingsProvider.align.options.colon"),
|
||||
YAMLBundle.message("YAMLLanguageCodeStyleSettingsProvider.align.options.value")
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customizeDefaults(@NotNull CommonCodeStyleSettings commonSettings,
|
||||
@@ -62,8 +64,8 @@ public class YAMLLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett
|
||||
"ALIGN_VALUES_PROPERTIES",
|
||||
YAMLBundle.message("YAMLLanguageCodeStyleSettingsProvider.align.values"),
|
||||
null,
|
||||
ALIGN_OPTIONS,
|
||||
ALIGN_VALUES);
|
||||
Holder.ALIGN_OPTIONS,
|
||||
Holder.ALIGN_VALUES);
|
||||
|
||||
consumer.showCustomOption(YAMLCodeStyleSettings.class,
|
||||
"SEQUENCE_ON_NEW_LINE",
|
||||
|
||||
@@ -28,17 +28,19 @@ import static com.intellij.patterns.PlatformPatterns.psiElement;
|
||||
* @author yole
|
||||
*/
|
||||
public class PyStdReferenceContributor extends PsiReferenceContributor {
|
||||
public static final PatternCondition<PsiElement> IN_OPTIONAL_PARENTHESIS_INSIDE_ASSIGNMENT =
|
||||
new PatternCondition<PsiElement>("in optional parenthesis inside assignment") {
|
||||
@Override
|
||||
public boolean accepts(@NotNull PsiElement element, ProcessingContext context) {
|
||||
PsiElement parent = element.getParent();
|
||||
while (parent instanceof PyParenthesizedExpression) {
|
||||
parent = parent.getParent();
|
||||
private static class Holder {
|
||||
private static final PatternCondition<PsiElement> IN_OPTIONAL_PARENTHESIS_INSIDE_ASSIGNMENT =
|
||||
new PatternCondition<PsiElement>("in optional parenthesis inside assignment") {
|
||||
@Override
|
||||
public boolean accepts(@NotNull PsiElement element, ProcessingContext context) {
|
||||
PsiElement parent = element.getParent();
|
||||
while (parent instanceof PyParenthesizedExpression) {
|
||||
parent = parent.getParent();
|
||||
}
|
||||
return parent instanceof PyAssignmentStatement;
|
||||
}
|
||||
return parent instanceof PyAssignmentStatement;
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
|
||||
@@ -66,7 +68,7 @@ public class PyStdReferenceContributor extends PsiReferenceContributor {
|
||||
final PsiReferenceProvider provider) {
|
||||
registrar.registerReferenceProvider(psiElement(PyStringLiteralExpression.class)
|
||||
.withParent(psiElement(PySequenceExpression.class)
|
||||
.with(IN_OPTIONAL_PARENTHESIS_INSIDE_ASSIGNMENT)
|
||||
.with(Holder.IN_OPTIONAL_PARENTHESIS_INSIDE_ASSIGNMENT)
|
||||
.inside(true, psiElement(PyAssignmentStatement.class)
|
||||
.withFirstChild(psiElement(PyTargetExpression.class).withName(name)))), provider);
|
||||
}
|
||||
|
||||
+16
-14
@@ -30,25 +30,27 @@ import static com.intellij.patterns.PlatformPatterns.psiElement;
|
||||
|
||||
|
||||
public class PythonFormattedStringReferenceContributor extends PsiReferenceContributor {
|
||||
public static final PsiElementPattern.Capture<PyStringLiteralExpression> PERCENT_STRING_PATTERN =
|
||||
psiElement(PyStringLiteralExpression.class).beforeLeaf(psiElement().withText("%")).withParent(PyBinaryExpression.class);
|
||||
public static final PsiElementPattern.Capture<PyStringLiteralExpression> FORMAT_STRING_PATTERN =
|
||||
psiElement(PyStringLiteralExpression.class)
|
||||
.withParent(psiElement(PyReferenceExpression.class)
|
||||
.with(new PatternCondition<PyReferenceExpression>("isFormatFunction") {
|
||||
static class Holder {
|
||||
private static final PsiElementPattern.Capture<PyStringLiteralExpression> PERCENT_STRING_PATTERN =
|
||||
psiElement(PyStringLiteralExpression.class).beforeLeaf(psiElement().withText("%")).withParent(PyBinaryExpression.class);
|
||||
static final PsiElementPattern.Capture<PyStringLiteralExpression> FORMAT_STRING_PATTERN =
|
||||
psiElement(PyStringLiteralExpression.class)
|
||||
.withParent(psiElement(PyReferenceExpression.class)
|
||||
.with(new PatternCondition<PyReferenceExpression>("isFormatFunction") {
|
||||
|
||||
@Override
|
||||
public boolean accepts(@NotNull PyReferenceExpression expression, ProcessingContext context) {
|
||||
String expressionName = expression.getName();
|
||||
return expressionName != null && expressionName.equals("format");
|
||||
}
|
||||
}))
|
||||
.withSuperParent(2, PyCallExpression.class);
|
||||
@Override
|
||||
public boolean accepts(@NotNull PyReferenceExpression expression, ProcessingContext context) {
|
||||
String expressionName = expression.getName();
|
||||
return expressionName != null && expressionName.equals("format");
|
||||
}
|
||||
}))
|
||||
.withSuperParent(2, PyCallExpression.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
|
||||
|
||||
registrar.registerReferenceProvider(psiElement().andOr(PERCENT_STRING_PATTERN, FORMAT_STRING_PATTERN),
|
||||
registrar.registerReferenceProvider(psiElement().andOr(Holder.PERCENT_STRING_PATTERN, Holder.FORMAT_STRING_PATTERN),
|
||||
new PythonFormattedStringReferenceProvider());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public class PythonFormattedStringReferenceProvider extends PsiReferenceProvider
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiReference[] getReferencesByElement(@NotNull final PsiElement element, @NotNull final ProcessingContext context) {
|
||||
if (PythonFormattedStringReferenceContributor.FORMAT_STRING_PATTERN.accepts(element)) {
|
||||
if (PythonFormattedStringReferenceContributor.Holder.FORMAT_STRING_PATTERN.accepts(element)) {
|
||||
return getReferencesFromFormatString((PyStringLiteralExpression)element);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -15,9 +15,9 @@ import com.jetbrains.python.psi.resolve.PyResolveContext
|
||||
|
||||
class PyRainbowVisitor : RainbowVisitor() {
|
||||
|
||||
companion object {
|
||||
private val IGNORED_NAMES = setOf(PyNames.NONE, PyNames.TRUE, PyNames.FALSE)
|
||||
private val DEFAULT_HIGHLIGHTING_KEY = DefaultLanguageHighlighterColors.LOCAL_VARIABLE
|
||||
object Holder {
|
||||
val IGNORED_NAMES = setOf(PyNames.NONE, PyNames.TRUE, PyNames.FALSE)
|
||||
val DEFAULT_HIGHLIGHTING_KEY = DefaultLanguageHighlighterColors.LOCAL_VARIABLE
|
||||
|
||||
@JvmStatic
|
||||
val HIGHLIGHTING_KEYS: Set<TextAttributesKey> = setOf(PyHighlighter.PY_PARAMETER, DEFAULT_HIGHLIGHTING_KEY)
|
||||
@@ -59,7 +59,7 @@ class PyRainbowVisitor : RainbowVisitor() {
|
||||
|
||||
private fun getReferenceContext(referenceExpression: PyReferenceExpression,
|
||||
visitedReferenceExpressions: MutableSet<PyReferenceExpression>): PsiElement? {
|
||||
if (referenceExpression.isQualified || referenceExpression.name in IGNORED_NAMES) return null
|
||||
if (referenceExpression.isQualified || referenceExpression.name in Holder.IGNORED_NAMES) return null
|
||||
|
||||
val resolved = referenceExpression.reference.resolve()
|
||||
return when (resolved) {
|
||||
@@ -74,7 +74,7 @@ class PyRainbowVisitor : RainbowVisitor() {
|
||||
}
|
||||
|
||||
private fun getTargetContext(targetExpression: PyTargetExpression): PsiElement? {
|
||||
if (targetExpression.isQualified || targetExpression.name in IGNORED_NAMES) return null
|
||||
if (targetExpression.isQualified || targetExpression.name in Holder.IGNORED_NAMES) return null
|
||||
|
||||
val parent = targetExpression.parent
|
||||
if (parent is PyGlobalStatement) return targetExpression.containingFile
|
||||
@@ -111,7 +111,7 @@ class PyRainbowVisitor : RainbowVisitor() {
|
||||
|
||||
private fun updateNameIfGlobal(context: PsiElement, name: String?) = if (context is PyFile && name != null) "global_$name" else name
|
||||
|
||||
private fun addInfo(context: PsiElement, rainbowElement: PsiElement, name: String, key: TextAttributesKey? = DEFAULT_HIGHLIGHTING_KEY) {
|
||||
private fun addInfo(context: PsiElement, rainbowElement: PsiElement, name: String, key: TextAttributesKey? = Holder.DEFAULT_HIGHLIGHTING_KEY) {
|
||||
addInfo(getInfo(context, rainbowElement, name, key))
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ public class PythonColorsPage implements RainbowColorSettingsPage, InspectionCol
|
||||
|
||||
@Override
|
||||
public boolean isRainbowType(TextAttributesKey type) {
|
||||
return PyRainbowVisitor.getHIGHLIGHTING_KEYS().contains(type);
|
||||
return PyRainbowVisitor.Holder.getHIGHLIGHTING_KEYS().contains(type);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -15,18 +15,19 @@ import static com.intellij.patterns.XmlPatterns.*;
|
||||
* @author peter
|
||||
*/
|
||||
public class RelaxNGReferenceContributor extends PsiReferenceContributor {
|
||||
private static final XmlNamedElementPattern RNG_TAG_PATTERN = xmlTag().withNamespace(RelaxNgMetaDataContributor.RNG_NAMESPACE);
|
||||
private static class Holder {
|
||||
private static final XmlNamedElementPattern RNG_TAG_PATTERN = xmlTag().withNamespace(RelaxNgMetaDataContributor.RNG_NAMESPACE);
|
||||
|
||||
private static final XmlNamedElementPattern.XmlAttributePattern NAME_ATTR_PATTERN = xmlAttribute("name");
|
||||
|
||||
private static final XmlNamedElementPattern.XmlAttributePattern NAME_PATTERN = NAME_ATTR_PATTERN.withParent(
|
||||
RNG_TAG_PATTERN.withLocalName("element", "attribute"));
|
||||
private static final XmlNamedElementPattern.XmlAttributePattern NAME_ATTR_PATTERN = xmlAttribute("name");
|
||||
|
||||
private static final XmlNamedElementPattern.XmlAttributePattern NAME_PATTERN = NAME_ATTR_PATTERN.withParent(
|
||||
RNG_TAG_PATTERN.withLocalName("element", "attribute"));
|
||||
}
|
||||
@Override
|
||||
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
|
||||
XmlUtil.registerXmlAttributeValueReferenceProvider(registrar, new String[]{
|
||||
"name"
|
||||
}, new PatternFilter(xmlAttributeValue().withParent(NAME_PATTERN)), true, new PrefixReferenceProvider());
|
||||
}, new PatternFilter(xmlAttributeValue().withParent(Holder.NAME_PATTERN)), true, new PrefixReferenceProvider());
|
||||
|
||||
// final XmlAttributeValuePattern id = xmlAttributeValue().withParent(xmlAttribute()).with(IdRefProvider.HAS_ID_REF_TYPE);
|
||||
// final XmlAttributeValuePattern idref = xmlAttributeValue().withParent(xmlAttribute()).with(IdRefProvider.HAS_ID_TYPE);
|
||||
|
||||
+9
-7
@@ -49,12 +49,14 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV
|
||||
|
||||
private static boolean ourDoJaxpTesting;
|
||||
|
||||
private static final TextAttributes NONEMPTY_TEXT_ATTRIBUTES = new TextAttributes() {
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
private static class Holder {
|
||||
private static final TextAttributes NONEMPTY_TEXT_ATTRIBUTES = new TextAttributes() {
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
private HighlightInfoHolder myHolder;
|
||||
|
||||
public XmlHighlightVisitor() {
|
||||
@@ -187,7 +189,7 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV
|
||||
HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(warning).range(childByRole, startOffset, startOffset + length).descriptionAndTooltip(localizedMessage).create();
|
||||
|
||||
if (highlightInfo == null) {
|
||||
highlightInfo = HighlightInfo.newHighlightInfo(warning).range(new TextRange(startOffset, startOffset + length)).textAttributes(NONEMPTY_TEXT_ATTRIBUTES).descriptionAndTooltip(localizedMessage).create();
|
||||
highlightInfo = HighlightInfo.newHighlightInfo(warning).range(new TextRange(startOffset, startOffset + length)).textAttributes(Holder.NONEMPTY_TEXT_ATTRIBUTES).descriptionAndTooltip(localizedMessage).create();
|
||||
}
|
||||
|
||||
for (final IntentionAction quickFixAction : quickFixActions) {
|
||||
|
||||
@@ -35,51 +35,56 @@ import static com.intellij.psi.xml.XmlTokenType.*;
|
||||
|
||||
public class XmlFileHighlighter extends SyntaxHighlighterBase {
|
||||
static final ExtensionPointName<EmbeddedTokenHighlighter> EMBEDDED_HIGHLIGHTERS = ExtensionPointName.create("com.intellij.embeddedTokenHighlighter");
|
||||
private static final MultiMap<IElementType, TextAttributesKey> ourMap = MultiMap.create();
|
||||
private static class Holder {
|
||||
private static final MultiMap<IElementType, TextAttributesKey> ourMap = MultiMap.create();
|
||||
|
||||
static {
|
||||
ourMap.putValue(XML_DATA_CHARACTERS, XmlHighlighterColors.XML_TAG_DATA);
|
||||
static {
|
||||
ourMap.putValue(XML_DATA_CHARACTERS, XmlHighlighterColors.XML_TAG_DATA);
|
||||
|
||||
for (IElementType type : ContainerUtil.ar(XML_COMMENT_START, XML_COMMENT_END, XML_COMMENT_CHARACTERS,
|
||||
XML_CONDITIONAL_COMMENT_END, XML_CONDITIONAL_COMMENT_END_START,
|
||||
XML_CONDITIONAL_COMMENT_START, XML_CONDITIONAL_COMMENT_START_END)) {
|
||||
ourMap.putValue(type, XmlHighlighterColors.XML_COMMENT);
|
||||
}
|
||||
for (IElementType type : ContainerUtil.ar(XML_COMMENT_START, XML_COMMENT_END, XML_COMMENT_CHARACTERS,
|
||||
XML_CONDITIONAL_COMMENT_END, XML_CONDITIONAL_COMMENT_END_START,
|
||||
XML_CONDITIONAL_COMMENT_START, XML_CONDITIONAL_COMMENT_START_END)) {
|
||||
ourMap.putValue(type, XmlHighlighterColors.XML_COMMENT);
|
||||
}
|
||||
|
||||
for (IElementType type : ContainerUtil.ar(XML_START_TAG_START, XML_END_TAG_START, XML_TAG_END, XML_EMPTY_ELEMENT_END, TAG_WHITE_SPACE)) {
|
||||
ourMap.putValue(type, XmlHighlighterColors.XML_TAG);
|
||||
}
|
||||
for (IElementType type : ContainerUtil.ar(XML_TAG_NAME, XML_CONDITIONAL_IGNORE, XML_CONDITIONAL_INCLUDE)) {
|
||||
ourMap.putValues(type, Arrays.asList(XmlHighlighterColors.XML_TAG, XmlHighlighterColors.XML_TAG_NAME));
|
||||
}
|
||||
ourMap.putValues(XML_NAME, Arrays.asList(XmlHighlighterColors.XML_TAG, XmlHighlighterColors.XML_ATTRIBUTE_NAME));
|
||||
for (IElementType type : ContainerUtil.ar(XML_EQ, XML_TAG_CHARACTERS,
|
||||
XML_ATTRIBUTE_VALUE_TOKEN, XML_ATTRIBUTE_VALUE_START_DELIMITER, XML_ATTRIBUTE_VALUE_END_DELIMITER)) {
|
||||
ourMap.putValues(type, Arrays.asList(XmlHighlighterColors.XML_TAG, XmlHighlighterColors.XML_ATTRIBUTE_VALUE));
|
||||
}
|
||||
for (IElementType type : ContainerUtil
|
||||
.ar(XML_START_TAG_START, XML_END_TAG_START, XML_TAG_END, XML_EMPTY_ELEMENT_END, TAG_WHITE_SPACE)) {
|
||||
ourMap.putValue(type, XmlHighlighterColors.XML_TAG);
|
||||
}
|
||||
for (IElementType type : ContainerUtil.ar(XML_TAG_NAME, XML_CONDITIONAL_IGNORE, XML_CONDITIONAL_INCLUDE)) {
|
||||
ourMap.putValues(type, Arrays.asList(XmlHighlighterColors.XML_TAG, XmlHighlighterColors.XML_TAG_NAME));
|
||||
}
|
||||
ourMap.putValues(XML_NAME, Arrays.asList(XmlHighlighterColors.XML_TAG, XmlHighlighterColors.XML_ATTRIBUTE_NAME));
|
||||
for (IElementType type : ContainerUtil.ar(XML_EQ, XML_TAG_CHARACTERS,
|
||||
XML_ATTRIBUTE_VALUE_TOKEN, XML_ATTRIBUTE_VALUE_START_DELIMITER,
|
||||
XML_ATTRIBUTE_VALUE_END_DELIMITER)) {
|
||||
ourMap.putValues(type, Arrays.asList(XmlHighlighterColors.XML_TAG, XmlHighlighterColors.XML_ATTRIBUTE_VALUE));
|
||||
}
|
||||
|
||||
for (IElementType type : ContainerUtil.ar(XML_DECL_START, XML_DOCTYPE_START, XML_DOCTYPE_SYSTEM, XML_DOCTYPE_PUBLIC,
|
||||
XML_ATTLIST_DECL_START, XML_ELEMENT_DECL_START, XML_ENTITY_DECL_START)) {
|
||||
ourMap.putValues(type, Arrays.asList(XmlHighlighterColors.XML_TAG, XmlHighlighterColors.XML_TAG_NAME));
|
||||
}
|
||||
for (IElementType type : ContainerUtil.ar(XML_DECL_START, XML_DOCTYPE_START, XML_DOCTYPE_SYSTEM, XML_DOCTYPE_PUBLIC,
|
||||
XML_ATTLIST_DECL_START, XML_ELEMENT_DECL_START, XML_ENTITY_DECL_START)) {
|
||||
ourMap.putValues(type, Arrays.asList(XmlHighlighterColors.XML_TAG, XmlHighlighterColors.XML_TAG_NAME));
|
||||
}
|
||||
|
||||
for (IElementType type : ContainerUtil.ar(XML_CONDITIONAL_SECTION_START, XML_CONDITIONAL_SECTION_END, XML_DECL_END, XML_DOCTYPE_END)) {
|
||||
ourMap.putValues(type, Arrays.asList(XmlHighlighterColors.XML_PROLOGUE, XmlHighlighterColors.XML_TAG_NAME));
|
||||
}
|
||||
for (IElementType type : ContainerUtil
|
||||
.ar(XML_CONDITIONAL_SECTION_START, XML_CONDITIONAL_SECTION_END, XML_DECL_END, XML_DOCTYPE_END)) {
|
||||
ourMap.putValues(type, Arrays.asList(XmlHighlighterColors.XML_PROLOGUE, XmlHighlighterColors.XML_TAG_NAME));
|
||||
}
|
||||
|
||||
ourMap.putValue(XML_PI_START, XmlHighlighterColors.XML_PROLOGUE);
|
||||
ourMap.putValue(XML_PI_END, XmlHighlighterColors.XML_PROLOGUE);
|
||||
ourMap.putValue(XML_PI_START, XmlHighlighterColors.XML_PROLOGUE);
|
||||
ourMap.putValue(XML_PI_END, XmlHighlighterColors.XML_PROLOGUE);
|
||||
|
||||
ourMap.putValue(XML_CHAR_ENTITY_REF, XmlHighlighterColors.XML_ENTITY_REFERENCE);
|
||||
ourMap.putValue(XML_ENTITY_REF_TOKEN, XmlHighlighterColors.XML_ENTITY_REFERENCE);
|
||||
ourMap.putValue(XML_CHAR_ENTITY_REF, XmlHighlighterColors.XML_ENTITY_REFERENCE);
|
||||
ourMap.putValue(XML_ENTITY_REF_TOKEN, XmlHighlighterColors.XML_ENTITY_REFERENCE);
|
||||
|
||||
ourMap.putValue(XML_BAD_CHARACTER, HighlighterColors.BAD_CHARACTER);
|
||||
ourMap.putValue(XML_BAD_CHARACTER, HighlighterColors.BAD_CHARACTER);
|
||||
|
||||
for (EmbeddedTokenHighlighter highlighter : EMBEDDED_HIGHLIGHTERS.getExtensionList()) {
|
||||
MultiMap<IElementType, TextAttributesKey> attributes = highlighter.getEmbeddedTokenAttributes();
|
||||
for (Map.Entry<IElementType, Collection<TextAttributesKey>> entry : attributes.entrySet()) {
|
||||
if (!ourMap.containsKey(entry.getKey())) {
|
||||
ourMap.putValues(entry.getKey(), entry.getValue());
|
||||
for (EmbeddedTokenHighlighter highlighter : EMBEDDED_HIGHLIGHTERS.getExtensionList()) {
|
||||
MultiMap<IElementType, TextAttributesKey> attributes = highlighter.getEmbeddedTokenAttributes();
|
||||
for (Map.Entry<IElementType, Collection<TextAttributesKey>> entry : attributes.entrySet()) {
|
||||
if (!ourMap.containsKey(entry.getKey())) {
|
||||
ourMap.putValues(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,7 +123,7 @@ public class XmlFileHighlighter extends SyntaxHighlighterBase {
|
||||
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
|
||||
//noinspection SynchronizationOnGetClass,SynchronizeOnThis
|
||||
synchronized (getClass()) {
|
||||
return ourMap.get(tokenType).toArray(TextAttributesKey.EMPTY_ARRAY);
|
||||
return Holder.ourMap.get(tokenType).toArray(TextAttributesKey.EMPTY_ARRAY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,9 +133,9 @@ public class XmlFileHighlighter extends SyntaxHighlighterBase {
|
||||
@Deprecated
|
||||
public static synchronized void registerEmbeddedTokenAttributes(Map<IElementType, TextAttributesKey> _keys1,
|
||||
Map<IElementType, TextAttributesKey> _keys2) {
|
||||
HashSet<IElementType> existingKeys = new HashSet<>(ourMap.keySet());
|
||||
addMissing(_keys1, existingKeys, ourMap);
|
||||
addMissing(_keys2, existingKeys, ourMap);
|
||||
HashSet<IElementType> existingKeys = new HashSet<>(Holder.ourMap.keySet());
|
||||
addMissing(_keys1, existingKeys, Holder.ourMap);
|
||||
addMissing(_keys2, existingKeys, Holder.ourMap);
|
||||
}
|
||||
|
||||
static void addMissing(Map<IElementType, TextAttributesKey> from, Set<IElementType> existingKeys, MultiMap<IElementType, TextAttributesKey> to) {
|
||||
|
||||
Reference in New Issue
Block a user