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

Java YAMLUtil类代码示例

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

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



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

示例1: createTableModel

import org.jetbrains.yaml.YAMLUtil; //导入依赖的package包/类
@Override
public TranslationTableModel createTableModel() {
    detactLanguages();
    Collection<String> availableKeys = new LinkedHashSet<>();//preserve order, no dups
    ConcurrentHashMap<String, Collection<YAMLKeyValue>> dataMap = new ConcurrentHashMap<>();
    VirtualFile virtualFile = fileMap.elements().nextElement();
    YAMLFileImpl yamlFile = (YAMLFileImpl) PsiManager.getInstance(project).findFile(virtualFile);
    if (yamlFile != null) {
        Collection<YAMLKeyValue> topLevelKeys = YAMLUtil.getTopLevelKeys(yamlFile);
        for (String eachLanguage : languages) {
            dataMap.put(eachLanguage, new HashSet<>());
            Collection<YAMLKeyValue> topLevelValuesLang = findChildValues(topLevelKeys, eachLanguage);
            for (YAMLKeyValue keyValue : topLevelValuesLang) {
                if (keyValue.getValue() instanceof YAMLCompoundValue) {
                    List<String> keysBuffer = new ArrayList<>();
                    getCompoundKeys0(keyValue, keyValue.getKeyText(), keysBuffer, dataMap, eachLanguage);
                    availableKeys.addAll(keysBuffer);
                } else {
                    availableKeys.add(keyValue.getKeyText());
                    dataMap.get(eachLanguage).add(keyValue);
                }
            }
        }
    }
    return new TranslationTableModel(availableKeys, dataMap).setPrefixKey(true);
}
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:27,代码来源:LanguageFileStrategy.java


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


示例3: multiResolve

import org.jetbrains.yaml.YAMLUtil; //导入依赖的package包/类
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    String nodeTypeNameToFindReferenceFor = yamlElement.getKeyText();

    // files which contain the NodeType definition
    Collection<VirtualFile> files = FileBasedIndex.getInstance().getContainingFiles(NodeTypesYamlFileIndex.KEY, nodeTypeNameToFindReferenceFor, GlobalSearchScope.allScope(yamlElement.getProject()));

    return files
            .stream()
            // get the PSI for each file
            .map(file -> PsiManager.getInstance(yamlElement.getProject()).findFile(file))
            // ensure we only have YAML files
            .filter(psiFile -> psiFile instanceof YAMLFile)
            .map(psiFile -> (YAMLFile) psiFile)
            // get all YAML keys in these files
            .flatMap(yamlFile -> YAMLUtil.getTopLevelKeys(yamlFile).stream())
            // get the correct YAML key
            .filter(yamlKeyValue -> yamlKeyValue.getKeyText().equals(nodeTypeNameToFindReferenceFor))
            // remove "current" element if it exists
            .filter(yamlKeyValue -> yamlElement != yamlKeyValue)
            // build up the result object
            .map(yamlKeyValue -> new PsiElementResolveResult(yamlKeyValue, true))
            .toArray(PsiElementResolveResult[]::new);
}
 
开发者ID:cvette,项目名称:intellij-neos,代码行数:26,代码来源:NodeTypeReference.java


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


示例5: insertKeyIntoFile

