com.jetbrains.php.PhpIcons Java Examples

The following examples show how to use com.jetbrains.php.PhpIcons. 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: LatteVariableCompletionProvider.java    From intellij-latte with MIT License 6 votes vote down vote up
private void attachTemplateTypeCompletions(@NotNull CompletionResultSet result, @NotNull Project project, @NotNull LatteFile file) {
	LattePhpType type = LatteUtil.findFirstLatteTemplateType(file);
	if (type == null) {
		return;
	}

	Collection<PhpClass> phpClasses = type.getPhpClasses(project);
	if (phpClasses != null) {
		for (PhpClass phpClass : phpClasses) {
			for (Field field : phpClass.getFields()) {
				if (!field.isConstant() && field.getModifier().isPublic()) {
					LookupElementBuilder builder = LookupElementBuilder.create(field, "$" + field.getName());
					builder = builder.withInsertHandler(PhpVariableInsertHandler.getInstance());
					builder = builder.withTypeText(LattePhpType.create(field.getType()).toString());
					builder = builder.withIcon(PhpIcons.VARIABLE);
					if (field.isDeprecated() || field.isInternal()) {
						builder = builder.withStrikeoutness(true);
					}
					result.addElement(builder);
				}
			}
		}
	}
}
 
Example #2
Source File: SmartyTemplateLineMarkerProvider.java    From idea-php-shopware-plugin with MIT License 6 votes vote down vote up
public void attachExtends(final SmartyFile smartyFile, final List<GotoRelatedItem> gotoRelatedItems) {

        final String templateName = TemplateUtil.getTemplateName(smartyFile.getProject(), smartyFile.getVirtualFile());
        if(templateName == null) {
            return;
        }

        FileBasedIndexImpl.getInstance().getFilesWithKey(SmartyExtendsStubIndex.KEY, new HashSet<>(Collections.singletonList(templateName)), virtualFile -> {

            PsiFile psiFile = PsiManager.getInstance(smartyFile.getProject()).findFile(virtualFile);
            if(psiFile != null) {
                gotoRelatedItems.add(new RelatedPopupGotoLineMarker.PopupGotoRelatedItem(psiFile, TemplateUtil.getTemplateName(psiFile.getProject(), psiFile.getVirtualFile())).withIcon(PhpIcons.IMPLEMENTED, PhpIcons.IMPLEMENTED));
            }

            return true;
        }, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(smartyFile.getProject()), SmartyFileType.INSTANCE));

    }
 
Example #3
Source File: EventSubscriberReferenceContributor.java    From idea-php-shopware-plugin with MIT License 6 votes vote down vote up
@NotNull
@Override
public Object[] getVariants() {

    final List<LookupElement> lookupElements = new ArrayList<>();

    PhpClass phpClass = PsiTreeUtil.getParentOfType(getElement(), PhpClass.class);
    if(phpClass == null) {
        return lookupElements.toArray();
    }

    for(Method method: phpClass.getMethods()) {
        if(method.getModifier().isPublic() && !method.getName().startsWith("_")) {
            lookupElements.add(LookupElementBuilder.create(method.getName()).withIcon(PhpIcons.METHOD).withTypeText("Method", true));
        }
    }

    return lookupElements.toArray();
}
 
Example #4
Source File: SmartyTemplateLineMarkerProvider.java    From idea-php-shopware-plugin with MIT License 6 votes vote down vote up
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 #5
Source File: Symfony2WebProfilerForm.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
private void renderRequestDetails(@NotNull ProfilerRequestInterface profilerRequest) {
    DefaultListModel<RequestDetails> listModel = (DefaultListModel<RequestDetails>) listRequestDetails.getModel();
    listModel.removeAllElements();

    DefaultDataCollectorInterface defaultDataCollector = profilerRequest.getCollector(DefaultDataCollectorInterface.class);
    if(defaultDataCollector != null) {
        if(defaultDataCollector.getRoute() != null) {
            listModel.addElement(new RequestDetails(defaultDataCollector.getRoute(), Symfony2Icons.ROUTE));
        }

        if(defaultDataCollector.getController() != null) {
            listModel.addElement(new RequestDetails(defaultDataCollector.getController(), PhpIcons.METHOD_ICON));
        }

        if(defaultDataCollector.getTemplate() != null) {
            listModel.addElement(new RequestDetails(defaultDataCollector.getTemplate(), TwigIcons.TwigFileIcon));
        }
    }
}
 
Example #6
Source File: TemplateLineMarker.java    From idea-php-laravel-plugin with MIT License 6 votes vote down vote up
/**
 * Support: @push('foobar')
 */
