mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-283327 DevKit: code insight for com.intellij.advancedSetting EP 'id' attribute
GitOrigin-RevId: d12e291f8e7c7c0a73489a844419aec46b01c7dc
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b4bc414901
commit
65eda74ef4
@@ -34,6 +34,7 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.devkit.DevKitBundle;
|
||||
import org.jetbrains.idea.devkit.dom.*;
|
||||
import org.jetbrains.idea.devkit.references.MessageBundleReferenceContributor;
|
||||
import org.jetbrains.idea.devkit.util.PsiUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -41,8 +42,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.patterns.StandardPatterns.or;
|
||||
import static com.intellij.patterns.XmlPatterns.xmlAttributeValue;
|
||||
import static com.intellij.patterns.XmlPatterns.xmlTag;
|
||||
import static com.intellij.patterns.XmlPatterns.*;
|
||||
|
||||
public class I18nReferenceContributor extends PsiReferenceContributor {
|
||||
|
||||
@@ -117,8 +117,17 @@ public class I18nReferenceContributor extends PsiReferenceContributor {
|
||||
Holder.SPRING_TOOL_WINDOW_CONTENT),
|
||||
new PropertyKeyReferenceProvider(false, "displayName", "bundle"));
|
||||
|
||||
registrar.registerReferenceProvider(extensionAttributePattern(new String[]{"groupKey"}, Holder.ADVANCED_SETTINGS_EP),
|
||||
new PropertyKeyReferenceProvider(false, "groupKey", null) {
|
||||
|
||||
XmlAttributeValuePattern idAttributeWithoutTitleKeyPattern =
|
||||
extensionAttributePattern(new String[]{"id"}, Holder.ADVANCED_SETTINGS_EP)
|
||||
.andNot(xmlAttributeValue().withSuperParent(2, xmlTag().withChild(xmlAttribute("titleKey"))));
|
||||
registrar.registerReferenceProvider(idAttributeWithoutTitleKeyPattern,
|
||||
new PropertyKeyReferenceProvider(false, "id", null) {
|
||||
@Override
|
||||
protected @NotNull String getFinalKeyValue(String keyValue) {
|
||||
return MessageBundleReferenceContributor.ADVANCED_SETTING + keyValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFallbackBundleName() {
|
||||
return ApplicationBundle.BUNDLE;
|
||||
@@ -131,6 +140,13 @@ public class I18nReferenceContributor extends PsiReferenceContributor {
|
||||
return ApplicationBundle.BUNDLE;
|
||||
}
|
||||
});
|
||||
registrar.registerReferenceProvider(extensionAttributePattern(new String[]{"groupKey"}, Holder.ADVANCED_SETTINGS_EP),
|
||||
new PropertyKeyReferenceProvider(false, "groupKey", null) {
|
||||
@Override
|
||||
protected String getFallbackBundleName() {
|
||||
return ApplicationBundle.BUNDLE;
|
||||
}
|
||||
});
|
||||
registrar.registerReferenceProvider(extensionAttributePattern(new String[]{"descriptionKey"}, Holder.ADVANCED_SETTINGS_EP),
|
||||
new PropertyKeyReferenceProvider(false, "descriptionKey", null) {
|
||||
@Override
|
||||
|
||||
@@ -93,7 +93,7 @@ class PropertyKeyReferenceProvider extends PsiReferenceProvider {
|
||||
}
|
||||
|
||||
if (value != null) {
|
||||
return new PsiReference[]{new MyPropertyReference(value, element, bundle, getFallbackBundleName())};
|
||||
return new PsiReference[]{new MyPropertyReference(getFinalKeyValue(value), element, bundle, getFallbackBundleName())};
|
||||
}
|
||||
}
|
||||
return PsiReference.EMPTY_ARRAY;
|
||||
@@ -104,6 +104,11 @@ class PropertyKeyReferenceProvider extends PsiReferenceProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected String getFinalKeyValue(String keyValue) {
|
||||
return keyValue;
|
||||
}
|
||||
|
||||
private PsiReference[] getTagReferences(XmlTag element) {
|
||||
final XmlTag parent = PsiTreeUtil.getParentOfType(element, XmlTag.class);
|
||||
if (parent == null) return PsiReference.EMPTY_ARRAY;
|
||||
|
||||
@@ -53,7 +53,7 @@ public final class MessageBundleReferenceContributor extends PsiReferenceContrib
|
||||
@NonNls private static final String TEXT = ".text";
|
||||
@NonNls private static final String DESCRIPTION = ".description";
|
||||
@NonNls private static final String TRAILING_LABEL = ".trailingLabel";
|
||||
@NonNls private static final String ADVANCED_SETTING = "advanced.setting.";
|
||||
@NonNls public static final String ADVANCED_SETTING = "advanced.setting.";
|
||||
@NonNls public static final String BUNDLE_PROPERTIES = "Bundle.properties";
|
||||
|
||||
@NonNls private static final String TOOLWINDOW_STRIPE_PREFIX = "toolwindow.stripe.";
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
my.key=My Text
|
||||
my.key=My Text
|
||||
advanced.setting.mySettingKey=Advanced Setting Key
|
||||
@@ -87,6 +87,11 @@
|
||||
key="<error descr="Cannot resolve property key">INVALID_KEY</error>"
|
||||
bundle="<error descr="Cannot resolve property bundle">INVALID_BUNDLE</error>"/>
|
||||
|
||||
<!-- 'id' = property key if 'titleKey' is not present -->
|
||||
<advancedSetting id="<error descr="Cannot resolve property key">INVALID_KEY</error>"
|
||||
default="dummy"/>
|
||||
<advancedSetting id="mySettingKey" default="this key exists"/>
|
||||
|
||||
<advancedSetting id="myAdvancedSetting"
|
||||
default="dummy"
|
||||
bundle="MyBundle"
|
||||
|
||||
Reference in New Issue
Block a user