Package fr.adrienbrault.idea.symfony2plugin.extension

Source Code of fr.adrienbrault.idea.symfony2plugin.extension.ControllerActionGotoRelatedCollectorParameter

package fr.adrienbrault.idea.symfony2plugin.extension;

import com.intellij.navigation.GotoRelatedItem;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiElementFilter;
import com.intellij.psi.util.PsiTreeUtil;
import com.jetbrains.php.lang.psi.elements.Method;
import com.jetbrains.php.lang.psi.elements.ParameterList;

import java.util.Collection;

public class ControllerActionGotoRelatedCollectorParameter {

    private final Collection<GotoRelatedItem> relatedItems;
    private final Method method;
    private PsiElement[] parameterLists = null;

    public ControllerActionGotoRelatedCollectorParameter(Method method, Collection<GotoRelatedItem> relatedItems) {
        this.relatedItems = relatedItems;
        this.method = method;
    }

    public Method getMethod() {
        return method;
    }

    public Collection<GotoRelatedItem> getRelatedItems() {
        return relatedItems;
    }

    public Project getProject() {
        return this.method.getProject();
    }

    public void add(GotoRelatedItem relatedItem) {
        this.relatedItems.add(relatedItem);
    }

    public void addAll(Collection<GotoRelatedItem> relatedItems) {
        this.relatedItems.addAll(relatedItems);
    }

    public PsiElement[] getParameterLists() {

        if(parameterLists != null) {
            return parameterLists;
        }

        return parameterLists = PsiTreeUtil.collectElements(method, new PsiElementFilter() {
            @Override
            public boolean isAccepted(PsiElement psiElement) {
                return psiElement.getParent() instanceof ParameterList;
            }
        });

    }

}
TOP

Related Classes of fr.adrienbrault.idea.symfony2plugin.extension.ControllerActionGotoRelatedCollectorParameter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.