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


Java YAMLUtil.getQualifiedKeyInFile方法代码示例

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


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

示例1: getHelpersInFile

import org.jetbrains.yaml.YAMLUtil; //导入方法依赖的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

示例2: invokeTranslation

import org.jetbrains.yaml.YAMLUtil; //导入方法依赖的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

示例3: createDefaults

import org.jetbrains.yaml.YAMLUtil; //导入方法依赖的package包/类
@NotNull
private static ServiceFileDefaults createDefaults(@NotNull YAMLFile psiFile) {
    YAMLKeyValue yamlKeyValueDefaults = YAMLUtil.getQualifiedKeyInFile(psiFile, "services", "_defaults");

    if(yamlKeyValueDefaults != null) {
        return new ServiceFileDefaults(
            YamlHelper.getYamlKeyValueAsBoolean(yamlKeyValueDefaults, "public"),
            YamlHelper.getYamlKeyValueAsBoolean(yamlKeyValueDefaults, "autowire")
        );
    }

    return ServiceFileDefaults.EMPTY;
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:14,代码来源:ServiceContainerUtil.java

示例4: getTwigGlobalsFromYamlConfig

import org.jetbrains.yaml.YAMLUtil; //导入方法依赖的package包/类
/**
 * Collects Twig globals in given yaml configuration
 *
 * twig:
 *    globals:
 *       ga_tracking: '%ga_tracking%'
 *       user_management: '@AppBundle\Service\UserManagement'
 */
@NotNull
public static Map<String, String> getTwigGlobalsFromYamlConfig(@NotNull YAMLFile yamlFile) {
    YAMLKeyValue yamlKeyValue = YAMLUtil.getQualifiedKeyInFile(yamlFile, "twig", "globals");
    if(yamlKeyValue == null) {
        return Collections.emptyMap();
    }

    YAMLValue value = yamlKeyValue.getValue();
    if(!(value instanceof YAMLMapping)) {
        return Collections.emptyMap();
    }

    Map<String, String> pair = new HashMap<>();

    for (YAMLPsiElement element : value.getYAMLElements()) {
        if(!(element instanceof YAMLKeyValue)) {
            continue;
        }

        String keyText = ((YAMLKeyValue) element).getKeyText();
        if(StringUtils.isBlank(keyText)) {
            continue;
        }

        String valueText = ((YAMLKeyValue) element).getValueText();
        if(StringUtils.isBlank(valueText)) {
            continue;
        }

        pair.put(keyText, valueText);
    }

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

示例5: visitRoot

import org.jetbrains.yaml.YAMLUtil; //导入方法依赖的package包/类
protected void visitRoot(PsiFile psiFile, String rootName, @NotNull ProblemsHolder holder) {
    if(!(psiFile instanceof YAMLFile)) {
        return;
    }

    YAMLKeyValue yamlKeyValue = YAMLUtil.getQualifiedKeyInFile((YAMLFile) psiFile, rootName);
    if(yamlKeyValue == null) {
        return;
    }

    YAMLCompoundValue yaml = PsiTreeUtil.findChildOfType(yamlKeyValue, YAMLMapping.class);
    if(yaml != null) {
        YamlHelper.attachDuplicateKeyInspection(yaml, holder);
    }
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:16,代码来源:YamlDuplicateServiceKeyInspection.java

示例6: processKeysAfterRoot

import org.jetbrains.yaml.YAMLUtil; //导入方法依赖的package包/类
/**
 * Process yaml key in second level filtered by a root:
 * File > roots -> "Item"
 * TODO: visitQualifiedKeyValuesInFile
 */
public static void processKeysAfterRoot(@NotNull PsiFile psiFile, @NotNull Processor<YAMLKeyValue> yamlKeyValueProcessor, @NotNull String... roots) {
    for (String root : roots) {
        YAMLKeyValue yamlKeyValue = YAMLUtil.getQualifiedKeyInFile((YAMLFile) psiFile, root);
        if(yamlKeyValue != null) {
            YAMLCompoundValue yaml = PsiTreeUtil.findChildOfType(yamlKeyValue, YAMLCompoundValue.class);
            if(yaml != null) {
                for(YAMLKeyValue yamlKeyValueVisit: PsiTreeUtil.getChildrenOfTypeAsList(yaml, YAMLKeyValue.class)) {
                    yamlKeyValueProcessor.process(yamlKeyValueVisit);
                }
            }
        }
    }
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:19,代码来源:YamlHelper.java

示例7: getQualifiedKeyValuesInFile

import org.jetbrains.yaml.YAMLUtil; //导入方法依赖的package包/类
/**
 * Get all key values in first level key visit
 *
 * parameters:
 *  foo: "foo"
 */
@NotNull
public static Collection<YAMLKeyValue> getQualifiedKeyValuesInFile(@NotNull YAMLFile yamlFile, @NotNull String firstLevelKeyToVisit) {
    YAMLKeyValue parameters = YAMLUtil.getQualifiedKeyInFile(yamlFile, firstLevelKeyToVisit);
    if(parameters == null) {
        return Collections.emptyList();
    }

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

示例8: visitQualifiedKeyValuesInFile

import org.jetbrains.yaml.YAMLUtil; //导入方法依赖的package包/类
/**
 * Visit all key values in first level key
 *
 * parameters:
 *  foo: "foo"
 */
public static void visitQualifiedKeyValuesInFile(@NotNull YAMLFile yamlFile, @NotNull String firstLevelKeyToVisit, @NotNull Consumer<YAMLKeyValue> consumer) {
    YAMLKeyValue parameters = YAMLUtil.getQualifiedKeyInFile(yamlFile, firstLevelKeyToVisit);
    if(parameters == null) {
        return;
    }

    visitNextKeyValues(parameters, consumer);
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:15,代码来源:YamlHelper.java

示例9: isValidForFile

import org.jetbrains.yaml.YAMLUtil; //导入方法依赖的package包/类
private boolean isValidForFile(@NotNull PsiFile file) {

        if(file instanceof XmlFile) {
            XmlTag rootTag = ((XmlFile) file).getRootTag();
            return !(rootTag == null || !"container".equals(rootTag.getName()));
        } else if(file instanceof YAMLFile) {
            return
                YAMLUtil.getQualifiedKeyInFile((YAMLFile) file, "parameters") != null ||
                YAMLUtil.getQualifiedKeyInFile((YAMLFile) file, "services") != null;
        }

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

示例10: getValueAt

import org.jetbrains.yaml.YAMLUtil; //导入方法依赖的package包/类
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    if (languages == null || languages.size() == 0) {
        return null;
    }
    List<String> keys = getKeys(true);
    switch (columnIndex) {
        case 0:
            return keys.get(rowIndex);
        default:
            Collection<YAMLKeyValue> collection = dataMap.get(languages.get(columnIndex - 1));
            YAMLKeyValue correctKeyValue = findByKey(keys.get(rowIndex), collection);
            if (collection == null || collection.size() == 0) {
                return "";
            }
            YAMLFile yamlFile;
            if (correctKeyValue == null) { //may be null because keys can be also written with dots and the above function couldn't find it
                yamlFile = (YAMLFile) new ArrayList<>(collection).get(0).getContainingFile();
            } else {
                yamlFile = (YAMLFile) correctKeyValue.getContainingFile();
            }
            String keyValueText = prefixKey ? languages.get(columnIndex - 1) + "." + keys.get(rowIndex) : keys.get(rowIndex);
            String[] keySplitted = GravYAMLUtils.splitKey(keyValueText);
            YAMLKeyValue keyValue = null;
            try {
                keyValue = YAMLUtil.getQualifiedKeyInFile(
                        yamlFile,
                        Arrays.asList(keySplitted));
            } catch (NullPointerException npe) {

            }
            if (keyValue == null && correctKeyValue == null) return "";
            if (keyValue == null) {
                //additional search because intellij yaml support doesn't know about keys with dot notation ...
                //so try to find it in the previous collected list
                keyValue = correctKeyValue;
            }

            String valueText;
            if (keyValue.getValue() instanceof YAMLSequence) {
                valueText = GravYAMLUtils.prettyPrint((YAMLSequence) keyValue.getValue());
            } else {
                valueText = keyValue.getValueText();
            }

            return valueText;
    }
}
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:49,代码来源:TranslationTableModel.java

示例11: getRouteNameTarget

import org.jetbrains.yaml.YAMLUtil; //导入方法依赖的package包/类
/**
 * Find every possible route name declaration inside yaml, xml or @Route annotation
 */
@Nullable
public static PsiElement getRouteNameTarget(@NotNull Project project, @NotNull String routeName) {
    for(VirtualFile virtualFile: RouteHelper.getRouteDefinitionInsideFile(project, routeName)) {
        PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);

        if(psiFile instanceof YAMLFile) {
            return YAMLUtil.getQualifiedKeyInFile((YAMLFile) psiFile, routeName);
        } else if(psiFile instanceof XmlFile) {
            PsiElement target = RouteHelper.getXmlRouteNameTarget((XmlFile) psiFile, routeName);
            if(target != null) {
                return target;
            }
        } else if(psiFile instanceof PhpFile) {
            // find on @Route annotation
            for (PhpClass phpClass : PhpPsiUtil.findAllClasses((PhpFile) psiFile)) {
                // get prefix by PhpClass
                String prefix = getRouteNamePrefix(phpClass);

                for (Method method : phpClass.getOwnMethods()) {
                    PhpDocComment docComment = method.getDocComment();
                    if(docComment == null) {
                        continue;
                    }

                    PhpDocCommentAnnotation container = AnnotationUtil.getPhpDocCommentAnnotationContainer(docComment);
                    if(container == null) {
                        continue;
                    }

                    // multiple @Route annotation in bundles are allowed
                    for (String routeClass : ROUTE_CLASSES) {
                        PhpDocTagAnnotation phpDocTagAnnotation = container.getPhpDocBlock(routeClass);
                        if(phpDocTagAnnotation != null) {
                            String annotationRouteName = phpDocTagAnnotation.getPropertyValue("name");
                            if(annotationRouteName != null) {
                                // name provided @Route(name="foobar")
                                if(routeName.equals(prefix + annotationRouteName)) {
                                    return phpDocTagAnnotation.getPropertyValuePsi("name");
                                }
                            } else {
                                // just @Route() without name provided
                                String routeByMethod = AnnotationBackportUtil.getRouteByMethod(phpDocTagAnnotation.getPhpDocTag());
                                if(routeName.equals(prefix + routeByMethod)) {
                                    return phpDocTagAnnotation.getPhpDocTag();
                                }
                            }
                        }
                    }
                }
            }
        }
    }

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

示例12: getTwigPathFromYamlConfig

import org.jetbrains.yaml.YAMLUtil; //导入方法依赖的package包/类
/**
 * Collects Twig path in given yaml configuration
 *
 * twig:
 *  paths:
 *   "%kernel.root_dir%/../src/vendor/bundle/Resources/views": core
 */
@NotNull
public static Collection<Pair<String, String>> getTwigPathFromYamlConfig(@NotNull YAMLFile yamlFile) {
    YAMLKeyValue yamlKeyValue = YAMLUtil.getQualifiedKeyInFile(yamlFile, "twig", "paths");
    if(yamlKeyValue == null) {
        return Collections.emptyList();
    }

    YAMLValue value = yamlKeyValue.getValue();
    if(!(value instanceof YAMLMapping)) {
        return Collections.emptyList();
    }

    Collection<Pair<String, String>> pair = new ArrayList<>();

    for (YAMLPsiElement element : value.getYAMLElements()) {
        if(!(element instanceof YAMLKeyValue)) {
            continue;
        }

        String keyText = ((YAMLKeyValue) element).getKeyText();
        if(StringUtils.isBlank(keyText)) {
            continue;
        }

        keyText = keyText.replace("\\", "/").replaceAll("/+", "/");

        // empty value is empty string on out side:
        // "foo: "
        String valueText = "";

        YAMLValue yamlValue = ((YAMLKeyValue) element).getValue();
        if (yamlValue != null) {
            valueText = ((YAMLKeyValue) element).getValueText();
        } else {
            // workaround for foo: !foobar
            // as we got tag element
            PsiElement key = ((YAMLKeyValue) element).getKey();
            if(key != null) {
                PsiElement nextSiblingOfType = PsiElementUtils.getNextSiblingOfType(key, PlatformPatterns.psiElement(YAMLTokenTypes.TAG));
                if(nextSiblingOfType != null) {
                    String text = nextSiblingOfType.getText();
                    if(text.startsWith("!")) {
                        valueText = StringUtils.stripStart(text, "!");
                    }
                }
            }
        }

        // Symfony 3.4 / 4.0: namespace overwrite: "@!Foo" => "@Foo"
        valueText = StringUtils.stripStart(valueText, "!");

        // normalize null value
        if(valueText.equals("~")) {
            valueText = "";
        }

        pair.add(Pair.create(valueText, keyText));
    }

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


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