• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java YAMLScalar类的典型用法和代码示例

java 2次浏览

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

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

示例1: registerReferenceProviders

点赞 3

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
    registrar.registerReferenceProvider(PlatformPatterns.psiElement(YAMLScalar.class),
            new PsiReferenceProvider() {
                @NotNull
                @Override
                public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
                    if (isConfigFile(element)) {
                        String valueText = ((YAMLScalar) element).getTextValue();
                        List<MacroResolver.Match> matches = new MacroResolver().resolve(valueText);
                        List<PsiReference> references = new ArrayList<>();
                        matches.stream()
                                .filter(match -> !match.isEscaped())
                                .map(match -> resolvePsiReferences(element, match.getReference(), (element instanceof YAMLQuotedText ? 1 : 0) + match.getStartPos()))
                                .forEach(references::addAll);
                        return references.toArray(new PsiReference[references.size()]);
                    }
                    return PsiReference.EMPTY_ARRAY;
                }
            });
}
 

开发者ID:seedstack,
项目名称:intellij-plugin,
代码行数:22,
代码来源:CoffigYamlReferenceContributor.java

示例2: visitCall

点赞 3

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
/**
 * class: FooClass
 * tags:
 *  - [ setFoo, [@args_bar] ]
 */
private void visitCall(PsiElement psiElement) {
    PsiElement yamlScalar = psiElement.getContext();
    if(!(yamlScalar instanceof YAMLScalar)) {
        return;
    }

    YamlHelper.visitServiceCallArgument((YAMLScalar) yamlScalar, visitor -> {
        PhpClass serviceClass = ServiceUtil.getResolvedClassDefinition(psiElement.getProject(), visitor.getClassName(), getLazyServiceCollector(psiElement.getProject()));
        if(serviceClass == null) {
            return;
        }

        Method method = serviceClass.findMethodByName(visitor.getMethod());
        if (method == null) {
            return;
        }

        YamlXmlServiceInstanceInspection.registerInstanceProblem(psiElement, holder, visitor.getParameterIndex(), method, getLazyServiceCollector(psiElement.getProject()));
    });
}
 

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

示例3: yamlVisitor

点赞 3

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
private void yamlVisitor(@NotNull ProblemsHolder holder, @NotNull PsiFile psiFile) {
    psiFile.acceptChildren(new PsiRecursiveElementVisitor() {
        @Override
        public void visitElement(PsiElement psiElement) {
            if(psiElement instanceof YAMLScalar) {
                String textValue = ((YAMLScalar) psiElement).getTextValue();
                if(textValue.length() > 0 && textValue.startsWith("!php/const:")) {
                    String constantName = textValue.substring(11);
                    if(StringUtils.isNotBlank(constantName) && ServiceContainerUtil.getTargetsForConstant(psiElement.getProject(), constantName).size() == 0) {
                        holder.registerProblem(psiElement, MESSAGE, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
                    }
                }
            }

            super.visitElement(psiElement);
        }
    });
}
 

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

示例4: addCompletions

点赞 3

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
    if(!Symfony2ProjectComponent.isEnabled(completionParameters.getPosition())) {
        return;
    }

    // - [ setContainer, [ @service_container ] ]
    PsiElement psiElement = completionParameters.getPosition();

    PsiElement yamlScalar = psiElement.getParent();
    if(yamlScalar instanceof YAMLScalar) {
        YamlHelper.visitServiceCall((YAMLScalar) yamlScalar, clazz -> {
            PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(psiElement.getProject(), clazz);
            if(phpClass != null) {
                PhpElementsUtil.addClassPublicMethodCompletion(completionResultSet, phpClass);
            }
        });
    }
}
 

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

示例5: getMethodGoto

点赞 3

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
@NotNull
private Collection<PsiElement> getMethodGoto(@NotNull PsiElement psiElement) {
    Collection<PsiElement> results = new ArrayList<>();

    PsiElement parent = psiElement.getParent();

    if(parent instanceof YAMLScalar) {
        YamlHelper.visitServiceCall((YAMLScalar) parent, clazz -> {
            PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(psiElement.getProject(),clazz);
            if(phpClass != null) {
                for(Method method: PhpElementsUtil.getClassPublicMethod(phpClass)) {
                    if(method.getName().equals(PsiElementUtils.trimQuote(psiElement.getText()))) {
                        results.add(method);
                    }
                }
            }
        });
    }

    return results;
}
 

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

