diff --git a/build.gradle.kts b/build.gradle.kts index b0d38c26d..818b2941f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -54,7 +54,7 @@ val pluginGroup = "org.move" val javaVersion = JavaVersion.VERSION_17 val pluginJarName = "intellij-move-$pluginVersion" -val kotlinReflectVersion = "1.8.10" +val kotlinReflectVersion = "1.9.10" val aptosVersion = "3.4.1" val remoteRobotVersion = "0.11.22" @@ -154,7 +154,7 @@ allprojects { kotlinOptions { jvmTarget = "17" languageVersion = "1.9" - apiVersion = "1.8" + apiVersion = "1.9" freeCompilerArgs = listOf("-Xjvm-default=all") } } @@ -267,7 +267,6 @@ project(":plugin") { // these are the only issues we tolerate RunPluginVerifierTask.FailureLevel.DEPRECATED_API_USAGES, RunPluginVerifierTask.FailureLevel.EXPERIMENTAL_API_USAGES, - RunPluginVerifierTask.FailureLevel.INTERNAL_API_USAGES, RunPluginVerifierTask.FailureLevel.SCHEDULED_FOR_REMOVAL_API_USAGES, ) ) diff --git a/src/main/kotlin/org/move/bytecode/AptosDecompiler.kt b/src/main/kotlin/org/move/bytecode/AptosDecompiler.kt index fbbeacd90..74af44b15 100644 --- a/src/main/kotlin/org/move/bytecode/AptosDecompiler.kt +++ b/src/main/kotlin/org/move/bytecode/AptosDecompiler.kt @@ -12,7 +12,7 @@ import com.intellij.openapi.vfs.newvfs.BulkFileListener import com.intellij.openapi.vfs.newvfs.events.VFileEvent import org.move.cli.settings.getAptosCli import org.move.openapiext.pathAsPath -import org.move.openapiext.rootDisposable +import org.move.openapiext.rootPluginDisposable import org.move.openapiext.rootPath import org.move.stdext.RsResult import org.move.stdext.unwrapOrElse @@ -121,6 +121,6 @@ fun Project.createDisposableOnFileChange(file: VirtualFile): Disposable { } } ) - Disposer.register(this.rootDisposable, disposable) + Disposer.register(this.rootPluginDisposable, disposable) return disposable } diff --git a/src/main/kotlin/org/move/cli/MoveProjectsService.kt b/src/main/kotlin/org/move/cli/MoveProjectsService.kt index 1ef9a94c1..642995c8f 100644 --- a/src/main/kotlin/org/move/cli/MoveProjectsService.kt +++ b/src/main/kotlin/org/move/cli/MoveProjectsService.kt @@ -91,12 +91,11 @@ class MoveProjectsService(val project: Project): Disposable { // activate auto-reload projectTracker.activate(moveProjectAware.projectId) - @Suppress("UnstableApiUsage") project.messageBus.connect(disposable) .subscribe(MOVE_SETTINGS_TOPIC, object: MoveSettingsListener { override fun > settingsChanged(e: SettingsChangedEventBase) { if (e.affectsMoveProjectsMetadata) { - val tracker = AutoImportProjectTracker.getInstance(project) + val tracker = ExternalSystemProjectTracker.getInstance(project) tracker.markDirty(moveProjectAware.projectId) tracker.scheduleProjectRefresh() } @@ -105,10 +104,9 @@ class MoveProjectsService(val project: Project): Disposable { // default projectTracker cannot detect Move.toml file creation, // as it's not present in the `settingsFiles` - @Suppress("UnstableApiUsage") project.messageBus.connect(disposable) .subscribe(VirtualFileManager.VFS_CHANGES, OnMoveTomlCreatedFileListener { - val tracker = AutoImportProjectTracker.getInstance(project) + val tracker = ExternalSystemProjectTracker.getInstance(project) tracker.markDirty(moveProjectAware.projectId) tracker.scheduleProjectRefresh() }) @@ -214,8 +212,6 @@ class MoveProjectsService(val project: Project): Disposable { private fun modifyProjectModel( modifyProjects: (List) -> CompletableFuture> ): CompletableFuture> { - val refreshStatusPublisher = - project.messageBus.syncPublisher(MOVE_PROJECTS_REFRESH_TOPIC) val syncOnRefreshTopic = { project.messageBus.takeIf { !it.isDisposed } ?.syncPublisher(MOVE_PROJECTS_REFRESH_TOPIC) diff --git a/src/main/kotlin/org/move/cli/externalLinter/MvExternalLinterConfigurable.kt b/src/main/kotlin/org/move/cli/externalLinter/MvExternalLinterConfigurable.kt index 867c63577..776b1bf92 100644 --- a/src/main/kotlin/org/move/cli/externalLinter/MvExternalLinterConfigurable.kt +++ b/src/main/kotlin/org/move/cli/externalLinter/MvExternalLinterConfigurable.kt @@ -17,7 +17,6 @@ import org.move.openapiext.fullWidthCell class MvExternalLinterConfigurable(val project: Project): BoundConfigurable("External Linters") { private val additionalArguments: RsCommandLineEditor = RsCommandLineEditor(project, RsCommandLineEditor.EmptyTextFieldCompletionProvider()) -// RsCommandLineEditor(project, CargoCommandCompletionProvider(project.cargoProjects, "check ") { null }) private val environmentVariables: EnvironmentVariablesComponent = EnvironmentVariablesComponent() diff --git a/src/main/kotlin/org/move/cli/util/RsCommandLineEditor.kt b/src/main/kotlin/org/move/cli/util/RsCommandLineEditor.kt index dabaf9cf5..d221adad4 100644 --- a/src/main/kotlin/org/move/cli/util/RsCommandLineEditor.kt +++ b/src/main/kotlin/org/move/cli/util/RsCommandLineEditor.kt @@ -1,24 +1,19 @@ package org.move.cli.util import com.intellij.codeInsight.completion.CompletionResultSet -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.editor.ex.EditorEx import com.intellij.openapi.project.Project import com.intellij.ui.EditorTextField import com.intellij.ui.ExpandableEditorSupport import com.intellij.ui.TextAccessor -import com.intellij.util.Function import com.intellij.util.TextFieldCompletionProvider import com.intellij.util.textCompletion.TextFieldWithCompletion import java.awt.BorderLayout -import java.awt.Dimension -import javax.swing.JComponent import javax.swing.JPanel class RsCommandLineEditor( private val project: Project, private val completionProvider: TextFieldCompletionProvider -) : JPanel(BorderLayout()), TextAccessor { +): JPanel(BorderLayout()), TextAccessor { private val textField = createTextField("") @@ -57,39 +52,7 @@ class RsCommandLineEditor( private class ExpandableEditorSupportWithCustomPopup( field: EditorTextField, private val createPopup: (text: String) -> EditorTextField -) : ExpandableEditorSupport(field) { - @Suppress("UnstableApiUsage") - override fun prepare(field: EditorTextField, onShow: Function): Content { - val popup = createPopup(onShow.`fun`(field.text)) - val background = field.background +): ExpandableEditorSupport(field) { - popup.background = background - popup.setOneLineMode(false) - popup.preferredSize = Dimension(field.width, 5 * field.height) - popup.addSettingsProvider { editor -> - initPopupEditor(editor, background) - copyCaretPosition(editor, field.editor) - } - - return object : Content { - override fun getContentComponent(): JComponent = popup - override fun getFocusableComponent(): JComponent = popup - override fun cancel(onHide: Function) { - field.text = onHide.`fun`(popup.text) - val editor = field.editor - if (editor != null) copyCaretPosition(editor, popup.editor) - if (editor is EditorEx) updateFieldFolding((editor as EditorEx?)!!) - } - } - } - - companion object { - private fun copyCaretPosition(destination: Editor, source: Editor?) { - if (source == null) return // unexpected - try { - destination.caretModel.caretsAndSelections = source.caretModel.caretsAndSelections - } catch (ignored: IllegalArgumentException) { - } - } - } + override fun createPopupEditor(field: EditorTextField, text: String): EditorTextField = createPopup(text) } diff --git a/src/main/kotlin/org/move/ide/MoveIcons.kt b/src/main/kotlin/org/move/ide/MoveIcons.kt index 5fa847084..2255bf976 100644 --- a/src/main/kotlin/org/move/ide/MoveIcons.kt +++ b/src/main/kotlin/org/move/ide/MoveIcons.kt @@ -3,17 +3,11 @@ package org.move.ide import com.intellij.icons.AllIcons import com.intellij.openapi.util.IconLoader import com.intellij.ui.AnimatedIcon -import com.intellij.ui.ColorUtil -import com.intellij.ui.JBColor import com.intellij.ui.LayeredIcon import com.intellij.ui.LayeredIcon.Companion.layeredIcon -import com.intellij.ui.icons.RgbImageFilterSupplier -import com.jetbrains.rd.generator.nova.array -import java.awt.Color import java.awt.Component import java.awt.Graphics import java.awt.Graphics2D -import java.awt.image.RGBImageFilter import javax.swing.Icon object MoveIcons { @@ -85,17 +79,6 @@ fun Icon.multiple(): Icon { return compoundIcon } -@Suppress("UnstableApiUsage") -fun Icon.grayed(): Icon = - IconLoader.filterIcon(this, object: RgbImageFilterSupplier { - override fun getFilter(): RGBImageFilter = object: RGBImageFilter() { - override fun filterRGB(x: Int, y: Int, rgb: Int): Int { - val color = Color(rgb, true) - return ColorUtil.toAlpha(color, (color.alpha / 2.2).toInt()).rgb - } - } - }) - /** * Rotates the icon by the given angle, in degrees. * diff --git a/src/main/kotlin/org/move/ide/actions/RsRunExternalLinterAction.kt b/src/main/kotlin/org/move/ide/actions/RsRunExternalLinterAction.kt index 42f3da0fe..529f3357d 100644 --- a/src/main/kotlin/org/move/ide/actions/RsRunExternalLinterAction.kt +++ b/src/main/kotlin/org/move/ide/actions/RsRunExternalLinterAction.kt @@ -10,11 +10,8 @@ import com.intellij.codeInspection.InspectionManager import com.intellij.codeInspection.actions.RunInspectionIntention import com.intellij.codeInspection.ex.InspectionManagerEx import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.util.Key import com.intellij.profile.codeInspection.InspectionProjectProfileManager -import org.move.cli.MoveProject import org.move.cli.runConfigurations.aptos.RunAptosCommandActionBase -import org.move.cli.runConfigurations.getAppropriateMoveProject import org.move.ide.inspections.MvExternalLinterInspection class MvRunExternalLinterAction: RunAptosCommandActionBase("Run External Linter") { @@ -24,16 +21,8 @@ class MvRunExternalLinterAction: RunAptosCommandActionBase("Run External Linter" val currentProfile = InspectionProjectProfileManager.getInstance(project).currentProfile val wrapper = currentProfile.getInspectionTool(MvExternalLinterInspection.SHORT_NAME, project) ?: return val managerEx = InspectionManager.getInstance(project) as InspectionManagerEx - val inspectionContext = RunInspectionIntention.createContext(wrapper, managerEx, null) - val cargoProject = getAppropriateMoveProject(e.dataContext) - inspectionContext.putUserData(CARGO_PROJECT, cargoProject) - - inspectionContext.doInspections(AnalysisScope(project)) - } - - companion object { - @JvmField - val CARGO_PROJECT: Key = Key.create("Move project") + val analysisScope = AnalysisScope(project) + RunInspectionIntention.rerunInspection(wrapper, managerEx, analysisScope, null) } } diff --git a/src/main/kotlin/org/move/ide/annotator/RsExternalLinterPass.kt b/src/main/kotlin/org/move/ide/annotator/RsExternalLinterPass.kt index fe1a1805c..4d716c0e7 100644 --- a/src/main/kotlin/org/move/ide/annotator/RsExternalLinterPass.kt +++ b/src/main/kotlin/org/move/ide/annotator/RsExternalLinterPass.kt @@ -174,7 +174,7 @@ class RsExternalLinterPassFactory( ) override fun createHighlightingPass(file: PsiFile, editor: Editor): TextEditorHighlightingPass? { - FileStatusMap.getDirtyTextRange(editor, passId) ?: return null + FileStatusMap.getDirtyTextRange(editor.document, file, passId) ?: return null return RsExternalLinterPass(this, file, editor) } diff --git a/src/main/kotlin/org/move/ide/inspections/MvExternalLinterInspection.kt b/src/main/kotlin/org/move/ide/inspections/MvExternalLinterInspection.kt index 6a614307b..dd54dafee 100644 --- a/src/main/kotlin/org/move/ide/inspections/MvExternalLinterInspection.kt +++ b/src/main/kotlin/org/move/ide/inspections/MvExternalLinterInspection.kt @@ -7,10 +7,9 @@ package org.move.ide.inspections import com.intellij.codeInsight.daemon.impl.HighlightInfo import com.intellij.codeInspection.* -import com.intellij.codeInspection.ex.GlobalInspectionContextImpl +import com.intellij.codeInspection.ex.GlobalInspectionContextEx import com.intellij.codeInspection.ex.GlobalInspectionContextUtil import com.intellij.codeInspection.reference.RefElement -import com.intellij.codeInspection.ui.InspectionToolPresentation import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.runReadAction @@ -33,6 +32,7 @@ import org.move.ide.annotator.createDisposableOnAnyPsiChange import org.move.lang.MoveFile import org.move.lang.core.psi.ext.ancestorOrSelf import org.move.lang.moveProject +import org.move.openapiext.rootPluginDisposable class MvExternalLinterInspection: GlobalSimpleInspectionTool() { @@ -62,7 +62,7 @@ class MvExternalLinterInspection: GlobalSimpleInspectionTool() { globalContext: GlobalInspectionContext, problemDescriptionsProcessor: ProblemDescriptionsProcessor ) { - if (globalContext !is GlobalInspectionContextImpl) return + if (globalContext !is GlobalInspectionContextEx) return val analyzedFiles = globalContext.getUserData(ANALYZED_FILES) ?: return val project = manager.project @@ -70,8 +70,8 @@ class MvExternalLinterInspection: GlobalSimpleInspectionTool() { val toolWrapper = currentProfile.getInspectionTool(SHORT_NAME, project) ?: return while (true) { - val disposable = project.messageBus.createDisposableOnAnyPsiChange() - .also { Disposer.register(project, it) } + val anyPsiChangeDisposable = project.messageBus.createDisposableOnAnyPsiChange() + .also { Disposer.register(project.rootPluginDisposable, it) } val moveProjects = run { val allProjects = project.moveProjectsService.allProjects if (allProjects.size == 1) { @@ -84,14 +84,14 @@ class MvExternalLinterInspection: GlobalSimpleInspectionTool() { } val futures = moveProjects.map { ApplicationManager.getApplication().executeOnPooledThread { - checkProjectLazily(it, disposable)?.value + checkProjectLazily(it, anyPsiChangeDisposable)?.value } } val annotationResults = futures.mapNotNull { it.get() } val exit = runReadAction { ProgressManager.checkCanceled() - if (Disposer.isDisposed(disposable)) return@runReadAction false + if (Disposer.isDisposed(anyPsiChangeDisposable)) return@runReadAction false if (annotationResults.size < moveProjects.size) return@runReadAction true for (annotationResult in annotationResults) { val problemDescriptors = getProblemDescriptors(analyzedFiles, annotationResult) @@ -140,7 +140,7 @@ class MvExternalLinterInspection: GlobalSimpleInspectionTool() { } } - private fun InspectionToolPresentation.addProblemDescriptors( + private fun InspectionToolResultExporter.addProblemDescriptors( descriptors: List, context: GlobalInspectionContext ) { diff --git a/src/main/kotlin/org/move/lang/core/types/infer/TypeInferenceWalker.kt b/src/main/kotlin/org/move/lang/core/types/infer/TypeInferenceWalker.kt index 9bf25489c..3d6c10038 100644 --- a/src/main/kotlin/org/move/lang/core/types/infer/TypeInferenceWalker.kt +++ b/src/main/kotlin/org/move/lang/core/types/infer/TypeInferenceWalker.kt @@ -392,7 +392,7 @@ class TypeInferenceWalker( } } - fun inferDotFieldTy(receiverTy: Ty, dotField: MvStructDotField, expected: Expectation): Ty { + fun inferDotFieldTy(receiverTy: Ty, dotField: MvStructDotField): Ty { val structTy = receiverTy.derefIfNeeded() as? TyStruct ?: return TyUnknown @@ -563,7 +563,7 @@ class TypeInferenceWalker( val field = dotExpr.structDotField return when { methodCall != null -> inferMethodCallTy(receiverTy, methodCall, expected) - field != null -> inferDotFieldTy(receiverTy, field, expected) + field != null -> inferDotFieldTy(receiverTy, field) // incomplete else -> TyUnknown } diff --git a/src/main/kotlin/org/move/openapiext/utils.kt b/src/main/kotlin/org/move/openapiext/utils.kt index 1f61cbeb6..b82cb90e4 100644 --- a/src/main/kotlin/org/move/openapiext/utils.kt +++ b/src/main/kotlin/org/move/openapiext/utils.kt @@ -90,7 +90,7 @@ fun saveAllDocuments() = FileDocumentManager.getInstance().saveAllDocuments() * This function saves all documents "as they are" (see [FileDocumentManager.saveDocumentAsIs]), but also fires that * these documents should be stripped later (when [saveAllDocuments] is called). */ -fun saveAllDocumentsAsTheyAre(reformatLater: Boolean = true) { +fun saveAllDocumentsAsTheyAre() { val documentManager = FileDocumentManager.getInstance() // val rustfmtWatcher = RustfmtWatcher.getInstance() // rustfmtWatcher.withoutReformatting { @@ -207,7 +207,7 @@ inline fun Project.nonBlocking(crossinline block: () -> R, crossinline uiCon block() }) .inSmartMode(this) - .expireWith(this.rootDisposable) + .expireWith(this.rootPluginDisposable) .finishOnUiThread(ModalityState.current()) { result -> uiContinuation(result) }.submit(AppExecutorUtil.getAppExecutorService()) @@ -219,7 +219,7 @@ class RootPluginDisposable: Disposable { override fun dispose() {} } -val Project.rootDisposable get() = this.service() +val Project.rootPluginDisposable get() = this.service() fun checkCommitIsNotInProgress(project: Project) { val app = ApplicationManager.getApplication()