com.intellij.codeInsight.navigation.NavigationGutterIconBuilder Java Examples
The following examples show how to use
com.intellij.codeInsight.navigation.NavigationGutterIconBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ORLineMarkerProvider.java From reasonml-idea-plugin with MIT License | 6 votes |
private void extractRelatedExpressions(@Nullable PsiElement element, @NotNull Collection<? super RelatedItemLineMarkerInfo<?>> result, @NotNull FileBase containingFile) { if (element == null) { return; } FileBase psiRelatedFile = PsiFinder.getInstance(containingFile.getProject()).findRelatedFile(containingFile); if (psiRelatedFile != null) { Collection<PsiNameIdentifierOwner> expressions = psiRelatedFile.getExpressions(element.getText()); if (expressions.size() == 1) { PsiNameIdentifierOwner relatedElement = expressions.iterator().next(); PsiElement nameIdentifier = relatedElement.getNameIdentifier(); if (nameIdentifier != null) { String tooltip = GutterIconTooltipHelper .composeText(new PsiElement[]{psiRelatedFile}, "", "Implements method <b>" + nameIdentifier.getText() + "</b> in <b>{0}</b>"); result.add(NavigationGutterIconBuilder. create(containingFile.isInterface() ? ORIcons.IMPLEMENTED : ORIcons.IMPLEMENTING). setTooltipText(tooltip). setAlignment(GutterIconRenderer.Alignment.RIGHT). setTargets(Collections.singleton(nameIdentifier instanceof PsiLowerSymbol ? nameIdentifier.getFirstChild() : nameIdentifier)). createLineMarkerInfo(element)); } } } }
Example #2
Source File: FileResourceUtil.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@Nullable public static RelatedItemLineMarkerInfo<PsiElement> getFileImplementsLineMarker(@NotNull PsiFile psiFile) { final Project project = psiFile.getProject(); VirtualFile virtualFile = psiFile.getVirtualFile(); if(virtualFile == null) { return null; } String bundleLocateName = FileResourceUtil.getBundleLocateName(project, virtualFile); if(bundleLocateName == null) { return null; } if(FileResourceUtil.getFileResourceRefers(project, bundleLocateName).size() == 0) { return null; } NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(PhpIcons.IMPLEMENTS). setTargets(new FileResourceUtil.FileResourceNotNullLazyValue(project, bundleLocateName)). setTooltipText("Navigate to resource"); return builder.createLineMarkerInfo(psiFile); }
Example #3
Source File: ConfigLineMarkerProvider.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private void visitRootElements(@NotNull Collection<LineMarkerInfo> result, @NotNull PsiElement psiElement, @NotNull LazyConfigTreeSignatures function) { PsiElement parent = psiElement.getParent(); if(!(parent instanceof YAMLKeyValue)) { return; } String keyText = ((YAMLKeyValue) parent).getKeyText(); Map<String, Collection<String>> treeSignatures = function.value(); if(!treeSignatures.containsKey(keyText)) { return; } NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.SYMFONY_LINE_MARKER) .setTargets(new MyClassIdLazyValue(psiElement.getProject(), treeSignatures.get(keyText), keyText)) .setTooltipText("Navigate to configuration"); result.add(builder.createLineMarkerInfo(psiElement)); }
Example #4
Source File: ServiceLineMarkerProvider.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * "FooValidator" back to "Foo" constraint */ private void constraintValidatorClassMarker(PsiElement psiElement, Collection<LineMarkerInfo> results) { PsiElement phpClass = psiElement.getContext(); if(!(phpClass instanceof PhpClass) || !PhpElementsUtil.isInstanceOf((PhpClass) phpClass, "Symfony\\Component\\Validator\\ConstraintValidatorInterface")) { return; } String fqn = ((PhpClass) phpClass).getFQN(); if(!fqn.endsWith("Validator")) { return; } Collection<PhpClass> phpClasses = new ArrayList<>( PhpElementsUtil.getClassesInterface(psiElement.getProject(), fqn.substring(0, fqn.length() - "Validator".length())) ); if(phpClasses.size() == 0) { return; } NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.SYMFONY_LINE_MARKER). setTargets(phpClasses). setTooltipText("Navigate to constraint"); results.add(builder.createLineMarkerInfo(psiElement)); }
Example #5
Source File: ServiceLineMarkerProvider.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * Constraints in same namespace and validateBy service name */ private void validatorClassMarker(PsiElement psiElement, Collection<LineMarkerInfo> results) { PsiElement phpClassContext = psiElement.getContext(); if(!(phpClassContext instanceof PhpClass) || !PhpElementsUtil.isInstanceOf((PhpClass) phpClassContext, "\\Symfony\\Component\\Validator\\Constraint")) { return; } // class in same namespace String className = ((PhpClass) phpClassContext).getFQN() + "Validator"; Collection<PhpClass> phpClasses = new ArrayList<>(PhpElementsUtil.getClassesInterface(psiElement.getProject(), className)); // @TODO: validateBy alias if(phpClasses.size() == 0) { return; } NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.SYMFONY_LINE_MARKER). setTargets(phpClasses). setTooltipText("Navigate to validator"); results.add(builder.createLineMarkerInfo(psiElement)); }
Example #6
Source File: YamlLineMarkerProvider.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * Find controller definition in yaml structor * * foo: * defaults: { _controller: "Bundle:Foo:Bar" } * controller: "Bundle:Foo:Bar" */ private void attachRouteActions(@NotNull Collection<LineMarkerInfo> lineMarkerInfos, @NotNull PsiElement psiElement) { if(psiElement.getNode().getElementType() != YAMLTokenTypes.SCALAR_KEY) { return; } PsiElement yamlKeyValue = psiElement.getParent(); if(!(yamlKeyValue instanceof YAMLKeyValue)) { return; } String yamlController = RouteHelper.getYamlController((YAMLKeyValue) yamlKeyValue); if(yamlController != null) { PsiElement[] methods = RouteHelper.getMethodsOnControllerShortcut(psiElement.getProject(), yamlController); if(methods.length > 0) { NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.TWIG_CONTROLLER_LINE_MARKER). setTargets(methods). setTooltipText("Navigate to action"); lineMarkerInfos.add(builder.createLineMarkerInfo(psiElement)); } } }
Example #7
Source File: XmlLineMarkerProvider.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private void attachRouteActions(@NotNull PsiElement psiElement, @NotNull Collection<LineMarkerInfo> lineMarkerInfos) { PsiElement xmlTag = psiElement.getParent(); if(!(xmlTag instanceof XmlTag) || !Pattern.getRouteTag().accepts(xmlTag)) { return; } String controller = RouteHelper.getXmlController((XmlTag) xmlTag); if(controller != null) { PsiElement[] methods = RouteHelper.getMethodsOnControllerShortcut(xmlTag.getProject(), controller); if(methods.length > 0) { NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.TWIG_CONTROLLER_LINE_MARKER). setTargets(methods). setTooltipText("Navigate to action"); lineMarkerInfos.add(builder.createLineMarkerInfo(psiElement)); } } }
Example #8
Source File: DoctrineMetadataLineMarkerProvider.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private void attachXmlRelationMarker(@NotNull PsiElement target, @NotNull XmlAttributeValue psiElement, @NotNull Collection<LineMarkerInfo> results) { String value = psiElement.getValue(); if(StringUtils.isBlank(value)) { return; } Collection<PhpClass> classesInterface = DoctrineMetadataUtil.getClassInsideScope(psiElement, value); if(classesInterface.size() == 0) { return; } NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.DOCTRINE_LINE_MARKER). setTargets(classesInterface). setTooltipText("Navigate to class"); results.add(builder.createLineMarkerInfo(target)); }
Example #9
Source File: ViewInflateLineMarker.java From idea-android-studio-plugin with GNU General Public License v2.0 | 6 votes |
private void attachLineIcon(@NotNull AndroidView view, @NotNull PsiElement psiElement, @NotNull Collection<LineMarkerInfo> result) { JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(psiElement.getProject()); PsiClass psiClass = psiFacade.findClass(view.getName(), GlobalSearchScope.allScope(psiElement.getProject())); if(psiClass == null) { return; } Icon icon = AndroidViewUtil.getCoreIconWithExtends(view, psiClass); if(icon == null) { icon = AndroidIcons.Views.View; } NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(icon). setTooltipText(view.getName()). setTargets(view.getXmlTarget()); result.add(builder.createLineMarkerInfo(psiElement)); }
Example #10
Source File: HaskellLineMarkerProvider.java From intellij-haskforce with Apache License 2.0 | 6 votes |
@Override protected void collectNavigationMarkers(@NotNull PsiElement element, Collection<? super RelatedItemLineMarkerInfo> result) { if (false && element instanceof PsiNamedElement) { PsiNamedElement namedElement = (PsiNamedElement) element; String value = namedElement.getName(); if (value != null) { Project project = element.getProject(); final List<HaskellUtil.FoundDefinition> found = HaskellUtil.findDefinitionNode(project, value, namedElement); final List<PsiNamedElement> namedNodes = ContainerUtil.newArrayList(); for (HaskellUtil.FoundDefinition fd : found) { namedNodes.add(fd.element); } if (namedNodes.size() > 0) { NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(HaskellIcons.FILE). setTargets(namedNodes). setTooltipText("Navigate to element definition"); result.add(builder.createLineMarkerInfo(element)); } } } }
Example #11
Source File: SimpleLineMarkerProvider.java From intellij-sdk-docs with Apache License 2.0 | 6 votes |
@Override protected void collectNavigationMarkers( @NotNull PsiElement element, @NotNull Collection< ? super RelatedItemLineMarkerInfo > result ) { // This must be an element with a literal expression as a parent if ( !(element instanceof PsiJavaTokenImpl) || !(element.getParent() instanceof PsiLiteralExpression) ) return; // The literal expression must start with the Simple language literal expression PsiLiteralExpression literalExpression = (PsiLiteralExpression) element.getParent(); String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null; if ( ( value == null ) || !value.startsWith( SimpleAnnotator.SIMPLE_PREFIX_STR + SimpleAnnotator.SIMPLE_SEPARATOR_STR ) ) return; // Get the Simple language property usage Project project = element.getProject(); String possibleProperties = value.substring( SimpleAnnotator.SIMPLE_PREFIX_STR.length()+ SimpleAnnotator.SIMPLE_SEPARATOR_STR.length() ); final List<SimpleProperty> properties = SimpleUtil.findProperties( project, possibleProperties ); if ( properties.size() > 0 ) { // Add the property to a collection of line marker info NavigationGutterIconBuilder< PsiElement > builder = NavigationGutterIconBuilder.create( SimpleIcons.FILE ) .setTargets( properties ) .setTooltipText( "Navigate to Simple language property" ); result.add( builder.createLineMarkerInfo( element ) ); } }
Example #12
Source File: RelatedPopupGotoLineMarker.java From idea-php-shopware-plugin with MIT License | 6 votes |
public static RelatedItemLineMarkerInfo<PsiElement> getSingleLineMarker(SmartyFile smartyFile, Collection<LineMarkerInfo> lineMarkerInfos, GotoRelatedItem gotoRelatedItem) { // hell: find any possible small icon Icon icon = null; if(gotoRelatedItem instanceof RelatedPopupGotoLineMarker.PopupGotoRelatedItem) { icon = ((RelatedPopupGotoLineMarker.PopupGotoRelatedItem) gotoRelatedItem).getSmallIcon(); } if(icon == null) { icon = ShopwarePluginIcons.SHOPWARE_LINEMARKER; } NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(icon). setTargets(gotoRelatedItem.getElement()); String customName = gotoRelatedItem.getCustomName(); if(customName != null) { builder.setTooltipText(customName); } return builder.createLineMarkerInfo(smartyFile); }
Example #13
Source File: SmartyTemplateLineMarkerProvider.java From idea-php-shopware-plugin with MIT License | 6 votes |
public void attachTemplateBlocks(PsiElement psiElement, Collection<LineMarkerInfo> lineMarkerInfos) { SmartyBlockGoToHandler goToHandler = new SmartyBlockGoToHandler(); PsiElement[] gotoDeclarationTargets = goToHandler.getGotoDeclarationTargets(psiElement, 0, null); if(gotoDeclarationTargets == null || gotoDeclarationTargets.length == 0) { return; } List<PsiElement> psiElements = Arrays.asList(gotoDeclarationTargets); if(psiElements.size() == 0) { return; } NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(PhpIcons.OVERRIDES). setTargets(psiElements). setTooltipText("Navigate to block"); lineMarkerInfos.add(builder.createLineMarkerInfo(psiElement)); }
Example #14
Source File: ExtJsTemplateLineMarkerProvider.java From idea-php-shopware-plugin with MIT License | 6 votes |
private void attachControllerAction(PsiElement sourceElement, Collection<LineMarkerInfo> lineMarkerInfos) { if(!ShopwareProjectComponent.isValidForProject(sourceElement)) { return; } String text = PsiElementUtils.trimQuote(sourceElement.getText()); if(text.startsWith("{") && text.endsWith("}")) { List<PsiElement> controllerTargets = ExtJsUtil.getControllerTargets(sourceElement, text); if(controllerTargets.size() > 0) { NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(ShopwarePluginIcons.SHOPWARE_LINEMARKER). setTargets(controllerTargets). setTooltipText("Navigate to action"); lineMarkerInfos.add(builder.createLineMarkerInfo(sourceElement)); } } }
Example #15
Source File: NodeTypeLineMarkerProvider.java From intellij-neos with GNU General Public License v3.0 | 6 votes |
@Override public void collectSlowLineMarkers(@NotNull List<PsiElement> elements, @NotNull Collection<LineMarkerInfo> result) { for (PsiElement el : elements) { if (!(el instanceof FusionType) || !(el.getParent() instanceof FusionPrototypeSignature) || (((FusionPrototypeSignature) el.getParent()).isInheritedInDefinition()) || (el.getParent().getParent().getParent() instanceof FusionPropertyDeletion)) { continue; } FusionType type = (FusionType) el; Collection<PsiElement> targets = ResolveEngine.getNodeTypeDefinitions(el.getProject(), type); if (!targets.isEmpty()) { RelatedItemLineMarkerInfo info = NavigationGutterIconBuilder .create(NeosIcons.NODE_TYPE) .setTargets(targets) .setTooltipText("Go to node type definition") .createLineMarkerInfo(el); result.add(info); } } }
Example #16
Source File: MethodLineMarkerProvider.java From intellij-neos with GNU General Public License v3.0 | 6 votes |
@Override public void collectSlowLineMarkers(@NotNull List<PsiElement> elements, @NotNull Collection<LineMarkerInfo> result) { for (PsiElement el : elements) { if (el instanceof Method && ((Method) el).getAccess().isPublic()) { VirtualFile template = ResolveEngine.findTemplate((Method) el); if (template != null) { PsiFile target = PsiManager.getInstance(el.getProject()).findFile(template); RelatedItemLineMarkerInfo info = NavigationGutterIconBuilder .create(NeosIcons.NODE_TYPE) .setTarget(target) .setTooltipText("Go to template") .createLineMarkerInfo(el); result.add(info); } } } }
Example #17
Source File: TemplateLineMarkerProvider.java From idea-php-typo3-plugin with MIT License | 6 votes |
@Override protected void collectNavigationMarkers(@NotNull PsiElement element, @NotNull Collection<? super RelatedItemLineMarkerInfo> result) { if (!PlatformPatterns.psiElement(FluidFile.class).accepts(element)) { return; } Collection<Method> possibleMethodTargetsForControllerAction = FluidUtil.findPossibleMethodTargetsForControllerAction( element.getProject(), FluidUtil.inferControllerNameFromTemplateFile((FluidFile) element), FluidUtil.inferActionNameFromTemplateFile((FluidFile) element) ); if (possibleMethodTargetsForControllerAction.size() > 0) { result.add( NavigationGutterIconBuilder .create(PhpIcons.METHOD) .setTargets(possibleMethodTargetsForControllerAction) .setTooltipText("Navigate to controller action") .createLineMarkerInfo(element) ); } }
Example #18
Source File: ControllerLineMarkerProvider.java From idea-php-typo3-plugin with MIT License | 6 votes |
@Override protected void collectNavigationMarkers(@NotNull PsiElement element, @NotNull Collection<? super RelatedItemLineMarkerInfo> result) { if (!PlatformPatterns.psiElement(PhpTokenTypes.IDENTIFIER).withParent(PlatformPatterns.psiElement(Method.class).withName(PlatformPatterns.string().endsWith("Action"))).accepts(element)) { return; } Collection<FluidFile> possibleMatchedTemplates = FluidUtil.findTemplatesForControllerAction((Method) element.getParent()); if (possibleMatchedTemplates.size() > 0) { result.add( NavigationGutterIconBuilder .create(FluidIcons.TEMPLATE_LINE_MARKER) .setTargets(possibleMatchedTemplates) .setTooltipText("Navigate to template") .createLineMarkerInfo(element) ); } }
Example #19
Source File: ClassLineMarkerProvider.java From phpstorm-plugin with MIT License | 6 votes |
private void classNameMarker(PhpClass currentClass, Collection<? super RelatedItemLineMarkerInfo> result, Project project) { Collection<PhpClass> target; String tooltip; if (Utils.isClassAtoumTest(currentClass)) { target = Utils.locateTestedClasses(project, currentClass); tooltip = "Navigate to tested class"; } else { target = Utils.locateTestClasses(project, currentClass); tooltip = "Navigate to test"; } if (target.size() == 0) { return; } NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Icons.ATOUM). setTargets(target). setTooltipText(tooltip); result.add(builder.createLineMarkerInfo(currentClass)); }
Example #20
Source File: ORLineMarkerProvider.java From reasonml-idea-plugin with MIT License | 5 votes |
@Override protected void collectNavigationMarkers(@NotNull PsiElement element, @NotNull Collection<? super RelatedItemLineMarkerInfo> result) { PsiElement parent = element.getParent(); FileBase containingFile = (FileBase) element.getContainingFile(); if (element instanceof PsiTypeConstrName) { FileBase psiRelatedFile = PsiFinder.getInstance(containingFile.getProject()).findRelatedFile(containingFile); if (psiRelatedFile != null) { Collection<PsiType> expressions = psiRelatedFile.getExpressions(element.getText(), PsiType.class); if (expressions.size() == 1) { PsiType relatedType = expressions.iterator().next(); PsiElement symbol = PsiTreeUtil.findChildOfType(element, PsiLowerSymbol.class); PsiElement relatedSymbol = PsiTreeUtil.findChildOfType(relatedType, PsiLowerSymbol.class); if (symbol != null && relatedSymbol != null) { result.add(NavigationGutterIconBuilder. create(containingFile.isInterface() ? ORIcons.IMPLEMENTED : ORIcons.IMPLEMENTING). setAlignment(GutterIconRenderer.Alignment.RIGHT). setTargets(Collections.singleton(relatedSymbol.getFirstChild())). createLineMarkerInfo(symbol.getFirstChild())); } } } } else if (element instanceof PsiLowerSymbol && parent instanceof PsiLet && ((PsiNameIdentifierOwner) parent).getNameIdentifier() == element) { extractRelatedExpressions(element.getFirstChild(), result, containingFile); } else if (element instanceof PsiLowerSymbol && parent instanceof PsiVal && ((PsiNameIdentifierOwner) parent).getNameIdentifier() == element) { extractRelatedExpressions(element.getFirstChild(), result, containingFile); } else if (element instanceof PsiLowerSymbol && parent instanceof PsiExternal && ((PsiNameIdentifierOwner) parent).getNameIdentifier() == element) { extractRelatedExpressions(element.getFirstChild(), result, containingFile); } else if (element instanceof PsiUpperSymbol && parent instanceof PsiInnerModule && ((PsiNameIdentifierOwner) parent).getNameIdentifier() == element) { extractRelatedExpressions(element.getFirstChild(), result, containingFile); } else if (element instanceof PsiUpperSymbol && parent instanceof PsiException && ((PsiNameIdentifierOwner) parent).getNameIdentifier() == element) { extractRelatedExpressions(element.getFirstChild(), result, containingFile); } }
Example #21
Source File: RouteLineMarkerProvider.java From idea-php-typo3-plugin with MIT License | 5 votes |
@Override protected void collectNavigationMarkers(@NotNull PsiElement element, @NotNull Collection<? super RelatedItemLineMarkerInfo> result) { if (!TYPO3CMSProjectSettings.isEnabled(element)) { return; } if (!getPositionPattern().accepts(element)) { return; } StringLiteralExpression literalExpression = (StringLiteralExpression) element.getParent(); String value = literalExpression.getContents(); if (value.isEmpty()) { return; } PsiElement methodReference = PsiTreeUtil.getParentOfType(element, MethodReference.class); if (PhpElementsUtil.isMethodWithFirstStringOrFieldReference(methodReference, "getAjaxUrl") || PhpElementsUtil.isMethodWithFirstStringOrFieldReference(methodReference, "buildUriFromRoute")) { if (RouteIndex.hasRoute(element.getProject(), value)) { Collection<RouteStub> routes = RouteIndex.getRoute(element.getProject(), value); routes.forEach(def -> { PsiElement[] routeDefinitionElements = RouteHelper.getRouteDefinitionElements(element.getProject(), value); NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder .create(TYPO3CMSIcons.ROUTE_ICON) .setTargets(routeDefinitionElements); if (def.getPath() != null) { builder.setTooltipTitle("Path: " + def.getPath()); } result.add(builder.createLineMarkerInfo(element)); }); } } }
Example #22
Source File: FileResourceUtil.java From idea-php-symfony2-plugin with MIT License | 5 votes |
/** * On route annotations we can have folder scope so: "@FooBundle/Controller/foo.php" can be equal "@FooBundle/Controller/" */ @Nullable public static RelatedItemLineMarkerInfo<PsiElement> getFileImplementsLineMarkerInFolderScope(@NotNull PsiFile psiFile) { VirtualFile virtualFile = psiFile.getVirtualFile(); if(virtualFile == null) { return null; } final Project project = psiFile.getProject(); String bundleLocateName = FileResourceUtil.getBundleLocateName(project, virtualFile); if(bundleLocateName == null) { return null; } Set<String> names = new HashSet<>(); names.add(bundleLocateName); // strip filename int i = bundleLocateName.lastIndexOf("/"); if(i > 0) { names.add(bundleLocateName.substring(0, i)); } int targets = 0; for (String name : names) { targets += FileResourceUtil.getFileResourceRefers(project, name).size(); } if(targets == 0) { return null; } NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(PhpIcons.IMPLEMENTS). setTargets(new FileResourceUtil.FileResourceNotNullLazyValue(project, names)). setTooltipText("Navigate to resource"); return builder.createLineMarkerInfo(psiFile); }
Example #23
Source File: ServiceUtil.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Nullable public static NavigationGutterIconBuilder<PsiElement> getLineMarkerForDecoratedServiceId(@NotNull Project project, @NotNull ServiceLineMarker lineMarker, @NotNull Map<String, Collection<ContainerService>> decorated, @NotNull String id) { if(!decorated.containsKey(id)) { return null; } NotNullLazyValue<Collection<? extends PsiElement>> lazy = ServiceIndexUtil.getServiceIdDefinitionLazyValue( project, ContainerUtil.map(decorated.get(id), ContainerService::getName) ); return NavigationGutterIconBuilder.create(PhpIcons.IMPLEMENTS) .setTargets(lazy) .setTooltipText(lineMarker == ServiceLineMarker.DECORATE ? "Navigate to decoration" : "Navigate to parent" ); }
Example #24
Source File: ServiceUtil.java From idea-php-symfony2-plugin with MIT License | 5 votes |
/** * Provides a lazy linemarker based on the given id eg for "decorated" or "parent" services: * * <service id="foo_bar_main" decorates="app.mailer"/> */ @NotNull public static RelatedItemLineMarkerInfo<PsiElement> getLineMarkerForDecoratesServiceId(@NotNull PsiElement psiElement, @NotNull ServiceLineMarker lineMarker, @NotNull String foreignId) { return NavigationGutterIconBuilder.create(PhpIcons.OVERRIDEN) .setTargets(ServiceIndexUtil.getServiceIdDefinitionLazyValue(psiElement.getProject(), Collections.singletonList(foreignId))) .setTooltipText(lineMarker == ServiceLineMarker.DECORATE ? "Navigate to decorated service" : "Navigate to parent service") .createLineMarkerInfo(psiElement); }
Example #25
Source File: ServiceLineMarkerProvider.java From idea-php-symfony2-plugin with MIT License | 5 votes |
private void formNameMarker(PsiElement psiElement, Collection<? super RelatedItemLineMarkerInfo> result) { if(!(psiElement instanceof StringLiteralExpression)) { return; } Method method = PsiTreeUtil.getParentOfType(psiElement, Method.class); if(method == null) { return; } if(PhpElementsUtil.isMethodInstanceOf(method, "\\Symfony\\Component\\Form\\FormTypeInterface", "getParent")) { // get form string; on blank string we dont need any further action String contents = ((StringLiteralExpression) psiElement).getContents(); if(StringUtils.isBlank(contents)) { return; } PsiElement formPsiTarget = FormUtil.getFormTypeToClass(psiElement.getProject(), contents); if(formPsiTarget != null) { NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.FORM_TYPE_LINE_MARKER). setTargets(formPsiTarget). setTooltipText("Navigate to form type"); result.add(builder.createLineMarkerInfo(psiElement)); } } }
Example #26
Source File: ServiceLineMarkerProvider.java From idea-php-symfony2-plugin with MIT License | 5 votes |
private void repositoryClassMarker(PsiElement psiElement, Collection<? super RelatedItemLineMarkerInfo> result) { PsiElement phpClassContext = psiElement.getContext(); if(!(phpClassContext instanceof PhpClass)) { return; } Collection<PsiFile> psiFiles = new ArrayList<>(); for (VirtualFile virtualFile : DoctrineMetadataUtil.findMetadataForRepositoryClass((PhpClass) phpClassContext)) { PsiFile file = PsiManager.getInstance(psiElement.getProject()).findFile(virtualFile); if(file == null) { continue; } psiFiles.add(file); } if(psiFiles.size() == 0) { return; } NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.DOCTRINE_LINE_MARKER). setTargets(psiFiles). setTooltipText("Navigate to metadata"); result.add(builder.createLineMarkerInfo(psiElement)); }
Example #27
Source File: ServiceLineMarkerProvider.java From idea-php-symfony2-plugin with MIT License | 5 votes |
private void entityClassMarker(PsiElement psiElement, Collection<? super RelatedItemLineMarkerInfo> result) { PsiElement phpClassContext = psiElement.getContext(); if(!(phpClassContext instanceof PhpClass)) { return; } Collection<PsiFile> psiFiles = new ArrayList<>(); // @TODO: use DoctrineMetadataUtil, for single resolve; we have collecting overhead here for(DoctrineModel doctrineModel: EntityHelper.getModelClasses(psiElement.getProject())) { PhpClass phpClass = doctrineModel.getPhpClass(); if(!PhpElementsUtil.isEqualClassName(phpClass, (PhpClass) phpClassContext)) { continue; } PsiFile psiFile = EntityHelper.getModelConfigFile(phpClass); // prevent self navigation for line marker if(psiFile == null || psiFile instanceof PhpFile) { continue; } psiFiles.add(psiFile); } if(psiFiles.size() == 0) { return; } NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.DOCTRINE_LINE_MARKER). setTargets(psiFiles). setTooltipText("Navigate to model"); result.add(builder.createLineMarkerInfo(psiElement)); }
Example #28
Source File: AnnotationUsageLineMarkerProvider.java From idea-php-annotation-plugin with MIT License | 5 votes |
@Override public void collectSlowLineMarkers(@NotNull List<PsiElement> psiElements, @NotNull Collection<LineMarkerInfo> results) { for(PsiElement psiElement: psiElements) { if(!getClassNamePattern().accepts(psiElement)) { continue; } PsiElement phpClass = psiElement.getContext(); if(!(phpClass instanceof PhpClass) || !AnnotationUtil.isAnnotationClass((PhpClass) phpClass)) { return; } String fqn = StringUtils.stripStart(((PhpClass) phpClass).getFQN(), "\\"); // find one index annotation class and stop processing on first match final boolean[] processed = {false}; FileBasedIndex.getInstance().getFilesWithKey(AnnotationUsageIndex.KEY, new HashSet<>(Collections.singletonList(fqn)), virtualFile -> { processed[0] = true; // stop on first match return false; }, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(psiElement.getProject()), PhpFileType.INSTANCE)); // we found at least one target to provide lazy target linemarker if(processed[0]) { NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(PhpIcons.IMPLEMENTS) .setTargets(new CollectionNotNullLazyValue(psiElement.getProject(), fqn)) .setTooltipText("Navigate to implementations"); results.add(builder.createLineMarkerInfo(psiElement)); } } }
Example #29
Source File: TwigLineMarkerProvider.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Nullable private LineMarkerInfo attachBlockOverwrites(@NotNull PsiElement psiElement, @NotNull FileOverwritesLazyLoader loader) { if(!TwigBlockUtil.hasBlockOverwrites(psiElement, loader)) { return null; } NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(PhpIcons.OVERRIDES) .setTargets(new BlockOverwriteLazyValue(psiElement)) .setTooltipText("Overwrites") .setCellRenderer(new MyBlockListCellRenderer()); return builder.createLineMarkerInfo(psiElement); }
Example #30
Source File: TwigLineMarkerProvider.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Nullable private LineMarkerInfo attachBlockImplements(@NotNull PsiElement psiElement, @NotNull FileImplementsLazyLoader implementsLazyLoader) { if(!TwigBlockUtil.hasBlockImplementations(psiElement, implementsLazyLoader)) { return null; } NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(PhpIcons.IMPLEMENTED) .setTargets(new BlockImplementationLazyValue(psiElement)) .setTooltipText("Implementations") .setCellRenderer(new MyBlockListCellRenderer()); return builder.createLineMarkerInfo(psiElement); }