@NotNull
private Collection<LineMarkerInfo> collectPushOverwrites(@NotNull LeafPsiElement psiElement, @NotNull String sectionName) {
    final List<GotoRelatedItem> gotoRelatedItems = new ArrayList<>();

    BladeTemplateUtil.visitUpPath(psiElement.getContainingFile(), 10, parameter -> {
        if(sectionName.equalsIgnoreCase(parameter.getContent())) {
            gotoRelatedItems.add(new RelatedPopupGotoLineMarker.PopupGotoRelatedItem(parameter.getPsiElement()).withIcon(LaravelIcons.LARAVEL, LaravelIcons.LARAVEL));
        }
    }, BladeTokenTypes.STACK_DIRECTIVE);

    if(gotoRelatedItems.size() == 0) {
        return Collections.emptyList();
    }

    return Collections.singletonList(
        getRelatedPopover("Stack Section", "Stack Overwrites", psiElement, gotoRelatedItems, PhpIcons.OVERRIDES)
    );
}
 
Example #7
Source File: ControllerToolboxProvider.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Nullable
@Override
public ProviderPresentation getPresentation() {
    return new ProviderPresentation() {
        @Nullable
        @Override
        public Icon getIcon() {
            return PhpIcons.METHOD_ICON;
        }

        @Nullable
        @Override
        public String getDescription() {
            return "Controller";
        }
    };
}
 
Example #8
Source File: FileResourceUtil.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@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 #9
Source File: FunctionProvider.java    From idea-php-toolbox with MIT License 6 votes vote down vote up
@Nullable
@Override
public ProviderPresentation getPresentation() {
    return new ProviderPresentation() {
        @Nullable
        @Override
        public Icon getIcon() {
            return PhpIcons.FUNCTION;
        }

        @Nullable
        @Override
        public String getDescription() {
            return "Functions";
        }
    };
}
 
Example #10
Source File: FunctionProvider.java    From idea-php-toolbox with MIT License 6 votes vote down vote up
@Nullable
@Override
public ProviderPresentation getPresentation() {
    return new ProviderPresentation() {
        @Nullable
        @Override
        public Icon getIcon() {
            return PhpIcons.FUNCTION;
        }

        @Nullable
        @Override
        public String getDescription() {
            return "Functions";
        }
    };
}
 
Example #11
Source File: DoctrineModelFieldLookupElement.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Override
public void renderElement(LookupElementPresentation presentation) {
    super.renderElement(presentation);

    presentation.setItemTextBold(withBoldness);
    presentation.setIcon(Symfony2Icons.DOCTRINE);
    presentation.setTypeGrayed(true);

    if(this.doctrineModelField.getTypeName() != null) {
        presentation.setTypeText(this.doctrineModelField.getTypeName());
    }

    if(this.doctrineModelField.getRelationType() != null) {
        presentation.setTailText(String.format("(%s)", this.doctrineModelField.getRelationType()), true);
    }

    if(this.doctrineModelField.getRelation() != null) {
        presentation.setTypeText(this.doctrineModelField.getRelation());
        presentation.setIcon(PhpIcons.CLASS_ICON);
    }

}
 
Example #12
Source File: EelProvider.java    From intellij-neos with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
    Project project = parameters.getPosition().getProject();
    Collection<String> contexts = FileBasedIndex.getInstance().getAllKeys(DefaultContextFileIndex.KEY, project);

    for (String eelHelper : contexts) {
        List<String> helpers = FileBasedIndex.getInstance().getValues(DefaultContextFileIndex.KEY, eelHelper, GlobalSearchScope.allScope(project));
        if (!helpers.isEmpty()) {
            for (String helper : helpers) {
                Collection<PhpClass> classes = PhpIndex.getInstance(project).getClassesByFQN(helper);
                for (PhpClass phpClass : classes) {
                    for (Method method : phpClass.getMethods()) {
                        if (!method.getAccess().isPublic()) {
                            continue;
                        }
                        if (method.getName().equals("allowsCallOfMethod")) {
                            continue;
                        }
                        String completionText = eelHelper + "." + method.getName() + "()";
                        result.addElement(LookupElementBuilder.create(completionText).withIcon(PhpIcons.METHOD_ICON));
                    }
                }
            }
        }
    }
}
 
