From e69bd9d701b63e7a3db8b0bb34f46da35c917caa Mon Sep 17 00:00:00 2001 From: Andrew Charneski Date: Sun, 15 Oct 2023 07:52:48 -0400 Subject: [PATCH] 1.2.15 --- .../actions/code/CommentsAction.groovy | 8 +- .../actions/code/CustomEditAction.groovy | 4 +- .../actions/code/DescribeAction.groovy | 5 +- .../aicoder/actions/code/DocAction.groovy | 8 +- .../actions/code/GenerateProjectAction.groovy | 83 +++++++++++-------- .../actions/code/ImplementStubAction.groovy | 3 +- .../code/InsertImplementationAction.groovy | 4 +- .../aicoder/actions/code/PasteAction.groovy | 6 +- .../actions/code/QuestionAction.groovy | 3 +- .../actions/code/RenameVariablesAction.groovy | 8 +- .../actions/generic/AnalogueFileAction.groovy | 6 +- .../actions/generic/CreateFileAction.groovy | 15 ++-- .../generic/GenerateStoryAction.groovy | 44 +++++----- .../generic/ReplaceOptionsAction.groovy | 6 +- .../MarkdownImplementActionGroup.groovy | 2 +- .../aicoder/actions/dev/CodeChatAction.kt | 2 +- .../aicoder/config/ActionSettingsRegistry.kt | 2 +- .../aicoder/config/ActionTable.kt | 4 +- .../aicoder/ui/ModelSelectionWidgetFactory.kt | 4 +- .../ui/TemperatureControlWidgetFactory.kt | 4 +- .../simiacryptus/aicoder/util/UITools.kt | 8 +- .../simiacryptus/aicoder/util/psi/PsiUtil.kt | 2 +- .../actions/code/CommentsAction.groovy | 8 +- .../actions/code/CustomEditAction.groovy | 4 +- .../actions/code/DescribeAction.groovy | 5 +- .../aicoder/actions/code/DocAction.groovy | 8 +- .../actions/code/GenerateProjectAction.groovy | 83 +++++++++++-------- .../actions/code/ImplementStubAction.groovy | 3 +- .../code/InsertImplementationAction.groovy | 4 +- .../aicoder/actions/code/PasteAction.groovy | 6 +- .../actions/code/QuestionAction.groovy | 3 +- .../actions/code/RenameVariablesAction.groovy | 8 +- .../actions/generic/AnalogueFileAction.groovy | 6 +- .../actions/generic/CreateFileAction.groovy | 15 ++-- .../generic/GenerateStoryAction.groovy | 44 +++++----- .../generic/ReplaceOptionsAction.groovy | 6 +- .../MarkdownImplementActionGroup.groovy | 2 +- .../actions/code/QuestionActionTest.kt | 2 +- .../actions/generic/PasteActionTest.kt | 2 +- 39 files changed, 245 insertions(+), 195 deletions(-) diff --git a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/CommentsAction.groovy b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/CommentsAction.groovy index e1294bc1..827f9d8b 100644 --- a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/CommentsAction.groovy +++ b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/CommentsAction.groovy @@ -41,11 +41,11 @@ class CommentsAction extends SelectionAction { String humanLanguage ) - public class CommentsAction_ConvertedText { - public String code; - public String language; + class CommentsAction_ConvertedText { + public String code + public String language - public ConvertedText() {} + def ConvertedText() {} } } diff --git a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/CustomEditAction.groovy b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/CustomEditAction.groovy index db7118c7..ead12541 100644 --- a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/CustomEditAction.groovy +++ b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/CustomEditAction.groovy @@ -23,9 +23,9 @@ class CustomEditAction extends SelectionAction { public String code = null public String language = null - public EditedText() {} + EditedText() {} - public EditedText(String code, String language) { + EditedText(String code, String language) { this.code = code this.language = language } diff --git a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/DescribeAction.groovy b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/DescribeAction.groovy index 7c357bc9..b9f90186 100644 --- a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/DescribeAction.groovy +++ b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/DescribeAction.groovy @@ -18,10 +18,11 @@ class DescribeAction extends SelectionAction { String humanLanguage ) - public class DescribeAction_ConvertedText { + class DescribeAction_ConvertedText { public String text = null public String language = null - public DescribeAction_ConvertedText() { + + DescribeAction_ConvertedText() { } } } diff --git a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/DocAction.groovy b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/DocAction.groovy index 9cdcfb1c..b446cfad 100644 --- a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/DocAction.groovy +++ b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/DocAction.groovy @@ -20,11 +20,11 @@ class DocAction extends SelectionAction { String humanLanguage ) - public class DocAction_ConvertedText { - public String text; - public String language; + class DocAction_ConvertedText { + public String text + public String language - public ConvertedText() {} + def ConvertedText() {} } } diff --git a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/GenerateProjectAction.groovy b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/GenerateProjectAction.groovy index 200a2aff..7c381b64 100644 --- a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/GenerateProjectAction.groovy +++ b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/GenerateProjectAction.groovy @@ -21,12 +21,11 @@ import java.util.concurrent.atomic.AtomicInteger import java.util.zip.ZipEntry import java.util.zip.ZipOutputStream -public class GenerateProjectAction extends FileContextAction { +class GenerateProjectAction extends FileContextAction { static Logger logger = LoggerFactory.getLogger(GenerateProjectAction.class) - - public GenerateProjectAction() { + GenerateProjectAction() { super(false, true) } @@ -50,14 +49,15 @@ public class GenerateProjectAction extends FileContextAction { Project newProject(String description) - public class Project implements ValidatedObject { + class Project implements ValidatedObject { public String name = '' public String description = '' public String language = '' public List features = [] public List libraries = [] public List buildTools = [] - public Project() {} + + Project() {} boolean validate() { return true } @@ -65,12 +65,13 @@ public class GenerateProjectAction extends FileContextAction { ProjectStatements getProjectStatements(String description, Project project) - public class ProjectStatements implements ValidatedObject { + class ProjectStatements implements ValidatedObject { public List assumptions = [] public List designPatterns = [] public List requirements = [] public List risks = [] - public ProjectStatements() {} + + ProjectStatements() {} boolean validate() { return true @@ -79,42 +80,46 @@ public class GenerateProjectAction extends FileContextAction { ProjectDesign buildProjectDesign(Project project, ProjectStatements requirements) - public class ProjectDesign implements ValidatedObject { + class ProjectDesign implements ValidatedObject { public List components = [] public List documents = [] public List tests = [] - public ProjectDesign() {} + + ProjectDesign() {} boolean validate() { return true } } - public class ComponentDetails implements ValidatedObject { + class ComponentDetails implements ValidatedObject { public String name = '' public String description = '' public List features = [] - public ComponentDetails() {} + + ComponentDetails() {} boolean validate() { return true } } - public class TestDetails implements ValidatedObject { + class TestDetails implements ValidatedObject { public String name = '' public List steps = [] public List expectations = [] - public TestDetails() {} + + TestDetails() {} boolean validate() { return true } } - public class DocumentationDetails implements ValidatedObject { + class DocumentationDetails implements ValidatedObject { public String name = '' public String description = '' public List sections = [] - public DocumentationDetails() {} + + DocumentationDetails() {} boolean validate() { return true @@ -123,9 +128,10 @@ public class GenerateProjectAction extends FileContextAction { CodeSpecificationList buildProjectFileSpecifications(Project project, ProjectStatements requirements, ProjectDesign design, boolean recursive) - public class CodeSpecificationList implements ValidatedObject { + class CodeSpecificationList implements ValidatedObject { public List files = [] - public CodeSpecificationList() {} + + CodeSpecificationList() {} boolean validate() { return true } @@ -135,9 +141,10 @@ public class GenerateProjectAction extends FileContextAction { TestSpecificationList buildTestFileSpecifications(Project project, ProjectStatements requirements, TestDetails design, boolean recursive) - public class TestSpecificationList implements ValidatedObject { + class TestSpecificationList implements ValidatedObject { public List files = [] - public TestSpecificationList() {} + + TestSpecificationList() {} boolean validate() { return true } @@ -145,55 +152,60 @@ public class GenerateProjectAction extends FileContextAction { DocumentSpecificationList buildDocumentationFileSpecifications(Project project, ProjectStatements requirements, DocumentationDetails design, boolean recursive) - public class DocumentSpecificationList implements ValidatedObject { + class DocumentSpecificationList implements ValidatedObject { public List files = [] - public DocumentSpecificationList() {} + + DocumentSpecificationList() {} boolean validate() { return true } } - public class CodeSpecification implements ValidatedObject { + class CodeSpecification implements ValidatedObject { public String description = '' public List requires = [] public List publicProperties = [] public List publicMethodSignatures = [] public String language = '' public FilePath location = new FilePath() - public CodeSpecification() {} + + CodeSpecification() {} boolean validate() { return true } } - public class DocumentSpecification implements ValidatedObject { + class DocumentSpecification implements ValidatedObject { public String description = '' public List requires = [] public List sections = [] public String language = '' public FilePath location = new FilePath() - public DocumentSpecification() {} + + DocumentSpecification() {} boolean validate() { return true } } - public class TestSpecification implements ValidatedObject { + class TestSpecification implements ValidatedObject { public String description = '' public List requires = [] public List steps = [] public List expectations = [] public String language = '' public FilePath location = new FilePath() - public TestSpecification() {} + + TestSpecification() {} boolean validate() { return true } } - public class FilePath implements ValidatedObject { + class FilePath implements ValidatedObject { public String file = '' - public FilePath() {} + + FilePath() {} boolean validate() { return file?.isBlank() == false @@ -206,10 +218,11 @@ public class GenerateProjectAction extends FileContextAction { SourceCode implementDocumentationSpecification(Project project, DocumentSpecification specification, DocumentationDetails documentation, List imports, DocumentSpecification specificationAgain) - public class SourceCode implements ValidatedObject { + class SourceCode implements ValidatedObject { public String language = '' public String code = '' - public SourceCode() {} + + SourceCode() {} boolean validate() { return true } @@ -417,7 +430,7 @@ public class GenerateProjectAction extends FileContextAction { } @SuppressWarnings("UNUSED") - public static class SettingsUI { + static class SettingsUI { @Name("Project Description") public JTextArea description = new JTextArea() @@ -425,18 +438,18 @@ public class GenerateProjectAction extends FileContextAction { public JTextField drafts = new JTextField("2") public JCheckBox saveAlternates = new JCheckBox("Save Alternates") - public SettingsUI() { + SettingsUI() { description.setLineWrap(true) description.setWrapStyleWord(true) } } - public static class Settings { + static class Settings { public String description = "" public int drafts = 2 public boolean saveAlternates = false - public Settings() {} + Settings() {} } @Override diff --git a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/ImplementStubAction.groovy b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/ImplementStubAction.groovy index 16fdbb08..719de519 100644 --- a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/ImplementStubAction.groovy +++ b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/ImplementStubAction.groovy @@ -23,7 +23,8 @@ class ImplementStubAction extends SelectionAction { static class ConvertedText { public String code public String language - public ConvertedText() {} + + ConvertedText() {} } } diff --git a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/InsertImplementationAction.groovy b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/InsertImplementationAction.groovy index e23acc7a..d329fb00 100644 --- a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/InsertImplementationAction.groovy +++ b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/InsertImplementationAction.groovy @@ -25,7 +25,7 @@ class InsertImplementationAction extends SelectionAction { public String code public String language - public ConvertedText() {} + ConvertedText() {} } } @@ -115,7 +115,7 @@ class InsertImplementationAction extends SelectionAction { int selectionEnd SelectionAction.ContextRange largestIntersectingComment - public PsiClassContextActionParams(int selectionStart, int selectionEnd, SelectionAction.ContextRange largestIntersectingComment) { + PsiClassContextActionParams(int selectionStart, int selectionEnd, SelectionAction.ContextRange largestIntersectingComment) { this.selectionStart = selectionStart this.selectionEnd = selectionEnd this.largestIntersectingComment = largestIntersectingComment diff --git a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/PasteAction.groovy b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/PasteAction.groovy index f73e4ddf..227e698f 100644 --- a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/PasteAction.groovy +++ b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/PasteAction.groovy @@ -19,10 +19,12 @@ class PasteAction extends SelectionAction { interface VirtualAPI { ConvertedText convert(String text, String from_language, String to_language) - public class ConvertedText { + + class ConvertedText { public String code public String language - public ConvertedText() {} + + ConvertedText() {} } } @Override diff --git a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/QuestionAction.groovy b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/QuestionAction.groovy index c23341e7..47bfb8f3 100644 --- a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/QuestionAction.groovy +++ b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/QuestionAction.groovy @@ -19,7 +19,8 @@ class QuestionAction extends SelectionAction { class Answer { public String text = null - public Answer() {} + + Answer() {} } } diff --git a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/RenameVariablesAction.groovy b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/RenameVariablesAction.groovy index 976096e4..7e714767 100644 --- a/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/RenameVariablesAction.groovy +++ b/src/main/groovy/com/github/simiacryptus/aicoder/actions/code/RenameVariablesAction.groovy @@ -18,17 +18,17 @@ class RenameVariablesAction extends SelectionAction { String humanLanguage ) - public class SuggestionResponse { + class SuggestionResponse { public List suggestions = [] - public SuggestionResponse() {} + SuggestionResponse() {} } - public class Suggestion { + class Suggestion { public String originalName = null public String suggestedName = null - public Suggestion() {} + Suggestion() {} } } diff --git a/src/main/groovy/com/github/simiacryptus/aicoder/actions/generic/AnalogueFileAction.groovy b/src/main/groovy/com/github/simiacryptus/aicoder/actions/generic/AnalogueFileAction.groovy index 6ca3629c..018d714e 100644 --- a/src/main/groovy/com/github/simiacryptus/aicoder/actions/generic/AnalogueFileAction.groovy +++ b/src/main/groovy/com/github/simiacryptus/aicoder/actions/generic/AnalogueFileAction.groovy @@ -18,7 +18,8 @@ class AnalogueFileAction extends FileContextAction private static class ProjectFile { public String path = "" public String code = "" - public ProjectFile() { + + ProjectFile() { } } @@ -36,7 +37,8 @@ class AnalogueFileAction extends FileContextAction static class Settings { public String directive = "" - public Settings() { + + Settings() { } } diff --git a/src/main/groovy/com/github/simiacryptus/aicoder/actions/generic/CreateFileAction.groovy b/src/main/groovy/com/github/simiacryptus/aicoder/actions/generic/CreateFileAction.groovy index e5cf1334..29a259b7 100644 --- a/src/main/groovy/com/github/simiacryptus/aicoder/actions/generic/CreateFileAction.groovy +++ b/src/main/groovy/com/github/simiacryptus/aicoder/actions/generic/CreateFileAction.groovy @@ -16,14 +16,15 @@ class CreateFileAction extends FileContextAction { super(false, true) } - public static class ProjectFile { + static class ProjectFile { public String path = "" public String code = "" - public ProjectFile() { + + ProjectFile() { } } - public static class SettingsUI { + static class SettingsUI { @Name("Directive") public JTextArea directive = new JTextArea( /* text = */ """ @@ -32,13 +33,15 @@ class CreateFileAction extends FileContextAction { /* rows = */ 3, /* columns = */ 120 ) - public SettingsUI() { + + SettingsUI() { } } - public static class Settings { + static class Settings { public String directive = "" - public Settings() { + + Settings() { } } diff --git a/src/main/groovy/com/github/simiacryptus/aicoder/actions/generic/GenerateStoryAction.groovy b/src/main/groovy/com/github/simiacryptus/aicoder/actions/generic/GenerateStoryAction.groovy index 068d059c..e97f3be9 100644 --- a/src/main/groovy/com/github/simiacryptus/aicoder/actions/generic/GenerateStoryAction.groovy +++ b/src/main/groovy/com/github/simiacryptus/aicoder/actions/generic/GenerateStoryAction.groovy @@ -18,13 +18,13 @@ class GenerateStoryAction extends FileContextAction characters = [] public List settings = [] @Description("Date and time of the start of the story (e.g. \"2021-01-01 12:00:00\")") @@ -67,16 +67,16 @@ class GenerateStoryAction extends FileContextAction storyEvents = [] - public StoryEvents() {} + StoryEvents() {} } - public class StoryEvent { + class StoryEvent { public String who = "" public String what = "" public String where = "" @@ -88,16 +88,16 @@ class GenerateStoryAction extends FileContextAction origins = [] - public StoryEvent() {} + StoryEvent() {} } - public class StoryObjectOrigin { + class StoryObjectOrigin { @Description("Actor or object name") public String name = "" @Description("Where did this object come from? e.g. \"Jackie was introduced in the previous chapter.\" or \"the book was found on a bookshelf\"") public String origin = "" - public StoryObjectOrigin() {} + StoryObjectOrigin() {} } StoryEvents generatePlotPoints(Idea idea, StoryTemplate story) @@ -122,20 +122,20 @@ class GenerateStoryAction extends FileContextAction items = [] public String settingEnd = "" - public ScreenplaySegment() {} + ScreenplaySegment() {} } - public class ScreenplayItem { + class ScreenplayItem { public String actor = "" public String type = "" public String text = "" - public ScreenplayItem() {} + ScreenplayItem() {} } Page writeStoryPage( @@ -145,12 +145,12 @@ class GenerateStoryAction extends FileContextAction { interface VirtualAPI { Suggestions suggestText(String template, List examples) - public class Suggestions { + + class Suggestions { public List choices = null - public Suggestions() {} + + Suggestions() {} } } diff --git a/src/main/groovy/com/github/simiacryptus/aicoder/actions/markdown/MarkdownImplementActionGroup.groovy b/src/main/groovy/com/github/simiacryptus/aicoder/actions/markdown/MarkdownImplementActionGroup.groovy index 750c7dca..c82d5af2 100644 --- a/src/main/groovy/com/github/simiacryptus/aicoder/actions/markdown/MarkdownImplementActionGroup.groovy +++ b/src/main/groovy/com/github/simiacryptus/aicoder/actions/markdown/MarkdownImplementActionGroup.groovy @@ -84,7 +84,7 @@ class MarkdownImplementActionGroup extends ActionGroup { public String code public String language - public ConvertedText() { + ConvertedText() { } } } diff --git a/src/main/kotlin/com/github/simiacryptus/aicoder/actions/dev/CodeChatAction.kt b/src/main/kotlin/com/github/simiacryptus/aicoder/actions/dev/CodeChatAction.kt index 013758ab..acd854d2 100644 --- a/src/main/kotlin/com/github/simiacryptus/aicoder/actions/dev/CodeChatAction.kt +++ b/src/main/kotlin/com/github/simiacryptus/aicoder/actions/dev/CodeChatAction.kt @@ -58,7 +58,7 @@ rootMessageTrail = var messageTrail = ChatSession.divInitializer() send("""$messageTrail
$userMessage
$spinner
""") messages += ChatMessage(ChatMessage.Role.user, userMessage) - val response = api.chat(chatRequest, model).choices?.first()?.message?.content.orEmpty() + val response = api.chat(chatRequest, model).choices.first()?.message?.content.orEmpty() messages += ChatMessage(ChatMessage.Role.assistant, response) messageTrail += ChatSessionFlexmark.renderMarkdown(response) send(messageTrail) diff --git a/src/main/kotlin/com/github/simiacryptus/aicoder/config/ActionSettingsRegistry.kt b/src/main/kotlin/com/github/simiacryptus/aicoder/config/ActionSettingsRegistry.kt index e4f5aa78..6f6ea5d9 100644 --- a/src/main/kotlin/com/github/simiacryptus/aicoder/config/ActionSettingsRegistry.kt +++ b/src/main/kotlin/com/github/simiacryptus/aicoder/config/ActionSettingsRegistry.kt @@ -90,7 +90,7 @@ class ActionSettingsRegistry { fun buildAction( code: String - ): AnAction? { + ): AnAction { val newClassName = this.className + "_" + Integer.toHexString(code.hashCode()) try { return with( diff --git a/src/main/kotlin/com/github/simiacryptus/aicoder/config/ActionTable.kt b/src/main/kotlin/com/github/simiacryptus/aicoder/config/ActionTable.kt index 693cd866..edfa5ed1 100644 --- a/src/main/kotlin/com/github/simiacryptus/aicoder/config/ActionTable.kt +++ b/src/main/kotlin/com/github/simiacryptus/aicoder/config/ActionTable.kt @@ -184,11 +184,11 @@ class ActionTable( val selectedSettings = actionSettings.find { it.id == dataModel.getValueAt(selectedRow, 2) } - if (!(selectedSettings?.isDynamic ?: false)) { + if (selectedSettings?.isDynamic != true) { JOptionPane.showMessageDialog(null, "Cannot remove non-dynamic action") return } - rowData.removeIf() { + rowData.removeIf { it[2] == selectedSettings?.id } this@ActionTable.parent.invalidate() diff --git a/src/main/kotlin/com/github/simiacryptus/aicoder/ui/ModelSelectionWidgetFactory.kt b/src/main/kotlin/com/github/simiacryptus/aicoder/ui/ModelSelectionWidgetFactory.kt index e314451f..5f1fc639 100644 --- a/src/main/kotlin/com/github/simiacryptus/aicoder/ui/ModelSelectionWidgetFactory.kt +++ b/src/main/kotlin/com/github/simiacryptus/aicoder/ui/ModelSelectionWidgetFactory.kt @@ -50,11 +50,11 @@ class ModelSelectionWidgetFactory : StatusBarWidgetFactory { return "Current active model" } - override fun getSelectedValue(): String? { + override fun getSelectedValue(): String { return activeModel } - override fun getPopup(): JBPopup? { + override fun getPopup(): JBPopup { val context = object : ComboBoxPopup.Context { override fun getProject(): Project? { return null diff --git a/src/main/kotlin/com/github/simiacryptus/aicoder/ui/TemperatureControlWidgetFactory.kt b/src/main/kotlin/com/github/simiacryptus/aicoder/ui/TemperatureControlWidgetFactory.kt index 009184cb..4b64249c 100644 --- a/src/main/kotlin/com/github/simiacryptus/aicoder/ui/TemperatureControlWidgetFactory.kt +++ b/src/main/kotlin/com/github/simiacryptus/aicoder/ui/TemperatureControlWidgetFactory.kt @@ -60,7 +60,7 @@ class TemperatureControlWidgetFactory : StatusBarWidgetFactory { return "AI Coding Assistant\nTemp = ${AppSettingsState.instance.temperature}" } - override fun getClickConsumer(): com.intellij.util.Consumer? { + override fun getClickConsumer(): Consumer { return Consumer { event: MouseEvent -> val widgetComp = event.component if (widgetComp != null) { @@ -134,7 +134,7 @@ class TemperatureControlWidgetFactory : StatusBarWidgetFactory { override fun getIcon(): Icon? = IconLoader.findIcon(javaClass.classLoader.getResource("./META-INF/toolbarIcon.svg")) - override fun getPresentation(): StatusBarWidget.WidgetPresentation? { + override fun getPresentation(): StatusBarWidget.WidgetPresentation { return this } } diff --git a/src/main/kotlin/com/github/simiacryptus/aicoder/util/UITools.kt b/src/main/kotlin/com/github/simiacryptus/aicoder/util/UITools.kt index f2d60b1a..0ccc5e48 100644 --- a/src/main/kotlin/com/github/simiacryptus/aicoder/util/UITools.kt +++ b/src/main/kotlin/com/github/simiacryptus/aicoder/util/UITools.kt @@ -499,7 +499,7 @@ object UITools { } catch (e: IllegalAccessException) { throw RuntimeException(e) } catch (e: Throwable) { - UITools.error(log, "Error processing " + field.name, e) + error(log, "Error processing " + field.name, e) } } } @@ -525,7 +525,7 @@ object UITools { } catch (e: IllegalAccessException) { throw RuntimeException(e) } catch (e: Throwable) { - UITools.error(log, "Error processing " + field.name, e) + error(log, "Error processing " + field.name, e) } } } @@ -843,7 +843,7 @@ object UITools { class BgTask( project : Project, title : String, canBeCancelled : Boolean, val task : (ProgressIndicator) -> T - ) : Task.Backgroundable(project, title ?: "", canBeCancelled, DEAF), Supplier { + ) : Task.Backgroundable(project, title, canBeCancelled, DEAF), Supplier { private val result = AtomicReference() private val isError = AtomicBoolean(false) @@ -1068,7 +1068,7 @@ object UITools { |""".trimMargin() formBuilder.addLabeledComponent("Error Report", wrapScrollPane(bugReportTextArea)) - if (!(dynamicActionException?.actionSetting?.isDynamic ?: true)) { + if (dynamicActionException?.actionSetting?.isDynamic == false) { val openButton = JXButton("Revert to Default") openButton.addActionListener { dynamicActionException?.actionSetting?.file?.delete() diff --git a/src/main/kotlin/com/github/simiacryptus/aicoder/util/psi/PsiUtil.kt b/src/main/kotlin/com/github/simiacryptus/aicoder/util/psi/PsiUtil.kt index 0588195f..154c474d 100644 --- a/src/main/kotlin/com/github/simiacryptus/aicoder/util/psi/PsiUtil.kt +++ b/src/main/kotlin/com/github/simiacryptus/aicoder/util/psi/PsiUtil.kt @@ -252,7 +252,7 @@ object PsiUtil { psiFile: PsiElement?, selectionStart: Int, selectionEnd: Int - ) = getSmallestIntersecting(psiFile!!, selectionStart?.toInt() ?: 0, selectionEnd?.toInt() ?: 0, *ELEMENTS_CODE) + ) = getSmallestIntersecting(psiFile!!, selectionStart.toInt(), selectionEnd.toInt(), *ELEMENTS_CODE) @JvmStatic fun getDeclaration(element: PsiElement): String { diff --git a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/CommentsAction.groovy b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/CommentsAction.groovy index e1294bc1..827f9d8b 100644 --- a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/CommentsAction.groovy +++ b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/CommentsAction.groovy @@ -41,11 +41,11 @@ class CommentsAction extends SelectionAction { String humanLanguage ) - public class CommentsAction_ConvertedText { - public String code; - public String language; + class CommentsAction_ConvertedText { + public String code + public String language - public ConvertedText() {} + def ConvertedText() {} } } diff --git a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/CustomEditAction.groovy b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/CustomEditAction.groovy index db7118c7..ead12541 100644 --- a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/CustomEditAction.groovy +++ b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/CustomEditAction.groovy @@ -23,9 +23,9 @@ class CustomEditAction extends SelectionAction { public String code = null public String language = null - public EditedText() {} + EditedText() {} - public EditedText(String code, String language) { + EditedText(String code, String language) { this.code = code this.language = language } diff --git a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/DescribeAction.groovy b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/DescribeAction.groovy index 7c357bc9..b9f90186 100644 --- a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/DescribeAction.groovy +++ b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/DescribeAction.groovy @@ -18,10 +18,11 @@ class DescribeAction extends SelectionAction { String humanLanguage ) - public class DescribeAction_ConvertedText { + class DescribeAction_ConvertedText { public String text = null public String language = null - public DescribeAction_ConvertedText() { + + DescribeAction_ConvertedText() { } } } diff --git a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/DocAction.groovy b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/DocAction.groovy index 9cdcfb1c..b446cfad 100644 --- a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/DocAction.groovy +++ b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/DocAction.groovy @@ -20,11 +20,11 @@ class DocAction extends SelectionAction { String humanLanguage ) - public class DocAction_ConvertedText { - public String text; - public String language; + class DocAction_ConvertedText { + public String text + public String language - public ConvertedText() {} + def ConvertedText() {} } } diff --git a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/GenerateProjectAction.groovy b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/GenerateProjectAction.groovy index 200a2aff..7c381b64 100644 --- a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/GenerateProjectAction.groovy +++ b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/GenerateProjectAction.groovy @@ -21,12 +21,11 @@ import java.util.concurrent.atomic.AtomicInteger import java.util.zip.ZipEntry import java.util.zip.ZipOutputStream -public class GenerateProjectAction extends FileContextAction { +class GenerateProjectAction extends FileContextAction { static Logger logger = LoggerFactory.getLogger(GenerateProjectAction.class) - - public GenerateProjectAction() { + GenerateProjectAction() { super(false, true) } @@ -50,14 +49,15 @@ public class GenerateProjectAction extends FileContextAction { Project newProject(String description) - public class Project implements ValidatedObject { + class Project implements ValidatedObject { public String name = '' public String description = '' public String language = '' public List features = [] public List libraries = [] public List buildTools = [] - public Project() {} + + Project() {} boolean validate() { return true } @@ -65,12 +65,13 @@ public class GenerateProjectAction extends FileContextAction { ProjectStatements getProjectStatements(String description, Project project) - public class ProjectStatements implements ValidatedObject { + class ProjectStatements implements ValidatedObject { public List assumptions = [] public List designPatterns = [] public List requirements = [] public List risks = [] - public ProjectStatements() {} + + ProjectStatements() {} boolean validate() { return true @@ -79,42 +80,46 @@ public class GenerateProjectAction extends FileContextAction { ProjectDesign buildProjectDesign(Project project, ProjectStatements requirements) - public class ProjectDesign implements ValidatedObject { + class ProjectDesign implements ValidatedObject { public List components = [] public List documents = [] public List tests = [] - public ProjectDesign() {} + + ProjectDesign() {} boolean validate() { return true } } - public class ComponentDetails implements ValidatedObject { + class ComponentDetails implements ValidatedObject { public String name = '' public String description = '' public List features = [] - public ComponentDetails() {} + + ComponentDetails() {} boolean validate() { return true } } - public class TestDetails implements ValidatedObject { + class TestDetails implements ValidatedObject { public String name = '' public List steps = [] public List expectations = [] - public TestDetails() {} + + TestDetails() {} boolean validate() { return true } } - public class DocumentationDetails implements ValidatedObject { + class DocumentationDetails implements ValidatedObject { public String name = '' public String description = '' public List sections = [] - public DocumentationDetails() {} + + DocumentationDetails() {} boolean validate() { return true @@ -123,9 +128,10 @@ public class GenerateProjectAction extends FileContextAction { CodeSpecificationList buildProjectFileSpecifications(Project project, ProjectStatements requirements, ProjectDesign design, boolean recursive) - public class CodeSpecificationList implements ValidatedObject { + class CodeSpecificationList implements ValidatedObject { public List files = [] - public CodeSpecificationList() {} + + CodeSpecificationList() {} boolean validate() { return true } @@ -135,9 +141,10 @@ public class GenerateProjectAction extends FileContextAction { TestSpecificationList buildTestFileSpecifications(Project project, ProjectStatements requirements, TestDetails design, boolean recursive) - public class TestSpecificationList implements ValidatedObject { + class TestSpecificationList implements ValidatedObject { public List files = [] - public TestSpecificationList() {} + + TestSpecificationList() {} boolean validate() { return true } @@ -145,55 +152,60 @@ public class GenerateProjectAction extends FileContextAction { DocumentSpecificationList buildDocumentationFileSpecifications(Project project, ProjectStatements requirements, DocumentationDetails design, boolean recursive) - public class DocumentSpecificationList implements ValidatedObject { + class DocumentSpecificationList implements ValidatedObject { public List files = [] - public DocumentSpecificationList() {} + + DocumentSpecificationList() {} boolean validate() { return true } } - public class CodeSpecification implements ValidatedObject { + class CodeSpecification implements ValidatedObject { public String description = '' public List requires = [] public List publicProperties = [] public List publicMethodSignatures = [] public String language = '' public FilePath location = new FilePath() - public CodeSpecification() {} + + CodeSpecification() {} boolean validate() { return true } } - public class DocumentSpecification implements ValidatedObject { + class DocumentSpecification implements ValidatedObject { public String description = '' public List requires = [] public List sections = [] public String language = '' public FilePath location = new FilePath() - public DocumentSpecification() {} + + DocumentSpecification() {} boolean validate() { return true } } - public class TestSpecification implements ValidatedObject { + class TestSpecification implements ValidatedObject { public String description = '' public List requires = [] public List steps = [] public List expectations = [] public String language = '' public FilePath location = new FilePath() - public TestSpecification() {} + + TestSpecification() {} boolean validate() { return true } } - public class FilePath implements ValidatedObject { + class FilePath implements ValidatedObject { public String file = '' - public FilePath() {} + + FilePath() {} boolean validate() { return file?.isBlank() == false @@ -206,10 +218,11 @@ public class GenerateProjectAction extends FileContextAction { SourceCode implementDocumentationSpecification(Project project, DocumentSpecification specification, DocumentationDetails documentation, List imports, DocumentSpecification specificationAgain) - public class SourceCode implements ValidatedObject { + class SourceCode implements ValidatedObject { public String language = '' public String code = '' - public SourceCode() {} + + SourceCode() {} boolean validate() { return true } @@ -417,7 +430,7 @@ public class GenerateProjectAction extends FileContextAction { } @SuppressWarnings("UNUSED") - public static class SettingsUI { + static class SettingsUI { @Name("Project Description") public JTextArea description = new JTextArea() @@ -425,18 +438,18 @@ public class GenerateProjectAction extends FileContextAction { public JTextField drafts = new JTextField("2") public JCheckBox saveAlternates = new JCheckBox("Save Alternates") - public SettingsUI() { + SettingsUI() { description.setLineWrap(true) description.setWrapStyleWord(true) } } - public static class Settings { + static class Settings { public String description = "" public int drafts = 2 public boolean saveAlternates = false - public Settings() {} + Settings() {} } @Override diff --git a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/ImplementStubAction.groovy b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/ImplementStubAction.groovy index 16fdbb08..719de519 100644 --- a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/ImplementStubAction.groovy +++ b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/ImplementStubAction.groovy @@ -23,7 +23,8 @@ class ImplementStubAction extends SelectionAction { static class ConvertedText { public String code public String language - public ConvertedText() {} + + ConvertedText() {} } } diff --git a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/InsertImplementationAction.groovy b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/InsertImplementationAction.groovy index e23acc7a..d329fb00 100644 --- a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/InsertImplementationAction.groovy +++ b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/InsertImplementationAction.groovy @@ -25,7 +25,7 @@ class InsertImplementationAction extends SelectionAction { public String code public String language - public ConvertedText() {} + ConvertedText() {} } } @@ -115,7 +115,7 @@ class InsertImplementationAction extends SelectionAction { int selectionEnd SelectionAction.ContextRange largestIntersectingComment - public PsiClassContextActionParams(int selectionStart, int selectionEnd, SelectionAction.ContextRange largestIntersectingComment) { + PsiClassContextActionParams(int selectionStart, int selectionEnd, SelectionAction.ContextRange largestIntersectingComment) { this.selectionStart = selectionStart this.selectionEnd = selectionEnd this.largestIntersectingComment = largestIntersectingComment diff --git a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/PasteAction.groovy b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/PasteAction.groovy index f73e4ddf..227e698f 100644 --- a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/PasteAction.groovy +++ b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/PasteAction.groovy @@ -19,10 +19,12 @@ class PasteAction extends SelectionAction { interface VirtualAPI { ConvertedText convert(String text, String from_language, String to_language) - public class ConvertedText { + + class ConvertedText { public String code public String language - public ConvertedText() {} + + ConvertedText() {} } } @Override diff --git a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/QuestionAction.groovy b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/QuestionAction.groovy index c23341e7..47bfb8f3 100644 --- a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/QuestionAction.groovy +++ b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/QuestionAction.groovy @@ -19,7 +19,8 @@ class QuestionAction extends SelectionAction { class Answer { public String text = null - public Answer() {} + + Answer() {} } } diff --git a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/RenameVariablesAction.groovy b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/RenameVariablesAction.groovy index 976096e4..7e714767 100644 --- a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/RenameVariablesAction.groovy +++ b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/code/RenameVariablesAction.groovy @@ -18,17 +18,17 @@ class RenameVariablesAction extends SelectionAction { String humanLanguage ) - public class SuggestionResponse { + class SuggestionResponse { public List suggestions = [] - public SuggestionResponse() {} + SuggestionResponse() {} } - public class Suggestion { + class Suggestion { public String originalName = null public String suggestedName = null - public Suggestion() {} + Suggestion() {} } } diff --git a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/generic/AnalogueFileAction.groovy b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/generic/AnalogueFileAction.groovy index 6ca3629c..018d714e 100644 --- a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/generic/AnalogueFileAction.groovy +++ b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/generic/AnalogueFileAction.groovy @@ -18,7 +18,8 @@ class AnalogueFileAction extends FileContextAction private static class ProjectFile { public String path = "" public String code = "" - public ProjectFile() { + + ProjectFile() { } } @@ -36,7 +37,8 @@ class AnalogueFileAction extends FileContextAction static class Settings { public String directive = "" - public Settings() { + + Settings() { } } diff --git a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/generic/CreateFileAction.groovy b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/generic/CreateFileAction.groovy index e5cf1334..29a259b7 100644 --- a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/generic/CreateFileAction.groovy +++ b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/generic/CreateFileAction.groovy @@ -16,14 +16,15 @@ class CreateFileAction extends FileContextAction { super(false, true) } - public static class ProjectFile { + static class ProjectFile { public String path = "" public String code = "" - public ProjectFile() { + + ProjectFile() { } } - public static class SettingsUI { + static class SettingsUI { @Name("Directive") public JTextArea directive = new JTextArea( /* text = */ """ @@ -32,13 +33,15 @@ class CreateFileAction extends FileContextAction { /* rows = */ 3, /* columns = */ 120 ) - public SettingsUI() { + + SettingsUI() { } } - public static class Settings { + static class Settings { public String directive = "" - public Settings() { + + Settings() { } } diff --git a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/generic/GenerateStoryAction.groovy b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/generic/GenerateStoryAction.groovy index 068d059c..e97f3be9 100644 --- a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/generic/GenerateStoryAction.groovy +++ b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/generic/GenerateStoryAction.groovy @@ -18,13 +18,13 @@ class GenerateStoryAction extends FileContextAction characters = [] public List settings = [] @Description("Date and time of the start of the story (e.g. \"2021-01-01 12:00:00\")") @@ -67,16 +67,16 @@ class GenerateStoryAction extends FileContextAction storyEvents = [] - public StoryEvents() {} + StoryEvents() {} } - public class StoryEvent { + class StoryEvent { public String who = "" public String what = "" public String where = "" @@ -88,16 +88,16 @@ class GenerateStoryAction extends FileContextAction origins = [] - public StoryEvent() {} + StoryEvent() {} } - public class StoryObjectOrigin { + class StoryObjectOrigin { @Description("Actor or object name") public String name = "" @Description("Where did this object come from? e.g. \"Jackie was introduced in the previous chapter.\" or \"the book was found on a bookshelf\"") public String origin = "" - public StoryObjectOrigin() {} + StoryObjectOrigin() {} } StoryEvents generatePlotPoints(Idea idea, StoryTemplate story) @@ -122,20 +122,20 @@ class GenerateStoryAction extends FileContextAction items = [] public String settingEnd = "" - public ScreenplaySegment() {} + ScreenplaySegment() {} } - public class ScreenplayItem { + class ScreenplayItem { public String actor = "" public String type = "" public String text = "" - public ScreenplayItem() {} + ScreenplayItem() {} } Page writeStoryPage( @@ -145,12 +145,12 @@ class GenerateStoryAction extends FileContextAction { interface VirtualAPI { Suggestions suggestText(String template, List examples) - public class Suggestions { + + class Suggestions { public List choices = null - public Suggestions() {} + + Suggestions() {} } } diff --git a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/markdown/MarkdownImplementActionGroup.groovy b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/markdown/MarkdownImplementActionGroup.groovy index 750c7dca..c82d5af2 100644 --- a/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/markdown/MarkdownImplementActionGroup.groovy +++ b/src/main/resources/sources/groovy/com/github/simiacryptus/aicoder/actions/markdown/MarkdownImplementActionGroup.groovy @@ -84,7 +84,7 @@ class MarkdownImplementActionGroup extends ActionGroup { public String code public String language - public ConvertedText() { + ConvertedText() { } } } diff --git a/src/test/kotlin/com/github/simiacryptus/aicoder/actions/code/QuestionActionTest.kt b/src/test/kotlin/com/github/simiacryptus/aicoder/actions/code/QuestionActionTest.kt index 67f9f64d..af521703 100644 --- a/src/test/kotlin/com/github/simiacryptus/aicoder/actions/code/QuestionActionTest.kt +++ b/src/test/kotlin/com/github/simiacryptus/aicoder/actions/code/QuestionActionTest.kt @@ -12,7 +12,7 @@ class QuestionActionTest : ActionTestBase() { @Test fun testProcessing() { testScript_SelectionAction(object : QuestionAction() { - override fun getConfig(project: Project?): String? { + override fun getConfig(project: Project?): String { return "How are you feeling?" } }, "/QuestionActionTest.md") diff --git a/src/test/kotlin/com/github/simiacryptus/aicoder/actions/generic/PasteActionTest.kt b/src/test/kotlin/com/github/simiacryptus/aicoder/actions/generic/PasteActionTest.kt index b964a430..b1172842 100644 --- a/src/test/kotlin/com/github/simiacryptus/aicoder/actions/generic/PasteActionTest.kt +++ b/src/test/kotlin/com/github/simiacryptus/aicoder/actions/generic/PasteActionTest.kt @@ -14,7 +14,7 @@ class PasteActionTest : ActionTestBase() { @Test fun testProcessing() { testScript_SelectionAction(object : PasteAction() { - override fun processSelection(state: SelectionAction.SelectionState, config: String?): String { + override fun processSelection(state: SelectionState, config: String?): String { Toolkit.getDefaultToolkit().systemClipboard.setContents(StringSelection(state.selectedText), null) return super.processSelection(state, config) }