generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(completion): add basic completion for project run tasks
Extend completion for project run tasks with basic support. - Added completion for project run tasks in ShireCompletionContributor.kt - Implemented ProjectRunProvider.kt for providing completions - Updated ProjectRunService.kt with lookupAvailableTask method - Added GradleTasksUtil.kt with createGradleTestConfiguration and createConfigForGradle methods - Updated JavaRunProjectService.kt with run and lookupAvailableTask methods
- Loading branch information
Showing
5 changed files
with
142 additions
and
6 deletions.
There are no files selected for viewing
17 changes: 14 additions & 3 deletions
17
core/src/main/kotlin/com/phodal/shirecore/provider/ProjectRunService.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
31 changes: 28 additions & 3 deletions
31
languages/java/src/main/kotlin/com/phodal/shirelang/java/impl/JavaRunProjectService.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 |
---|---|---|
@@ -1,14 +1,39 @@ | ||
package com.phodal.shirelang.java.impl | ||
|
||
import com.intellij.codeInsight.completion.CompletionParameters | ||
import com.intellij.codeInsight.completion.CompletionResultSet | ||
import com.intellij.codeInsight.lookup.LookupElement | ||
import com.intellij.codeInsight.lookup.LookupElementBuilder | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.projectRoots.JavaSdk | ||
import com.intellij.openapi.roots.ProjectRootManager | ||
import com.intellij.util.SmartList | ||
import com.phodal.shirecore.provider.ProjectRunService | ||
import com.phodal.shirelang.java.toolchain.GradleTasksUtil | ||
import icons.GradleIcons | ||
|
||
class JavaRunProjectService : ProjectRunService { | ||
override fun isAvailable(project: Project): Boolean { | ||
TODO("Not yet implemented") | ||
return ProjectRootManager.getInstance(project).projectSdk is JavaSdk | ||
} | ||
|
||
override fun run(project: Project, taskName: String?) { | ||
TODO("Not yet implemented") | ||
override fun run(project: Project, taskName: String) { | ||
// val configureGradleTask = GradleTasksUtil.createConfigForGradle(project, taskName) | ||
} | ||
|
||
override fun lookupAvailableTask( | ||
project: Project, | ||
parameters: CompletionParameters, | ||
result: CompletionResultSet, | ||
): List<LookupElement> { | ||
val lookupElements: MutableList<LookupElement> = SmartList() | ||
GradleTasksUtil.collectGradleTasksWithCheck(project).forEach { | ||
val element = LookupElementBuilder.create(it.text) | ||
.withTypeText(it.description) | ||
.withIcon(GradleIcons.Gradle) | ||
result.addElement(element) | ||
} | ||
|
||
return lookupElements | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
shirelang/src/main/kotlin/com/phodal/shirelang/completion/provider/ProjectRunProvider.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,22 @@ | ||
package com.phodal.shirelang.completion.provider | ||
|
||
import com.intellij.codeInsight.completion.CompletionParameters | ||
import com.intellij.codeInsight.completion.CompletionProvider | ||
import com.intellij.codeInsight.completion.CompletionResultSet | ||
import com.intellij.util.ProcessingContext | ||
import com.phodal.shirecore.provider.ProjectRunService | ||
|
||
class ProjectRunProvider : CompletionProvider<CompletionParameters>() { | ||
override fun addCompletions( | ||
parameters: CompletionParameters, | ||
context: ProcessingContext, | ||
result: CompletionResultSet, | ||
) { | ||
ProjectRunService.all().forEach { completionProvider -> | ||
val elements = completionProvider.lookupAvailableTask(parameters.editor.project!!, parameters, result) | ||
elements.forEach { | ||
result.addElement(it) | ||
} | ||
} | ||
} | ||
} |