// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.idea.devkit.themes;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.jetbrains.jsonSchema.extension.JsonSchemaFileProvider;
import com.jetbrains.jsonSchema.extension.JsonSchemaProviderFactory;
import com.jetbrains.jsonSchema.extension.SchemaType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Collections;
import java.util.List;

/**
 * @author Konstantin Bulenkov
 */
public class ThemeJsonSchemaProviderFactory implements JsonSchemaProviderFactory {
  private static final String THEME_SCHEMA = "/schemes/theme.schema.json";

  @NotNull
  @Override
  public List<JsonSchemaFileProvider> getProviders(@NotNull Project project) {
    return Collections.singletonList(new JsonSchemaFileProvider() {
      @Override
      public boolean isAvailable(@NotNull VirtualFile file) {
        return file.getName().endsWith(".theme.json");
      }

      @NotNull
      @Override
      public String getName() {
        return "IntelliJ Themes";
      }

      @Nullable
      @Override
      public VirtualFile getSchemaFile() {
        return VfsUtil.findFileByURL(getClass().getResource(THEME_SCHEMA));
      }

      @NotNull
      @Override
      public SchemaType getSchemaType() {
        return SchemaType.embeddedSchema;
      }
    });
  }
}

@@ -581,16 +581,63 @@
 ullable;
+%0Aimport org.jetbrains.idea.devkit.util.PsiUtil;
 %0A%0Aimport
@@ -980,24 +980,114 @@
  project) %7B%0A
+    if (!PsiUtil.isPluginProject(project)) %7B%0A      return Collections.emptyList();%0A    %7D%0A%0A
     return C

enable theme json schema provider for plugin projects only