Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
acharneski committed Oct 19, 2023
1 parent 09fa9ec commit 500a1d5
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 103 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# **AI Coding Assistant Plugin for IntelliJ**

The only fully open source plugin for IntelliJ that integrates with OpenAI's GPT-4 API.
**Fully open source plugin for IntelliJ that integrates with OpenAI's GPT-4 API**

* This requires an OpenAI access token, which you can get by signing up for a developer account at https://platform.openai.com/
* No membership fees! API access is paid but is billed by usage, with no base fee. The plugin is free and open source.
Expand All @@ -21,6 +21,9 @@ Federation against Ukraine and various other countries, this plugin will not fun
_We are working on a solution to this problem_, but cannot yet promise a date for the victory.
**_Slava Ukraini!_**

**NOTE**: This project is not affiliated with OpenAI, JetBrains, or any other corporation or organization.
It is provided free of charge, as-is, with no warranty or guarantee of any kind.

## **Installation & Configuration**

To begin with AI Coding Assistant, you will need an [OpenAI access token](https://platform.openai.com/account/api-keys).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class QuestionAction extends SelectionAction<String> {

def blockComment = state.language?.blockComment
def fromString = blockComment?.fromString(answer)
return "${state.indent}${fromString.withIndent(state.indent)}\n${state.indent}" + state.selectedText
return "${state.indent}${fromString?.withIndent(state.indent) ?: ""}\n${state.indent}" + state.selectedText
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ReplaceOptionsAction extends SelectionAction<String> {
}

@Override
String processSelection(@Nullable AnActionEvent event, @NotNull SelectionState selectionState, @Nullable String config) {
String processSelection(@Nullable AnActionEvent event, @NotNull SelectionState state, @Nullable String config) {
List<String> choices = UITools.run(event==null?null:event.project, templateText, true, true, {
String selectedText = state.selectedText
int idealLength = pow(2, 2 + ceil(log(selectedText.length()))).intValue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import java.util.stream.Collectors
class ActionSettingsRegistry {

val actionSettings: MutableMap<String, ActionSettings> = HashMap()
val version = 1.8
val version = 1.9

fun edit(superChildren: Array<out AnAction>): Array<AnAction> {
val children = superChildren.toList().toMutableList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class QuestionAction extends SelectionAction<String> {

def blockComment = state.language?.blockComment
def fromString = blockComment?.fromString(answer)
return "${state.indent}${fromString.withIndent(state.indent)}\n${state.indent}" + state.selectedText
return "${state.indent}${fromString?.withIndent(state.indent) ?: ""}\n${state.indent}" + state.selectedText
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ReplaceOptionsAction extends SelectionAction<String> {
}

@Override
String processSelection(@Nullable AnActionEvent event, @NotNull SelectionState selectionState, @Nullable String config) {
String processSelection(@Nullable AnActionEvent event, @NotNull SelectionState state, @Nullable String config) {
List<String> choices = UITools.run(event==null?null:event.project, templateText, true, true, {
String selectedText = state.selectedText
int idealLength = pow(2, 2 + ceil(log(selectedText.length()))).intValue()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.simiacryptus.aicoder

import com.github.simiacryptus.aicoder.UITestUtil.Companion.awaitProcessing
import com.github.simiacryptus.aicoder.UITestUtil.Companion.awaitBackgroundProgress
import com.github.simiacryptus.aicoder.UITestUtil.Companion.canRunTests
import com.github.simiacryptus.aicoder.UITestUtil.Companion.click
import com.github.simiacryptus.aicoder.UITestUtil.Companion.enterLines
Expand Down Expand Up @@ -266,7 +266,7 @@ class ApplicationDevelopmentUITest {
menuAction("Insert Implementation"), outputDir,
name, "${reportPrefix}menu", out
)
awaitProcessing()
awaitBackgroundProgress()
//keyboard.hotKey(KeyEvent.VK_SHIFT, KeyEvent.VK_UP)
//keyboard.hotKey(KeyEvent.VK_DELETE)
keyboard.hotKey(KeyEvent.VK_SHIFT, KeyEvent.VK_ALT, KeyEvent.VK_DOWN) // Move current line down
Expand Down Expand Up @@ -341,7 +341,7 @@ class ApplicationDevelopmentUITest {
outputDir,
name, "${reportPrefix}Rename_Variables", out
)
awaitProcessing()
awaitBackgroundProgress()
sleep(1000)
writeImage(
screenshot("//div[@class='JDialog']"),
Expand All @@ -368,7 +368,7 @@ class ApplicationDevelopmentUITest {
outputDir,
name, "${reportPrefix}Add_Doc_Comments", out
)
awaitProcessing()
awaitBackgroundProgress()
keyboard.hotKey(KeyEvent.VK_CONTROL, KeyEvent.VK_HOME) // Move to top
writeImage(
screenshot("//div[@class='IdeRootPane']"),
Expand Down Expand Up @@ -403,7 +403,7 @@ class ApplicationDevelopmentUITest {
name, "${reportPrefix}Ask_Q2", out
)
click("//div[@text.key='button.ok']")
awaitProcessing()
awaitBackgroundProgress()
keyboard.hotKey(KeyEvent.VK_CONTROL, KeyEvent.VK_HOME) // Move to top
writeImage(
screenshot("//div[@class='IdeRootPane']"),
Expand All @@ -427,7 +427,7 @@ class ApplicationDevelopmentUITest {
outputDir,
name, "${reportPrefix}Add_Code_Comments", out
)
awaitProcessing()
awaitBackgroundProgress()
writeImage(
screenshot("//div[@class='IdeRootPane']"),
outputDir,
Expand Down Expand Up @@ -465,4 +465,4 @@ class ApplicationDevelopmentUITest {
}


}
}
6 changes: 3 additions & 3 deletions src/test/kotlin/com/github/simiacryptus/aicoder/UITest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class UITest {
val out = PrintWriter(FileOutputStream(testOutputFile))
out.use { out ->
documentJavaImplementation("Text_to_Morse", "Convert text to Morse code", out, outputDir)
documentJavaImplementation("Prime_Numbers", "Print all prime numbers from 1 to 100", out, outputDir)
//documentJavaImplementation("Prime_Numbers", "Print all prime numbers from 1 to 100", out, outputDir)
// documentJavaImplementation("Calculate_Pi", "Calculate Pi using the convergence of x = 1+sin x starting at x=3", out, buildDir)
// documentJavaImplementation("Java_8", "Demonstrate language features of Java 8", out, buildDir)
// documentJavaImplementation("Draw_A_Smile", "Draw a smiley face", out, buildDir)
Expand Down Expand Up @@ -133,7 +133,7 @@ class UITest {
if (!canRunTests()) return
val testOutputFile = File(outputDir, "markdown.md")
val out = PrintWriter(FileOutputStream(testOutputFile))
documentMarkdownTableOps("State_Details", "Data Table of State Details", out, outputDir)
//documentMarkdownTableOps("State_Details", "Data Table of State Details", out, outputDir)
documentMarkdownListAppend("Puppy_Playtime", "Top 10 Best Ways to Play with Puppies", arrayOf(), out, outputDir)
out.close() // Close file
}
Expand All @@ -147,4 +147,4 @@ class UITest {
out.close() // Close file
}

}
}
Loading

0 comments on commit 500a1d5

Please sign in to comment.