diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/inspection/MissingServiceInspection.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/inspection/MissingServiceInspection.java index 666a34877..e19e0fab9 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/inspection/MissingServiceInspection.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/inspection/MissingServiceInspection.java @@ -10,6 +10,7 @@ import com.jetbrains.php.lang.psi.elements.StringLiteralExpression; import fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent; import fr.adrienbrault.idea.symfony2plugin.config.yaml.YamlElementPatternHelper; +import fr.adrienbrault.idea.symfony2plugin.dic.ServiceReference; import fr.adrienbrault.idea.symfony2plugin.dic.container.util.ServiceContainerUtil; import fr.adrienbrault.idea.symfony2plugin.stubs.ContainerCollectionResolver; import fr.adrienbrault.idea.symfony2plugin.util.PhpElementsUtil; @@ -19,6 +20,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.yaml.YAMLLanguage; +import java.util.Arrays; + /** * @author Daniel Espendiller */ @@ -48,7 +51,7 @@ public void visitElement(PsiElement element) { if(element.getLanguage() == PhpLanguage.INSTANCE && element instanceof StringLiteralExpression) { // PHP MethodReference methodReference = PsiElementUtils.getMethodReferenceWithFirstStringParameter((StringLiteralExpression) element); - if (methodReference != null && PhpElementsUtil.isMethodReferenceInstanceOf(methodReference, ServiceContainerUtil.SERVICE_GET_SIGNATURES)) { + if (methodReference != null && Arrays.stream(element.getReferences()).anyMatch(ref -> ref instanceof ServiceReference)) { String serviceName = PhpElementsUtil.getFirstArgumentStringValue(methodReference); if (StringUtils.isNotBlank(serviceName) && !hasService(serviceName)) { holder.registerProblem(element, INSPECTION_MESSAGE, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/routing/inspection/PhpRouteMissingInspection.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/routing/inspection/PhpRouteMissingInspection.java index 961721030..67638559b 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/routing/inspection/PhpRouteMissingInspection.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/routing/inspection/PhpRouteMissingInspection.java @@ -6,14 +6,14 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent; -import fr.adrienbrault.idea.symfony2plugin.routing.PhpRouteReferenceContributor; import fr.adrienbrault.idea.symfony2plugin.routing.Route; import fr.adrienbrault.idea.symfony2plugin.routing.RouteHelper; -import fr.adrienbrault.idea.symfony2plugin.util.MethodMatcher; +import fr.adrienbrault.idea.symfony2plugin.routing.RouteReference; import fr.adrienbrault.idea.symfony2plugin.util.PhpElementsUtil; import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; +import java.util.Arrays; import java.util.Collection; /** @@ -43,16 +43,12 @@ public void visitElement(@NotNull PsiElement element) { } private void invoke(@NotNull String routeName, @NotNull final PsiElement element, @NotNull ProblemsHolder holder) { - MethodMatcher.MethodMatchParameter methodMatchParameter = new MethodMatcher.StringParameterMatcher(element, 0) - .withSignature(PhpRouteReferenceContributor.GENERATOR_SIGNATURES) - .match(); - - if(methodMatchParameter == null) { + if(Arrays.stream(element.getReferences()).noneMatch(ref -> ref instanceof RouteReference)) { return; } Collection route = RouteHelper.getRoute(element.getProject(), routeName); - if(route.size() == 0) { + if(route.isEmpty()) { holder.registerProblem(element, "Symfony: Missing Route", ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new RouteGuessTypoQuickFix(routeName)); } } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/PhpTemplateMissingInspection.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/PhpTemplateMissingInspection.java index 88c973485..b7f4cdab5 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/PhpTemplateMissingInspection.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/PhpTemplateMissingInspection.java @@ -10,7 +10,6 @@ import com.jetbrains.php.lang.psi.elements.ParameterList; import com.jetbrains.php.lang.psi.elements.StringLiteralExpression; import fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent; -import fr.adrienbrault.idea.symfony2plugin.config.SymfonyPhpReferenceContributor; import fr.adrienbrault.idea.symfony2plugin.templating.inspection.TemplateCreateByNameLocalQuickFix; import fr.adrienbrault.idea.symfony2plugin.templating.inspection.TemplateGuessTypoQuickFix; import fr.adrienbrault.idea.symfony2plugin.templating.util.TwigUtil; @@ -21,6 +20,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Arrays; + /** * @author Daniel Espendiller */ @@ -81,7 +82,7 @@ private String getTemplateNameIfMissing(@NotNull StringLiteralExpression psiElem return null; } - if (!PhpElementsUtil.isMethodReferenceInstanceOf((MethodReference) methodReference, SymfonyPhpReferenceContributor.TEMPLATE_SIGNATURES)) { + if(Arrays.stream(psiElement.getReferences()).noneMatch(ref -> ref instanceof TemplateReference)) { return null; }