forked from cjllanwarne/winstanley
-
Notifications
You must be signed in to change notification settings - Fork 4
/
WdlPsiImplUtil.scala
34 lines (28 loc) · 1.32 KB
/
WdlPsiImplUtil.scala
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
package winstanley.psi.impl
import com.intellij.psi.{PsiElement, PsiReference}
import winstanley.psi.{WdlVariableLookup, WdlWorkflowBlock}
import winstanley.references.WdlDeclarationReference
import winstanley.structure.WdlImplicits._
/**
* This class is used by the .bnf compiler to implement the 'methods=[...]' methods on PsiElements.
*
* Put all your other junk util methods somewhere else!
*/
object WdlPsiImplUtil extends
WdlNamedElementImplUtil with
WdlVariableLookupImplUtil
/**
* Provides the getName, setName and getNameIdentifier methods for the WdlNamedElement subclasses (see (eg) declaration and scatter_declaration in the bnf)
*/
sealed trait WdlNamedElementImplUtil {
def getName(namedElement: WdlNamedElementImpl): String = namedElement.declaredValueName.orNull
// TODO: Implement for "refactor/rename" functionality
def setName(namedElement: WdlNamedElementImpl, newName: String): PsiElement = ???
def getNameIdentifier(namedElement: WdlNamedElementImpl): PsiElement = namedElement.getIdentifierNode.map(_.getPsi).orNull
}
sealed trait WdlVariableLookupImplUtil {
/**
* This is the method that enables the 'go to declaration' functionality for variable usages.
*/
def getReferences(wdlVariableLookup: WdlVariableLookup): Array[PsiReference] = Array(WdlDeclarationReference(wdlVariableLookup))
}