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

Java YAMLDocument类代码示例

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

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



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

示例1: getElementNamePairs

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


示例2: YamlCompletionContributor

import org.jetbrains.yaml.psi.YAMLDocument; //导入依赖的package包/类
public YamlCompletionContributor() {

        extend(
            CompletionType.BASIC, PlatformPatterns.psiElement().withParent(PlatformPatterns.psiElement(YAMLDocument.class)).inFile(
            PlatformPatterns.psiFile().withName(PlatformPatterns.string().endsWith(".info.yml"))
        ),
            new CompletionProvider<CompletionParameters>() {
                @Override
                protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {

                    if(!DrupalProjectComponent.isEnabled(completionParameters.getOriginalPosition())) {
                        return;
                    }

                    for(String key: MODULE_KEYS) {
                        completionResultSet.addElement(LookupElementBuilder.create(key).withIcon(DrupalIcons.DRUPAL));
                    }

                }
            }
        );
    }
 
开发者ID:Haehnchen,项目名称:idea-php-drupal-symfony2-bridge,代码行数:23,代码来源:YamlCompletionContributor.java


示例3: visitFile

import org.jetbrains.yaml.psi.YAMLDocument; //导入依赖的package包/类
@Override
public void visitFile(PsiFile file) {
    // @TODO: detection of routing files in right way
    // routing.yml
    // comment.routing.yml
    // routing/foo.yml
    if(!YamlHelper.isRoutingFile(file)) {
        return;
    }

    YAMLDocument document = PsiTreeUtil.findChildOfType(file, YAMLDocument.class);
    if(document == null) {
        return;
    }

    YAMLValue topLevelValue = document.getTopLevelValue();
    if(topLevelValue != null) {
        YamlHelper.attachDuplicateKeyInspection(topLevelValue, holder);
    }
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:21,代码来源:DuplicateLocalRouteInspection.java


示例4: testGetYamlRouteDefinitionsWithMethods

import org.jetbrains.yaml.psi.YAMLDocument; //导入依赖的package包/类
/**
 * @see fr.adrienbrault.idea.symfony2plugin.routing.RouteHelper#getYamlRouteDefinitions
 */
public void testGetYamlRouteDefinitionsWithMethods() {
    Collection<StubIndexedRoute> yamlRouteDefinitions = RouteHelper.getYamlRouteDefinitions(YamlPsiElementFactory.createFromText(getProject(), YAMLDocument.class,
        "route1:\n" +
        "    path: /foo\n" +
        "    methods: [GET]\n" +
        "route2:\n" +
        "    path: /foo\n" +
        "    methods: GET\n" +
        "route3:\n" +
        "    path: /foo\n" +
        "    methods: [GET,   POST]\n"
    ));

    assertContainsElements(Collections.singletonList("get"), ContainerUtil.find(yamlRouteDefinitions, new MyEqualStubIndexedRouteCondition("route1")).getMethods());
    assertContainsElements(Collections.singletonList("get"), ContainerUtil.find(yamlRouteDefinitions, new MyEqualStubIndexedRouteCondition("route2")).getMethods());
    assertContainsElements(Arrays.asList("get", "post"), ContainerUtil.find(yamlRouteDefinitions, new MyEqualStubIndexedRouteCondition("route3")).getMethods());
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:21,代码来源:RouteHelperTest.java


示例5: getDocuments

import org.jetbrains.yaml.psi.YAMLDocument; //导入依赖的package包/类
public List<YAMLDocument> getDocuments() {
    final ArrayList<YAMLDocument> result = new ArrayList<>();
    for (ASTNode node : getNode().getChildren(TokenSet.create(YAMLElementTypes.DOCUMENT))) {
        result.add((YAMLDocument) node.getPsi());
    }
    return result;
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:8,代码来源:CoffigYamlFileImpl.java


示例6: findCoffigDocuments

import org.jetbrains.yaml.psi.YAMLDocument; //导入依赖的package包/类
public static List<YAMLDocument> findCoffigDocuments(Project project) {
    List<YAMLDocument> result = new ArrayList<>();
    for (VirtualFile virtualFile : findCoffigFiles(project)) {
        YAMLFile coffigFile = (YAMLFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (coffigFile != null) {
            result.addAll(coffigFile.getDocuments());
        }
    }
    return result;
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:11,代码来源:CoffigUtil.java


示例7: findCoffigKeys

import org.jetbrains.yaml.psi.YAMLDocument; //导入依赖的package包/类
public static Set<YAMLKeyValue> findCoffigKeys(Project project, String path) {
    Set<YAMLKeyValue> results = new HashSet<>();
    for (YAMLDocument yamlDocument : findCoffigDocuments(project)) {
        YAMLKeyValue yamlKeyValue = searchForKey(yamlDocument, path.split("\\."), 0);
        if (yamlKeyValue != null) {
            results.add(yamlKeyValue);
        }
    }
    return results;
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:11,代码来源:CoffigUtil.java


示例8: getDocuments

import org.jetbrains.yaml.psi.YAMLDocument; //导入依赖的package包/类
public List<YAMLDocument> getDocuments()
{
    ArrayList<YAMLDocument> result = new ArrayList<>();
    ASTNode[] var2 = this.getNode().getChildren(TokenSet.create(YAMLElementTypes.DOCUMENT));
    for (ASTNode node : var2)
    {
        result.add((YAMLDocument) node.getPsi());
    }

    return result;
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:12,代码来源:RamlFile.java


示例9: apply

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


示例10: collectSlowLineMarkers

import org.jetbrains.yaml.psi.YAMLDocument; //导入依赖的package包/类
@Override
public void collectSlowLineMarkers(@NotNull List<PsiElement> elements, @NotNull Collection<LineMarkerInfo> result) {
    for (PsiElement el : elements) {
        if (!NeosProjectComponent.isEnabled(el)) {
            return;
        }

        if (!el.getContainingFile().getVirtualFile().getName().startsWith("NodeTypes.")) {
            continue;
        }

        if (!(el instanceof YAMLKeyValue)) {
            continue;
        }

        YAMLMapping parentMapping = ((YAMLKeyValue) el).getParentMapping();
        if (parentMapping != null && parentMapping.getParent() instanceof YAMLDocument) {
            String nodeType = ((YAMLKeyValue) el).getKeyText();
            String[] nodeTypeSplit = nodeType.split(":");

            if (nodeTypeSplit.length < 2) {
                continue;
            }

            List<PsiElement> targets = ResolveEngine.getPrototypeDefinitions(el.getProject(), nodeTypeSplit[1], nodeTypeSplit[0]);
            if (!targets.isEmpty()) {
                RelatedItemLineMarkerInfo info = NavigationGutterIconBuilder
                        .create(FusionIcons.PROTOTYPE)
                        .setTargets(targets)
                        .setTooltipText("Go to Fusion prototype")
                        .createLineMarkerInfo(el);
                result.add(info);
            }
        }
    }
}
 
开发者ID:cvette,项目名称:intellij-neos,代码行数:37,代码来源:PrototypeLineMarkerProvider.java


示例11: getTopLevelMapping

import org.jetbrains.yaml.psi.YAMLDocument; //导入依赖的package包/类
/**
 * Gets the top-level mapping in the document, if present.
 *
 * @param element an element within the document.
 * @return the top-level mapping, or {@code null} if one is not defined (e.g. in an empty document).
 */
@Nullable
public static YAMLMapping getTopLevelMapping(final PsiElement element) {
    final YAMLDocument document = PsiTreeUtil.getParentOfType(element, YAMLDocument.class);
    if (document != null) {
        final YAMLValue topLevelValue = document.getTopLevelValue();
        if (topLevelValue instanceof YAMLMapping) {
            return (YAMLMapping) topLevelValue;
        }
    }
    return null;
}
 
开发者ID:tinselspoon,项目名称:intellij-kubernetes,代码行数:18,代码来源:KubernetesYamlPsiUtil.java


示例12: findGUIDFromFile

import org.jetbrains.yaml.psi.YAMLDocument; //导入依赖的package包/类
public static String findGUIDFromFile(@NotNull YAMLFile psiFile)
{
	String guid = null;
	List<YAMLDocument> documents = psiFile.getDocuments();
	for(YAMLDocument document : documents)
	{
		YAMLValue topLevelValue = document.getTopLevelValue();
		if(topLevelValue instanceof YAMLMapping)
		{
			YAMLKeyValue guidValue = ((YAMLMapping) topLevelValue).getKeyValueByKey(Unity3dMetaManager.GUID_KEY);
			guid = guidValue == null ? null : guidValue.getValueText();
		}
	}
	return guid;
}
 
开发者ID:consulo,项目名称:consulo-unity3d,代码行数:16,代码来源:Unity3dMetaIndexExtension.java


示例13: getPsiTargets

import org.jetbrains.yaml.psi.YAMLDocument; //导入依赖的package包/类
@NotNull
@Override
public Collection<PsiElement> getPsiTargets(PsiElement psiElement) {

    PsiElement element = psiElement.getParent();
    if(!(element instanceof StringLiteralExpression)) {
        return Collections.emptyList();
    }

    final String contents = ((StringLiteralExpression) element).getContents();
    if(StringUtils.isBlank(contents)) {
        return Collections.emptyList();
    }

    final Collection<PsiElement> psiElements = new ArrayList<>();
    FileBasedIndex.getInstance().getFilesWithKey(ConfigSchemaIndex.KEY, new HashSet<>(Collections.singletonList(contents)), virtualFile -> {

        PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(virtualFile);
        if(psiFile == null) {
            return true;
        }

        YAMLDocument yamlDocument = PsiTreeUtil.getChildOfType(psiFile, YAMLDocument.class);
        if(yamlDocument == null) {
            return true;
        }

        for(YAMLKeyValue yamlKeyValue: PsiTreeUtil.getChildrenOfTypeAsList(yamlDocument, YAMLKeyValue.class)) {
            String keyText = PsiElementUtils.trimQuote(yamlKeyValue.getKeyText());
            if(StringUtils.isNotBlank(keyText) && keyText.equals(contents)) {
                psiElements.add(yamlKeyValue);
            }
        }

        return true;
    }, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(getProject()), YAMLFileType.YML));

    return psiElements;
}
 
开发者ID:Haehnchen,项目名称:idea-php-drupal-symfony2-bridge,代码行数:40,代码来源:ConfigCompletionGoto.java


示例14: testGetYamlRouteDefinitionsForControllerKeyword

import org.jetbrains.yaml.psi.YAMLDocument; //导入依赖的package包/类
/**
 * @see fr.adrienbrault.idea.symfony2plugin.routing.RouteHelper#getYamlRouteDefinitions
 */
public void testGetYamlRouteDefinitionsForControllerKeyword() {
    Collection<StubIndexedRoute> yamlRouteDefinitions = RouteHelper.getYamlRouteDefinitions(YamlPsiElementFactory.createFromText(getProject(), YAMLDocument.class,
        "foo_keyword:\n" +
            "   path: /foo\n" +
            "   controller: 'AppBundle:Blog:list'\n"
    ));

    StubIndexedRoute route = ContainerUtil.find(yamlRouteDefinitions, new MyEqualStubIndexedRouteCondition("foo_keyword"));
    assertNotNull(route);

    assertContainsElements(Collections.singletonList("AppBundle:Blog:list"), route.getController());
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:16,代码来源:RouteHelperTest.java


示例15: isKey

import org.jetbrains.yaml.psi.YAMLDocument; //导入依赖的package包/类
private boolean isKey(PsiElement position) {
    PsiElement parentContext = position.getParent().getContext();
    PsiElement leftContext = Optional.ofNullable(position.getContext()).map(PsiElement::getPrevSibling).orElse(null);
    return parentContext instanceof YAMLMapping || parentContext instanceof YAMLDocument || leftContext != null && ((LeafPsiElement) leftContext).getElementType() == YAMLTokenTypes.INDENT;
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:6,代码来源:CoffigCompletionContributor.java


示例16: createWarningsForMissingElementsInDescription

import org.jetbrains.yaml.psi.YAMLDocument; //导入依赖的package包/类
private void createWarningsForMissingElementsInDescription(YAMLDocument yamlDocument, YAMLFile yamlFile, AnnotationHolder holder) {
    List<PsiElement> commentsList = Arrays.stream(yamlFile.getChildren()).filter(e -> e instanceof PsiComment).collect(toList());
    for (int index = 0; index < keysForDocumentation.length; index++) {
        createWarningsIfNecessary(keysForDescription[index], commentsList, holder, getElementNamePairs(yamlDocument, keysForDocumentation[index]));
    }
}
 
开发者ID:CloudSlang,项目名称:cs-intellij-plugin,代码行数:7,代码来源:ExecutableAnnotator.java


示例17: addCompletions

import org.jetbrains.yaml.psi.YAMLDocument; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {

    PsiElement element = completionParameters.getPosition();
    if(!Symfony2ProjectComponent.isEnabled(element)) {
        return;
    }

    PsiElement yamlScalar = element.getParent();
    if(yamlScalar == null) {
        return;
    }

    PsiElement yamlCompount = yamlScalar.getParent();

    // yaml document root context
    if(yamlCompount.getParent() instanceof YAMLDocument) {
        attachRootConfig(completionResultSet, element);
        return;
    }

    // check inside yaml key value context
    if(!(yamlCompount instanceof YAMLCompoundValue || yamlCompount instanceof YAMLKeyValue)) {
        return;
    }

    // get all parent yaml keys
    List<String> items = YamlHelper.getParentArrayKeys(element);
    if(items.size() == 0) {
        return;
    }

    // normalize for xml
    items = ContainerUtil.map(items, s -> s.replace('_', '-'));

    // reverse to get top most item first
    Collections.reverse(items);

    Document document = getConfigTemplate(element.getProject().getBaseDir());
    if(document == null) {
        return;
    }

    Node configNode = getMatchingConfigNode(document, items);
    if(configNode == null) {
        return;
    }

    getConfigPathLookupElements(completionResultSet, configNode, false);

    // map shortcuts like eg <dbal default-connection="">
    if(configNode instanceof Element) {
        NamedNodeMap attributes = configNode.getAttributes();
        for (int i = 0; i < attributes.getLength(); i++) {
            String attributeName = attributes.item(i).getNodeName();
            if(attributeName.startsWith("default-")) {
                Node defaultNode = getElementByTagNameWithUnPluralize((Element) configNode, attributeName.substring("default-".length()));
                if(defaultNode != null) {
                    getConfigPathLookupElements(completionResultSet, defaultNode, true);
                }
            }
        }
    }

}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:66,代码来源:ConfigCompletionProvider.java


示例18: testGetYamlRouteDefinitionsAsHashAndKeyValue

import org.jetbrains.yaml.psi.YAMLDocument; //导入依赖的package包/类
/**
 * @see fr.adrienbrault.idea.symfony2plugin.routing.RouteHelper#getYamlRouteDefinitions
 */
public void testGetYamlRouteDefinitionsAsHashAndKeyValue() {
    Collection<String[]> providers = new ArrayList<String[]>() {{
        add(new String[] {"'MyController::fooAction'", "MyController::fooAction"});
        add(new String[] {"MyController::fooAction", "MyController::fooAction"});
        add(new String[] {"\"MyController::fooAction\"", "MyController::fooAction"});
    }};

    for (String[] provider : providers) {
        Collection<YAMLDocument> yamlDocuments = new ArrayList<YAMLDocument>();

        yamlDocuments.add(YamlPsiElementFactory.createFromText(getProject(), YAMLDocument.class, String.format(
                "route1:\n" +
                "    path: /foo\n" +
                "    defaults: { _controller: %s }",
            provider[1]
        )));

        yamlDocuments.add(YamlPsiElementFactory.createFromText(getProject(), YAMLDocument.class, String.format(
            "route1:\n" +
                "    path: /foo\n" +
                "    defaults:\n" +
                "       _controller: %s",
            provider[1]
        )));

        yamlDocuments.add(YamlPsiElementFactory.createFromText(getProject(), YAMLDocument.class, String.format(
            "route1:\n" +
                "    pattern: /foo\n" +
                "    defaults:\n" +
                "       _controller: %s",
            provider[1]
        )));

        for (YAMLDocument yamlDocument : yamlDocuments) {
            StubIndexedRoute route1 = ContainerUtil.find(RouteHelper.getYamlRouteDefinitions(yamlDocument), new MyEqualStubIndexedRouteCondition("route1"));
            assertNotNull(route1);

            assertEquals(provider[1], route1.getController());
            assertEquals("route1", route1.getName());
            assertEquals("/foo", route1.getPath());
        }
    }
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:47,代码来源:RouteHelperTest.java


示例19: isTopLevelMapping

import org.jetbrains.yaml.psi.YAMLDocument; //导入依赖的package包/类
/**
 * Gets whether a given {@link YAMLKeyValue} is at the root level of the document.
 *
 * @param keyValue the element to evaluate.
 * @return {@code true} if this is a top-level mapping; otherwise, {@code false}.
 */
private static boolean isTopLevelMapping(final YAMLKeyValue keyValue) {
    return keyValue.getParentMapping() != null && keyValue.getParentMapping().getParent() instanceof YAMLDocument;
}
 
开发者ID:tinselspoon,项目名称:intellij-kubernetes,代码行数:10,代码来源:KubernetesYamlCompletionContributor.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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