From b58c1cc8a1b68dc0836425f503ab23e7134d1144 Mon Sep 17 00:00:00 2001 From: ghik Date: Wed, 26 Feb 2020 11:57:45 +0100 Subject: [PATCH] updated to idea 2020.1 --- build.sbt | 6 ++--- project/plugins.sbt | 4 ++-- resources/META-INF/plugin.xml | 4 ++-- .../HoconSyntaxHighlightingAnnotator.scala | 23 +++++++++++-------- .../plugins/hocon/lang/HoconFileType.scala | 2 +- .../navigation/HoconFindUsagesHandler.scala | 2 +- .../HoconGotoSymbolContributor.scala | 6 ++--- .../HoconErrorHighlightingAnnotator.scala | 9 ++++---- 8 files changed, 31 insertions(+), 25 deletions(-) diff --git a/build.sbt b/build.sbt index d912494..c997b11 100644 --- a/build.sbt +++ b/build.sbt @@ -1,14 +1,14 @@ import org.jetbrains.sbtidea.Keys._ intellijPluginName in ThisBuild := "intellij-hocon" -intellijBuild in ThisBuild := "193.4778.7" +intellijBuild in ThisBuild := "201.5616.10" val junitInterfaceVersion = "0.11" -val silencerVersion = "1.4.4" +val silencerVersion = "1.6.0" lazy val hocon = project.in(file(".")).enablePlugins(SbtIdeaPlugin).settings( scalaVersion := "2.12.10", - version := "2019.3.99-SNAPSHOT", + version := "2020.1.99-SNAPSHOT", scalaSource in Compile := baseDirectory.value / "src", scalaSource in Test := baseDirectory.value / "test", resourceDirectory in Compile := baseDirectory.value / "resources", diff --git a/project/plugins.sbt b/project/plugins.sbt index f6d0207..94d2a8c 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ resolvers += Resolver.url("jetbrains-sbt", url(s"https://dl.bintray.com/jetbrains/sbt-plugins"))(Resolver.ivyStylePatterns) -addSbtPlugin("org.jetbrains" % "sbt-idea-plugin" % "3.3.0") -addSbtPlugin("org.jetbrains" % "sbt-ide-settings" % "1.0.0") \ No newline at end of file +addSbtPlugin("org.jetbrains" % "sbt-idea-plugin" % "3.5.0") +addSbtPlugin("org.jetbrains" % "sbt-ide-settings" % "1.0.0") diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index f3ff0bd..1237c97 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -3,9 +3,9 @@ org.jetbrains.plugins.hocon HOCON Standalone HOCON plugin for IntelliJ IDEA - 2019.3.99-SNAPSHOT + 2020.1.99-SNAPSHOT Roman Janusz, AVSystem, JetBrains - + com.intellij.modules.platform com.intellij.modules.lang com.intellij.modules.java diff --git a/src/org/jetbrains/plugins/hocon/highlight/HoconSyntaxHighlightingAnnotator.scala b/src/org/jetbrains/plugins/hocon/highlight/HoconSyntaxHighlightingAnnotator.scala index 957f6c6..dc9b5f7 100644 --- a/src/org/jetbrains/plugins/hocon/highlight/HoconSyntaxHighlightingAnnotator.scala +++ b/src/org/jetbrains/plugins/hocon/highlight/HoconSyntaxHighlightingAnnotator.scala @@ -1,7 +1,8 @@ package org.jetbrains.plugins.hocon package highlight -import com.intellij.lang.annotation.{AnnotationHolder, Annotator} +import com.intellij.lang.annotation.{AnnotationHolder, Annotator, HighlightSeverity} +import com.intellij.openapi.editor.colors.TextAttributesKey import com.intellij.psi.PsiElement class HoconSyntaxHighlightingAnnotator extends Annotator { @@ -13,34 +14,38 @@ class HoconSyntaxHighlightingAnnotator extends Annotator { def annotate(element: PsiElement, holder: AnnotationHolder): Unit = { lazy val parentType = element.getParent.getNode.getElementType lazy val firstChildType = element.getFirstChild.getNode.getElementType + + def annot(attrs: TextAttributesKey): Unit = + holder.newSilentAnnotation(HighlightSeverity.INFORMATION).range(element).textAttributes(attrs).create() + element.getNode.getElementType match { case Null => - holder.createInfoAnnotation(element, null).setTextAttributes(HoconHighlighterColors.Null) + annot(HoconHighlighterColors.Null) case Boolean => - holder.createInfoAnnotation(element, null).setTextAttributes(HoconHighlighterColors.Boolean) + annot(HoconHighlighterColors.Boolean) case Number => - holder.createInfoAnnotation(element, null).setTextAttributes(HoconHighlighterColors.Number) + annot(HoconHighlighterColors.Number) case UnquotedChars if parentType == Include => - holder.createInfoAnnotation(element, null).setTextAttributes(HoconHighlighterColors.Include) + annot(HoconHighlighterColors.Include) case UnquotedChars if parentType == Included || parentType == QualifiedIncluded => - holder.createInfoAnnotation(element, null).setTextAttributes(HoconHighlighterColors.IncludeModifier) + annot(HoconHighlighterColors.IncludeModifier) case LParen | RParen if parentType == Included || parentType == QualifiedIncluded => - holder.createInfoAnnotation(element, null).setTextAttributes(HoconHighlighterColors.IncludeModifierParens) + annot(HoconHighlighterColors.IncludeModifierParens) case KeyPart if firstChildType == UnquotedString => val textAttributesKey = element.getParent.getParent.getNode.getElementType match { case Path => HoconHighlighterColors.SubstitutionKey case KeyedField.extractor() => HoconHighlighterColors.EntryKey } - holder.createInfoAnnotation(element, null).setTextAttributes(textAttributesKey) + annot(textAttributesKey) case Period if parentType == Path || parentType == PrefixedField => - holder.createInfoAnnotation(element, null).setTextAttributes(HoconHighlighterColors.PathSeparator) + annot(HoconHighlighterColors.PathSeparator) case _ => } diff --git a/src/org/jetbrains/plugins/hocon/lang/HoconFileType.scala b/src/org/jetbrains/plugins/hocon/lang/HoconFileType.scala index 0f3fe62..db59d64 100644 --- a/src/org/jetbrains/plugins/hocon/lang/HoconFileType.scala +++ b/src/org/jetbrains/plugins/hocon/lang/HoconFileType.scala @@ -11,7 +11,7 @@ final class HoconFileType extends LanguageFileType(HoconLanguage) { def getName = "HOCON" } object HoconFileType { - val DefaultExtension = "conf" + final val DefaultExtension = "conf" def isHocon(fileType: FileType): Boolean = fileType match { case _: HoconFileType => true diff --git a/src/org/jetbrains/plugins/hocon/navigation/HoconFindUsagesHandler.scala b/src/org/jetbrains/plugins/hocon/navigation/HoconFindUsagesHandler.scala index 719c419..478e4c1 100644 --- a/src/org/jetbrains/plugins/hocon/navigation/HoconFindUsagesHandler.scala +++ b/src/org/jetbrains/plugins/hocon/navigation/HoconFindUsagesHandler.scala @@ -60,7 +60,7 @@ class HoconFindUsagesHandlerFactory extends FindUsagesHandlerFactory { class HoconFindUsagesHandler(element: PsiElement) extends FindUsagesHandler(element) { override def processElementUsages( - element: PsiElement, processor: Processor[UsageInfo], options: FindUsagesOptions + element: PsiElement, processor: Processor[_ >: UsageInfo], options: FindUsagesOptions ): Boolean = { val res = element match { case hkey: HKey if options.isUsages => ReadAction.compute { () => diff --git a/src/org/jetbrains/plugins/hocon/navigation/HoconGotoSymbolContributor.scala b/src/org/jetbrains/plugins/hocon/navigation/HoconGotoSymbolContributor.scala index ea9edc5..4a58999 100644 --- a/src/org/jetbrains/plugins/hocon/navigation/HoconGotoSymbolContributor.scala +++ b/src/org/jetbrains/plugins/hocon/navigation/HoconGotoSymbolContributor.scala @@ -22,10 +22,10 @@ class HoconGotoSymbolContributor extends ChooseByNameContributorEx { private def enabled(project: Project): Boolean = HoconProjectSettings.getInstance(project).searchInGotoSymbol - def processNames(processor: Processor[String], scope: GlobalSearchScope, filter: IdFilter): Unit = - FileBasedIndex.getInstance.processAllKeys(HoconKeyIndex.Id, processor, scope, filter) + def processNames(processor: Processor[_ >: String], scope: GlobalSearchScope, filter: IdFilter): Unit = + FileBasedIndex.getInstance.processAllKeys[String](HoconKeyIndex.Id, processor, scope, filter) - def processElementsWithName(name: String, processor: Processor[NavigationItem], parameters: FindSymbolParameters): Unit = + def processElementsWithName(name: String, processor: Processor[_ >: NavigationItem], parameters: FindSymbolParameters): Unit = if (enabled(parameters.getProject)) ReadAction.run { () => val project = parameters.getProject val scope = parameters.getSearchScope diff --git a/src/org/jetbrains/plugins/hocon/parser/HoconErrorHighlightingAnnotator.scala b/src/org/jetbrains/plugins/hocon/parser/HoconErrorHighlightingAnnotator.scala index a214b1f..5161cc1 100644 --- a/src/org/jetbrains/plugins/hocon/parser/HoconErrorHighlightingAnnotator.scala +++ b/src/org/jetbrains/plugins/hocon/parser/HoconErrorHighlightingAnnotator.scala @@ -2,7 +2,7 @@ package org.jetbrains.plugins.hocon package parser import com.intellij.lang.ASTNode -import com.intellij.lang.annotation.{AnnotationHolder, Annotator} +import com.intellij.lang.annotation.{AnnotationHolder, Annotator, HighlightSeverity} import com.intellij.lexer.StringLiteralLexer import com.intellij.psi.tree.IElementType import com.intellij.psi.{PsiElement, StringEscapesTokenTypes, TokenType} @@ -30,9 +30,9 @@ class HoconErrorHighlightingAnnotator extends Annotator { case (tokenType, _) => tokenType != null } foreach { case (StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN, range) => - holder.createErrorAnnotation(range, "invalid escape character") + holder.newAnnotation(HighlightSeverity.ERROR, "invalid escape character").range(range).create() case (StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN, range) => - holder.createErrorAnnotation(range, "invalid unicode escape") + holder.newAnnotation(HighlightSeverity.ERROR, "invalid unicode escape").range(range).create() case _ => } @@ -53,7 +53,8 @@ class HoconErrorHighlightingAnnotator extends Annotator { case (required, actual) => - holder.createErrorAnnotation(child, s"cannot concatenate ${uncaps(required.toString)} with ${uncaps(actual.toString)}") + val msg = s"cannot concatenate ${uncaps(required.toString)} with ${uncaps(actual.toString)}" + holder.newAnnotation(HighlightSeverity.ERROR, msg).range(child).create() validateConcatenation(actual, child.getTreeNext) }