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

Java YAMLKeyValue类代码示例

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

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



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

示例1: searchForKey

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
private static YAMLKeyValue searchForKey(YAMLPsiElement yamlPsiElement, String[] path, int index) {
    if (index < path.length) {
        for (YAMLPsiElement current : yamlPsiElement.getYAMLElements()) {
            if (current instanceof YAMLKeyValue) {
                if (path[index].equals(((YAMLKeyValue) current).getKeyText())) {
                    if (index == path.length - 1) {
                        return ((YAMLKeyValue) current);
                    } else {
                        return searchForKey(current, path, index + 1);
                    }
                }
            } else {
                return searchForKey(current, path, index);
            }
        }
    }
    return null;
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:19,代码来源:CoffigUtil.java


示例2: getElementNamePairs

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
private List<Pair<PsiElement, String>> getElementNamePairs(YAMLDocument yamlDocument, String elementName) {
    final PsiElement psiElement = findChildRecursively(yamlDocument, new String[]{elementName});
    if (psiElement == null) {
        return Collections.emptyList();
    }

    List<Pair<PsiElement, String>> elementStringPairs = new ArrayList<>();
    try (BufferedReader reader = new BufferedReader(new StringReader(psiElement.getText()))) {
        for (String line; (line = reader.readLine()) != null;) {
            final Matcher matcher = keyInListPattern.matcher(line);
            if (matcher.find()) {
                String elementNameGroup = matcher.group(1);
                YAMLPsiElement childElement = findChildRecursively((YAMLPsiElement) psiElement, new String[]{elementNameGroup});
                PsiElement elementToHighlight = (childElement != null) ? childElement : ((psiElement instanceof YAMLKeyValue) ? ((YAMLKeyValue) psiElement).getKey() : psiElement);
                elementStringPairs.add(new ImmutablePair<>(elementToHighlight, elementNameGroup));
            }
        }
    } catch (IOException ignore) {  // this code is never reached because the reader reads from memory
    }
    return elementStringPairs;
}
 
开发者ID:CloudSlang,项目名称:cs-intellij-plugin,代码行数:22,代码来源:ExecutableAnnotator.java


示例3: getHelpersInFile

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
public static HashMap<String, String> getHelpersInFile(@NotNull PsiFile psiFile) {
    YAMLKeyValue defaultContext = YAMLUtil.getQualifiedKeyInFile((YAMLFile) psiFile, "Neos", "Fusion", "defaultContext");

    if (defaultContext == null) {
        defaultContext = YAMLUtil.getQualifiedKeyInFile((YAMLFile) psiFile, "TYPO3", "TypoScript", "defaultContext");
    }

    HashMap<String, String> result = new HashMap<>();
    if (defaultContext != null) {
        PsiElement mapping = defaultContext.getLastChild();
        if (mapping instanceof YAMLMapping) {
            for (PsiElement mappingElement : mapping.getChildren()) {
                if (mappingElement instanceof YAMLKeyValue) {
                    YAMLKeyValue keyValue = (YAMLKeyValue) mappingElement;
                    result.put(keyValue.getKeyText(), keyValue.getValueText());
                    NeosProjectComponent.getLogger().debug(keyValue.getKeyText() + ": " + keyValue.getValueText());
                }
            }
        }
    }

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


示例4: getReferencesByElement

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
    YAMLKeyValue yamlElement = (YAMLKeyValue) element;

    // we support the following cases:
    // - superTypes
    // - constraints.nodeTypes
    // - root level (to find other definitions on root)
    if (parentKeyIs(yamlElement, "superTypes")
            || (parentKeyIs(yamlElement, "nodeTypes") && grandparentKeyIs(yamlElement, "constraints"))
            || isOnRootLevel(yamlElement)) {
        return new PsiReference[]{
                new NodeTypeReference(yamlElement)
        };
    }

    return PsiReference.EMPTY_ARRAY;
}
 
开发者ID:cvette,项目名称:intellij-neos,代码行数:20,代码来源:NodeTypeReferenceContributor.java


示例5: accepts

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
@Override
public boolean accepts(@NotNull PsiElement psiElement, ProcessingContext processingContext) {
    PsiElement currentElement = psiElement.getParent();
    String expectedKey;
    int i = 0;
    int j = 0;

    while (currentElement != null) {
        if (i < Array.getLength(this.keys)) {
            if (YAMLKeyValue.class.isInstance(currentElement)) {
                expectedKey = this.keys[i++];
                if (!expectedKey.equals("*") && !expectedKey.equals(((YAMLKeyValue) currentElement).getKeyText())) {
                    return false;
                }
            }
        } else if (!this.rootTypes[j++].isInstance(currentElement)) {
            return false;
        }

        currentElement = currentElement.getParent();
    }

    return !(i < Array.getLength(this.keys) || j < Array.getLength(this.rootTypes));
}
 
开发者ID:cvette,项目名称:intellij-neos,代码行数:25,代码来源:ParentKeysPatternCondition.java


示例6: annotate

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
@Override
public void annotate(@NotNull final PsiElement element, @NotNull final AnnotationHolder annotationHolder) {
    if (!KubernetesYamlPsiUtil.isKubernetesFile(element)) {
        return;
    }
    final ModelProvider modelProvider = ModelProvider.INSTANCE;
    final ResourceTypeKey resourceKey = KubernetesYamlPsiUtil.findResourceKey(element);
    if (resourceKey != null && element instanceof YAMLKeyValue) {
        final YAMLKeyValue keyValue = (YAMLKeyValue) element;
        final Model model = KubernetesYamlPsiUtil.modelForKey(modelProvider, resourceKey, keyValue);
        if (keyValue.getValue() instanceof YAMLMapping && model != null) {
            final YAMLMapping mapping = (YAMLMapping) keyValue.getValue();
            final Set<String> expectedProperties = model.getProperties().keySet();
            //noinspection ConstantConditions
            mapping.getKeyValues()
                   .stream()
                   .filter(k -> !expectedProperties.contains(k.getKeyText().trim()))
                   .forEach(k -> annotationHolder.createWarningAnnotation(k.getKey(), "Property '" + k.getKeyText() + "' is not expected here.").registerFix(new DeletePropertyIntentionAction()));
        }
    }
}
 
开发者ID:tinselspoon,项目名称:intellij-kubernetes,代码行数:22,代码来源:PropertyNotInModelAnnotator.java


示例7: annotate

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
@Override
public void annotate(@NotNull final PsiElement element, @NotNull final AnnotationHolder annotationHolder) {
    if (!KubernetesYamlPsiUtil.isKubernetesFile(element)) {
        return;
    }
    final ModelProvider modelProvider = ModelProvider.INSTANCE;
    final ResourceTypeKey resourceKey = KubernetesYamlPsiUtil.findResourceKey(element);
    if (resourceKey != null && element instanceof YAMLKeyValue) {
        final YAMLKeyValue keyValue = (YAMLKeyValue) element;
        final Model model = KubernetesYamlPsiUtil.modelForKey(modelProvider, resourceKey, keyValue);
        if (model != null && keyValue.getKey() != null) {
            if (keyValue.getValue() instanceof YAMLMapping) {
                final YAMLMapping mapping = (YAMLMapping) keyValue.getValue();
                addErrors(annotationHolder, model, keyValue.getKey(), mapping);
            } else if (keyValue.getValue() instanceof YAMLSequence) {
                final YAMLSequence sequence = (YAMLSequence) keyValue.getValue();
                for (final YAMLSequenceItem item : sequence.getItems()) {
                    if (item.getValue() instanceof YAMLMapping) {
                        addErrors(annotationHolder, model, item.getFirstChild(), (YAMLMapping) item.getValue());
                    }
                }
            }
        }
    }
}
 
开发者ID:tinselspoon,项目名称:intellij-kubernetes,代码行数:26,代码来源:MissingRequiredPropertiesAnnotator.java


示例8: annotate

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
@Override
public void annotate(@NotNull final PsiElement element, @NotNull final AnnotationHolder annotationHolder) {
    if (!KubernetesYamlPsiUtil.isKubernetesFile(element)) {
        return;
    }
    if (element instanceof YAMLMapping) {
        final YAMLMapping mapping = (YAMLMapping) element;
        final Collection<YAMLKeyValue> keyValues = mapping.getKeyValues();
        final Set<String> existingKeys = new HashSet<>(keyValues.size());
        for (final YAMLKeyValue keyValue : keyValues) {
            if (keyValue.getKey() != null && !existingKeys.add(keyValue.getKeyText().trim())) {
                annotationHolder.createErrorAnnotation(keyValue.getKey(), "Duplicated property '" + keyValue.getKeyText() + "'").registerFix(new DeletePropertyIntentionAction());
            }
        }
    }
}
 
开发者ID:tinselspoon,项目名称:intellij-kubernetes,代码行数:17,代码来源:DuplicateKeyAnnotator.java


示例9: getIndexer

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {

    return inputData -> {

        Map<String, Void> map = new THashMap<>();

        PsiFile psiFile = inputData.getPsiFile();
        if(!(psiFile instanceof YAMLFile) || !psiFile.getName().endsWith(".menu.yml")) {
            return map;
        }

        for (YAMLKeyValue yamlKeyValue : YamlHelper.getTopLevelKeyValues((YAMLFile) psiFile)) {
            String keyText = yamlKeyValue.getKeyText();
            if(StringUtils.isBlank(keyText)) {
                continue;
            }

            map.put(keyText, null);
        }

        return map;
    };
}
 
开发者ID:Haehnchen,项目名称:idea-php-drupal-symfony2-bridge,代码行数:26,代码来源:MenuIndex.java


示例10: getIndexer

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {

    return inputData -> {

        Map<String, Void> map = new THashMap<>();

        PsiFile psiFile = inputData.getPsiFile();
        if(!(psiFile instanceof YAMLFile) || !psiFile.getName().endsWith(".permissions.yml")) {
            return map;
        }

        for (YAMLKeyValue yamlKeyValue : YamlHelper.getTopLevelKeyValues((YAMLFile) psiFile)) {
            String keyText = yamlKeyValue.getKeyText();
            if(StringUtils.isBlank(keyText)) {
                continue;
            }

            map.put(keyText, null);
        }

        return map;
    };
}
 
开发者ID:Haehnchen,项目名称:idea-php-drupal-symfony2-bridge,代码行数:26,代码来源:PermissionIndex.java


示例11: testThatRoutePermissionCompletesAndNavigates

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
public void testThatRoutePermissionCompletesAndNavigates() {
    assertCompletionContains(YAMLFileType.YML, "" +
            "config.import_full:\n" +
            "  requirements:\n" +
            "    _permission: '<caret>'",
        "synchronize configuration"
    );

    assertNavigationMatch(YAMLFileType.YML, "" +
            "config.import_full:\n" +
            "  requirements:\n" +
            "    _permission: 'synchronize<caret> configuration'",
        PlatformPatterns.psiElement(YAMLKeyValue.class).with(new PatternCondition<YAMLKeyValue>("key") {
            @Override
            public boolean accepts(@NotNull YAMLKeyValue yamlKeyValue, ProcessingContext processingContext) {
                return "synchronize configuration".equals(yamlKeyValue.getKeyText());
            }
        })
    );
}
 
开发者ID:Haehnchen,项目名称:idea-php-drupal-symfony2-bridge,代码行数:21,代码来源:YamlPermissionGotoCompletionTest.java


示例12: getMetadata

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
@Nullable
public DoctrineMetadataModel getMetadata(@NotNull DoctrineMappingDriverArguments args) {

    PsiFile psiFile = args.getPsiFile();
    if(!(psiFile instanceof YAMLFile)) {
        return null;
    }

    Collection<DoctrineModelField> fields = new ArrayList<>();
    DoctrineMetadataModel model = new DoctrineMetadataModel(fields);

    for (YAMLKeyValue yamlKeyValue : YamlHelper.getTopLevelKeyValues((YAMLFile) psiFile)) {
        // first line is class name; check of we are right
        if(args.isEqualClass(YamlHelper.getYamlKeyName(yamlKeyValue))) {
            model.setTable(YamlHelper.getYamlKeyValueAsString(yamlKeyValue, "table"));
            fields.addAll(EntityHelper.getModelFieldsSet(yamlKeyValue));
        }
    }

    if(model.isEmpty()) {
        return null;
    }

    return model;
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:26,代码来源:DoctrineYamlMappingDriver.java


示例13: create

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
@Nullable
private static Collection<ServiceTagInterface> create(@NotNull YAMLKeyValue yamlHash) {

    final Collection<ServiceTagInterface> tags = new ArrayList<>();

    YamlHelper.visitTagsOnServiceDefinition(yamlHash, args -> {
        String methodName = args.getAttribute("method");
        if (StringUtils.isBlank(methodName)) {
            return;
        }

        tags.add(args);
    });

    return tags;
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:17,代码来源:ServiceTagFactory.java


示例14: buildVisitor

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
@NotNull
public PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, boolean isOnTheFly) {
    if (!Symfony2ProjectComponent.isEnabled(holder.getProject())) {
        return super.buildVisitor(holder, isOnTheFly);
    }

    return new PsiElementVisitor() {
        @Override
        public void visitElement(PsiElement element) {
            if(element instanceof XmlAttribute) {
                registerXmlAttributeProblem(holder, (XmlAttribute) element);
            } else if(element instanceof YAMLKeyValue) {
                registerYmlRoutePatternProblem(holder, (YAMLKeyValue) element);
            }

            super.visitElement(element);
        }
    };
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:20,代码来源:ContainerSettingDeprecatedInspection.java


示例15: buildVisitor

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
@NotNull
public PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, boolean isOnTheFly) {
    if(!Symfony2ProjectComponent.isEnabled(holder.getProject())) {
        return super.buildVisitor(holder, isOnTheFly);
    }

    return new PsiElementVisitor() {
        @Override
        public void visitElement(PsiElement element) {
            if(element instanceof XmlAttributeValue) {
                registerAttributeRequirementProblem(holder, (XmlAttributeValue) element, "_method");
                registerAttributeRequirementProblem(holder, (XmlAttributeValue) element, "_scheme");
            } else if(element instanceof XmlAttribute) {
                registerRoutePatternProblem(holder, (XmlAttribute) element);
            } else if(element instanceof YAMLKeyValue) {
                registerYmlRoutePatternProblem(holder, (YAMLKeyValue) element);
            }

            super.visitElement(element);
        }
    };
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:23,代码来源:RouteSettingDeprecatedInspection.java


示例16: getRouteName

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
@Nullable
@Override
public String getRouteName() {

    YAMLKeyValue defaultKeyValue = PsiTreeUtil.getParentOfType(this.psiElement.getParent(), YAMLKeyValue.class);
    if(defaultKeyValue == null) {
        return null;
    }

    YAMLKeyValue def = PsiTreeUtil.getParentOfType(defaultKeyValue, YAMLKeyValue.class);
    if(def == null) {
        return null;
    }

    return YamlHelper.getYamlKeyName(def);
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:17,代码来源:ControllerMethodInspection.java


示例17: addCompletions

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
    PsiElement position = parameters.getPosition();

    if(!Symfony2ProjectComponent.isEnabled(position)) {
        return;
    }

    PsiElement serviceDefinition = position.getParent();
    if(serviceDefinition instanceof YAMLKeyValue) {
        YAMLKeyValue aClass = YamlHelper.getYamlKeyValue((YAMLKeyValue) serviceDefinition, "class");
        if(aClass == null) {
            PhpClassCompletionProvider.addClassCompletion(parameters, completionResultSet, position, false);
        }
    }
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:17,代码来源:YamlCompletionContributor.java


示例18: addYamlClassMethods

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
private static void addYamlClassMethods(@Nullable PsiElement psiElement, CompletionResultSet completionResultSet, String classTag) {

        if(psiElement == null) {
            return;
        }

        YAMLKeyValue classKeyValue = PsiElementUtils.getChildrenOfType(psiElement, PlatformPatterns.psiElement(YAMLKeyValue.class).withName(classTag));
        if(classKeyValue == null) {
            return;
        }

        PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(psiElement.getProject(), classKeyValue.getValueText());
        if(phpClass != null) {
            PhpElementsUtil.addClassPublicMethodCompletion(completionResultSet, phpClass);
        }
    }
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:17,代码来源:YamlCompletionContributor.java


示例19: visitRootElements

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
private void visitRootElements(@NotNull Collection<LineMarkerInfo> result, @NotNull PsiElement psiElement, @NotNull LazyConfigTreeSignatures function) {
    PsiElement parent = psiElement.getParent();
    if(!(parent instanceof YAMLKeyValue)) {
        return;
    }

    String keyText = ((YAMLKeyValue) parent).getKeyText();
    Map<String, Collection<String>> treeSignatures = function.value();
    if(!treeSignatures.containsKey(keyText)) {
        return;
    }

    NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.SYMFONY_LINE_MARKER)
        .setTargets(new MyClassIdLazyValue(psiElement.getProject(), treeSignatures.get(keyText), keyText))
        .setTooltipText("Navigate to configuration");

    result.add(builder.createLineMarkerInfo(psiElement));
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:19,代码来源:ConfigLineMarkerProvider.java


示例20: invokeTranslation

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入依赖的package包/类
private static PsiElement invokeTranslation(@NotNull final YAMLFile yamlFile, @NotNull final String keyName, @NotNull final String translation) {
    String[] split = keyName.split("\\.");
    PsiElement psiElement = YamlHelper.insertKeyIntoFile(yamlFile, "'" + translation + "'", split);
    if(psiElement == null) {
        return null;
    }

    // resolve target to get value
    YAMLKeyValue target = YAMLUtil.getQualifiedKeyInFile(yamlFile, split);
    if(target != null && target.getValue() != null) {
        return target.getValue();
    } else if(target != null) {
        return target;
    }

    return yamlFile;
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:18,代码来源:TranslationInsertUtil.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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