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.
feat(usage): enable to search for usage
- Loading branch information
Showing
10 changed files
with
79 additions
and
14 deletions.
There are no files selected for viewing
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
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
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/com/feakin/intellij/ide/search/FkFindUsagesHandler.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,8 @@ | ||
package com.feakin.intellij.ide.search | ||
|
||
import com.intellij.find.findUsages.FindUsagesHandler | ||
import com.intellij.psi.PsiElement | ||
|
||
class FkFindUsagesHandler(psiElement: PsiElement, private val secondaryElements: Array<PsiElement>) : FindUsagesHandler(psiElement) { | ||
override fun getSecondaryElements(): Array<PsiElement> = secondaryElements | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/com/feakin/intellij/ide/search/FkFindUsagesHandlerFactory.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,19 @@ | ||
package com.feakin.intellij.ide.search | ||
|
||
import com.feakin.intellij.psi.FeakinNamedElement | ||
import com.intellij.find.findUsages.FindUsagesHandler | ||
import com.intellij.find.findUsages.FindUsagesHandlerFactory | ||
import com.intellij.psi.PsiElement | ||
|
||
class FkFindUsagesHandlerFactory : FindUsagesHandlerFactory() { | ||
override fun canFindUsages(element: PsiElement): Boolean = element is FeakinNamedElement | ||
|
||
override fun createFindUsagesHandler(element: PsiElement, forHighlightUsages: Boolean): FindUsagesHandler { | ||
val secondaryElements = if (!forHighlightUsages) findSecondaryElements(element) else emptyList() | ||
return FkFindUsagesHandler(element, secondaryElements.toTypedArray()) | ||
} | ||
|
||
private fun findSecondaryElements(element: PsiElement): List<PsiElement> { | ||
return emptyList() | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/kotlin/com/feakin/intellij/ide/search/FkFindUsagesProvider.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,21 @@ | ||
package com.feakin.intellij.ide.search | ||
|
||
import com.feakin.intellij.psi.FeakinNamedElement | ||
import com.intellij.lang.HelpID | ||
import com.intellij.lang.findUsages.FindUsagesProvider | ||
import com.intellij.psi.PsiElement | ||
|
||
class FkFindUsagesProvider : FindUsagesProvider { | ||
override fun getWordsScanner() = FkWordScanner() | ||
|
||
override fun canFindUsagesFor(psiElement: PsiElement): Boolean = psiElement is FeakinNamedElement | ||
|
||
override fun getHelpId(psiElement: PsiElement): String = HelpID.FIND_OTHER_USAGES | ||
|
||
override fun getType(element: PsiElement): String = "" | ||
|
||
override fun getDescriptiveName(element: PsiElement): String = (element as? FeakinNamedElement)?.name.orEmpty() | ||
|
||
override fun getNodeText(element: PsiElement, useFullName: Boolean): String = "" | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/com/feakin/intellij/ide/search/FkWordScanner.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,13 @@ | ||
package com.feakin.intellij.ide.search | ||
|
||
import com.feakin.intellij.lexer.FeakinElementTypes.* | ||
import com.feakin.intellij.lexer.FkLexer | ||
import com.intellij.lang.cacheBuilder.DefaultWordsScanner | ||
import com.intellij.psi.tree.TokenSet | ||
|
||
class FkWordScanner : DefaultWordsScanner( | ||
FkLexer(), | ||
TokenSet.create(IDENTIFIER), | ||
TokenSet.create(BLOCK_COMMENT, COMMENT), | ||
TokenSet.create(STRING_LITERAL) | ||
) |
5 changes: 0 additions & 5 deletions
5
src/main/kotlin/com/feakin/intellij/lexer/FeakinLexerAdapter.kt
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
package com.feakin.intellij.lexer | ||
|
||
import com.intellij.lexer.FlexAdapter | ||
|
||
class FkLexer : FlexAdapter(com.feakin.intellij.lexer._FeakinLexer(null)) |
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
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