Java Code Examples for fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#isRoutingFile()

The following examples show how to use fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#isRoutingFile() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DuplicateLocalRouteInspection.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@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);
    }
}
 
Example 2
Source File: RouteSettingDeprecatedInspection.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
private void registerYmlRoutePatternProblem(@NotNull ProblemsHolder holder, @NotNull YAMLKeyValue element) {
    String s = PsiElementUtils.trimQuote(element.getKeyText());
    if("pattern".equals(s) && YamlHelper.isRoutingFile(element.getContainingFile())) {
        // pattern: foo
        holder.registerProblem(element.getKey(), "Pattern is deprecated; use path instead", ProblemHighlightType.LIKE_DEPRECATED);

    } else if(("_method".equals(s) || "_scheme".equals(s)) && YamlHelper.isRoutingFile(element.getContainingFile())) {
        // requirements: { _method: 'foo', '_scheme': 'foo' }
        YAMLKeyValue parentOfType = PsiTreeUtil.getParentOfType(element, YAMLKeyValue.class);
        if(parentOfType != null && "requirements".equals(parentOfType.getKeyText())) {
            holder.registerProblem(element.getKey(), String.format("The '%s' requirement is deprecated", s), ProblemHighlightType.LIKE_DEPRECATED);
        }
    }
}
 
Example 3
Source File: YamlCompletionContributor.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) {

            if(!YamlHelper.isRoutingFile(parameters.getOriginalFile())) {
                return;
            }

            super.addCompletions(parameters, context, resultSet);
        }