未验证 提交 2326d4b8 编写于 作者: 梦境迷离's avatar 梦境迷离 提交者: GitHub

Small optimization (#58)

上级 d265f5bd
...@@ -2,13 +2,13 @@ import sbt.Def ...@@ -2,13 +2,13 @@ import sbt.Def
import sbtrelease.ReleaseStateTransformations._ import sbtrelease.ReleaseStateTransformations._
name := "scala-macro-tools" name := "scala-macro-tools"
organization := "io.github.jxnu-liguobin"
lazy val scala212 = "2.12.14" lazy val scala212 = "2.12.14"
lazy val scala211 = "2.11.12" lazy val scala211 = "2.11.12"
lazy val scala213 = "2.13.6" lazy val scala213 = "2.13.6"
scalaVersion := scala213 scalaVersion := scala213
organization := "io.github.jxnu-liguobin"
lazy val supportedScalaVersions = List(scala213, scala212, scala211) lazy val supportedScalaVersions = List(scala213, scala212, scala211)
......
import org.jetbrains.sbtidea.Keys._
name := "scala-macro-tools-intellij-plugin" name := "scala-macro-tools-intellij-plugin"
organization := "io.github.jxnu-liguobin"
lazy val scala213 = "2.13.6" lazy val scala213 = "2.13.6"
scalaVersion := scala213 scalaVersion := scala213
organization := "io.github.jxnu-liguobin"
import org.jetbrains.sbtidea.Keys._
lazy val `intellij-plugin` = (project in file(".")) lazy val `intellij-plugin` = (project in file("."))
.enablePlugins(SbtIdeaPlugin) .enablePlugins(SbtIdeaPlugin)
.settings( .settings(
version := (version in ThisBuild).value, version := (ThisBuild / version).value,
scalaVersion := scala213, scalaVersion := scala213,
ThisBuild / intellijPluginName := "Scala-Macro-Tools", ThisBuild / intellijPluginName := "Scala-Macro-Tools",
ThisBuild / intellijBuild := "211.7628.21", // @see https://confluence.jetbrains.com/display/IDEADEV/IDEA+2021.1+latest+builds ThisBuild / intellijBuild := "211.7628.21", // @see https://confluence.jetbrains.com/display/IDEADEV/IDEA+2021.1+latest+builds
ThisBuild / intellijPlatform := IntelliJPlatform.IdeaCommunity, ThisBuild / intellijPlatform := IntelliJPlatform.IdeaCommunity,
Global / intellijAttachSources := true, Global / intellijAttachSources := true,
Compile / javacOptions ++= "--release" :: "11" :: Nil, Compile / javacOptions ++= "--release" :: "11" :: Nil,
// Global / scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked", "-Xfatal-warnings"), // Global / scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked", "-Xfatal-warnings"),
intellijPlugins ++= Seq("com.intellij.java", "com.intellij.java-i18n", "org.intellij.scala").map(_.toPlugin), intellijPlugins ++= Seq("com.intellij.java", "com.intellij.java-i18n", "org.intellij.scala").map(_.toPlugin),
libraryDependencies ++= Seq.empty, libraryDependencies ++= Seq.empty,
unmanagedResourceDirectories in Compile += baseDirectory.value / "src" / "main" / "resources", Compile / unmanagedResourceDirectories += baseDirectory.value / "src" / "main" / "resources",
unmanagedResourceDirectories in Test += baseDirectory.value / "src" / "test" / "resources", Test / unmanagedResourceDirectories += baseDirectory.value / "src" / "test" / "resources",
patchPluginXml := pluginXmlOptions { xml => patchPluginXml := pluginXmlOptions { xml =>
xml.version = (version in ThisBuild).value xml.version = (ThisBuild / version).value
xml.pluginDescription = IO.read(baseDirectory.value / "src" / "main" / "resources" / "patch" / "description.html") xml.pluginDescription = IO.read(baseDirectory.value / "src" / "main" / "resources" / "patch" / "description.html")
xml.changeNotes = IO.read(baseDirectory.value / "src" / "main" / "resources" / "patch" / "change.html") xml.changeNotes = IO.read(baseDirectory.value / "src" / "main" / "resources" / "patch" / "change.html")
}, },
......
package io.github.dreamylost.plugin.processor.clazz package io.github.dreamylost.plugin.processor.clazz
import io.github.dreamylost.plugin.ScalaMacroNames import io.github.dreamylost.plugin.ScalaMacroNames
import io.github.dreamylost.plugin.processor.{ AbsProcessor, ProcessType }
import io.github.dreamylost.plugin.processor.ProcessType.ProcessType import io.github.dreamylost.plugin.processor.ProcessType.ProcessType
import io.github.dreamylost.plugin.processor.{ AbsProcessor, ProcessType }
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.{ ScClass, ScObject, ScTypeDefinition } import org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.{ ScClass, ScObject, ScTypeDefinition }
/** /**
...@@ -21,19 +21,14 @@ class LogProcessor extends AbsProcessor { ...@@ -21,19 +21,14 @@ class LogProcessor extends AbsProcessor {
typ match { typ match {
case ProcessType.Field => case ProcessType.Field =>
source match { source match {
case clazz @ (_: ScClass | _: ScObject) => case clazz@(_: ScClass | _: ScObject) =>
clazz.annotations(ScalaMacroNames.LOG).lastOption match { clazz.annotations(ScalaMacroNames.LOG).lastOption.fold[Seq[String]](Nil) { an => {
case Some(an) =>
// annotation expr string
an.annotationExpr.getText match { an.annotationExpr.getText match {
case expr if expr.contains("Slf4j") => case expr if expr.contains("Slf4j") => Seq(logExpr("org.slf4j.Logger"))
Seq(logExpr("org.slf4j.Logger")) case expr if expr.contains("Log4j2") => Seq(logExpr("org.apache.logging.log4j.Logger"))
case expr if expr.contains("Log4j2") => case _ => Seq(logExpr())
Seq(logExpr("org.apache.logging.log4j.Logger")) }
case _ =>
Seq(logExpr())
} }
case None => Nil
} }
case _ => Nil case _ => Nil
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册