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 3a4baf0e..c9eb50e5 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 @@ -13,6 +13,8 @@ import kotlin.Pair import org.jetbrains.annotations.NotNull import org.jetbrains.annotations.Nullable +import static com.intellij.openapi.application.ActionsKt.runReadAction + class InsertImplementationAction extends SelectionAction { interface VirtualAPI { @@ -88,12 +90,14 @@ class InsertImplementationAction extends SelectionAction { .reduce { a, b -> "$a $b" }.get() if(null != state.psiFile) { def code = UITools.run(state.project, "Insert Implementation", true, true, { - def psiClassContext = PsiClassContext.getContext( + def psiClassContext = runReadAction { + PsiClassContext.getContext( state.psiFile, psiClassContextActionParams.selectionStart, psiClassContextActionParams.selectionEnd, computerLanguage ).toString() + } proxy.implementCode( specification, psiClassContext, 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 61d8b0c9..25e1ddd9 100644 --- a/src/main/kotlin/com/github/simiacryptus/aicoder/config/ActionSettingsRegistry.kt +++ b/src/main/kotlin/com/github/simiacryptus/aicoder/config/ActionSettingsRegistry.kt @@ -11,7 +11,7 @@ import java.util.stream.Collectors class ActionSettingsRegistry { val actionSettings: MutableMap = HashMap() - private val version = 1.91 + private val version = 2.0001 fun edit(superChildren: Array): Array { val children = superChildren.toList().toMutableList() 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 3a4baf0e..c9eb50e5 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 @@ -13,6 +13,8 @@ import kotlin.Pair import org.jetbrains.annotations.NotNull import org.jetbrains.annotations.Nullable +import static com.intellij.openapi.application.ActionsKt.runReadAction + class InsertImplementationAction extends SelectionAction { interface VirtualAPI { @@ -88,12 +90,14 @@ class InsertImplementationAction extends SelectionAction { .reduce { a, b -> "$a $b" }.get() if(null != state.psiFile) { def code = UITools.run(state.project, "Insert Implementation", true, true, { - def psiClassContext = PsiClassContext.getContext( + def psiClassContext = runReadAction { + PsiClassContext.getContext( state.psiFile, psiClassContextActionParams.selectionStart, psiClassContextActionParams.selectionEnd, computerLanguage ).toString() + } proxy.implementCode( specification, psiClassContext,