mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
[json] schema - properly handle quoted items in completion for non-json languages
GitOrigin-RevId: d290f06dceaf2a0a3733ab8e2e6fbda8df61de06
This commit is contained in:
committed by
intellij-monorepo-bot
parent
267e5f22cf
commit
1649edc73c
@@ -39,6 +39,8 @@ public interface JsonLikePsiWalker {
|
||||
boolean allowsSingleQuotes();
|
||||
default boolean isValidIdentifier(String string, Project project) { return true; }
|
||||
|
||||
default boolean isQuotedString(@NotNull PsiElement element) { return false; }
|
||||
|
||||
boolean hasMissingCommaAfter(@NotNull PsiElement element);
|
||||
|
||||
Set<String> getPropertyNamesOfParentObject(@NotNull PsiElement originalPosition, PsiElement computedPosition);
|
||||
|
||||
@@ -40,6 +40,11 @@ public class JsonOriginalPsiWalker implements JsonLikePsiWalker {
|
||||
&& JsonDialectUtil.isStandardJson(CompletionUtil.getOriginalOrSelf(parent));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isQuotedString(@NotNull PsiElement element) {
|
||||
return element instanceof JsonStringLiteral;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThreeState isName(PsiElement element) {
|
||||
final PsiElement parent = element.getParent();
|
||||
|
||||
@@ -157,9 +157,14 @@ public final class JsonSchemaCompletionContributor extends CompletionContributor
|
||||
myProject = originalPosition.getProject();
|
||||
myResultConsumer = resultConsumer;
|
||||
myVariants = new HashSet<>();
|
||||
myWalker = JsonLikePsiWalker.getWalker(myPosition, myRootSchema);
|
||||
myWrapInQuotes = !(position.getParent() instanceof JsonStringLiteral);
|
||||
myInsideStringLiteral = position.getParent() instanceof JsonStringLiteral;
|
||||
JsonLikePsiWalker psiWalker = JsonLikePsiWalker.getWalker(myPosition, myRootSchema);
|
||||
PsiElement positionParent = position.getParent();
|
||||
boolean isInsideQuotedString = positionParent != null
|
||||
&& psiWalker != null
|
||||
&& psiWalker.isQuotedString(positionParent);
|
||||
myWrapInQuotes = !isInsideQuotedString;
|
||||
myWalker = psiWalker;
|
||||
myInsideStringLiteral = isInsideQuotedString;
|
||||
}
|
||||
|
||||
public void work() {
|
||||
|
||||
@@ -41,6 +41,11 @@ public final class YamlJsonPsiWalker implements JsonLikePsiWalker {
|
||||
private YamlJsonPsiWalker() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isQuotedString(@NotNull PsiElement element) {
|
||||
return element instanceof YAMLQuotedText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThreeState isName(PsiElement element) {
|
||||
PsiElement parent = element.getParent();
|
||||
|
||||
Reference in New Issue
Block a user