Skip to content

Commit

Permalink
fix: remove UtilsKt usages
Browse files Browse the repository at this point in the history
  • Loading branch information
pderakhshanfar committed Dec 13, 2024
1 parent 7d4227a commit 33e5c40
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import com.intellij.psi.PsiElementFactory
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiJavaFile
import com.intellij.psi.PsiManager
import com.intellij.refactoring.suggested.startOffset
import com.intellij.util.containers.stream
import org.jetbrains.research.testspark.bundles.plugin.PluginLabelsBundle
import org.jetbrains.research.testspark.data.UIContext
Expand Down Expand Up @@ -202,7 +201,7 @@ class JavaDisplayUtils : DisplayUtils {

// insert imports to a code
PsiDocumentManager.getInstance(project).getDocument(outputFile)!!.insertString(
outputFile.importList?.startOffset ?: outputFile.packageStatement?.startOffset ?: 0,
outputFile.importList?.startOffsetInParent ?: outputFile.packageStatement?.startOffsetInParent ?: 0,
uiContext.testGenerationOutput.importsCode.joinToString("\n") + "\n\n",
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ import com.intellij.psi.PsiDocumentManager
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiJavaFile
import com.intellij.psi.PsiManager
import com.intellij.refactoring.suggested.endOffset
import com.intellij.refactoring.suggested.startOffset
import com.intellij.util.containers.stream
import org.jetbrains.kotlin.psi.KtClass
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.psi.psiUtil.pureEndOffset
import org.jetbrains.research.testspark.bundles.plugin.PluginLabelsBundle
import org.jetbrains.research.testspark.data.UIContext
import org.jetbrains.research.testspark.display.utils.ErrorMessageManager
Expand Down Expand Up @@ -213,8 +212,8 @@ class KotlinDisplayUtils : DisplayUtils {
val importsString = uiContext.testGenerationOutput.importsCode.joinToString("\n") + "\n\n"

// Find the insertion offset
val insertionOffset = outputFile.importList?.startOffset
?: outputFile.packageDirective?.endOffset
val insertionOffset = outputFile.importList?.startOffsetInParent
?: outputFile.packageDirective?.pureEndOffset
?: 0

// Insert the imports into the document
Expand Down

0 comments on commit 33e5c40

Please sign in to comment.