mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
WEB-25928 webpack config inspection incorrectly flags "empty" as invalid value for node.fs
This commit is contained in:
@@ -356,14 +356,26 @@ public class JsonBySchemaObjectAnnotator implements Annotator {
|
||||
private void checkForEnum(PsiElement value, JsonSchemaObject schema) {
|
||||
//enum values + pattern -> don't check enum values
|
||||
if (schema.getEnum() == null || schema.getPattern() != null) return;
|
||||
final String text = value.getText();
|
||||
final String text = StringUtil.notNullize(value.getText());
|
||||
final List<Object> objects = schema.getEnum();
|
||||
for (Object object : objects) {
|
||||
if (object.toString().equalsIgnoreCase(text)) return;
|
||||
if (myWalker.onlyDoubleQuotesForStringLiterals()) {
|
||||
if (object.toString().equalsIgnoreCase(text)) return;
|
||||
} else {
|
||||
if (equalsIgnoreQuotesAndCase(object.toString(), text)) return;
|
||||
}
|
||||
}
|
||||
error("Value should be one of: [" + StringUtil.join(objects, o -> o.toString(), ", ") + "]", value);
|
||||
}
|
||||
|
||||
private static boolean equalsIgnoreQuotesAndCase(@NotNull final String s1, @NotNull final String s2) {
|
||||
final boolean quoted1 = StringUtil.isQuotedString(s1);
|
||||
final boolean quoted2 = StringUtil.isQuotedString(s2);
|
||||
if (quoted1 != quoted2) return false;
|
||||
if (!quoted1) return s1.equalsIgnoreCase(s2);
|
||||
return StringUtil.unquoteString(s1).equalsIgnoreCase(StringUtil.unquoteString(s2));
|
||||
}
|
||||
|
||||
private void checkArray(JsonValueAdapter value, JsonSchemaObject schema) {
|
||||
final JsonArrayValueAdapter asArray = value.getAsArray();
|
||||
if (asArray == null) return;
|
||||
|
||||
@@ -32,6 +32,7 @@ public interface JsonLikePsiWalker {
|
||||
PsiElement goUpToCheckable(@NotNull final PsiElement element);
|
||||
List<JsonSchemaWalker.Step> findPosition(@NotNull final PsiElement element, boolean isName, boolean forceLastTransition);
|
||||
boolean isNameQuoted();
|
||||
boolean onlyDoubleQuotesForStringLiterals();
|
||||
boolean hasPropertiesBehindAndNoComma(@NotNull PsiElement element);
|
||||
Set<String> getPropertyNamesOfParentObject(@NotNull PsiElement element);
|
||||
@Nullable JsonPropertyAdapter getParentPropertyAdapter(@NotNull PsiElement element);
|
||||
|
||||
@@ -121,6 +121,11 @@ public class JsonOriginalPsiWalker implements JsonLikePsiWalker {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onlyDoubleQuotesForStringLiterals() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPropertiesBehindAndNoComma(@NotNull PsiElement element) {
|
||||
PsiElement current = element instanceof JsonProperty ? element : PsiTreeUtil.getParentOfType(element, JsonProperty.class);
|
||||
|
||||
Reference in New Issue
Block a user