-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
EmberReferenceContributor.kt
60 lines (50 loc) · 2.8 KB
/
EmberReferenceContributor.kt
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
50
51
52
53
54
55
56
57
58
59
60
package com.emberjs.psi
import com.emberjs.patterns.EmberPatterns.inEmberFile
import com.emberjs.patterns.EmberPatterns.jsQuotedArgument
import com.intellij.psi.PsiReferenceContributor
import com.intellij.psi.PsiReferenceRegistrar
class EmberReferenceContributor : PsiReferenceContributor() {
override fun registerReferenceProviders(registrar: PsiReferenceRegistrar) {
PROVIDERS.forEach { registrar.registerReferenceProvider(it.first, it.second) }
}
companion object {
private val PROVIDERS = listOf(
// from Ember.inject
argIn("controller") to providerFor("controller"),
argIn("service") to providerFor("service"),
// from Ember.Controller
argIn("transitionToRoute") to providerFor("route"),
// from Ember.Route
argIn("controllerFor") to providerFor("controller"),
argIn("intermediateTransitionTo") to providerFor("route"),
argIn("modelFor") to providerFor("route"),
argIn("paramsFor") to providerFor("route"),
argIn("render").and(inEmberFile("route")) to providerFor("template"),
argIn("replaceWith") to providerFor("route"),
argIn("transitionTo") to providerFor("route"),
// from DS
argIn("attr").and(inEmberFile("model")) to providerFor("transform"),
argIn("hasMany").and(inEmberFile("model")) to providerFor("model"),
argIn("belongsTo").and(inEmberFile("model")) to providerFor("model"),
// from DS.Store
argIn("adapterFor") to providerFor("adapter"),
argIn("createRecord") to providerFor("model", "adapter"),
argIn("filter") to providerFor("model", "adapter"),
argIn("findAll") to providerFor("model", "adapter"),
argIn("findRecord") to providerFor("model", "adapter"),
argIn("hasRecordForId") to providerFor("model"),
argIn("modelFor") to providerFor("model"),
argIn("normalize") to providerFor("model", "serializer"),
argIn("peekAll") to providerFor("model"),
argIn("peekRecord") to providerFor("model"),
argIn("pushPayload") to providerFor("model"),
argIn("query") to providerFor("model", "adapter"),
argIn("queryRecord") to providerFor("model", "adapter"),
argIn("recordIsLoaded") to providerFor("model"),
argIn("unloadAll") to providerFor("model"),
argIn("unloadRecord") to providerFor("model")
)
private fun argIn(name: String) = jsQuotedArgument(name, 0)
private fun providerFor(vararg types: String) = EmberReferenceProvider.forTypes(*types)
}
}