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


Java YAMLKeyValue类代码示例

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


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


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