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


Java YAMLUtil类代码示例

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


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


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