Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3d5c582

Browse files
assertArrayEquals overload is not found, tests doesn't compile#135
resolving merge conflict with main branch, use the very last (just added to the list) library with matching name
1 parent80dcff4 commit3d5c582

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

‎utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt‎

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,18 @@ import com.intellij.openapi.application.runWriteAction
3838
importcom.intellij.openapi.command.WriteCommandAction
3939
importcom.intellij.openapi.components.service
4040
importcom.intellij.openapi.editor.colors.EditorColorsManager
41+
importcom.intellij.openapi.module.Module
4142
importcom.intellij.openapi.options.ShowSettingsUtil
4243
importcom.intellij.openapi.projectRoots.JavaSdkVersion
4344
importcom.intellij.openapi.roots.ContentEntry
4445
importcom.intellij.openapi.roots.DependencyScope
4546
importcom.intellij.openapi.roots.ExternalLibraryDescriptor
4647
importcom.intellij.openapi.roots.JavaProjectModelModificationService
48+
importcom.intellij.openapi.roots.LibraryOrderEntry
49+
importcom.intellij.openapi.roots.ModifiableRootModel
4750
importcom.intellij.openapi.roots.ModuleRootManager
51+
importcom.intellij.openapi.roots.ModuleRootModificationUtil
52+
importcom.intellij.openapi.roots.ModuleSourceOrderEntry
4853
importcom.intellij.openapi.roots.ui.configuration.ClasspathEditor
4954
importcom.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable
5055
importcom.intellij.openapi.ui.ComboBox
@@ -111,6 +116,8 @@ import javax.swing.JComponent
111116
importjavax.swing.JList
112117
importjavax.swing.JPanel
113118
importkotlin.streams.toList
119+
importorg.jetbrains.concurrency.thenRun
120+
importorg.utbot.intellij.plugin.ui.utils.allLibraries
114121

115122
privateconstvalRECENTS_KEY="org.utbot.recents"
116123

@@ -642,7 +649,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
642649
}
643650

644651
selectedTestFramework.isInstalled=true
645-
addDependency(libraryDescriptor)
652+
addDependency(model.testModule,libraryDescriptor)
646653
.onError { selectedTestFramework.isInstalled=false }
647654
}
648655

@@ -663,7 +670,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
663670
val versionInProject= libraryInProject?.libraryName?.parseVersion()
664671

665672
selectedMockFramework.isInstalled=true
666-
addDependency(mockitoCoreLibraryDescriptor(versionInProject))
673+
addDependency(model.testModule,mockitoCoreLibraryDescriptor(versionInProject))
667674
.onError { selectedMockFramework.isInstalled=false }
668675
}
669676

@@ -701,11 +708,34 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
701708
* Note that version restrictions will be applied only if they are present on target machine
702709
* Otherwise latest release version will be installed.
703710
*/
704-
privatefunaddDependency(libraryDescriptor:ExternalLibraryDescriptor):Promise<Void> {
705-
returnJavaProjectModelModificationService
711+
privatefunaddDependency(module:Module,libraryDescriptor:ExternalLibraryDescriptor):Promise<Void> {
712+
val promise=JavaProjectModelModificationService
706713
.getInstance(model.project)
707714
//this method returns JetBrains internal Promise that is difficult to deal with, but it is our way
708715
.addDependency(model.testModule, libraryDescriptor,DependencyScope.TEST)
716+
promise.thenRun {
717+
module.allLibraries()
718+
.lastOrNull { library-> library.libraryName== libraryDescriptor.presentableName }?.let {
719+
ModuleRootModificationUtil.updateModel(module) { model-> placeEntryToCorrectPlace(model, it) }
720+
}
721+
}
722+
return promise
723+
}
724+
725+
/**
726+
* Reorders library list to unsure that just added library with proper version is listed prior to old-versioned one
727+
*/
728+
privatefunplaceEntryToCorrectPlace(model:ModifiableRootModel,addedEntry:LibraryOrderEntry) {
729+
val order= model.orderEntries
730+
val lastEntry= order.last()
731+
if (lastEntryisLibraryOrderEntry&& lastEntry.library== addedEntry.library) {
732+
val insertionPoint= order.indexOfFirst { itisModuleSourceOrderEntry }+1
733+
if (insertionPoint>0) {
734+
System.arraycopy(order, insertionPoint, order, insertionPoint+1, order.size-1- insertionPoint)
735+
order[insertionPoint]= lastEntry
736+
model.rearrangeOrderEntries(order)
737+
}
738+
}
709739
}
710740

711741
privatefuncreateMockFrameworkNotificationDialog()=Messages.showYesNoDialog(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp