• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JsonFile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.json.psi.JsonFile的典型用法代码示例。如果您正苦于以下问题:Java JsonFile类的具体用法?Java JsonFile怎么用?Java JsonFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JsonFile类属于com.intellij.json.psi包,在下文中一共展示了JsonFile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getHomePage

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
private static String getHomePage(PsiDirectory directory) {
    PsiFile pkg = directory.findFile("package.json");
    if (pkg != null && pkg instanceof JsonFile) {
        if (((JsonFile) pkg).getTopLevelValue() instanceof JsonObject) {
            JsonObject object = (JsonObject) ((JsonFile) pkg).getTopLevelValue();
            if (object != null) {
                JsonProperty homePage = object.findProperty("homepage");
                if (homePage != null && homePage.getValue() != null && homePage.getValue() instanceof JsonStringLiteral) {
                    JsonStringLiteral propValue = (JsonStringLiteral) homePage.getValue();
                    return propValue.getValue();
                }
            }
        }
    }
    return null;
}
 
开发者ID:misakuo,项目名称:weex-language-support,代码行数:17,代码来源:ExtraModulesUtil.java


示例2: getMain

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
private static PsiFile getMain(PsiDirectory moduleRoot) {
    PsiFile pkg = moduleRoot.findFile("package.json");
    if (pkg != null && pkg instanceof JsonFile) {
        if (((JsonFile) pkg).getTopLevelValue() instanceof JsonObject) {
            JsonObject object = (JsonObject) ((JsonFile) pkg).getTopLevelValue();
            if (object != null) {
                JsonProperty property = object.findProperty("main");
                if (property != null && property.getValue() != null && property.getValue() instanceof JsonStringLiteral) {
                    JsonStringLiteral propValue = (JsonStringLiteral) property.getValue();
                    String value = propValue.getValue();
                    PsiFile psiFile = moduleRoot.findFile(value.replace("./", ""));
                    return psiFile;
                }
            }
        }
    }
    return null;
}
 
开发者ID:misakuo,项目名称:weex-language-support,代码行数:19,代码来源:ExtraModulesUtil.java


示例3: getModuleName

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
public static String getModuleName(PsiDirectory dir) {
    PsiFile pkg = dir.findFile("package.json");
    String name = dir.getName();
    if (pkg != null && pkg instanceof JsonFile) {
        if (((JsonFile) pkg).getTopLevelValue() instanceof JsonObject) {
            JsonObject object = (JsonObject) ((JsonFile) pkg).getTopLevelValue();
            if (object != null) {
                JsonProperty property = object.findProperty("name");
                JsonProperty property1 = object.findProperty("version");
                if (property != null && property.getValue() != null && property.getValue() instanceof JsonStringLiteral) {
                    JsonStringLiteral propValue = (JsonStringLiteral) property.getValue();
                    name = propValue.getValue();
                    if (property1 != null && property1.getValue() != null && property1.getValue() instanceof JsonStringLiteral) {
                        JsonStringLiteral propValue1 = (JsonStringLiteral) property1.getValue();
                        name = name + ":" + propValue1.getValue();
                    }
                }
            }
        }
    }
    return name;
}
 
开发者ID:misakuo,项目名称:weex-language-support,代码行数:23,代码来源:ExtraModulesUtil.java


