JsonSchemaCompletionContributor and PsiReferenceContributor
Answered
Hi.
I realized PsiReferenceContributor for JSON language. Also I realized getVariants method in PsiReferenceProvider for code completion and it's work great (Go To declaration, code completion).
But if I choose JSON schema for file, code completion did not work and getVariants never call.
I think this is because getVariants called from the LegacyCompletionContributor which called after the JsonSchemaCompletionContributor. JsonSchemaCompletionContributor stopping the execution chain if JSON file has JSON schema.
public static void doCompletion(@NotNull final CompletionParameters parameters,
@NotNull final CompletionResultSet result,
@NotNull final JsonSchemaObject rootSchema) {
doCompletion(parameters, result, rootSchema, true);
}
public static void doCompletion(@NotNull final CompletionParameters parameters,
@NotNull final CompletionResultSet result,
@NotNull final JsonSchemaObject rootSchema,
boolean stop) {
final PsiElement completionPosition = parameters.getOriginalPosition() != null ? parameters.getOriginalPosition() :
parameters.getPosition();
new Worker(rootSchema, parameters.getPosition(), completionPosition, result).work();
if (stop) {
result.stopHere();
}
}
Is it a bug or is there a way to perform getVariants with JSON schema?
Please sign in to leave a comment.
You could use com.jetbrains.jsonSchema.remote.JsonSchemaCatalogExclusion to disable JSON scheme completely for your file(s).