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

Java JsonProperty类代码示例

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

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



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

示例1: findReferences

import com.intellij.json.psi.JsonProperty; //导入依赖的package包/类
@NotNull
@Override
public Collection<PsiReference> findReferences( PsiElement element )
{
  Collection<PsiReference> references = super.findReferences( element );

  if( element instanceof JsonProperty )
  {
    //## hack: IJ's json parser considers all properties having the same name as the same reference, which is total crap
    references.clear();
  }

  // Store refs to manifold types
  storeTypeManifoldReferences( element );

  return references;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:18,代码来源:RenameResourceElementProcessor.java


示例2: getHomePage

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


示例3: getMain

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


示例4: getModuleName

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


示例5: compute

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


示例6: findPropertyValue

import com.intellij.json.psi.JsonProperty; //导入依赖的package包/类
@Nullable
public static JsonValue findPropertyValue(@Nullable final JsonValue rootValue, @NotNull final String path) {
  if(rootValue == null)
    return null;

  JsonValue currentValue = rootValue;
  for(final String name : path.split("/")) {
    List<JsonProperty> properties = PsiTreeUtil.getChildrenOfTypeAsList(currentValue, JsonProperty.class);
    boolean found = false;
    for (JsonProperty property : properties) {
      if (!property.getName().equals(name))
        continue;
      currentValue = property.getValue();
      found = true;
    }
    if (!found)
      return null;
  }
  return currentValue;

}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:22,代码来源:JsonPsiUtil.java


示例7: findComponents

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


示例8: getPartialJsonSwaggerFileNames

import com.intellij.json.psi.JsonProperty; //导入依赖的package包/类
private Set<String> getPartialJsonSwaggerFileNames(final PsiFile file) {
    final Set<String> result = new HashSet<>();

    file.accept(new JsonRecursiveElementVisitor() {
        @Override
        public void visitProperty(@NotNull JsonProperty property) {
            if (SwaggerConstants.REF_KEY.equals(property.getName())) {
                if (property.getValue() != null) {
                    final String refValue = StringUtils.removeAllQuotes(property.getValue().getText());
                    if (refValue.contains(FileConstants.JSON_FILE_NAME_SUFFIX)) {
                        result.add(extractFileNameFromFileRefValue(refValue) + DELIMITER +
                                getSwaggerFileType(property.getValue(), refValue));
                    }
                }
            }
            super.visitProperty(property);
        }
    });

    return result;
}
 
开发者ID:zalando,项目名称:intellij-swagger,代码行数:22,代码来源:SwaggerDataIndexer.java


示例9: buildVisitor

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


示例10: apply

import com.intellij.json.psi.JsonProperty; //导入依赖的package包/类
@Override
public void apply(@NotNull Editor editor, @NotNull JsonSmartEnterProcessor processor, @NotNull PsiElement element)
  throws IncorrectOperationException {
  if (element instanceof JsonProperty) {
    final JsonValue propertyValue = ((JsonProperty)element).getValue();
    if (propertyValue != null) {
      if (terminatedOnCurrentLine(editor, propertyValue) && !isFollowedByTerminal(propertyValue, COMMA)) {
        editor.getDocument().insertString(propertyValue.getTextRange().getEndOffset(), ",");
        processor.myShouldAddNewline = true;
      }
    }
    else {
      final JsonValue propertyKey = ((JsonProperty)element).getNameElement();
      final int keyEndOffset = propertyKey.getTextRange().getEndOffset();
      //processor.myFirstErrorOffset = keyEndOffset;
      if (terminatedOnCurrentLine(editor, propertyKey) && !isFollowedByTerminal(propertyKey, COLON)) {
        processor.myFirstErrorOffset = keyEndOffset + 2;
        editor.getDocument().insertString(keyEndOffset, ": ");
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:JsonSmartEnterProcessor.java


示例11: getElementInfo

import com.intellij.json.psi.JsonProperty; //导入依赖的package包/类
@NotNull
@Override
public String getElementInfo(@NotNull PsiElement e) {
  if (e instanceof JsonProperty) {
    return ((JsonProperty)e).getName();
  }
  //else if (isArrayElement(e)) {
  //  List<JsonValue> elements = ((JsonArray)e.getParent()).getValueList();
  //  for (int i = 0; i < elements.size(); i++) {
  //    if (e == elements.get(i)) {
  //      return String.valueOf(i);
  //    }
  //  }
  //}
  throw new AssertionError("Breadcrumbs can be extracted only from JsonProperty elements");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:JsonBreadcrumbsProvider.java


示例12: getValue

import com.intellij.json.psi.JsonProperty; //导入依赖的package包/类
@Nullable
private static String getValue(@NotNull final JsonProperty property) {
  final JsonValue value = property.getValue();

  if(!(value instanceof JsonStringLiteral)) {
    return null;
  }

  final JsonStringLiteral literal = (JsonStringLiteral)value;
  final String text = literal.getText();

  if(isNullOrEmpty(text) || text.length() < 3) {
    return null;
  }

  return text.substring(1, text.length() - 1);
}
 
开发者ID:defrac,项目名称:defrac-plugin-intellij,代码行数:18,代码来源:MainClassReferenceProvider.java


示例13: registerReferenceProviders

import com.intellij.json.psi.JsonProperty; //导入依赖的package包/类
@Override
public void registerReferenceProviders(@NotNull final PsiReferenceRegistrar registrar) {
  registrar.registerReferenceProvider(
      psiElement(PsiLiteralExpression.class).
          withSuperParent(3, psiElement(PsiAnnotation.class)),
      new InjectionReferenceProvider()
  );

  registrar.registerReferenceProvider(
      psiElement(PsiLiteralExpression.class).
          withSuperParent(3, psiElement(PsiAnnotation.class)),
      new InjectorReferenceProvider()
  );

  registrar.registerReferenceProvider(
      psiElement(PsiLiteralExpression.class).
          withLanguage(JavaLanguage.INSTANCE).
          withSuperParent(3, psiElement(PsiAnnotation.class)),
      new MacroReferenceProvider()
  );

  registrar.registerReferenceProvider(
      psiElement(JsonProperty.class).withLanguage(JsonLanguage.INSTANCE),
      new MainClassReferenceProvider()
  );
}
 
开发者ID:defrac,项目名称:defrac-plugin-intellij,代码行数:27,代码来源:ReferenceContributor.java


示例14: localReferencePattern

import com.intellij.json.psi.JsonProperty; //导入依赖的package包/类
private PsiElementPattern.Capture<JsonLiteral> localReferencePattern(final String refTypePrefix) {
    return psiElement(JsonLiteral.class)
            .withParent(psiElement(JsonProperty.class).withName(OpenApiConstants.REF_KEY))
            .withText(StandardPatterns.string().contains(refTypePrefix))
            .andNot(StandardPatterns.string().contains(FileConstants.JSON_FILE_NAME_SUFFIX))
            .withLanguage(JsonLanguage.INSTANCE);
}
 
开发者ID:zalando,项目名称:intellij-swagger,代码行数:8,代码来源:OpenApiJsonReferenceContributor.java


示例15: localDefinitionsPattern

import com.intellij.json.psi.JsonProperty; //导入依赖的package包/类
private PsiElementPattern.Capture<JsonLiteral> localDefinitionsPattern() {
    return swagger(psiElement(JsonLiteral.class)
            .withParent(psiElement(JsonProperty.class).withName(SwaggerConstants.REF_KEY))
            .withText(StandardPatterns.string().contains(SwaggerConstants.LOCAL_DEFINITIONS_PREFIX))
            .andNot(StandardPatterns.string().contains(FileConstants.JSON_FILE_NAME_SUFFIX))
            .withLanguage(JsonLanguage.INSTANCE));
}
 
开发者ID:zalando,项目名称:intellij-swagger,代码行数:8,代码来源:SwaggerJsonReferenceContributor.java


示例16: isIncomplete

import com.intellij.json.psi.JsonProperty; //导入依赖的package包/类
@Override
public boolean isIncomplete() {
  final ASTNode lastChildNode = myNode.getLastChildNode();
  if (hasElementType(myNode, OBJECT)) {
    return lastChildNode != null && lastChildNode.getElementType() != R_CURLY;
  }
  else if (hasElementType(myNode, ARRAY)) {
    return lastChildNode != null && lastChildNode.getElementType() != R_BRACKET;
  }
  else if (hasElementType(myNode, PROPERTY)) {
    return ((JsonProperty)myPsiElement).getValue() == null;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:JsonBlock.java


示例17: getQualifiedName

import com.intellij.json.psi.JsonProperty; //导入依赖的package包/类
@Nullable
@Override
public String getQualifiedName(PsiElement element) {
  if (!(element instanceof JsonElement)) {
    return null;
  }
  final LinkedList<String> qualifiers = new LinkedList<String>();
  JsonProperty parentProperty = PsiTreeUtil.getNonStrictParentOfType(element, JsonProperty.class);
  while (parentProperty != null) {
    qualifiers.addFirst(parentProperty.getName());
    parentProperty = PsiTreeUtil.getParentOfType(parentProperty, JsonProperty.class);
  }
  return qualifiers.isEmpty() ? null : StringUtil.join(qualifiers, ".");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:JsonQualifiedNameProvider.java


示例18: getType

import com.intellij.json.psi.JsonProperty; //导入依赖的package包/类
@NotNull
@Override
public String getType(@NotNull PsiElement element) {
  if (element instanceof JsonProperty) {
    return "property";
  }
  return "";
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:JsonFindUsagesProvider.java


示例19: isReferenceTo

import com.intellij.json.psi.JsonProperty; //导入依赖的package包/类
@Override
public boolean isReferenceTo(PsiElement element) {
  if (!(element instanceof JsonProperty)) {
    return false;
  }
  // May reference to the property with the same name for compatibility with JavaScript JSON support
  final JsonProperty otherProperty = (JsonProperty)element;
  final PsiElement selfResolve = resolve();
  return otherProperty.getName().equals(getCanonicalText()) && selfResolve != otherProperty;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:JsonPropertyNameReference.java


示例20: compute

import com.intellij.json.psi.JsonProperty; //导入依赖的package包/类
@Nullable
@Override
public Result<Map<String, JsonProperty>> compute() {
  final Map<String, JsonProperty> cache = new HashMap<String, JsonProperty>();
  for (JsonProperty property : getPropertyList()) {
    final String propertyName = property.getName();
    // Preserve the old behavior - return the first value in findProperty()
    if (!cache.containsKey(propertyName)) {
      cache.put(propertyName, property);
    }
  }
  // Cached value is invalidated every time file containing this object is modified
  return CachedValueProvider.Result.createSingleDependency(cache, JsonObjectMixin.this);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:JsonObjectMixin.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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