aboutsummaryrefslogtreecommitdiffstats
path: root/integration/intellij/src/main/java/ai/vespa/intellij/schema/psi/SdElementDescriptionProvider.java
blob: 14bb4598ce295b2036b7ae56b80f0d793e712821 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.intellij.schema.psi;

import com.intellij.psi.ElementDescriptionLocation;
import com.intellij.psi.ElementDescriptionProvider;
import com.intellij.psi.PsiElement;
import ai.vespa.intellij.schema.psi.impl.SdNamedElementImpl;

/**
 * This class is used for the extension (in plugin.xml), to enable "find Usages" window take the element description from 
 * here. Used only for the "target" element.
 *
 * @author Shahar Ariel
 */
public class SdElementDescriptionProvider implements ElementDescriptionProvider {
    
    /**
     * Controls the headline of the element in the "Find Usages" window.
     *
     * @param psiElement the element to describe
     * @return a string with the description to write in the headline
     */
    @Override
    public String getElementDescription(PsiElement psiElement, ElementDescriptionLocation elementDescriptionLocation) {
        if (psiElement instanceof SdDeclaration) {
            return ((SdNamedElementImpl) psiElement).getTypeName();
        } else {
            return "";
        }
    }

}