当前位置: 首页>>代码示例>>Java>>正文


Java YAMLKeyValue.getKey方法代码示例

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


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

示例1: 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

示例2: 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

示例3: apply

import org.jetbrains.yaml.psi.YAMLKeyValue; //导入方法依赖的package包/类
@Override
public void apply(@NotNull PsiFile file, List<RuntimeException> annotationResult, @NotNull AnnotationHolder holder) {
    if (file instanceof YAMLFile) {
        YAMLFile yamlFile = (YAMLFile) file;
        if (!yamlFile.getDocuments().isEmpty()) {
            YAMLDocument yamlDocument = yamlFile.getDocuments().get(0);
            PsiElement found = findChildRecursively(yamlDocument, new String[]{"flow", "operation", "decision"});
            if (found instanceof YAMLKeyValue) {
                YAMLKeyValue keyValue = (YAMLKeyValue) found;
                found = keyValue.getKey();
            } else {
                found = yamlDocument;
            }
            createErrorAnnotations(found, yamlFile, holder, annotationResult);
            createWarningsForMissingElementsInDescription(yamlDocument, yamlFile, holder);
        }
        if (!annotationResult.isEmpty()) {
            HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
                    .descriptionAndTooltip("Found " + annotationResult.size() + " errors")
                    .range(file).create();
            if (highlightInfo != null) {
                Problem problem = new ProblemImpl(file.getVirtualFile(), highlightInfo, true);
                WolfTheProblemSolver theProblemSolver = WolfTheProblemSolver.getInstance(file.getProject());
                theProblemSolver.reportProblems(file.getVirtualFile(), Collections.singletonList(problem));
            }
        }
    }
}
 
开发者ID:CloudSlang,项目名称:cs-intellij-plugin,代码行数:29,代码来源:ExecutableAnnotator.java


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