-
-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2256 from adrolter/feature/inspections-use-psi-refs
Use PsiReference list to determine if "missing" inspections apply
- Loading branch information
Showing
3 changed files
with
11 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
*/ | ||
|
@@ -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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
*/ | ||
|
@@ -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; | ||
} | ||
|
||
|