Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
IceMimosa committed Jul 10, 2021
1 parent 08904eb commit 0e205a1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package io.github.dreamylost.plugin

import com.intellij.openapi.Disposable
import io.github.dreamylost.plugin.processor.Processor
import io.github.dreamylost.plugin.processor.clazz.{ApplyProcessor, BuilderProcessor, ConstructorProcessor, JsonProcessor, LogProcessor}
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.{ScClass, ScObject, ScTypeDefinition}
import io.github.dreamylost.plugin.processor.clazz.{ ApplyProcessor, BuilderProcessor, ConstructorProcessor, JsonProcessor, LogProcessor }
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.{ ScClass, ScObject, ScTypeDefinition }

import scala.collection.mutable

Expand Down Expand Up @@ -33,9 +33,9 @@ class ScalaMacroProcessorProvider extends Disposable {
def findProcessors(source: ScTypeDefinition): Seq[Processor] = {
processors.filter { p =>
source match {
case obj: ScObject => obj.hasAnnotation(p._1) || obj.fakeCompanionClassOrCompanionClass.hasAnnotation(p._1)
case obj: ScObject => obj.hasAnnotation(p._1) || obj.fakeCompanionClassOrCompanionClass.hasAnnotation(p._1)
case clazz: ScClass => clazz.hasAnnotation(p._1)
case _ => source.hasAnnotation(p._1)
case _ => source.hasAnnotation(p._1)
}
}.values.toSeq
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.github.dreamylost.plugin.processor.clazz

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 io.github.dreamylost.plugin.processor.{ AbsProcessor, ProcessType }
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.{ ScClass, ScObject, ScTypeDefinition }

/**
* Desc: Processor for annotation apply
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package io.github.dreamylost.plugin.processor.clazz

import io.github.dreamylost.plugin.ScalaMacroNames
import io.github.dreamylost.plugin.processor.ProcessType.ProcessType
import io.github.dreamylost.plugin.processor.{AbsProcessor, ProcessType}
import io.github.dreamylost.plugin.processor.{ AbsProcessor, ProcessType }
import org.jetbrains.plugins.scala.lang.psi.api.expr.ScMethodCall
import org.jetbrains.plugins.scala.lang.psi.api.statements.ScVariableDefinition
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.{ScClass, ScTypeDefinition}
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.{ ScClass, ScTypeDefinition }
import org.jetbrains.plugins.scala.lang.psi.types.ScLiteralType

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ class LogProcessor extends AbsProcessor {
typ match {
case ProcessType.Field =>
source match {
case clazz@(_: ScClass | _: ScObject) =>
clazz.annotations(ScalaMacroNames.LOG).lastOption.fold[Seq[String]](Nil) { an => {
an.annotationExpr.getText match {
case expr if expr.contains("Slf4j") => Seq(logExpr("org.slf4j.Logger"))
case expr if expr.contains("Log4j2") => Seq(logExpr("org.apache.logging.log4j.Logger"))
case _ => Seq(logExpr())
case clazz @ (_: ScClass | _: ScObject) =>
clazz.annotations(ScalaMacroNames.LOG).lastOption.fold[Seq[String]](Nil) { an =>
{
an.annotationExpr.getText match {
case expr if expr.contains("Slf4j") => Seq(logExpr("org.slf4j.Logger"))
case expr if expr.contains("Log4j2") => Seq(logExpr("org.apache.logging.log4j.Logger"))
case _ => Seq(logExpr())
}
}
}
}
case _ => Nil
}
case _ => Nil
Expand Down

0 comments on commit 0e205a1

Please sign in to comment.