-
-
Notifications
You must be signed in to change notification settings - Fork 136
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 #2314 from Haehnchen/feature/ux-component-search
add Twig components to "Search Everywhere"
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/main/java/fr/adrienbrault/idea/symfony2plugin/ux/UxComponentSymbolContributor.java
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,50 @@ | ||
package fr.adrienbrault.idea.symfony2plugin.ux; | ||
|
||
import com.intellij.navigation.ChooseByNameContributorEx; | ||
import com.intellij.navigation.NavigationItem; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.psi.PsiFile; | ||
import com.intellij.psi.search.GlobalSearchScope; | ||
import com.intellij.util.Processor; | ||
import com.intellij.util.indexing.FindSymbolParameters; | ||
import com.intellij.util.indexing.IdFilter; | ||
import com.jetbrains.php.lang.psi.elements.PhpClass; | ||
import fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent; | ||
import fr.adrienbrault.idea.symfony2plugin.navigation.NavigationItemExStateless; | ||
import fr.adrienbrault.idea.symfony2plugin.util.UxUtil; | ||
import icons.TwigIcons; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* @author Daniel Espendiller <[email protected]> | ||
*/ | ||
public class UxComponentSymbolContributor implements ChooseByNameContributorEx { | ||
@Override | ||
public void processNames(@NotNull Processor<? super String> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { | ||
Project project = scope.getProject(); | ||
if (!Symfony2ProjectComponent.isEnabled(project)) { | ||
return; | ||
} | ||
|
||
for (UxUtil.TwigComponent allComponentName : UxUtil.getAllComponentNames(project)) { | ||
processor.process(allComponentName.name()); | ||
} | ||
} | ||
|
||
@Override | ||
public void processElementsWithName(@NotNull String name, @NotNull Processor<? super NavigationItem> processor, @NotNull FindSymbolParameters parameters) { | ||
Project project = parameters.getProject(); | ||
if (!Symfony2ProjectComponent.isEnabled(project)) { | ||
return; | ||
} | ||
|
||
for (PhpClass component : UxUtil.getTwigComponentPhpClasses(project, name)) { | ||
processor.process(NavigationItemExStateless.create(component, name, component.getIcon(), "TwigComponent (" + component.getName() + ")", false)); | ||
} | ||
|
||
for (PsiFile component : UxUtil.getComponentTemplates(project, name)) { | ||
processor.process(NavigationItemExStateless.create(component, name, TwigIcons.TwigFileIcon, "TwigComponent (" + component.getName() + ")", false)); | ||
} | ||
} | ||
} |
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