Skip to content

Commit

Permalink
1.1.1 (#49)
Browse files Browse the repository at this point in the history
* 1.1.1

* Remove getActionUpdateThread

* 1.0.11
  • Loading branch information
acharneski authored Jun 4, 2023
1 parent 1845ee7 commit 9b473f9
Show file tree
Hide file tree
Showing 42 changed files with 371 additions and 200 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
### Added
-

## [1.1.1]

### Added
- "Analogue File" action

### Improved
- Various bug fixes

## [1.1.0]

### Added
Expand Down
35 changes: 17 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ fun properties(key: String) = project.findProperty(key).toString()

plugins {
id("java")
id("scala")
id("org.jetbrains.kotlin.jvm") version "1.7.21"
id("org.jetbrains.intellij") version "1.13.3"
id("org.jetbrains.changelog") version "2.0.0"
Expand All @@ -24,31 +23,31 @@ repositories {
val kotlin_version = "1.7.21"
val jetty_version = "11.0.15"
val slf4j_version = "2.0.5"
val skyenet_version = "1.0.7"
val skyenet_version = "1.0.8"
dependencies {

implementation("com.simiacryptus:joe-penai:1.0.9")
implementation(group = "com.simiacryptus", name = "joe-penai", version = "1.0.10")

implementation("com.simiacryptus.skyenet:util:$skyenet_version")
implementation("com.simiacryptus.skyenet:core:$skyenet_version")
implementation("com.simiacryptus.skyenet:webui:$skyenet_version")
implementation(group = "com.simiacryptus.skyenet", name = "util", version = skyenet_version)
implementation(group = "com.simiacryptus.skyenet", name = "core", version = skyenet_version)
implementation(group = "com.simiacryptus.skyenet", name = "webui", version = skyenet_version)

implementation("org.eclipse.jetty:jetty-server:$jetty_version")
implementation("org.eclipse.jetty:jetty-servlet:$jetty_version")
implementation("org.eclipse.jetty:jetty-annotations:$jetty_version")
implementation("org.eclipse.jetty.websocket:websocket-jetty-server:$jetty_version")
implementation("org.eclipse.jetty.websocket:websocket-jetty-client:$jetty_version")
implementation("org.eclipse.jetty.websocket:websocket-servlet:$jetty_version")
implementation(group = "org.eclipse.jetty", name = "jetty-server", version = jetty_version)
implementation(group = "org.eclipse.jetty", name = "jetty-servlet", version = jetty_version)
implementation(group = "org.eclipse.jetty", name = "jetty-annotations", version = jetty_version)
implementation(group = "org.eclipse.jetty.websocket", name = "websocket-jetty-server", version = jetty_version)
implementation(group = "org.eclipse.jetty.websocket", name = "websocket-jetty-client", version = jetty_version)
implementation(group = "org.eclipse.jetty.websocket", name = "websocket-servlet", version = jetty_version)

implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
implementation(group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version = kotlin_version)
implementation(group = "org.jetbrains.kotlin", name = "kotlin-reflect", version = kotlin_version)
testImplementation(kotlin("script-runtime"))

implementation("org.slf4j:slf4j-api:$slf4j_version")
implementation(group = "org.slf4j", name = "slf4j-api", version = slf4j_version)

testImplementation("com.intellij.remoterobot:remote-robot:0.11.16")
testImplementation("com.intellij.remoterobot:remote-fixtures:0.11.16")
testImplementation("com.squareup.okhttp3:okhttp:3.14.9")
testImplementation(group = "com.intellij.remoterobot", name = "remote-robot", version = "0.11.16")
testImplementation(group = "com.intellij.remoterobot", name = "remote-fixtures", version = "0.11.16")
testImplementation(group = "com.squareup.okhttp3", name = "okhttp", version = "3.14.9")
}


Expand Down
11 changes: 4 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pluginName = intellij-aicoder
pluginRepositoryUrl = https://github.com/SimiaCryptus/intellij-aicoder
# SemVer format -> https://semver.org
pluginVersion = 1.1.0
pluginVersion = 1.1.1

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 203
Expand All @@ -22,12 +22,6 @@ pluginUntilBuild = 231.*
# IntelliJ IDEA Ultimate
platformType = IU
# https://mvnrepository.com/artifact/com.jetbrains.intellij.idea/ideaIU
#platformVersion = 2021.3.3
#platformPlugins = com.intellij.java, org.intellij.scala:2021.3.22, Pythonid:213.7172.26, org.jetbrains.plugins.go:213.7172.6

#platformVersion = 2022.3.1
#platformPlugins = com.intellij.java, org.intellij.scala:2022.3.16, Pythonid:223.8214.52, org.jetbrains.plugins.go:223.8214.52

platformVersion = 2023.1.1
platformPlugins = com.intellij.java

Expand All @@ -39,6 +33,9 @@ platformPlugins = com.intellij.java
#platformType = RD
#platformPlugins = JavaScript

#platformType = PY
#platformPlugins = Pythonid

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 8.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ interface SoftwareProjectAI {
}

override fun validate(): Boolean {
if (file?.isBlank() != false) return false
return true
return file?.isBlank() == false
// return super.validate()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.simiacryptus.aicoder.actions

import com.github.simiacryptus.aicoder.util.UITools
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.simiacryptus.openai.OpenAIClient
Expand All @@ -12,13 +13,15 @@ abstract class BaseAction(
icon: Icon? = null,
) : AnAction(name, description, icon) {

//override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

val api: OpenAIClient
get() = UITools.api

override fun update(e: AnActionEvent) {
e.presentation.isEnabledAndVisible = isEnabled(e)
super.update(e)
override fun update(event: AnActionEvent) {
event.presentation.isEnabledAndVisible = isEnabled(event)
super.update(event)
}

open fun isEnabled(e: AnActionEvent): Boolean = true
open fun isEnabled(event: AnActionEvent): Boolean = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CommentsAction : BaseAction() {


override fun actionPerformed(event: AnActionEvent) {
val editor = event.getRequiredData(CommonDataKeys.EDITOR)
val editor = event.getData(CommonDataKeys.EDITOR) ?: return
val caretModel = editor.caretModel
val primaryCaret = caretModel.primaryCaret
val selectionStart = primaryCaret.selectionStart
Expand All @@ -60,17 +60,16 @@ class CommentsAction : BaseAction() {
).code ?: ""
}
UITools.writeableFn(event) {
UITools.replaceString(editor.document, selectionStart, selectionEnd, newText!!)
UITools.replaceString(editor.document, selectionStart, selectionEnd, newText)
}
}

}

override fun isEnabled(e: AnActionEvent): Boolean {
override fun isEnabled(event: AnActionEvent): Boolean {
if (UITools.isSanctioned()) return false
if (!UITools.hasSelection(e)) return false
val computerLanguage = ComputerLanguage.getComputerLanguage(e) ?: return false
if (computerLanguage == ComputerLanguage.Text) return false
return true
if (!UITools.hasSelection(event)) return false
val computerLanguage = ComputerLanguage.getComputerLanguage(event) ?: return false
return computerLanguage != ComputerLanguage.Text
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.github.simiacryptus.aicoder.actions.code

import com.github.simiacryptus.aicoder.actions.BaseAction
import com.github.simiacryptus.aicoder.util.ComputerLanguage
import com.github.simiacryptus.aicoder.util.UITools
import com.github.simiacryptus.aicoder.util.UITools.getIndent
import com.github.simiacryptus.aicoder.util.psi.PsiTranslationTree
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.command.WriteCommandAction
Expand All @@ -14,14 +14,14 @@ import com.intellij.openapi.vfs.VirtualFile
import java.io.IOException
import java.util.concurrent.atomic.AtomicReference

class ConvertFileToLanguage(private val targetLanguage: ComputerLanguage) : AnAction(
class ConvertFileToLanguage(private val targetLanguage: ComputerLanguage) : BaseAction(
targetLanguage.name
) {
override fun actionPerformed(event: AnActionEvent) {
val sourceLanguage = ComputerLanguage.getComputerLanguage(event)
val indent = getIndent(event.getData(CommonDataKeys.CARET))
val virtualFile = event.getRequiredData(CommonDataKeys.VIRTUAL_FILE)
val psiFile = event.getRequiredData(CommonDataKeys.PSI_FILE)
val virtualFile = event.getData(CommonDataKeys.VIRTUAL_FILE) ?: return
val psiFile = event.getData(CommonDataKeys.PSI_FILE) ?: return
val project = event.project!!
Thread {
UITools.run(project, "Converting to " + targetLanguage.name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ open class CustomEditAction(
).create()

override fun actionPerformed(event: AnActionEvent) {
val editor = event.getRequiredData(CommonDataKeys.EDITOR)
val editor = event.getData(CommonDataKeys.EDITOR) ?: return
val caretModel = editor.caretModel
val primaryCaret = caretModel.primaryCaret
val selectionStart = primaryCaret.selectionStart
Expand All @@ -75,7 +75,7 @@ open class CustomEditAction(
UITools.writeableFn(event) {
UITools.replaceString(
editor.document, selectionStart, selectionEnd,
newText!!
newText
)
}
}
Expand All @@ -85,11 +85,10 @@ open class CustomEditAction(
open fun getInstruction(): String? =
JOptionPane.showInputDialog(null, "Instruction:", "Edit Code", JOptionPane.QUESTION_MESSAGE)

override fun isEnabled(e: AnActionEvent): Boolean {
override fun isEnabled(event: AnActionEvent): Boolean {
if (UITools.isSanctioned()) return false
if (!UITools.hasSelection(e)) return false
val computerLanguage = ComputerLanguage.getComputerLanguage(e) ?: return false
if (computerLanguage == ComputerLanguage.Text) return false
return true
if (!UITools.hasSelection(event)) return false
val computerLanguage = ComputerLanguage.getComputerLanguage(event) ?: return false
return computerLanguage != ComputerLanguage.Text
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DescribeAction : BaseAction() {


override fun actionPerformed(event: AnActionEvent) {
val editor = event.getRequiredData(CommonDataKeys.EDITOR)
val editor = event.getData(CommonDataKeys.EDITOR) ?: return
val caretModel = editor.caretModel
val primaryCaret = caretModel.primaryCaret
var selectionStart = primaryCaret.selectionStart
Expand All @@ -67,7 +67,7 @@ class DescribeAction : BaseAction() {
) {
proxy.describeCode(
code = IndentedText.fromString(selectedText).textBlock.toString().trim(),
computerLanguage = language!!.name,
computerLanguage = language.name,
humanLanguage = settings.humanLanguage,
).text ?: ""
}
Expand All @@ -94,11 +94,10 @@ class DescribeAction : BaseAction() {
}
}

override fun isEnabled(e: AnActionEvent): Boolean {
override fun isEnabled(event: AnActionEvent): Boolean {
if (UITools.isSanctioned()) return false
val computerLanguage = ComputerLanguage.getComputerLanguage(e) ?: return false
if (computerLanguage == ComputerLanguage.Text) return false
return true
val computerLanguage = ComputerLanguage.getComputerLanguage(event) ?: return false
return computerLanguage != ComputerLanguage.Text
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.github.simiacryptus.aicoder.util.ComputerLanguage
import com.github.simiacryptus.aicoder.util.IndentedText
import com.github.simiacryptus.aicoder.util.UITools
import com.github.simiacryptus.aicoder.util.UITools.insertString
import com.github.simiacryptus.aicoder.util.UITools.replaceString
import com.github.simiacryptus.aicoder.util.psi.PsiUtil
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
Expand Down Expand Up @@ -75,16 +74,15 @@ class DocAction : BaseAction() {
override fun actionPerformed(event: AnActionEvent) {
val language = ComputerLanguage.getComputerLanguage(event)
val caret = event.getData(CommonDataKeys.CARET)
val psiFile = event.getRequiredData(CommonDataKeys.PSI_FILE)
val psiFile = event.getData(CommonDataKeys.PSI_FILE) ?: return
val smallestIntersectingMethod =
PsiUtil.getSmallestIntersectingMajorCodeElement(psiFile, caret!!)
?: return
val settings = AppSettingsState.instance
val code = smallestIntersectingMethod.text
val indentedInput = IndentedText.fromString(code)
val startOffset = smallestIntersectingMethod.textRange.startOffset
val endOffset = smallestIntersectingMethod.textRange.endOffset
val document = event.getRequiredData(CommonDataKeys.EDITOR).document
val document = (event.getData(CommonDataKeys.EDITOR) ?: return).document
val outputHumanLanguage = settings.humanLanguage

UITools.redoableTask(event) {
Expand Down Expand Up @@ -113,7 +111,7 @@ class DocAction : BaseAction() {
val computerLanguage = ComputerLanguage.getComputerLanguage(event) ?: return false
if (computerLanguage == ComputerLanguage.Text) return false
if (computerLanguage.docStyle.isEmpty()) return false
val psiFile = event.getRequiredData(CommonDataKeys.PSI_FILE)
val psiFile = event.getData(CommonDataKeys.PSI_FILE) ?: return false
val caret = event.getData(CommonDataKeys.CARET)
PsiUtil.getSmallestIntersectingMajorCodeElement(psiFile, caret!!) ?: return false
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ImplementStubAction : BaseAction() {

override fun actionPerformed(event: AnActionEvent) {
val caret = event.getData(CommonDataKeys.CARET)
val psiFile = event.getRequiredData(CommonDataKeys.PSI_FILE)
val psiFile = event.getData(CommonDataKeys.PSI_FILE) ?: return
val smallestIntersectingMethod = getSmallestIntersectingMajorCodeElement(psiFile, caret!!) ?: return
val computerLanguage = ComputerLanguage.getComputerLanguage(event) ?: return
val settings = AppSettingsState.instance
Expand All @@ -53,7 +53,7 @@ class ImplementStubAction : BaseAction() {
//declaration = StringTools.stripPrefix(declaration.toString().trim(), PsiUtil.getDocComment(smallestIntersectingMethod).trim());
declaration = StringTools.stripSuffix(declaration.toString().trim(), getCode(smallestIntersectingMethod).trim())
declaration = declaration.toString().trim()
val document = event.getRequiredData(CommonDataKeys.EDITOR).document
val document = (event.getData(CommonDataKeys.EDITOR) ?: return).document
val textRange = smallestIntersectingMethod.textRange
val finalDeclaration = declaration
val outputHumanLanguage = settings.humanLanguage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ class InsertImplementationAction : BaseAction() {
val humanLanguage = AppSettingsState.instance.humanLanguage
val computerLanguage = ComputerLanguage.getComputerLanguage(event)
val psiClassContextActionParams = getPsiClassContextActionParams(event).get()
val editor = event.getRequiredData(CommonDataKeys.EDITOR)
val editor = event.getData(CommonDataKeys.EDITOR) ?: return
val caretModel = editor.caretModel
val primaryCaret = caretModel.primaryCaret
val settings = AppSettingsState.instance
var instruct = psiClassContextActionParams.largestIntersectingComment.text.trim { it <= ' ' }
if (primaryCaret.selectionEnd > primaryCaret.selectionStart) {
val selectedText = Objects.requireNonNull(primaryCaret.selectedText)
Expand Down Expand Up @@ -97,11 +96,11 @@ class InsertImplementationAction : BaseAction() {
val largestIntersectingComment: PsiElement
)

override fun isEnabled(e: AnActionEvent): Boolean {
override fun isEnabled(event: AnActionEvent): Boolean {
if (UITools.isSanctioned()) return false
val computerLanguage = ComputerLanguage.getComputerLanguage(e) ?: return false
val computerLanguage = ComputerLanguage.getComputerLanguage(event) ?: return false
if (computerLanguage == ComputerLanguage.Text) return false
return getPsiClassContextActionParams(e).isPresent
return getPsiClassContextActionParams(event).isPresent
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PasteAction : BaseAction() {
).create()

override fun actionPerformed(event: AnActionEvent) {
val editor = event.getRequiredData(CommonDataKeys.EDITOR)
val editor = event.getData(CommonDataKeys.EDITOR) ?: return
val caretModel = editor.caretModel
val primaryCaret = caretModel.primaryCaret
val selectionStart = primaryCaret.selectionStart
Expand Down Expand Up @@ -65,12 +65,12 @@ class PasteAction : BaseAction() {
}
}

override fun isEnabled(e: AnActionEvent): Boolean {
override fun isEnabled(event: AnActionEvent): Boolean {
if (UITools.isSanctioned()) return false
return if (CopyPasteManager.getInstance()
.getContents<Any?>(DataFlavor.stringFlavor) == null
) false else {
val computerLanguage = ComputerLanguage.getComputerLanguage(e) ?: return false
val computerLanguage = ComputerLanguage.getComputerLanguage(event) ?: return false
computerLanguage != ComputerLanguage.Text
}
}
Expand Down
Loading

0 comments on commit 9b473f9

Please sign in to comment.