import org.jetbrains.yaml.YAMLUtil; //导入依赖的package包/类
@Nullable
public static PsiElement insertKeyIntoFile(final @NotNull YAMLFile yamlFile, final @NotNull YAMLKeyValue yamlKeyValue, @NotNull String... keys) {
    String keyText = yamlKeyValue.getKeyText();

    return insertKeyIntoFile(yamlFile, (yamlMapping, chainedKey) -> {
        String text = yamlKeyValue.getText();

        final String previousIndent = StringUtil.repeatSymbol(' ', YAMLUtil.getIndentInThisLine(yamlMapping));

        // split content of array value object;
        // drop first item as getValueText() removes our key indent
        String[] remove = (String[]) ArrayUtils.remove(text.split("\\r?\\n"), 0);

        List<String> map = ContainerUtil.map(remove, s -> previousIndent + s);

        return "\n" + StringUtils.strip(StringUtils.join(map, "\n"), "\n");
    }, (String[]) ArrayUtils.add(keys, keyText));
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:19,代码来源:YamlHelper.java


示例6: createFileMap

import org.jetbrains.yaml.YAMLUtil; //导入依赖的package包/类
@Override
public void createFileMap(@NotNull VirtualFile file) {
    fileMap.clear();
    YAMLFile yamlFile = (YAMLFile) PsiManager.getInstance(project).findFile(file);
    if (yamlFile != null) {
        Collection<YAMLKeyValue> topLevelKeys = YAMLUtil.getTopLevelKeys(yamlFile);
        for (YAMLKeyValue each : topLevelKeys) {
            fileMap.put(each.getKeyText(), file);
        }
    }
}
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:12,代码来源:LanguageFileStrategy.java


示例7: createTableModel

import org.jetbrains.yaml.YAMLUtil; //导入依赖的package包/类
@Override
public TranslationTableModel createTableModel() {
    detactLanguages();
    ConcurrentHashMap<String, Collection<YAMLKeyValue>> dataMap = new ConcurrentHashMap<>();
    Collection<String> availableKeys = new LinkedHashSet<>();//preserve order, no dups
    Collection<VirtualFile> removeFiles = new ArrayList<>();
    Set<Map.Entry<String, VirtualFile>> set = fileMap.entrySet();
    for (Map.Entry<String, VirtualFile> each : set) {
        //this should never be accessed if VirtualFileListener works correctly
        if (each.getValue() == null || !each.getValue().exists()) {
            fileMap.remove(each.getKey());
            continue;
        }
        YAMLFileImpl yamlFile = (YAMLFileImpl) PsiManager.getInstance(project).findFile(each.getValue());
        if (yamlFile != null) {
            String lang = each.getValue().getNameWithoutExtension();
            dataMap.put(lang, new HashSet<>());
            for (YAMLKeyValue keyValue : YAMLUtil.getTopLevelKeys(yamlFile)) {

                if (keyValue.getValue() instanceof YAMLCompoundValue) {
                    List<String> keysBuffer = new ArrayList<>();
                    getCompoundKeys0(keyValue, keyValue.getKeyText(), keysBuffer, dataMap, lang);
                    availableKeys.addAll(keysBuffer);
                } else {
                    availableKeys.add(keyValue.getKeyText());
                    dataMap.get(lang).add(keyValue);
                }
            }
        }
    }
    return new TranslationTableModel(availableKeys, dataMap);
}
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:33,代码来源:LanguageFolderStrategy.java


示例8: doIndex

import org.jetbrains.yaml.YAMLUtil; //导入依赖的package包/类
@NotNull
private Map<String, Void> doIndex(FileContent fileContent) {
    Map<String, Void> result = new HashMap<>();
    YAMLUtil.getTopLevelKeys((YAMLFile)fileContent.getPsiFile())
            .forEach(yamlKeyValue -> result.put(yamlKeyValue.getKeyText(), null));
    return result;
}
 
开发者ID:cvette,项目名称:intellij-neos,代码行数:8,代码来源:NodeTypesYamlFileIndex.java


示例9: getNodeTypeDefinitions

import org.jetbrains.yaml.YAMLUtil; //导入依赖的package包/类
public static Collection<PsiElement> getNodeTypeDefinitions(Project project, String name, @Nullable String namespace) {
    String fqn = "Neos.Neos" + ":" + name;
    if (namespace != null) {
        String aliasNamespace = findNamespaceByAlias(project, namespace);
        if (aliasNamespace != null) {
            fqn = aliasNamespace + ":" + name;
        } else {
            fqn = namespace + ":" + name;
        }
    }

    Collection<VirtualFile> files = FileBasedIndex.getInstance().getContainingFiles(NodeTypesYamlFileIndex.KEY, fqn, GlobalSearchScope.allScope(project));

    // Check for legacy namespace
    if (files.isEmpty() && namespace == null) {
        return getNodeTypeDefinitions(project, name, "TYPO3.Neos");
    }

    final String finalFqn = fqn;
    return files
            .stream()
            // get the PSI for each file
            .map(file -> PsiManager.getInstance(project).findFile(file))
            // ensure we only have YAML files
            .filter(psiFile -> psiFile instanceof YAMLFile)
            .map(psiFile -> (YAMLFile) psiFile)
            // get all YAML keys in these files
            .flatMap(yamlFile -> YAMLUtil.getTopLevelKeys(yamlFile).stream())
            // get the correct YAML key
            .filter(yamlKeyValue -> yamlKeyValue.getKeyText().equals(finalFqn))
            .collect(Collectors.toList());
}
 
开发者ID:cvette,项目名称:intellij-neos,代码行数:33,代码来源:ResolveEngine.java


示例10: invoke

import org.jetbrains.yaml.YAMLUtil; //导入依赖的package包/类
@Override
public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement psiElement) throws IncorrectOperationException {
    final YAMLElementGenerator elementGenerator = YAMLElementGenerator.getInstance(project);
    for (final String missingKey : missingKeys) {
        final YAMLKeyValue newKeyValue = elementGenerator.createYamlKeyValue(missingKey, "");
        mapping.add(elementGenerator.createEol());
        mapping.add(elementGenerator.createIndent(YAMLUtil.getIndentToThisElement(mapping)));
        mapping.add(newKeyValue);
    }
}
 
开发者ID:tinselspoon,项目名称:intellij-kubernetes,代码行数:11,代码来源:CreateMissingPropertiesIntentionAction.java


示例11: isKubernetesFile

import org.jetbrains.yaml.YAMLUtil; //导入依赖的package包/类
/**
 * Determines whether the element is within a Kubernetes YAML file. This is done by checking for the presence of "apiVersion" or "kind" as top-level keys within the first document of the file.
 *
 * @param element an element within the file to check.
 * @return true if the element is within A Kubernetes YAML file, otherwise, false.
 */
public static boolean isKubernetesFile(final PsiElement element) {
    final PsiFile file = element.getContainingFile();
    if (file instanceof YAMLFile) {
        final Collection<YAMLKeyValue> keys = YAMLUtil.getTopLevelKeys((YAMLFile) file);
        return keys.stream().map(YAMLKeyValue::getKeyText).anyMatch(s -> "apiVersion".equals(s) || "kind".equals(s));
    }
    return false;
}
 
开发者ID:tinselspoon,项目名称:intellij-kubernetes,代码行数:15,代码来源:KubernetesYamlPsiUtil.java


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


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


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


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


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


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


示例18: getStringValueOfKeyInProbablyMapping

import org.jetbrains.yaml.YAMLUtil; //导入依赖的package包/类
@Nullable
public static String getStringValueOfKeyInProbablyMapping(@Nullable YAMLValue node, @NotNull String keyText) {
    YAMLKeyValue mapping = YAMLUtil.findKeyInProbablyMapping(node, keyText);
    if(mapping == null) {
        return null;
    }

    YAMLValue value = mapping.getValue();
    if(value == null) {
        return null;
    }

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


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


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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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