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

Java JsonObject类代码示例

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

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



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

示例1: getHomePage

import com.intellij.json.psi.JsonObject; //导入依赖的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.JsonObject; //导入依赖的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.JsonObject; //导入依赖的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: buildVisitor

import com.intellij.json.psi.JsonObject; //导入依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
  return new JsonElementVisitor() {
    @Override
    public void visitObject(@NotNull JsonObject o) {
      final MultiMap<String, PsiElement> keys = new MultiMap<String, PsiElement>();
      for (JsonProperty property : o.getPropertyList()) {
        keys.putValue(property.getName(), property.getNameElement());
      }
      for (Map.Entry<String, Collection<PsiElement>> entry : keys.entrySet()) {
        final Collection<PsiElement> sameNamedKeys = entry.getValue();
        if (sameNamedKeys.size() > 1) {
          for (PsiElement element : sameNamedKeys) {
            holder.registerProblem(element, JsonBundle.message("inspection.duplicate.keys.msg.duplicate.keys", entry.getKey()));
          }
        }
      }
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:JsonDuplicatePropertyKeysInspection.java


示例5: getIndexer

import com.intellij.json.psi.JsonObject; //导入依赖的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


示例6: loadModules

import com.intellij.json.psi.JsonObject; //导入依赖的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


示例7: getNextObjectParent

import com.intellij.json.psi.JsonObject; //导入依赖的package包/类
private PsiElement getNextObjectParent(final PsiElement psiElement) {
    if (psiElement == null) {
        return null;
    }

    if (psiElement instanceof JsonObject ||
            (psiElement instanceof YAMLKeyValue || psiElement instanceof YAMLMapping) &&
                    !(psiElement instanceof JsonStringLiteral)) {
        return psiElement;
    }

    return getNextObjectParent(psiElement.getParent());
}
 
开发者ID:zalando,项目名称:intellij-swagger,代码行数:14,代码来源:PathFinder.java


示例8: JsonBlock

import com.intellij.json.psi.JsonObject; //导入依赖的package包/类
public JsonBlock(@Nullable JsonBlock parent,
                 @NotNull ASTNode node,
                 @NotNull CodeStyleSettings settings,
                 @Nullable Alignment alignment,
                 @NotNull Indent indent,
                 @Nullable Wrap wrap) {
  myParent = parent;
  myNode = node;
  myPsiElement = node.getPsi();
  myAlignment = alignment;
  myIndent = indent;
  myWrap = wrap;
  mySettings = settings;

  mySpacingBuilder = JsonFormattingBuilderModel.createSpacingBuilder(settings);

  if (myPsiElement instanceof JsonObject) {
    myChildWrap = Wrap.createWrap(getCustomSettings().OBJECT_WRAPPING, true);
  }
  else if (myPsiElement instanceof JsonArray) {
    myChildWrap = Wrap.createWrap(getCustomSettings().ARRAY_WRAPPING, true);
  }
  else {
    myChildWrap = null;
  }

  myPropertyValueAlignment = myPsiElement instanceof JsonObject ? Alignment.createAlignment(true) : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:JsonBlock.java


示例9: checkAddProperty

import com.intellij.json.psi.JsonObject; //导入依赖的package包/类
private void checkAddProperty(@NotNull String before, @NotNull String after, final boolean first) {
  getCustomCodeStyleSettings().OBJECT_WRAPPING = CommonCodeStyleSettings.DO_NOT_WRAP;
  myFixture.configureByText(JsonFileType.INSTANCE, before);
  final PsiElement atCaret = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
  final JsonObject jsonObject = PsiTreeUtil.getParentOfType(atCaret, JsonObject.class);
  assertNotNull(jsonObject);
  WriteCommandAction.runWriteCommandAction(getProject(), () -> {
    JsonPsiUtil.addProperty(jsonObject, new JsonElementGenerator(getProject()).createProperty("foo", "null"), first);
  });
  myFixture.checkResult(after);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:JsonPsiUtilTest.java


示例10: loadModules

import com.intellij.json.psi.JsonObject; //导入依赖的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


示例11: swagger

import com.intellij.json.psi.JsonObject; //导入依赖的package包/类
private <T extends PsiElement> PsiElementPattern.Capture<T> swagger(final PsiElementPattern.Capture<T> pattern) {
    return pattern.
            inside(psiElement(JsonObject.class).withChild(psiElement().withName(SwaggerConstants.SWAGGER)));
}
 
开发者ID:zalando,项目名称:intellij-swagger,代码行数:5,代码来源:SwaggerJsonReferenceContributor.java


示例12: JsonStructureViewModel

import com.intellij.json.psi.JsonObject; //导入依赖的package包/类
public JsonStructureViewModel(@NotNull PsiFile psiFile, @Nullable Editor editor) {
  super(psiFile, editor, new JsonStructureViewElement((JsonFile)psiFile));
  withSuitableClasses(JsonFile.class, JsonProperty.class, JsonObject.class, JsonArray.class);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:JsonStructureViewModel.java


示例13: getReferencesByElement

import com.intellij.json.psi.JsonObject; //导入依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull final PsiElement element,
                                             @NotNull final ProcessingContext context) {
  if(!(element instanceof JsonProperty)) {
    return PsiReference.EMPTY_ARRAY;
  }

  final JsonProperty property = (JsonProperty)element;

  if(!"main".equals(property.getName())) {
    return PsiReference.EMPTY_ARRAY;
  }

  final PsiFile file = element.getContainingFile();

  if(file == null || file.getFileType() != DefracSettingsFileType.getInstance()) {
    return PsiReference.EMPTY_ARRAY;
  }

  // (1) get literal
  final String value = getValue((JsonProperty)element);

  if(isNullOrEmpty(value)) {
    return PsiReference.EMPTY_ARRAY;
  }

  final JsonObject object =
      getParentOfType(property, JsonObject.class, /*strict=*/true);

  if(object == null) {
    return PsiReference.EMPTY_ARRAY;
  }

  final JsonProperty scope =
      getParentOfType(object, JsonProperty.class, /*strict=*/true);

  final DefracPlatform targetPlatform;

  if(scope == null) {
    targetPlatform = DefracPlatform.GENERIC;
  } else {
    // note: could make sure parent is generic!
    //       otherwise we
    targetPlatform = DefracPlatform.byName(scope.getName());

    if(targetPlatform == null) {
      return PsiReference.EMPTY_ARRAY;
    }
  }

  return new PsiReference[] {
      new MainClassReference(
          value,
          checkNotNull((JsonStringLiteral) property.getValue()),
          targetPlatform)
  };
}
 
开发者ID:defrac,项目名称:defrac-plugin-intellij,代码行数:59,代码来源:MainClassReferenceProvider.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Project类代码示例发布时间:2022-05-23
下一篇:
Java S18PacketEntityTeleport类代码示例发布时间: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