示例6: testGetYamlConstructorTypeHint

点赞 3

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
/**
 * @see fr.adrienbrault.idea.symfony2plugin.dic.container.util.ServiceContainerUtil#getYamlConstructorTypeHint
 */
public void testGetYamlConstructorTypeHint() {
    myFixture.configureByText("test.yml", "" +
        "services:\n" +
        "   NamedArgument\\Foobar:\n" +
        "       arguments: ['<caret>']\n"
    );

    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());

    YAMLScalar parent = (YAMLScalar) psiElement.getParent();

    ServiceTypeHint typeHint = ServiceContainerUtil.getYamlConstructorTypeHint(
        parent,
        new ContainerCollectionResolver.LazyServiceCollector(getProject())
    );

    assertEquals(0, typeHint.getIndex());
    assertEquals("__construct", typeHint.getMethod().getName());
}
 

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

示例7: testGetYamlConstructorTypeHintForNamedArgument

点赞 3

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
/**
 * @see fr.adrienbrault.idea.symfony2plugin.dic.container.util.ServiceContainerUtil#getYamlConstructorTypeHint
 */
public void testGetYamlConstructorTypeHintForNamedArgument() {
    myFixture.configureByText("test.yml", "" +
        "services:\n" +
        "   NamedArgument\\Foobar:\n" +
        "       arguments:\n" +
        "           $foobar: '<caret>'\n"
    );

    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());

    YAMLScalar parent = (YAMLScalar) psiElement.getParent();

    ServiceTypeHint typeHint = ServiceContainerUtil.getYamlConstructorTypeHint(
        parent,
        new ContainerCollectionResolver.LazyServiceCollector(getProject())
    );

    assertEquals(0, typeHint.getIndex());
    assertEquals("__construct", typeHint.getMethod().getName());
}
 

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

示例8: testVisitServiceCall

点赞 3

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
/**
 * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#visitServiceCall
 */
public void testVisitServiceCall() {
    myFixture.configureByText(YAMLFileType.YML, "services:\n" +
        "    foobar:\n" +
        "       class: Foo\\Bar\n" +
        "       calls:\n" +
        "           - [ '<caret>' ]\n"
    );

    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
    YAMLScalar parent = (YAMLScalar) psiElement.getParent();

    Collection<String> values = new ArrayList<>();
    YamlHelper.visitServiceCall(parent, values::add);

    assertContainsElements(values, "Foo\\Bar");
}
 

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

示例9: testVisitServiceCallForNamedServices

点赞 3

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
/**
 * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#visitServiceCall
 */
public void testVisitServiceCallForNamedServices() {
    myFixture.configureByText(YAMLFileType.YML, "services:\n" +
        "    Foo\\Bar:\n" +
        "       calls:\n" +
        "           - [ '<caret>' ]\n"
    );

    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
    YAMLScalar parent = (YAMLScalar) psiElement.getParent();

    Collection<String> values = new ArrayList<>();
    YamlHelper.visitServiceCall(parent, values::add);

    assertContainsElements(values, "Foo\\Bar");
}
 

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

示例10: testVisitServiceCallArgument

点赞 3

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
/**
 * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#visitServiceCallArgument
 */
public void testVisitServiceCallArgument() {
    myFixture.configureByText(YAMLFileType.YML, "services:\n" +
        "    foobar:\n" +
        "       class: Foo\\Bar\n" +
        "       calls:\n" +
        "           - [ 'setBar', [@f<caret>oo] ]\n"
    );

    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
    YAMLScalar parent = (YAMLScalar) psiElement.getParent();

    Collection<String> values = new ArrayList<>();
    YamlHelper.visitServiceCallArgument(parent, parameterVisitor ->
        values.add(parameterVisitor.getClassName() + ":" + parameterVisitor.getMethod() + ":" + parameterVisitor.getParameterIndex())
    );

    assertContainsElements(values, "Foo\\Bar:setBar:0");
}
 

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

示例11: testVisitServiceCallArgumentAsNamedService

点赞 3

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
/**
 * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#visitServiceCallArgument
 */