示例4: getCatberryVersion

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
@Nullable
private String getCatberryVersion() {
  if (DumbService.isDumb(project))
    return null;

  final NotNullLazyValue<ModificationTracker> tracker = getCatberryTracker();
  return CachedValuesManager.getManager(project).getCachedValue(project, new CachedValueProvider<String>() {
    @Nullable
    @Override
    public Result<String> compute() {
      VirtualFile vf = project.getBaseDir().findChild("package.json");
      if (vf == null)
        return Result.create(null, tracker.getValue());
      final JsonFile file = (JsonFile) PsiManager.getInstance(project).findFile(vf);
      if (file == null || file.getTopLevelValue()==null)
        return Result.create(null, tracker.getValue());
      JsonValue value = JsonPsiUtil.findPropertyValue(file.getTopLevelValue(), "dependencies/catberry");
      if (value != null)
        return Result.create(value.getText(), file);
      return Result.create(null, tracker.getValue());
    }
  });
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:24,代码来源:CatberryProjectConfigurationManager.java


示例5: compute

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
@Nullable
@Override
public Result<String[]> compute() {
  List<Object> dependencies = new LinkedList<Object>();
  for(JsonFile configFile : findConfigFiles()) {
    dependencies.add(configFile);
    JsonValue jsonValue = JsonPsiUtil.findPropertyValue(configFile.getTopLevelValue(), "componentsGlob");
    if(jsonValue == null)
      continue;
    List<String> paths = new LinkedList<String>();
    if(jsonValue instanceof JsonStringLiteral) {
      paths.add(((JsonStringLiteral)jsonValue).getValue());
    } else if(jsonValue instanceof JsonArray) {
      for(JsonStringLiteral item: PsiTreeUtil.findChildrenOfType(jsonValue, JsonStringLiteral.class))
        paths.add(item.getValue());
    }
    return Result.create(createValue(paths.toArray(new String[paths.size()])), jsonValue);
  }
  dependencies.add(tracker.getValue());
  return Result.create(createValue(), dependencies);
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:22,代码来源:ComponentsDirectoriesProvider.java


示例6: compute

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
@SuppressWarnings("Duplicates")
@Nullable
@Override
public Result<String> compute() {
  List<Object> dependencies = new LinkedList<Object>();
  for(JsonFile configFile : findConfigFiles()) {
    dependencies.add(configFile);
    JsonStringLiteral jsonValue = ObjectUtils.tryCast(
        JsonPsiUtil.findPropertyValue(configFile.getTopLevelValue(),"storesDirectory"), JsonStringLiteral.class);
    if(jsonValue == null)
      continue;
    return Result.create(createValue(jsonValue.getValue()), configFile);
  }
  dependencies.add(tracker.getValue());
  return Result.create(createValue(null), dependencies);
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:17,代码来源:StoresDirectoryProvider.java


示例7: compute

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
@Nullable
@Override
public Result<TemplateEngine> compute() {
  final JsonFile packageJsonFile = findPackageJsonFile();
  if (packageJsonFile == null)
    return Result.create(null, tracker.getValue());

  if(packageJsonFile.getTopLevelValue()==null)
    return Result.create(null, packageJsonFile);

  JsonValue dependencies = JsonPsiUtil.findPropertyValue(packageJsonFile.getTopLevelValue(), "dependencies");
  if(dependencies == null)
    return Result.create(null, packageJsonFile);
  List<JsonProperty> properties = PsiTreeUtil.getChildrenOfTypeAsList(dependencies, JsonProperty.class);
  for (JsonProperty property : properties) {
    TemplateEngine engine = engines.get(property.getName());
    if (engine != null)
      return Result.create(engine, packageJsonFile);
  }
  return Result.create(null, packageJsonFile);
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:22,代码来源:TemplateEngineProvider.java


示例8: findComponents

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
@NotNull
public static Map<String, PsiFile> findComponents(@NotNull final Project project) {
  Map<String, PsiFile> result = new HashMap<String, PsiFile>();
  Collection<VirtualFile> virtualFiles =
      FileBasedIndex.getInstance().getContainingFiles(FilenameIndex.NAME, CatberryConstants.CAT_COMPONENT_JSON,
          GlobalSearchScope.allScope(project));
  for (VirtualFile virtualFile : virtualFiles) {
    JsonFile psiFile = (JsonFile) PsiManager.getInstance(project).findFile(virtualFile);
    if (psiFile != null) {
      JsonProperty[] properties = PsiTreeUtil.getChildrenOfType(psiFile.getTopLevelValue(), JsonProperty.class);
      if (properties != null) {
        for (JsonProperty property : properties) {
          if (!property.getName().equals("name"))
            continue;
          if (property.getValue() != null && property.getValue() instanceof JsonStringLiteral)
            result.put(((JsonStringLiteral) property.getValue()).getValue(), psiFile);
          break;
        }
      }
    }
  }
  return result;
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:24,代码来源:CatberryComponentUtils.java


示例9: getIndexer

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
    return inputData -> {
        Map<String, Void> map = new HashMap<>();
        JsonFile jsonFile = (JsonFile)inputData.getPsiFile();
        if (!Settings.isEnabled(jsonFile.getProject())) {
            return map;
        }

        JsonObject jsonObject = PsiTreeUtil.getChildOfType(jsonFile, JsonObject.class);
        if (jsonObject == null) {
            return map;
        }
        ComposerPackageModel composerObject = new ComposerPackageModelImpl(jsonObject);

        String type = composerObject.getType();
        if (type == null) {
            return map;
        }

        if (!type.startsWith("magento2-")) {
            return map;
        }

        String name = composerObject.getName();

        if (name != null) {
            map.put(name, null);
        }

        return map;
    };
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:35,代码来源:ModulePackageIndex.java


示例10: loadModules

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
private void loadModules() {
    Collection<String> packages = FileBasedIndex.getInstance().getAllKeys(ModulePackageIndex.KEY, this.project);
    PsiManager psiManager = PsiManager.getInstance(this.project);
    for (String packageName: packages) {
        if (components.containsKey(packageName)) {
            continue;
        }

        Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance()
            .getContainingFiles(ModulePackageIndex.KEY, packageName, GlobalSearchScope.allScope(this.project));

        if (containingFiles.size() > 0) {
            VirtualFile configurationFile = containingFiles.iterator().next();

            PsiFile psiFile = psiManager.findFile(configurationFile);
            if (psiFile != null && psiFile instanceof JsonFile) {
                JsonObject jsonObject = PsiTreeUtil.getChildOfType((JsonFile) psiFile, JsonObject.class);
                if (jsonObject == null) {
                    continue;
                }

                MagentoComponent magentoComponent;
                ComposerPackageModel composerPackageModel = new ComposerPackageModelImpl(jsonObject);
                if ("magento2-module".equals(composerPackageModel.getType())) {
                    magentoComponent = new MagentoModuleImpl(new ComposerPackageModelImpl(jsonObject), psiFile.getContainingDirectory());
                } else {
                    magentoComponent = new MagentoComponentImp(new ComposerPackageModelImpl(jsonObject), psiFile.getContainingDirectory());
                }

                components.put(
                    packageName,
                    magentoComponent
                );
            }
        }
    }
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:38,代码来源:MagentoComponentManager.java


示例11: findPackageJsonFile

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
@Nullable
protected JsonFile findPackageJsonFile() {
  VirtualFile packageVFile = project.getBaseDir().findChild("package.json");
  if (packageVFile == null)
    return null;
  return ObjectUtils.tryCast(PsiManager.getInstance(project).findFile(packageVFile), JsonFile.class);
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:8,代码来源:BaseConfigurationProvider.java


示例12: findMainJsFile

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
@Nullable
protected JSFile findMainJsFile(@NotNull JsonFile packageJsonFile) {
  final JsonStringLiteralImpl value = ObjectUtils.tryCast(JsonPsiUtil.findPropertyValue(
      packageJsonFile.getTopLevelValue(), "main"), JsonStringLiteralImpl.class);
  if (value == null)
    return null;

  VirtualFile mainJsVFile = packageJsonFile.getVirtualFile().getParent().findFileByRelativePath(value.getValue());
  if (mainJsVFile == null)
    return null;

  return ObjectUtils.tryCast(PsiManager.getInstance(project).findFile(mainJsVFile), JSFile.class);
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:14,代码来源:BaseConfigurationProvider.java


示例13: findConfigFiles

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
@NotNull
protected JsonFile[] findConfigFiles() {
  VirtualFile configDir = project.getBaseDir().findChild("config");
  if(configDir == null)
    return new JsonFile[0];
  List<JsonFile> files = new LinkedList<JsonFile>();
  PsiManager psiManager = PsiManager.getInstance(project);
  for(VirtualFile file : configDir.getChildren()) {
    JsonFile jsonFile = ObjectUtils.tryCast(psiManager.findFile(file), JsonFile.class);
    if(jsonFile != null)
      files.add(jsonFile);
  }
  return files.toArray(new JsonFile[files.size()]);
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:15,代码来源:BaseConfigurationProvider.java


示例14: findComponentTemplate

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
@Nullable
public static PsiFile findComponentTemplate(@NotNull final Project project, @NotNull String name) {
  Collection<VirtualFile> virtualFiles =
      FileBasedIndex.getInstance().getContainingFiles(FilenameIndex.NAME, CatberryConstants.CAT_COMPONENT_JSON,
          GlobalSearchScope.allScope(project));
  CatberryProjectConfigurationManager manager = CatberryProjectConfigurationManager.getInstance(project);
  final TemplateEngine engine = manager.getTemplateEngine();
  if(engine == null)
    return null;
  for (VirtualFile virtualFile : virtualFiles) {
    JsonFile psiFile = (JsonFile) PsiManager.getInstance(project).findFile(virtualFile);
    if (psiFile != null) {
      JsonStringLiteralImpl value = ObjectUtils.tryCast(JsonPsiUtil.findPropertyValue(
          psiFile.getTopLevelValue(), "name"), JsonStringLiteralImpl.class);
      if (value == null || !name.equals(value.getValue()))
        continue;

      String template = "./" + CatberryConstants.DEFAULT_TEMPLATE_PREFIX + engine.getExtension();
      value = ObjectUtils.tryCast(JsonPsiUtil.findPropertyValue(
          psiFile.getTopLevelValue(), "template"), JsonStringLiteralImpl.class);
      if (value != null)
        template = value.getValue();

      VirtualFile f = psiFile.getVirtualFile().getParent();
      f = f.findFileByRelativePath(template);
      return f != null ? PsiManager.getInstance(project).findFile(f) : null;
    }
  }
  return null;
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:31,代码来源:CatberryComponentUtils.java


示例15: getComposerManifest

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
@Nullable
public static JsonFile getComposerManifest(PsiDirectory currentDirectory) {
    if (currentDirectory == null) {
        return null;
    }

    JsonFile composerFile;
    do {
        composerFile = getComposerManifestInDirectory(currentDirectory);
        currentDirectory = currentDirectory.getParentDirectory();
    } while (composerFile == null && currentDirectory != null && !currentDirectory.equals(currentDirectory.getProject().getBaseDir()) );

    return composerFile;
}
 
开发者ID:cvette,项目名称:intellij-neos,代码行数:15,代码来源:ComposerUtil.java


示例16: getComposerManifestInDirectory

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
@Nullable
public static JsonFile getComposerManifestInDirectory(@NotNull PsiDirectory packageDirContext) {
    for (PsiFile psiFile : packageDirContext.getFiles()) {
        if (psiFile instanceof JsonFile && psiFile.getName().equals("composer.json")) {
            return (JsonFile) psiFile;
        }
    }

    return null;
}
 
开发者ID:cvette,项目名称:intellij-neos,代码行数:11,代码来源:ComposerUtil.java


示例17: collectAdditionalElements

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
@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();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:JsonSmartEnterProcessor.java


示例18: loadModules

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
private void loadModules() {
    Collection<String> packages = FileBasedIndex.getInstance().getAllKeys(ModulePackageFileBasedIndex.NAME, this.project);
    PsiManager psiManager = PsiManager.getInstance(this.project);
    for (String packageName: packages) {
        if (components.containsKey(packageName)) {
            continue;
        }

        Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance()
            .getContainingFiles(ModulePackageFileBasedIndex.NAME, packageName, GlobalSearchScope.allScope(this.project));

        if (containingFiles.size() > 0) {
            VirtualFile configurationFile = containingFiles.iterator().next();

            PsiFile psiFile = psiManager.findFile(configurationFile);
            if (psiFile != null && psiFile instanceof JsonFile) {
                JsonObject jsonObject = PsiTreeUtil.getChildOfType((JsonFile) psiFile, JsonObject.class);
                if (jsonObject == null) {
                    continue;
                }

                MagentoComponent magentoComponent;
                ComposerPackageModel composerPackageModel = new ComposerPackageModelImpl(jsonObject);
                if ("magento2-module".equals(composerPackageModel.getType())) {
                    magentoComponent = new MagentoModuleImpl(new ComposerPackageModelImpl(jsonObject), psiFile.getContainingDirectory());
                } else {
                    magentoComponent = new MagentoComponentImp(new ComposerPackageModelImpl(jsonObject), psiFile.getContainingDirectory());
                }

                components.put(
                    packageName,
                    magentoComponent
                );
            }
        }
    }
}
 
开发者ID:dkvashninbay,项目名称:magento2plugin,代码行数:38,代码来源:MagentoComponentManager.java


示例19: shouldHighlightErrorElement

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
@Override
public boolean shouldHighlightErrorElement(@NotNull PsiErrorElement element) {
    final PsiFile file = element.getContainingFile();
    if(file instanceof JsonFile) {
        if(Boolean.TRUE.equals(file.getVirtualFile().getUserData(JSGraphQLLanguageUIProjectService.IS_GRAPH_QL_VARIABLES_VIRTUAL_FILE))) {
            // this is the variables file for GraphQL, so ignore errors as long as it's empty
            return !file.getText().isEmpty();
        }
    }
    return true;
}
 
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:12,代码来源:JSGraphQLVariablesHighlightErrorFilter.java


示例20: isNodeModule

import com.intellij.json.psi.JsonFile; //导入依赖的package包/类
public static boolean isNodeModule(PsiDirectory dir) {
    PsiFile pkg = dir.findFile("package.json");
    return pkg != null && pkg instanceof JsonFile;
}
 
开发者ID:misakuo,项目名称:weex-language-support,代码行数:5,代码来源:ExtraModulesUtil.java



注:本文中的com.intellij.json.psi.JsonFile类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AIllegalArgument类代码示例发布时间:2022-05-23
下一篇:
Java QueryFactory类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap