-
-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constants in methods argument of Route attribute cause plugin exception #1705
Labels
Comments
Hi @andyexeter. Thank you for great bug report. I was able to reproduce your issue. My first idea here is to wrap https://github.com/Haehnchen/idea-php-symfony2-plugin/blob/master/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpElementsUtil.java#L632-L651 with dumb mode check but I'm not sure if it's right direction. Index: src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpElementsUtil.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpElementsUtil.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpElementsUtil.java
--- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpElementsUtil.java
+++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpElementsUtil.java (date 1632149790480)
@@ -1,7 +1,6 @@
package fr.adrienbrault.idea.symfony2plugin.util;
import com.intellij.codeInsight.completion.CompletionResultSet;
-import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.patterns.ElementPattern;
import com.intellij.patterns.PatternCondition;
@@ -630,27 +629,24 @@
}
return resolvedString;
- }
- else if (!DumbService.getInstance(psiElement.getProject()).isDumb()) {
- if(psiElement instanceof Field) {
- return getStringValue(((Field) psiElement).getDefaultValue(), depth);
- } else if(psiElement instanceof ClassConstantReference && "class".equals(((ClassConstantReference) psiElement).getName())) {
- // Foobar::class
- return getClassConstantPhpFqn((ClassConstantReference) psiElement);
- } else if(psiElement instanceof PhpReference) {
- PsiReference psiReference = psiElement.getReference();
- if(psiReference == null) {
- return null;
- }
+ } else if(psiElement instanceof Field) {
+ return getStringValue(((Field) psiElement).getDefaultValue(), depth);
+ } else if(psiElement instanceof ClassConstantReference && "class".equals(((ClassConstantReference) psiElement).getName())) {
+ // Foobar::class
+ return getClassConstantPhpFqn((ClassConstantReference) psiElement);
+ } else if(psiElement instanceof PhpReference) {
+ PsiReference psiReference = psiElement.getReference();
+ if(psiReference == null) {
+ return null;
+ }
- PsiElement ref = psiReference.resolve();
- if(ref instanceof PhpReference) {
- return getStringValue(psiElement, depth);
- }
+ PsiElement ref = psiReference.resolve();
+ if(ref instanceof PhpReference) {
+ return getStringValue(psiElement, depth);
+ }
- if(ref instanceof Field) {
- return getStringValue(((Field) ref).getDefaultValue());
- }
+ if(ref instanceof Field) {
+ return getStringValue(((Field) ref).getDefaultValue());
}
}
|
Haehnchen
added a commit
that referenced
this issue
Apr 27, 2022
Haehnchen
added a commit
that referenced
this issue
Apr 27, 2022
Haehnchen
added a commit
that referenced
this issue
Apr 27, 2022
Haehnchen
added a commit
that referenced
this issue
Apr 27, 2022
Haehnchen
added a commit
that referenced
this issue
Apr 27, 2022
Haehnchen
added a commit
that referenced
this issue
Apr 27, 2022
Haehnchen
added a commit
that referenced
this issue
Apr 27, 2022
#1705 support constants for route name and path via first level self owning
fixed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PhpStorm Version: 2021.2.1
Plugin version: 0.23.212
When using a constant in the
methods
argument of aRoute
attribute, the following exception is thrown:Click to expand
This leads to a "Missing Route" warning on all route names in Twig templates and in arguments to the router.
Reproducible example code:
Using the fully-qualified class name instead of a
use
statement doesn't seem to help.Replacing the constant with string literals e.g
GET
resolves the issue, but I'd like to use constants if possible.I've set up a small reproducer here, if it helps: https://github.com/andyexeter/idea-symfony-plugin-routing-issue-demo
The text was updated successfully, but these errors were encountered: