generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/main/kotlin/com/feakin/intellij/ide/navigate/FkDomainObjectNavigationContributor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.feakin.intellij.ide.navigate | ||
|
||
import com.feakin.intellij.FeakinLanguage | ||
import com.feakin.intellij.psi.stubs.FkContextIndex | ||
import com.intellij.lang.Language | ||
import com.intellij.navigation.ChooseByNameContributorEx | ||
import com.intellij.navigation.GotoClassContributor | ||
import com.intellij.navigation.NavigationItem | ||
import com.intellij.psi.search.GlobalSearchScope | ||
import com.intellij.psi.stubs.StubIndex | ||
import com.intellij.util.Processor | ||
import com.intellij.util.indexing.FindSymbolParameters | ||
import com.intellij.util.indexing.IdFilter | ||
|
||
class FkDomainObjectNavigationContributor : GotoClassContributor, ChooseByNameContributorEx { | ||
override fun processNames(processor: Processor<in String?>, scope: GlobalSearchScope, filter: IdFilter?) { | ||
if (!StubIndex.getInstance() | ||
.processAllKeys(FkContextIndex.KEY, processor, scope, filter) | ||
) { | ||
return | ||
} | ||
} | ||
|
||
override fun processElementsWithName( | ||
name: String, | ||
processor: Processor<in NavigationItem>, | ||
parameters: FindSymbolParameters | ||
) { | ||
} | ||
|
||
override fun getQualifiedName(item: NavigationItem): String? { | ||
return null | ||
} | ||
|
||
override fun getQualifiedNameSeparator(): String? { | ||
return null | ||
} | ||
|
||
override fun getElementLanguage(): Language { | ||
return FeakinLanguage | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/kotlin/com/feakin/intellij/psi/stubs/FkNamedElement.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.feakin.intellij.psi.stubs | ||
|
||
import com.feakin.intellij.psi.FeakinNamedElement | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.psi.PsiElement | ||
import com.intellij.psi.search.GlobalSearchScope | ||
import com.intellij.psi.stubs.StringStubIndexExtension | ||
import com.intellij.psi.stubs.StubIndex | ||
import com.intellij.psi.stubs.StubIndexKey | ||
|
||
class FkNamedElementIndex : StringStubIndexExtension<FeakinNamedElement>() { | ||
override fun getKey(): StubIndexKey<String, FeakinNamedElement> = KEY | ||
|
||
companion object { | ||
val KEY: StubIndexKey<String, FeakinNamedElement> = | ||
StubIndexKey.createIndexKey("com.feakin.intellij.psi.stubs.index.FkNamedElementIndex") | ||
|
||
fun findElementsByName( | ||
project: Project, | ||
target: String, | ||
scope: GlobalSearchScope = GlobalSearchScope.allScope(project) | ||
): Collection<FeakinNamedElement> { | ||
return getElements(KEY, target, project, scope) | ||
} | ||
} | ||
} | ||
|
||
inline fun <Key, reified Psi : PsiElement> getElements( | ||
indexKey: StubIndexKey<Key, Psi>, | ||
key: Key, project: Project, | ||
scope: GlobalSearchScope? | ||
): Collection<Psi> = | ||
StubIndex.getElements(indexKey, key, project, scope, Psi::class.java) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters