Search in sources :

Example 1 with HTMLMasonMethodDefinition

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

the class HTMLMasonMethodReference method resolveInner.

@NotNull
@Override
protected ResolveResult[] resolveInner(boolean incompleteCode) {
    PerlString element = getElement();
    String methodName = getRangeInElement().substring(element.getText());
    if (StringUtil.isNotEmpty(methodName)) {
        PsiReference[] references = element.getReferences();
        if (references.length == 2) {
            PsiReference componentReference = references[0];
            PsiElement startComponent = componentReference.resolve();
            if (startComponent instanceof HTMLMasonFileImpl) {
                HTMLMasonMethodDefinition methodDefinition = ((HTMLMasonFileImpl) startComponent).findMethodDefinitionByNameInThisOrParents(methodName);
                if (methodDefinition != null) {
                    return new ResolveResult[] { new PsiElementResolveResult(methodDefinition) };
                }
            }
        }
    }
    return ResolveResult.EMPTY_ARRAY;
}
Also used : HTMLMasonMethodDefinition(com.perl5.lang.htmlmason.parser.psi.HTMLMasonMethodDefinition) HTMLMasonFileImpl(com.perl5.lang.htmlmason.parser.psi.impl.HTMLMasonFileImpl) PerlString(com.perl5.lang.perl.psi.PerlString) PerlString(com.perl5.lang.perl.psi.PerlString) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with HTMLMasonMethodDefinition

use of com.perl5.lang.htmlmason.parser.psi.HTMLMasonMethodDefinition 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)

Aggregations

HTMLMasonMethodDefinition (com.perl5.lang.htmlmason.parser.psi.HTMLMasonMethodDefinition)2 HTMLMasonFileImpl (com.perl5.lang.htmlmason.parser.psi.impl.HTMLMasonFileImpl)2 NavigationGutterIconBuilder (com.intellij.codeInsight.navigation.NavigationGutterIconBuilder)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 PerlString (com.perl5.lang.perl.psi.PerlString)1 List (java.util.List)1 NotNull (org.jetbrains.annotations.NotNull)1