Search in sources :

Example 1 with JsonFile

use of com.intellij.json.psi.JsonFile in project intellij-community by JetBrains.

the class JsonSchemaReader method create.

@Nullable
public static JsonSchemaReader create(@NotNull Project project, @NotNull VirtualFile key) {
    final PsiFile psiFile = PsiManager.getInstance(project).findFile(key);
    if (!(psiFile instanceof JsonFile))
        return null;
    final List<JsonValue> values = ((JsonFile) psiFile).getAllTopLevelValues();
    if (values.size() != 1 || !(values.get(0) instanceof JsonObject))
        return null;
    return new JsonSchemaReader((JsonObject) values.get(0));
}
Also used : JsonValue(com.intellij.json.psi.JsonValue) JsonFile(com.intellij.json.psi.JsonFile) JsonObject(com.intellij.json.psi.JsonObject) PsiFile(com.intellij.psi.PsiFile) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with JsonFile

use of com.intellij.json.psi.JsonFile in project intellij-community by JetBrains.

the class JsonSmartEnterProcessor method collectAdditionalElements.

@Override
protected void collectAdditionalElements(@NotNull PsiElement element, @NotNull List<PsiElement> result) {
    // include all parents as well
    PsiElement parent = element.getParent();
    while (parent != null && !(parent instanceof JsonFile)) {
        result.add(parent);
        parent = parent.getParent();
    }
}
Also used : JsonFile(com.intellij.json.psi.JsonFile) PsiElement(com.intellij.psi.PsiElement)

Aggregations

JsonFile (com.intellij.json.psi.JsonFile)2 JsonObject (com.intellij.json.psi.JsonObject)1 JsonValue (com.intellij.json.psi.JsonValue)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 Nullable (org.jetbrains.annotations.Nullable)1