Example #13
Source File: TemplateLineMarkerProvider.java    From idea-php-typo3-plugin with MIT License 6 votes vote down vote up
@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 #14
Source File: TwigLineMarkerProvider.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Nullable
private LineMarkerInfo attachExtends(@NotNull TwigFile twigFile) {
    Collection<String> templateNames = TwigUtil.getTemplateNamesForFile(twigFile);

    boolean found = false;
    for(String templateName: templateNames) {
        Project project = twigFile.getProject();

        Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance().getContainingFiles(
            TwigExtendsStubIndex.KEY, templateName, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), TwigFileType.INSTANCE)
        );

        // stop on first target, we load them lazily afterwards
        if(containingFiles.size() > 0) {
            found = true;
            break;
        }
    }

    if(!found) {
        return null;
    }

    NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(PhpIcons.IMPLEMENTED)
        .setTargets(new TemplateExtendsLazyTargets(twigFile.getProject(), twigFile.getVirtualFile()))
        .setTooltipText("Navigate to extends")
        .setCellRenderer(new MyFileReferencePsiElementListCellRenderer());

    return builder.createLineMarkerInfo(twigFile);
}
 
Example #15
Source File: QueryBuilderCompletionContributor.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
private void buildLookupElements(CompletionResultSet completionResultSet, QueryBuilderScopeContext collect) {
    for(Map.Entry<String, QueryBuilderPropertyAlias> entry: collect.getPropertyAliasMap().entrySet()) {
        DoctrineModelField field = entry.getValue().getField();
        LookupElementBuilder lookup = LookupElementBuilder.create(entry.getKey());
        lookup = lookup.withIcon(Symfony2Icons.DOCTRINE);
        if(field != null) {
            lookup = lookup.withTypeText(field.getTypeName(), true);

            if(field.getRelationType() != null) {
                lookup = lookup.withTailText("(" + field.getRelationType() + ")", true);
                lookup = lookup.withTypeText(field.getRelation(), true);
                lookup = lookup.withIcon(PhpIcons.CLASS_ICON);
            } else {
                // relation tail text wins
                String column = field.getColumn();
                if(column != null) {
                    lookup = lookup.withTailText("(" + column + ")", true);
                }
            }

        }

        // highlight fields which are possible in select statement
        if(collect.getSelects().contains(entry.getValue().getAlias())) {
            lookup = lookup.withBoldness(true);
        }

        completionResultSet.addElement(lookup);

    }
}
 
Example #16
Source File: TwigLineMarkerProvider.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Nullable
private LineMarkerInfo attachIncludes(@NotNull TwigFile twigFile) {
    Collection<String> templateNames = TwigUtil.getTemplateNamesForFile(twigFile);

    boolean found = false;
    for(String templateName: templateNames) {
        Project project = twigFile.getProject();

        Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance().getContainingFiles(
            TwigIncludeStubIndex.KEY, templateName, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), TwigFileType.INSTANCE)
        );

        // stop on first target, we load them lazily afterwards
        if(containingFiles.size() > 0) {
            found = true;
            break;
        }
    }

    if(!found) {
        return null;
    }

    NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(PhpIcons.IMPLEMENTED)
        .setTargets(new MyTemplateIncludeLazyValue(twigFile, templateNames))
        .setTooltipText("Navigate to includes")
        .setCellRenderer(new MyFileReferencePsiElementListCellRenderer());

    return builder.createLineMarkerInfo(twigFile);
}
 
Example #17
Source File: TwigLineMarkerProvider.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@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);
}
 
Example #18
Source File: FunctionProvider.java    From idea-php-toolbox with MIT License 5 votes vote down vote up
@NotNull
@Override
public Collection<LookupElement> getLookupElements(@NotNull PhpToolboxCompletionContributorParameter parameter) {
    return PhpIndex.getInstance(parameter.getProject())
        .getAllFunctionNames(PrefixMatcher.ALWAYS_TRUE).stream().map(
            s -> LookupElementBuilder.create(s).withIcon(PhpIcons.FUNCTION)
        )
        .collect(Collectors.toCollection(HashSet::new));
}
 
Example #19
Source File: TwigLineMarkerProvider.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@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 #20
Source File: TwigLineMarkerProvider.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Override
protected Icon getIcon(PsiElement psiElement) {
    if(psiElement.getNode().getElementType() == TwigElementTypes.INCLUDE_TAG) {
        return PhpIcons.IMPLEMENTED;
    } else if(psiElement.getNode().getElementType() == TwigElementTypes.EMBED_TAG) {
        return PhpIcons.OVERRIDEN;
    }

    return TwigIcons.TwigFileIcon;
}
 
Example #21
Source File: TwigExtensionParser.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@NotNull
public static Icon getIcon(@NotNull TwigExtensionType twigExtensionType) {
    if(twigExtensionType == TwigExtensionType.FUNCTION_NODE) {
        return PhpIcons.CLASS_INITIALIZER;
    }

    if(twigExtensionType == TwigExtensionType.SIMPLE_FUNCTION) {
        return PhpIcons.FUNCTION;
    }

    if(twigExtensionType == TwigExtensionType.FUNCTION_METHOD) {
        return PhpIcons.METHOD_ICON;
    }

    if(twigExtensionType == TwigExtensionType.FILTER) {
        return PhpIcons.STATIC_FIELD;
    }

    if(twigExtensionType == TwigExtensionType.SIMPLE_TEST) {
        return PhpIcons.CONSTANT;
    }

    if(twigExtensionType == TwigExtensionType.OPERATOR) {
        return PhpIcons.VARIABLE;
    }

    return PhpIcons.WEB_ICON;
}
 
