Search in sources :

Example 11 with HTMLMasonFileImpl

use of com.perl5.lang.htmlmason.parser.psi.impl.HTMLMasonFileImpl in project Perl5-IDEA by Camelcade.

the class HTMLMasonLineMarkerProvider method collectNavigationMarkers.

@Override
protected void collectNavigationMarkers(@NotNull PsiElement element, Collection<? super RelatedItemLineMarkerInfo> result) {
    if (element instanceof HTMLMasonFileImpl) {
        HTMLMasonFileImpl parentComponent = ((HTMLMasonFileImpl) element).getParentComponent();
        if (parentComponent != null) {
            NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(AllIcons.Gutter.ImplementingMethod).setTargets(parentComponent).setTooltipText("Parent component");
            result.add(builder.createLineMarkerInfo(element));
        }
        List<HTMLMasonFileImpl> childComponents = ((HTMLMasonFileImpl) element).getChildComponents();
        if (!childComponents.isEmpty()) {
            NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(AllIcons.Gutter.ImplementedMethod).setTargets(childComponents).setTooltipText("Child components");
            result.add(builder.createLineMarkerInfo(element));
        }
    } else if (element instanceof HTMLMasonMethodDefinition) {
        String methodName = ((HTMLMasonMethodDefinition) element).getName();
        PsiFile component = element.getContainingFile();
        if (StringUtil.isNotEmpty(methodName) && component instanceof HTMLMasonFileImpl) {
            // method in parent components
            HTMLMasonMethodDefinition methodDefinition = ((HTMLMasonFileImpl) component).findMethodDefinitionByNameInParents(methodName);
            if (methodDefinition != null) {
                NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(AllIcons.Gutter.OverridingMethod).setTargets(methodDefinition).setTooltipText("Overriding method");
                result.add(builder.createLineMarkerInfo(element));
            }
            // method in subcomponents
            List<HTMLMasonMethodDefinition> methodDefinitions = ((HTMLMasonFileImpl) component).findMethodDefinitionByNameInChildComponents(methodName);
            if (!methodDefinitions.isEmpty()) {
                NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(AllIcons.Gutter.OverridenMethod).setTargets(methodDefinitions).setTooltipText("Overriden methods");
                result.add(builder.createLineMarkerInfo(element));
            }
        }
    }
}
Also used : HTMLMasonMethodDefinition(com.perl5.lang.htmlmason.parser.psi.HTMLMasonMethodDefinition) HTMLMasonFileImpl(com.perl5.lang.htmlmason.parser.psi.impl.HTMLMasonFileImpl) NavigationGutterIconBuilder(com.intellij.codeInsight.navigation.NavigationGutterIconBuilder) PsiFile(com.intellij.psi.PsiFile) List(java.util.List) PsiElement(com.intellij.psi.PsiElement)

Example 12 with HTMLMasonFileImpl

use of com.perl5.lang.htmlmason.parser.psi.impl.HTMLMasonFileImpl in project Perl5-IDEA by Camelcade.

the class HTMLMasonSuperTypeHierarchyStructure method getSubElements.

@Override
protected Collection<PsiElement> getSubElements(PsiElement element) {
    assert element instanceof HTMLMasonFileImpl;
    PsiElement parent = ((HTMLMasonFileImpl) element).getParentComponent();
    if (parent != null) {
        List<PsiElement> result = new ArrayList<>();
        result.add(parent);
        return result;
    }
    return Collections.emptyList();
}
Also used : HTMLMasonFileImpl(com.perl5.lang.htmlmason.parser.psi.impl.HTMLMasonFileImpl) ArrayList(java.util.ArrayList) PsiElement(com.intellij.psi.PsiElement)

Example 13 with HTMLMasonFileImpl

use of com.perl5.lang.htmlmason.parser.psi.impl.HTMLMasonFileImpl in project Perl5-IDEA by Camelcade.

the class HTMLMasonTypeHierarchyTreeStructure method getLinearParents.

protected static List<PsiElement> getLinearParents(PsiElement element) {
    assert element instanceof HTMLMasonFileImpl;
    List<PsiElement> result = new ArrayList<>();
    Set<PsiElement> recursionMap = new THashSet<>();
    HTMLMasonFileImpl run = (HTMLMasonFileImpl) element;
    while (run != null) {
        if (recursionMap.contains(run)) {
            break;
        }
        result.add(0, run);
        recursionMap.add(run);
        run = run.getParentComponent();
    }
    return result;
}
Also used : HTMLMasonFileImpl(com.perl5.lang.htmlmason.parser.psi.impl.HTMLMasonFileImpl) ArrayList(java.util.ArrayList) PsiElement(com.intellij.psi.PsiElement) THashSet(gnu.trove.THashSet)

Aggregations

HTMLMasonFileImpl (com.perl5.lang.htmlmason.parser.psi.impl.HTMLMasonFileImpl)11 PerlString (com.perl5.lang.perl.psi.PerlString)6 PsiElement (com.intellij.psi.PsiElement)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 Project (com.intellij.openapi.project.Project)3 PsiFile (com.intellij.psi.PsiFile)3 HTMLMasonSettings (com.perl5.lang.htmlmason.idea.configuration.HTMLMasonSettings)3 ArrayList (java.util.ArrayList)3 NotNull (org.jetbrains.annotations.NotNull)3 Nullable (org.jetbrains.annotations.Nullable)3 HTMLMasonMethodDefinition (com.perl5.lang.htmlmason.parser.psi.HTMLMasonMethodDefinition)2 CompletionResultSet (com.intellij.codeInsight.completion.CompletionResultSet)1 NavigationGutterIconBuilder (com.intellij.codeInsight.navigation.NavigationGutterIconBuilder)1 TextRange (com.intellij.openapi.util.TextRange)1 PsiReference (com.intellij.psi.PsiReference)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 EditorNotificationPanel (com.intellij.ui.EditorNotificationPanel)1 HTMLMasonCompositeElement (com.perl5.lang.htmlmason.parser.psi.HTMLMasonCompositeElement)1 HTMLMasonSubcomponentDefitnition (com.perl5.lang.htmlmason.parser.psi.HTMLMasonSubcomponentDefitnition)1 HTMLMasonMethodReference (com.perl5.lang.htmlmason.parser.psi.references.HTMLMasonMethodReference)1