IDEA-216532 Theme metadata: new property "since"

GitOrigin-RevId: 41f5e0dfb1212e8978db24cde3aad422c63308d8
This commit is contained in:
Yann Cébron
2019-07-02 06:52:16 +03:00
committed by intellij-monorepo-bot
parent 1372de2b19
commit d1ee8fef17
4 changed files with 30 additions and 4 deletions
@@ -31,6 +31,8 @@ public class UIThemeMetadata {
private boolean deprecated;
private String since;
public boolean isDeprecated() {
return deprecated;
}
@@ -49,6 +51,11 @@ public class UIThemeMetadata {
return source;
}
@Nullable
public String getSince() {
return since;
}
@SuppressWarnings("unused")
private void setKey(String key) {
this.key = key;
@@ -69,6 +76,11 @@ public class UIThemeMetadata {
this.source = source;
}
@SuppressWarnings("unused")
public void setSince(String since) {
this.since = since;
}
@Override
public String toString() {
return "UIKeyMetadata{" +
@@ -76,6 +88,7 @@ public class UIThemeMetadata {
", description='" + description + '\'' +
", source='" + source + '\'' +
", deprecated=" + deprecated +
", since='" + since + '\'' +
'}';
}
}
@@ -1,5 +1,5 @@
{
"version": "0.1",
"version": "0.2",
"type": "object",
"$schema": "http://json-schema.org/draft-07/schema#",
"required": [
@@ -46,6 +46,13 @@
"type": "boolean",
"description": "Whether this key is deprecated. Note replacement (if any) in description.",
"default": false
},
"since": {
"type": "string",
"description": "Version in which key was introduced.",
"examples": [
"2019.2"
]
}
},
"required": [
@@ -103,13 +103,14 @@ public class ThemeJsonCompletionContributor extends CompletionContributor {
final String description = uiKeyMetadata.getDescription();
final boolean deprecated = uiKeyMetadata.isDeprecated();
final String source = uiKeyMetadata.getSource();
final String tailText = (StringUtil.isEmpty(description) ? "" : " (" + description + ")") +
(StringUtil.isEmpty(source) ? "" : " in " + source);
final String since = uiKeyMetadata.getSince();
final LookupElementBuilder builder =
LookupElementBuilder.create(completionKey)
.withPresentableText(key)
.withStrikeoutness(deprecated)
.withTailText(tailText, true)
.appendTailText(StringUtil.isEmpty(since) ? "" : " [" + since + "]", true)
.appendTailText(StringUtil.isEmpty(description) ? "" : " (" + description + ")", true)
.appendTailText(StringUtil.isEmpty(source) ? "" : " in " + source, true)
.withTypeText("[" + ObjectUtils.chooseNotNull(themeMetadata.getName(), themeMetadata.getPluginId()) + "]")
.withInsertHandler(shouldSurroundWithQuotes ? MyInsertHandler.SURROUND_WITH_QUOTES : MyInsertHandler.INSTANCE);
@@ -65,6 +65,11 @@ public class ThemeJsonDocumentationProvider extends AbstractDocumentationProvide
});
}
final String since = uiKeyMetadata.getSince();
if (since != null) {
appendSection(sb, "Since", since);
}
sb.append(DocumentationMarkup.SECTIONS_END);
return sb.toString();
}