-
-
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 #2360 from Haehnchen/feature/route-deprecated-insp…
…ection-language split RouteControllerDeprecatedInspection into language implentations to reduce wall time calls
- Loading branch information
Showing
4 changed files
with
59 additions
and
26 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 |
---|---|---|
|
@@ -20,39 +20,59 @@ | |
/** | ||
* @author Daniel Espendiller <[email protected]> | ||
*/ | ||
public class RouteControllerDeprecatedInspection extends LocalInspectionTool { | ||
public class RouteControllerDeprecatedInspection { | ||
public static class MyXmlLocalInspectionTool extends LocalInspectionTool { | ||
@Override | ||
public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) { | ||
Project project = holder.getProject(); | ||
if (!Symfony2ProjectComponent.isEnabled(project)) { | ||
return super.buildVisitor(holder, isOnTheFly); | ||
} | ||
|
||
return new PsiElementVisitor() { | ||
@Override | ||
public void visitElement(@NotNull PsiElement element) { | ||
if (XmlHelper.getRouteControllerPattern().accepts(element)) { | ||
PsiElement parent = element.getParent(); | ||
if (parent != null) { | ||
String text = RouteXmlReferenceContributor.getControllerText(parent); | ||
if(text != null) { | ||
extracted(project, element, text, holder); | ||
} | ||
} | ||
} | ||
|
||
@NotNull | ||
public PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, boolean isOnTheFly) { | ||
Project project = holder.getProject(); | ||
if (!Symfony2ProjectComponent.isEnabled(project)) { | ||
return super.buildVisitor(holder, isOnTheFly); | ||
super.visitElement(element); | ||
} | ||
}; | ||
} | ||
} | ||
|
||
return new PsiElementVisitor() { | ||
@Override | ||
public void visitElement(@NotNull PsiElement element) { | ||
if (XmlHelper.getRouteControllerPattern().accepts(element)) { | ||
PsiElement parent = element.getParent(); | ||
if (parent != null) { | ||
String text = RouteXmlReferenceContributor.getControllerText(parent); | ||
if(text != null) { | ||
public static class MyYamlLocalInspectionTool extends LocalInspectionTool { | ||
@Override | ||
public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) { | ||
Project project = holder.getProject(); | ||
if (!Symfony2ProjectComponent.isEnabled(project)) { | ||
return super.buildVisitor(holder, isOnTheFly); | ||
} | ||
|
||
return new PsiElementVisitor() { | ||
@Override | ||
public void visitElement(@NotNull PsiElement element) { | ||
if(YamlElementPatternHelper.getSingleLineScalarKey("_controller", "controller").accepts(element)) { | ||
String text = PsiElementUtils.trimQuote(element.getText()); | ||
if (StringUtils.isNotBlank(text)) { | ||
extracted(project, element, text, holder); | ||
} | ||
} | ||
} else if(YamlElementPatternHelper.getSingleLineScalarKey("_controller", "controller").accepts(element)) { | ||
String text = PsiElementUtils.trimQuote(element.getText()); | ||
if (StringUtils.isNotBlank(text)) { | ||
extracted(project, element, text, holder); | ||
} | ||
} | ||
|
||
super.visitElement(element); | ||
} | ||
}; | ||
super.visitElement(element); | ||
} | ||
}; | ||
} | ||
} | ||
|
||
private void extracted(@NotNull Project project, @NotNull PsiElement element, String text, @NotNull ProblemsHolder holder) { | ||
private static void extracted(@NotNull Project project, @NotNull PsiElement element, String text, @NotNull ProblemsHolder holder) { | ||
for (PsiElement psiElement : RouteHelper.getMethodsOnControllerShortcut(project, text)) { | ||
if (!(psiElement instanceof PhpNamedElement)) { | ||
continue; | ||
|
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
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
src/main/resources/inspectionDescriptions/RouteControllerDeprecatedInspectionYaml.html
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<html> | ||
<body> | ||
<!-- tooltip end --> | ||
</body> | ||
</html> |