blob: 592408b5c36383b8f3ab6d26fc7f0760b1cda4e9 (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.intellij.schema.model;
import ai.vespa.intellij.schema.psi.SdFirstPhaseDefinition;
import ai.vespa.intellij.schema.psi.SdFunctionDefinition;
import ai.vespa.intellij.schema.psi.SdSecondPhaseDefinition;
import com.intellij.psi.PsiElement;
/**
* @author bratseth
*/
public class Function {
private final String name;
private final PsiElement definition;
private final RankProfile owner;
private Function(String name, PsiElement definition, RankProfile owner) {
this.name = name;
this.definition = definition;
this.owner = owner;
}
public PsiElement definition() { return definition; }
public String name() { return name; }
public RankProfile owner() { return owner; }
@Override
public String toString() {
return "function " + name();
}
public static Function from(SdFirstPhaseDefinition firstPhase, RankProfile owner) {
return new Function("first-phase", firstPhase, owner);
}
public static Function from(SdSecondPhaseDefinition secondPhase, RankProfile owner) {
return new Function("second-phase", secondPhase, owner);
}
public static Function from(SdFunctionDefinition definition, RankProfile owner) {
return new Function(definition.getName(), definition, owner);
}
}
|