aboutsummaryrefslogtreecommitdiffstats
path: root/integration/intellij/src/main/java/ai/vespa/intellij/schema/psi/SdIdentifier.java
blob: 1ac88cb3acd8cfacd1cea01a13b80347d3512d1c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Copyright Yahoo. 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.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;

/**
 * This interface represents an identifier in the SD language (regular identifiers and identifiers with dash).
 * @author Shahar Ariel
 */
public interface SdIdentifier extends PsiElement {

    default boolean isFunctionName(PsiElement file, String name) {
        for (SdFunctionDefinition macro : PsiTreeUtil.collectElementsOfType(file, SdFunctionDefinition.class)) {
            if (name.equals(macro.getName())) {
                return true;
            }
        }
        return false;
    }
    
}