|
1 | 1 | package fr.adrienbrault.idea.symfony2plugin.routing.inspection;
|
2 | 2 |
|
3 |
| -import com.intellij.codeInspection.ProblemHighlightType; |
4 | 3 | import com.intellij.codeInspection.ProblemsHolder;
|
5 |
| -import com.intellij.ide.highlighter.XmlFileType; |
6 | 4 | import com.intellij.psi.PsiElement;
|
7 |
| -import com.intellij.psi.search.GlobalSearchScope; |
8 |
| -import com.intellij.util.indexing.FileBasedIndex; |
9 |
| -import com.jetbrains.php.lang.PhpFileType; |
10 |
| -import fr.adrienbrault.idea.symfony2plugin.routing.Route; |
11 |
| -import fr.adrienbrault.idea.symfony2plugin.routing.RouteHelper; |
12 |
| -import fr.adrienbrault.idea.symfony2plugin.stubs.indexes.AnnotationRoutesStubIndex; |
13 |
| -import fr.adrienbrault.idea.symfony2plugin.stubs.indexes.RoutesStubIndex; |
| 5 | +import fr.adrienbrault.idea.symfony2plugin.routing.PhpRouteInspection; |
14 | 6 | import org.jetbrains.annotations.NotNull;
|
15 |
| -import org.jetbrains.yaml.YAMLFileType; |
16 |
| - |
17 |
| -import java.util.Collection; |
18 |
| -import java.util.Map; |
19 | 7 |
|
20 | 8 | /**
|
21 | 9 | * @author Daniel Espendiller <daniel@espendiller.net>
|
22 | 10 | */
|
23 | 11 | public class PhpRouteMissingInspection extends AbstractPhpRouteInspection {
|
24 |
| - |
25 | 12 | protected void annotateRouteName(PsiElement target, @NotNull ProblemsHolder holder, final String routeName) {
|
26 |
| - |
27 |
| - Map<String, Route> routes = RouteHelper.getCompiledRoutes(target.getProject()); |
28 |
| - |
29 |
| - if(routes.containsKey(routeName)) { |
30 |
| - return; |
31 |
| - } |
32 |
| - |
33 |
| - Collection fileCollection = FileBasedIndex.getInstance().getContainingFiles(RoutesStubIndex.KEY, routeName, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(target.getProject()), YAMLFileType.YML, XmlFileType.INSTANCE)); |
34 |
| - if(fileCollection.size() > 0) { |
35 |
| - return; |
36 |
| - } |
37 |
| - |
38 |
| - fileCollection = FileBasedIndex.getInstance().getContainingFiles(AnnotationRoutesStubIndex.KEY, routeName, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(target.getProject()), PhpFileType.INSTANCE)); |
39 |
| - if(fileCollection.size() > 0) { |
40 |
| - return; |
41 |
| - } |
42 |
| - |
43 |
| - holder.registerProblem(target, "Missing Route", ProblemHighlightType.GENERIC_ERROR_OR_WARNING); |
44 |
| - |
| 13 | + PhpRouteInspection.annotateRouteName(target, holder, routeName); |
45 | 14 | }
|
46 |
| - |
47 | 15 | }
|
0 commit comments