-
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.
#15 First implementation of action that creates PDD todo
- Loading branch information
Alexey Vinogradov
committed
Aug 7, 2019
1 parent
b598688
commit 6ff74f8
Showing
7 changed files
with
73 additions
and
12 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
28 changes: 28 additions & 0 deletions
28
src/main/kotlin/com/aivinog1/pdd/plugin/template/CreateNewPddAction.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,28 @@ | ||
package com.aivinog1.pdd.plugin.template | ||
|
||
import com.intellij.lang.LanguageCommenters | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.actionSystem.CommonDataKeys | ||
import com.intellij.openapi.diagnostic.Logger | ||
import com.intellij.psi.PsiFile | ||
|
||
class CreateNewPddAction(private val logger: Logger = Logger.getInstance("CreateNewPddAction")) : AnAction("Create a new PDD.") { | ||
|
||
override fun actionPerformed(e: AnActionEvent) { | ||
val file = e.getData(CommonDataKeys.PSI_FILE) | ||
if (file != null) { | ||
actionPerformed(file) | ||
} | ||
} | ||
|
||
|
||
// @todo #15:30m For now, this method did nothing but only logging the language and the comment symbol. | ||
// Needs to implement inserting a todo. | ||
private fun actionPerformed(file: PsiFile) { | ||
val language = file.language | ||
val commenter = LanguageCommenters.INSTANCE.forLanguage(language) | ||
val lineCommentPrefix = commenter.lineCommentPrefix | ||
logger.trace("Current language: $language. It's comment is $lineCommentPrefix.") | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
src/test/kotlin/com/aivinog1/pdd/plugin/template/CreateNewPddActionTest.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,31 @@ | ||
package com.aivinog1.pdd.plugin.template | ||
|
||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.actionSystem.CommonDataKeys | ||
import com.intellij.openapi.diagnostic.Logger | ||
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixture4TestCase | ||
import io.mockk.* | ||
import org.junit.Test | ||
|
||
class CreateNewPddActionTest: LightPlatformCodeInsightFixture4TestCase() { | ||
|
||
private val logger: Logger = mockk() | ||
private val createNewPddAction = CreateNewPddAction(logger = logger) | ||
|
||
override fun getTestDataPath(): String { | ||
return "testData" | ||
} | ||
|
||
@Test | ||
fun `test that simple java file has comment`() { | ||
every { logger.trace("Current language: Language: JAVA. It's comment is //.") } just Runs | ||
// @todo #15:30m After CreateNewPddAction became registered let's drop this mock and invite action via the IntelliJ platform. | ||
val actionEvent: AnActionEvent = mockk() | ||
every { actionEvent.getData(CommonDataKeys.PSI_FILE) } returns myFixture.configureByFile("SimpleJavaClass.java") | ||
createNewPddAction.actionPerformed(actionEvent) | ||
verify { | ||
logger.trace("Current language: Language: JAVA. It's comment is //.") | ||
} | ||
confirmVerified(logger) | ||
} | ||
} |
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 org.test; | ||
|
||
class Test { | ||
private String test; | ||
} |
6ff74f8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
15-4f88ae36
discovered inbuild.gradle.kts
and submitted as #37. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.6ff74f8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
15-e5aa706c
discovered insrc/main/kotlin/com/aivinog1/pdd/plugin/template/CreateNewPddAction.kt
and submitted as #38. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.6ff74f8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
15-e3928364
discovered insrc/main/resources/META-INF/plugin.xml
and submitted as #39. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.6ff74f8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
15-d8babfd8
discovered insrc/test/kotlin/com/aivinog1/pdd/plugin/template/CreateNewPddActionTest.kt
and submitted as #40. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.