public void testVisitServiceCallArgumentAsNamedService() {
    myFixture.configureByText(YAMLFileType.YML, "services:\n" +
        "    Foo\\Bar:\n" +
        "       calls:\n" +
        "           - [ 'setBar', [@f<caret>oo] ]\n"
    );

    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
    YAMLScalar parent = (YAMLScalar) psiElement.getParent();

    Collection<String> values = new ArrayList<>();
    YamlHelper.visitServiceCallArgument(parent, parameterVisitor ->
        values.add(parameterVisitor.getClassName() + ":" + parameterVisitor.getMethod() + ":" + parameterVisitor.getParameterIndex())
    );

    assertContainsElements(values, "Foo\\Bar:setBar:0");
}
 

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

示例12: testVisitServiceCallArgumentMethodIndex

点赞 3

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
/**
 * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#visitServiceCallArgumentMethodIndex
 */
public void testVisitServiceCallArgumentMethodIndex() {
    myFixture.configureByText(YAMLFileType.YML, "services:\n" +
        "    foobar:\n" +
        "       class: Foo\\Bar\n" +
        "       calls:\n" +
        "           - [ 'setBar', [@f<caret>oo] ]\n"
    );

    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
    YAMLScalar parent = (YAMLScalar) psiElement.getParent();

    Collection<Parameter> parameters = new ArrayList<>();
    YamlHelper.visitServiceCallArgumentMethodIndex(parent, parameters::add);

    assertNotNull(ContainerUtil.find(parameters, parameter -> "arg1".equals(parameter.getName())));
}
 

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

示例13: testVisitServiceCallArgumentMethodIndexForNamedServices

点赞 3

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
/**
 * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#visitServiceCallArgumentMethodIndex
 */
public void testVisitServiceCallArgumentMethodIndexForNamedServices() {
    myFixture.configureByText(YAMLFileType.YML, "services:\n" +
        "    Foo\\Bar:\n" +
        "       calls:\n" +
        "           - [ 'setBar', ['@foo', @f<caret>oo] ]\n"
    );

    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
    YAMLScalar parent = (YAMLScalar) psiElement.getParent();

    Collection<Parameter> parameters = new ArrayList<>();
    YamlHelper.visitServiceCallArgumentMethodIndex(parent, parameters::add);

    assertNotNull(ContainerUtil.find(parameters, parameter -> "arg2".equals(parameter.getName())));
}
 

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

示例14: getYamlScalarKey

点赞 2

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
@Nullable
public static String getYamlScalarKey(@NotNull PsiElement psiElement) {
    PsiElement parent = psiElement.getParent();

    if(!(parent instanceof YAMLScalar)) {
        return null;
    }

    String text = ((YAMLScalar) parent).getTextValue();
    if(StringUtils.isBlank(text)) {
        return null;
    }

    return text;
}
 

开发者ID:Haehnchen,
项目名称:idea-php-drupal-symfony2-bridge,
代码行数:16,
代码来源:YamlRegistrarUtil.java

示例15: visitElement

点赞 2

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
@Override
public void visitElement(PsiElement element) {

    if(YamlElementPatternHelper.getSingleLineScalarKey("class").accepts(element)) {

        // class: '\Foo'
        String text = PsiElementUtils.trimQuote(element.getText());
        if(StringUtils.isBlank(text)) {
            super.visitElement(element);
            return;
        }

        PsiElement yamlScalar = element.getParent();
        if(!(yamlScalar instanceof YAMLScalar)) {
            super.visitElement(element);
            return;
        }

        PsiElement classKey = yamlScalar.getParent();
        if(classKey instanceof YAMLKeyValue) {
            PsiElement yamlCompoundValue = classKey.getParent();
            if(yamlCompoundValue instanceof YAMLCompoundValue) {
                PsiElement serviceKeyValue = yamlCompoundValue.getParent();
                if(serviceKeyValue instanceof YAMLKeyValue) {
                    Set<String> tags = YamlHelper.collectServiceTags((YAMLKeyValue) serviceKeyValue);
                    if(tags != null && tags.size() > 0) {
                        registerTaggedProblems(element, tags, text, holder, this.lazyServiceCollector);
                    }
                }

            }
        }

    }


    super.visitElement(element);
}
 

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

示例16: getTextValueForElement

