Skip to content

Commit

Permalink
updated to idea 2020.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ghik committed Feb 26, 2020
1 parent b8b8d25 commit b58c1cc
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 25 deletions.
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -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")
addSbtPlugin("org.jetbrains" % "sbt-idea-plugin" % "3.5.0")
addSbtPlugin("org.jetbrains" % "sbt-ide-settings" % "1.0.0")
4 changes: 2 additions & 2 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<id>org.jetbrains.plugins.hocon</id>
<name>HOCON</name>
<description>Standalone HOCON plugin for IntelliJ IDEA</description>
<version>2019.3.99-SNAPSHOT</version>
<version>2020.1.99-SNAPSHOT</version>
<vendor>Roman Janusz, AVSystem, JetBrains</vendor>
<idea-version since-build="193.0" until-build="220.0"/>
<idea-version since-build="201.0" until-build="220.0"/>
<depends>com.intellij.modules.platform</depends>
<depends>com.intellij.modules.lang</depends>
<depends optional="true" config-file="hocon-java.xml">com.intellij.modules.java</depends>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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 _ =>
}
Expand Down
2 changes: 1 addition & 1 deletion src/org/jetbrains/plugins/hocon/lang/HoconFileType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 { () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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 _ =>
}

Expand All @@ -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)

}
Expand Down

0 comments on commit b58c1cc

Please sign in to comment.