Skip to content

Commit

Permalink
deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
gregsh committed Feb 18, 2021
1 parent 5ae5a5a commit 54168a5
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 28 deletions.
8 changes: 4 additions & 4 deletions src/clojure-constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 27 additions & 17 deletions src/lang/clojure-editor-psi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

/**
Expand All @@ -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
Expand Down Expand Up @@ -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()
}
}
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -765,9 +778,6 @@ class ClojureParamInfoProvider : ParameterInfoHandlerWithTabActionSupport<CList,

override fun getArgumentListClass(): Class<CList> = 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<Any>()
override fun getParameterCloseChars(): String = ")"

override fun showParameterInfo(element: CList, context: CreateParameterInfoContext) =
context.showHint(element, element.textRange.startOffset, this)
Expand All @@ -776,7 +786,7 @@ class ClojureParamInfoProvider : ParameterInfoHandlerWithTabActionSupport<CList,
class ClojureParamInlayHintsHandler : InlayParameterHintsProvider {

companion object {
private val OPTION = Option("clojure.parameter.hints", "Show parameter names", false)
private val OPTION = Option("clojure.parameter.hints", { "Show parameter names" }, false)
}

override fun getParameterHints(element: PsiElement): List<InlayInfo> {
Expand Down
3 changes: 1 addition & 2 deletions src/lang/clojure-psi-java.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/lang/clojure-psi-symbols.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

}

Expand Down
5 changes: 3 additions & 2 deletions src/tools/tools-repl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<AnAction>, context: DataContext) =
override fun promote(actions: List<AnAction>, context: DataContext) =
actions.find { it is ReplExecuteAction }?.let { listOf(it) }
}

Expand Down Expand Up @@ -340,7 +341,7 @@ private fun findReplInner(project: Project, virtualFile: VirtualFile): Triple<Ru
(it.executionConsole as ReplConsole).let { isExclusive(it) }
}
val sameTitleContent = allDescriptors.find {
Comparing.equal(title, it.displayName)
Objects.equals(title, it.displayName)
}
val contentToReuse = ownContent ?: exclusiveContent ?: sameTitleContent
return Triple(contentToReuse, title, workingDir)
Expand Down
3 changes: 2 additions & 1 deletion tests/lang/formatter-tests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class ClojureFormatterTest : BasePlatformTestCase() {

override fun setUp() {
super.setUp()
settingsManager.run { setTemporarySettings(CodeStyle.getSettings(project).clone()) }
val settings = CodeStyleSettingsManager.getInstance(project).cloneSettings(CodeStyle.getSettings(project))
settingsManager.setTemporarySettings(settings)
}

override fun tearDown() {
Expand Down

0 comments on commit 54168a5

Please sign in to comment.