diff --git a/src/clojure-constants.kt b/src/clojure-constants.kt index 36a496a..610ca8a 100644 --- a/src/clojure-constants.kt +++ b/src/clojure-constants.kt @@ -140,10 +140,10 @@ object ClojureConstants { } object ClojureIcons { - @JvmStatic val CLOJURE_ICON = IconLoader.getIcon("/icons/clojure.svg") - @JvmStatic val FILE = IconLoader.getIcon("/icons/clojureFile.svg") - @JvmStatic val NAMESPACE = IconLoader.getIcon("/icons/namespace.svg") - @JvmStatic val SYMBOL = IconLoader.getIcon("/icons/symbol.svg") + @JvmStatic val CLOJURE_ICON = IconLoader.getIcon("/icons/clojure.svg", ClojureIcons::class.java) + @JvmStatic val FILE = IconLoader.getIcon("/icons/clojureFile.svg", ClojureIcons::class.java) + @JvmStatic val NAMESPACE = IconLoader.getIcon("/icons/namespace.svg", ClojureIcons::class.java) + @JvmStatic val SYMBOL = IconLoader.getIcon("/icons/symbol.svg", ClojureIcons::class.java) @JvmStatic val DEFN = AllIcons.Nodes.Function @JvmStatic val MACRO = AllIcons.Nodes.AbstractMethod @JvmStatic val FIELD = AllIcons.Nodes.Field diff --git a/src/lang/clojure-editor-psi.kt b/src/lang/clojure-editor-psi.kt index 32e73d8..b306c6f 100644 --- a/src/lang/clojure-editor-psi.kt +++ b/src/lang/clojure-editor-psi.kt @@ -35,13 +35,13 @@ import com.intellij.codeInsight.hints.HintInfo import com.intellij.codeInsight.hints.InlayInfo import com.intellij.codeInsight.hints.InlayParameterHintsProvider import com.intellij.codeInsight.hints.Option -import com.intellij.codeInsight.lookup.LookupElement import com.intellij.codeInsight.lookup.LookupElementBuilder import com.intellij.codeInsight.navigation.BackgroundUpdaterTask import com.intellij.icons.AllIcons import com.intellij.lang.ExpressionTypeProvider import com.intellij.lang.annotation.AnnotationHolder import com.intellij.lang.annotation.Annotator +import com.intellij.lang.annotation.HighlightSeverity import com.intellij.lang.documentation.DocumentationProviderEx import com.intellij.lang.parameterInfo.* import com.intellij.navigation.NavigationItem @@ -99,6 +99,7 @@ import org.intellij.clojure.psi.stubs.CPrototypeStub import org.intellij.clojure.tools.findReplForFile import org.intellij.clojure.util.* import java.awt.event.MouseEvent +import java.util.* import java.util.concurrent.ConcurrentLinkedQueue /** @@ -110,15 +111,24 @@ class ClojureAnnotator : Annotator { if (element is CSForm && (element.parentForm as? CList).firstForm == element && element.firstChild.elementType != C_SYM && element.parentForm.iterate(CReaderMacro::class).isEmpty) { - holder.createInfoAnnotation(element.valueRange, null).textAttributes = ClojureColors.CALLABLE + holder.newSilentAnnotation(HighlightSeverity.INFORMATION) + .range(element.valueRange) + .textAttributes(ClojureColors.CALLABLE) + .create() } if (element is CCommented || element.flags and FLAG_COMMENTED != 0) { - holder.createInfoAnnotation(element, null).textAttributes = ClojureColors.FORM_COMMENT + holder.newSilentAnnotation(HighlightSeverity.INFORMATION) + .range(element) + .textAttributes(ClojureColors.FORM_COMMENT) + .create() } if (element is CSymbol && element.flags and FLAG_QUOTED != 0 && !element.parentForm.iterate().find { it is CSymbol || it.elementType == C_SYM } ?.prevSibling.let { it is CReaderMacro && it.firstChild.elementType.let { it == C_QUOTE || it == C_SYNTAX_QUOTE } }) { - holder.createInfoAnnotation(element.valueRange, null).textAttributes = ClojureColors.QUOTED_SYM + holder.newSilentAnnotation(HighlightSeverity.INFORMATION) + .range(element.valueRange) + .textAttributes(ClojureColors.QUOTED_SYM) + .create() } if (element is CSymbol && element.flags and FLAG_QUOTED == 0) { var enforced: TextAttributes? = null @@ -154,10 +164,13 @@ class ClojureAnnotator : Annotator { } } if (attrs != null) { - holder.createInfoAnnotation(element.valueRange, null).run { - textAttributes = attrs - enforcedTextAttributes = enforced - } + holder.newSilentAnnotation(HighlightSeverity.INFORMATION) + .range(element.valueRange) + .textAttributes(attrs) + .apply { + enforced?.let { enforcedTextAttributes(it) } + } + .create() } } } @@ -493,7 +506,7 @@ class ClojureDocumentationProvider : DocumentationProviderEx() { } val newText = sb.toString() val prevText = component.text - if (!Comparing.equal(newText, prevText)) { + if (!Objects.equals(newText, prevText)) { component.replaceText(newText, element) } }, 100, alarmDisposable) @@ -543,20 +556,20 @@ class ClojureLineMarkerProvider : LineMarkerProviderDescriptor() { def?.type == "defmulti" -> if (!MM1.isEnabled) null else LineMarkerInfo(leaf, leaf.textRange, MM1.icon!!, { "Show implementations" }, - { event, o -> showNavPopup(o, event) }, GutterIconRenderer.Alignment.RIGHT) + { event, o -> showNavPopup(o, event) }, GutterIconRenderer.Alignment.RIGHT, { "Show implementations" }) def == null && parentName == "defmethod" -> if (!MM2.isEnabled) null else LineMarkerInfo(leaf, leaf.textRange, MM2.icon!!, { "Show declaration" }, - { _, o -> navigate(o) }, GutterIconRenderer.Alignment.LEFT) + { _, o -> navigate(o) }, GutterIconRenderer.Alignment.LEFT, { "Show declaration" }) def?.type == "method" && (grandName == "defprotocol" || grandName == "definterface") -> { if (!P1.isEnabled) null else LineMarkerInfo(leaf, leaf.textRange, P1.icon!!, { "Show implementations" }, - { event, o -> showNavPopup(o, event) }, GutterIconRenderer.Alignment.LEFT) + { event, o -> showNavPopup(o, event) }, GutterIconRenderer.Alignment.LEFT, { "Show implementations" }) } ClojureConstants.OO_ALIKE_SYMBOLS.contains(grandName) -> if (!P1.isEnabled) null else LineMarkerInfo(leaf, leaf.textRange, P2.icon!!, { "Show declaration" }, - { _, o -> navigate(o) }, GutterIconRenderer.Alignment.LEFT) + { _, o -> navigate(o) }, GutterIconRenderer.Alignment.LEFT, { "Show declaration" }) else -> null } } @@ -765,9 +778,6 @@ class ClojureParamInfoProvider : ParameterInfoHandlerWithTabActionSupport = CList::class.java override fun getActualParameters(o: CList) = o.childForms.skip(1).toList().toTypedArray() - override fun couldShowInLookup() = true - override fun getParametersForLookup(item: LookupElement?, context: ParameterInfoContext?) = emptyArray() - override fun getParameterCloseChars(): String = ")" override fun showParameterInfo(element: CList, context: CreateParameterInfoContext) = context.showHint(element, element.textRange.startOffset, this) @@ -776,7 +786,7 @@ class ClojureParamInfoProvider : ParameterInfoHandlerWithTabActionSupport { diff --git a/src/lang/clojure-psi-java.kt b/src/lang/clojure-psi-java.kt index 5dbd6ba..7467e90 100644 --- a/src/lang/clojure-psi-java.kt +++ b/src/lang/clojure-psi-java.kt @@ -24,7 +24,6 @@ import com.intellij.lang.documentation.DocumentationProviderEx import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.progress.ProcessCanceledException import com.intellij.openapi.project.Project -import com.intellij.openapi.util.Comparing import com.intellij.openapi.util.NotNullLazyKey import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.text.StringUtil @@ -621,7 +620,7 @@ abstract class JavaHelper { if (acceptsName(paramType, parameter)) continue val info = (findClass(paramType) as? MyElement)?.delegate as? ClassInfo if (info != null) { - if (Comparing.equal(info.superClass, parameter)) continue + if (Objects.equals(info.superClass, parameter)) continue if (info.interfaces.contains(parameter)) continue } return false diff --git a/src/lang/clojure-psi-symbols.kt b/src/lang/clojure-psi-symbols.kt index e9adb98..f0e7ae3 100644 --- a/src/lang/clojure-psi-symbols.kt +++ b/src/lang/clojure-psi-symbols.kt @@ -32,7 +32,6 @@ import com.intellij.pom.PomTargetPsiElement import com.intellij.pom.references.PomService import com.intellij.psi.* import com.intellij.psi.impl.PomTargetPsiElementImpl -import com.intellij.psi.search.EverythingGlobalScope import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.search.LocalSearchScope import com.intellij.psi.search.SearchScope @@ -76,7 +75,7 @@ class ClojureDefinitionService(val project: Project) { @JvmStatic fun getInstance(project: Project) = ServiceManager.getService(project, ClojureDefinitionService::class.java)!! @JvmStatic fun getClojureSearchScope(project: Project): GlobalSearchScope = - GlobalSearchScope.getScopeRestrictedByFileTypes(EverythingGlobalScope(project), ClojureFileType) + GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.everythingScope(project), ClojureFileType) } diff --git a/src/tools/tools-repl.kt b/src/tools/tools-repl.kt index 45de46b..df58f47 100644 --- a/src/tools/tools-repl.kt +++ b/src/tools/tools-repl.kt @@ -83,6 +83,7 @@ import java.io.File import java.io.IOException import java.io.InputStream import java.io.OutputStream +import java.util.* import java.util.concurrent.TimeUnit import javax.swing.Icon import javax.swing.JList @@ -279,7 +280,7 @@ fun ConsoleView.println(text: String = "") = print(text + "\n", ConsoleViewConte fun ConsoleView.printerr(text: String) = print(text + "\n", ConsoleViewContentType.ERROR_OUTPUT) class ReplActionPromoter : ActionPromoter { - override fun promote(actions: MutableList, context: DataContext) = + override fun promote(actions: List, context: DataContext) = actions.find { it is ReplExecuteAction }?.let { listOf(it) } } @@ -340,7 +341,7 @@ private fun findReplInner(project: Project, virtualFile: VirtualFile): Triple