点赞 2

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
@Nullable
public static String getTextValueForElement(@NotNull PsiElement psiElement) {
    PsiElement parent = psiElement.getParent();

    String value = null;
    if(parent instanceof StringLiteralExpression) {
        value = ((StringLiteralExpression) parent).getContents();
    } else if(parent instanceof XmlAttributeValue) {
        // <foo attr="FOO"/>
        value = ((XmlAttributeValue) parent).getValue();
    } else if(parent instanceof XmlText) {
        // <foo>FOO</foo>
        value = ((XmlText) parent).getValue();
    } else if(parent instanceof YAMLScalar) {
        // foo: foo, foo: 'foo', foo: "foo"
        value = ((YAMLScalar) parent).getTextValue();
    } else if(psiElement.getNode().getElementType() == TwigTokenTypes.STRING_TEXT) {
        // twig: 'foobar'
        value = psiElement.getText();
    }

    if(StringUtils.isBlank(value)) {
        return null;
    }

    return value;
}
 

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

示例17: getFactoryStringGoto

点赞 2

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
/**
 * Factory goto: "factory: 'foo:bar'"
 */
@NotNull
private Collection<PsiElement> getFactoryStringGoto(@NotNull PsiElement psiElement) {
    PsiElement parent = psiElement.getParent();
    if(!(parent instanceof YAMLScalar)) {
        return Collections.emptyList();
    }

    String textValue = ((YAMLScalar) parent).getTextValue();
    String[] split = textValue.split(":");
    if(split.length != 2) {
        return Collections.emptyList();
    }

    PhpClass phpClass = ServiceUtil.getServiceClass(psiElement.getProject(), split[0]);
    if(phpClass == null) {
        return Collections.emptyList();
    }

    Collection<PsiElement> results = new ArrayList<>();

    for (Method method : phpClass.getMethods()) {
        if(split[1].equals(method.getName())) {
            results.add(method);
        }
    }

    return results;
}
 

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

示例18: getGlobalServiceStringPattern

点赞 2

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
/**
 * foo: b<caret>ar
 * foo: [ b<caret>ar ]
 * foo: { b<caret>ar }
 * foo:
 *  - b<caret>ar
 */
private PsiElementPattern.Capture<PsiElement> getGlobalServiceStringPattern() {
    return PlatformPatterns.psiElement().withParent(
            PlatformPatterns.psiElement(YAMLScalar.class).withParent(PlatformPatterns.or(
                    PlatformPatterns.psiElement(YAMLKeyValue.class),
                    PlatformPatterns.psiElement(YAMLSequenceItem.class),
                    PlatformPatterns.psiElement(YAMLMapping.class)
            )));
}
 

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

示例19: getPlaceholderFromTranslation

点赞 2

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
/**
 * Extract common placeholder pattern from translation content
 */
@NotNull
public static Set<String> getPlaceholderFromTranslation(@NotNull Project project, @NotNull String key, @NotNull String domain) {
    Set<String> placeholder = new HashSet<>();
    Set<VirtualFile> visitedXlf = new HashSet<>();

    for (PsiElement element : TranslationUtil.getTranslationPsiElements(project, key, domain)) {
        if (element instanceof YAMLScalar) {
            String textValue = ((YAMLScalar) element).getTextValue();
            if(StringUtils.isBlank(textValue)) {
                continue;
            }

            placeholder.addAll(
                TranslationUtil.getPlaceholderFromTranslation(textValue)
            );
        } else if("xlf".equalsIgnoreCase(element.getContainingFile().getVirtualFile().getExtension()) || "xliff".equalsIgnoreCase(element.getContainingFile().getVirtualFile().getExtension())) {
            VirtualFile virtualFile = element.getContainingFile().getVirtualFile();

            // visiting on file scope because we dont rely on xlf and xliff registered as XML file
            // dont visit file twice
            if(!visitedXlf.contains(virtualFile)) {
                try {
                    visitXliffTranslations(
                        element.getContainingFile().getVirtualFile().getInputStream(),
                        new MyXlfTranslationConsumer(placeholder, key)
                    );
                } catch (IOException ignored) {
                }
            }

            visitedXlf.add(virtualFile);
        }
    }

    return placeholder;
}
 

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

示例20: addCompletions