Example #22
Source File: FileResourceUtil.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
/**
 * 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 vote down vote up
@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 vote down vote up
/**
 * 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: DoctrineRepositoryReference.java    From idea-php-annotation-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public Object[] getVariants() {

    List<LookupElement> lookupElements = PhpIndex.getInstance(getElement().getProject())
        .getAllSubclasses("\\Doctrine\\Common\\Persistence\\ObjectRepository").stream()
        .map(phpClass -> LookupElementBuilder.create(phpClass.getPresentableFQN()).withIcon(PhpIcons.CLASS_ICON))
        .collect(Collectors.toList());

    return lookupElements.toArray();
}
 
Example #26
Source File: AnnotationCompletionContributor.java    From idea-php-annotation-plugin with MIT License 5 votes vote down vote up
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
    PsiElement psiElement = parameters.getOriginalPosition();
    if(psiElement == null) {
        return;
    }

    PhpClass phpClass = AnnotationUtil.getClassFromConstant(psiElement);
    if(phpClass != null) {
        phpClass.getFields().stream().filter(Field::isConstant).forEach(field ->
            result.addElement(LookupElementBuilder.create(field.getName()).withIcon(PhpIcons.FIELD).withTypeText(phpClass.getName(), true))
        );
    }
}
 
Example #27
Source File: AnnotationUsageLineMarkerProvider.java    From idea-php-annotation-plugin with MIT License 5 votes vote down vote up
@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 #28
Source File: TemplateLineMarker.java    From idea-php-laravel-plugin with MIT License 5 votes vote down vote up
/**
 * Support: @stack('foobar')
 */
@NotNull
private Collection<LineMarkerInfo> collectStackImplements(@NotNull LeafPsiElement psiElement, @NotNull String sectionName, @NotNull LazyVirtualFileTemplateResolver resolver) {
    Collection<String> templateNames = resolver.resolveTemplateName(psiElement.getContainingFile());
    if(templateNames.size() == 0) {
        return Collections.emptyList();
    }

    List<GotoRelatedItem> gotoRelatedItems = new ArrayList<>();

    Set<VirtualFile> virtualFiles = BladeTemplateUtil.getExtendsImplementations(psiElement.getProject(), templateNames);
    if(virtualFiles.size() == 0) {
        return Collections.emptyList();
    }

    for(VirtualFile virtualFile: virtualFiles) {
        PsiFile psiFile = PsiManager.getInstance(psiElement.getProject()).findFile(virtualFile);
        if(psiFile != null) {
            BladeTemplateUtil.visit(psiFile, BladeTokenTypes.PUSH_DIRECTIVE, parameter -> {
                if (sectionName.equalsIgnoreCase(parameter.getContent())) {
                    gotoRelatedItems.add(new RelatedPopupGotoLineMarker.PopupGotoRelatedItem(parameter.getPsiElement()).withIcon(LaravelIcons.LARAVEL, LaravelIcons.LARAVEL));
                }
            });
        }
    }

    if(gotoRelatedItems.size() == 0) {
        return Collections.emptyList();
    }

    return Collections.singletonList(
        getRelatedPopover("Push Implementation", "Push Implementation", psiElement, gotoRelatedItems, PhpIcons.IMPLEMENTED)
    );
}
 
Example #29
Source File: ContextReference.java    From idea-php-typo3-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public Object[] getVariants() {
    List<LookupElement> elements = new ArrayList<>();
    for (String availableAspect : TYPO3Utility.getAvailableAspects()) {
        elements.add(
            LookupElementBuilder
                .create(availableAspect)
                .withIcon(PhpIcons.CLASS_ICON)
                .withTypeText(TYPO3Utility.getFQNByAspectName(availableAspect), true)
        );
    }

    return elements.toArray();
}
 
Example #30
Source File: FunctionProvider.java    From idea-php-toolbox with MIT License 5 votes vote down vote up
@NotNull
@Override
public Collection<LookupElement> getLookupElements(@NotNull PhpToolboxCompletionContributorParameter parameter) {
    return PhpIndex.getInstance(parameter.getProject())
        .getAllFunctionNames(PrefixMatcher.ALWAYS_TRUE).stream().map(
            s -> LookupElementBuilder.create(s).withIcon(PhpIcons.FUNCTION)
        )
        .collect(Collectors.toCollection(HashSet::new));
}