点赞 2

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
    Stream<LookupElementBuilder> stream = null;
    PsiElement position = completionParameters.getPosition();

    // No completion on ordinary YAML files
    if (!isConfigFile(position)) {
        return;
    }

    // Completion for YAML keys
    if (isKey(position)) {
        stream = KEY_COMPLETION_PROVIDER.resolve(resolvePath(position), position)
                .map(prev -> LookupElementBuilder.create(prev.getLookupString() + ": ")
                        .withPresentableText(prev.getLookupString())
                );
    }
    // Completion for YAML values
    else if (isValue(position)) {
        YAMLScalar yamlScalar = (YAMLScalar) position.getContext();
        if (yamlScalar != null) {
            int cursorOffset = calculateCursorOffset(completionParameters, position, yamlScalar);
            List<MacroResolver.Match> matches = new MacroResolver().resolve(yamlScalar.getTextValue().substring(0, cursorOffset));
            if (!matches.isEmpty()) {
                MacroResolver.Match closestMatch = findClosestMatch(matches, cursorOffset);
                if (closestMatch != null) {
                    MacroInfo macroInfo = resolveMacroInfo(closestMatch, completionResultSet, cursorOffset);
                    completionResultSet = macroInfo.completionResultSet;
                    stream = KEY_COMPLETION_PROVIDER.resolve(macroInfo.path, position);
                }
            } else {
                stream = VALUE_COMPLETION_PROVIDER.resolve(resolvePath(position), position);
            }
        }
    }

    // Add lookup elements to completion results
    if (stream != null) {
        stream.forEach(completionResultSet::addElement);
    }
}
 

开发者ID:seedstack,
项目名称:intellij-plugin,
代码行数:42,
代码来源:CoffigCompletionContributor.java

示例21: calculateCursorOffset

点赞 2

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
private int calculateCursorOffset(@NotNull CompletionParameters completionParameters, PsiElement position, YAMLScalar yamlScalar) {
    // YAML quoted text is shifted by one because of starting quote
    return completionParameters.getOffset() - (position.getTextRange().getStartOffset() + (yamlScalar instanceof YAMLQuotedText ? 1 : 0));
}
 

开发者ID:seedstack,
项目名称:intellij-plugin,
代码行数:5,
代码来源:CoffigCompletionContributor.java

示例22: isValue

点赞 2

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
private boolean isValue(PsiElement position) {
    return position != null && position.getContext() instanceof YAMLScalar;
}
 

开发者ID:seedstack,
项目名称:intellij-plugin,
代码行数:4,
代码来源:CoffigCompletionContributor.java

示例23: collectRouteInlineClasses

点赞 2

import org.jetbrains.yaml.psi.YAMLScalar; //导入依赖的package包/类
private void collectRouteInlineClasses(@NotNull Collection<LineMarkerInfo> results, @NotNull Project project, @NotNull PsiElement psiElement) {

        if(!(YamlElementPatternHelper.getSingleLineScalarKey("_form").accepts(psiElement) ||
            YamlElementPatternHelper.getSingleLineScalarKey("_entity_form").accepts(psiElement))
            ) {
            return;
        }

        PsiElement yamlScalar = psiElement.getParent();
        if(!(yamlScalar instanceof YAMLScalar)) {
            return;
        }

        String textValue = ((YAMLScalar) yamlScalar).getTextValue();

        Collection<PhpClass> classesInterface = new ArrayList<>(PhpElementsUtil.getClassesInterface(project, textValue));
        classesInterface.addAll(IndexUtil.getFormClassForId(project, textValue));

        if(classesInterface.size() == 0) {
            return;
        }

        PsiElement yamlKeyValue = yamlScalar.getParent();
        if(!(yamlKeyValue instanceof YAMLKeyValue)) {
            return;
        }

        YAMLMapping parentMapping = ((YAMLKeyValue) yamlKeyValue).getParentMapping();
        if(parentMapping == null) {
            return;
        }

        PsiElement parent = parentMapping.getParent();
        if(!(parent instanceof YAMLKeyValue)) {
            return;
        }

        String keyText = ((YAMLKeyValue) parent).getKeyText();

        if(!"defaults".equals(keyText)) {
            return;
        }

        YAMLMapping parentMapping1 = ((YAMLKeyValue) parent).getParentMapping();
        if(parentMapping1 == null) {
            return;
        }

        PsiElement parent1 = parentMapping1.getParent();
        if(!(parent1 instanceof YAMLKeyValue)) {
            return;
        }

        NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.FORM_TYPE_LINE_MARKER).
            setTargets(classesInterface).
            setTooltipText("Navigate to form");

        results.add(builder.createLineMarkerInfo(parent1));
    }
 

开发者ID:Haehnchen,
项目名称:idea-php-drupal-symfony2-bridge,
代码行数:60,
代码来源:RouteFormLineMarkerProvider.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)