Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦境迷离
Scala Macro Tools
提交
c483bf52
S
Scala Macro Tools
项目概览
梦境迷离
/
Scala Macro Tools
上一次同步 大约 1 年
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Scala Macro Tools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c483bf52
编写于
1月 02, 2022
作者:
梦境迷离
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove plugin from repository
上级
11b71226
变更
33
隐藏空白更改
内联
并排
Showing
33 changed file
with
15 addition
and
660 deletion
+15
-660
build.sbt
build.sbt
+1
-4
intellij-plugin/build.sbt
intellij-plugin/build.sbt
+0
-32
intellij-plugin/project/build.properties
intellij-plugin/project/build.properties
+0
-1
intellij-plugin/project/plugins.sbt
intellij-plugin/project/plugins.sbt
+0
-2
intellij-plugin/src/main/resources/META-INF/plugin.xml
intellij-plugin/src/main/resources/META-INF/plugin.xml
+0
-30
intellij-plugin/src/main/resources/META-INF/pluginIcon.png
intellij-plugin/src/main/resources/META-INF/pluginIcon.png
+0
-0
intellij-plugin/src/main/resources/META-INF/pluginIcon.svg
intellij-plugin/src/main/resources/META-INF/pluginIcon.svg
+0
-16
intellij-plugin/src/main/resources/messages/PluginBundle.properties
...lugin/src/main/resources/messages/PluginBundle.properties
+0
-20
intellij-plugin/src/main/resources/patch/change.html
intellij-plugin/src/main/resources/patch/change.html
+0
-23
intellij-plugin/src/main/resources/patch/description.html
intellij-plugin/src/main/resources/patch/description.html
+0
-22
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/PluginBundle.scala
...src/main/scala/org/bitlap/tools/plugin/PluginBundle.scala
+0
-19
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/ScalaMacroInjector.scala
...in/scala/org/bitlap/tools/plugin/ScalaMacroInjector.scala
+0
-36
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/ScalaMacroNames.scala
.../main/scala/org/bitlap/tools/plugin/ScalaMacroNames.scala
+0
-17
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/ScalaMacroProcessorProvider.scala
...org/bitlap/tools/plugin/ScalaMacroProcessorProvider.scala
+0
-43
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/processor/AbsProcessor.scala
...cala/org/bitlap/tools/plugin/processor/AbsProcessor.scala
+0
-71
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/processor/ProcessType.scala
...scala/org/bitlap/tools/plugin/processor/ProcessType.scala
+0
-11
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/processor/Processor.scala
...n/scala/org/bitlap/tools/plugin/processor/Processor.scala
+0
-24
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/processor/clazz/ApplyProcessor.scala
.../bitlap/tools/plugin/processor/clazz/ApplyProcessor.scala
+0
-35
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/processor/clazz/BuilderProcessor.scala
...itlap/tools/plugin/processor/clazz/BuilderProcessor.scala
+0
-76
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/processor/clazz/ConstructorProcessor.scala
...p/tools/plugin/processor/clazz/ConstructorProcessor.scala
+0
-64
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/processor/clazz/EqualsAndHashCodeProcessor.scala
...s/plugin/processor/clazz/EqualsAndHashCodeProcessor.scala
+0
-29
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/processor/clazz/JsonProcessor.scala
...g/bitlap/tools/plugin/processor/clazz/JsonProcessor.scala
+0
-30
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/processor/clazz/LogProcessor.scala
...rg/bitlap/tools/plugin/processor/clazz/LogProcessor.scala
+0
-39
project/build.properties
project/build.properties
+1
-1
project/plugins.sbt
project/plugins.sbt
+0
-2
src/main/scala/org/bitlap/tools/logs/BaseLog.scala
src/main/scala/org/bitlap/tools/logs/BaseLog.scala
+1
-1
src/main/scala/org/bitlap/tools/logs/JLogImpl.scala
src/main/scala/org/bitlap/tools/logs/JLogImpl.scala
+1
-1
src/main/scala/org/bitlap/tools/logs/Log4J2Impl.scala
src/main/scala/org/bitlap/tools/logs/Log4J2Impl.scala
+1
-1
src/main/scala/org/bitlap/tools/logs/LogType.scala
src/main/scala/org/bitlap/tools/logs/LogType.scala
+6
-6
src/main/scala/org/bitlap/tools/logs/Slf4jImpl.scala
src/main/scala/org/bitlap/tools/logs/Slf4jImpl.scala
+1
-1
src/main/scala/org/bitlap/tools/logs/extension/ScalaLoggingLazyImpl.scala
...rg/bitlap/tools/logs/extension/ScalaLoggingLazyImpl.scala
+1
-1
src/main/scala/org/bitlap/tools/logs/extension/ScalaLoggingStrictImpl.scala
.../bitlap/tools/logs/extension/ScalaLoggingStrictImpl.scala
+1
-1
src/main/scala/org/bitlap/tools/package.scala
src/main/scala/org/bitlap/tools/package.scala
+1
-1
未找到文件。
build.sbt
浏览文件 @
c483bf52
...
...
@@ -95,7 +95,4 @@ def paradise(): Def.Setting[Seq[ModuleID]] = {
case
Some
((
2
,
n
))
if
n
<
13
=>
Some
(
"org.scalamacros"
%
"paradise"
%
"2.1.1"
cross
CrossVersion
.
full
)
case
_
=>
None
}).
fold
(
Seq
.
empty
[
ModuleID
])(
f
=>
Seq
(
compilerPlugin
(
f
)))
}
// Only to import, and every thing in /intellij-plugin.
lazy val `intellij
-
plugin
`
=
(
project
in
file
(
"intellij-plugin"
)).
settings
(
publish
/
skip
:=
true
)
}
\ No newline at end of file
intellij-plugin/build.sbt
已删除
100644 → 0
浏览文件 @
11b71226
import
org.jetbrains.sbtidea.Keys._
name
:=
"scala-macro-tools-intellij-plugin"
organization
:=
"org.bitlap.tools"
lazy
val
scala213
=
"2.13.6"
scalaVersion
:=
scala213
lazy
val
`
intellij
-
plugin
`
=
(
project
in
file
(
"."
))
.
enablePlugins
(
SbtIdeaPlugin
)
.
settings
(
version
:=
(
ThisBuild
/
version
).
value
,
scalaVersion
:=
scala213
,
ThisBuild
/
intellijPluginName
:=
"Scala-Macro-Tools"
,
ThisBuild
/
intellijBuild
:=
"213.5744.223"
,
// https://confluence.jetbrains.com/display/IDEADEV/IDEA+2021.3+latest+builds
ThisBuild
/
intellijPlatform
:=
IntelliJPlatform
.
IdeaCommunity
,
Global
/
intellijAttachSources
:=
true
,
Compile
/
javacOptions
++=
"--release"
::
"11"
::
Nil
,
// Global / scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked", "-Xfatal-warnings"),
intellijPlugins
++=
Seq
(
"com.intellij.java"
,
"com.intellij.java-i18n"
,
"org.intellij.scala"
).
map
(
_
.
toPlugin
),
libraryDependencies
++=
Seq
.
empty
,
Compile
/
unmanagedResourceDirectories
+=
baseDirectory
.
value
/
"src"
/
"main"
/
"resources"
,
Test
/
unmanagedResourceDirectories
+=
baseDirectory
.
value
/
"src"
/
"test"
/
"resources"
,
patchPluginXml
:=
pluginXmlOptions
{
xml
=>
// xml.version = (ThisBuild / version).value
xml
.
version
=
"0.3.4"
xml
.
pluginDescription
=
IO
.
read
(
baseDirectory
.
value
/
"src"
/
"main"
/
"resources"
/
"patch"
/
"description.html"
)
xml
.
changeNotes
=
IO
.
read
(
baseDirectory
.
value
/
"src"
/
"main"
/
"resources"
/
"patch"
/
"change.html"
)
},
publish
/
skip
:=
true
,
)
intellij-plugin/project/build.properties
已删除
100644 → 0
浏览文件 @
11b71226
sbt.version
=
1.6.1
\ No newline at end of file
intellij-plugin/project/plugins.sbt
已删除
100644 → 0
浏览文件 @
11b71226
addSbtPlugin
(
"org.jetbrains"
%
"sbt-ide-settings"
%
"1.1.0"
)
addSbtPlugin
(
"org.jetbrains"
%
"sbt-idea-plugin"
%
"3.13.5"
)
\ No newline at end of file
intellij-plugin/src/main/resources/META-INF/plugin.xml
已删除
100644 → 0
浏览文件 @
11b71226
<?xml version="1.0" encoding="UTF-8"?>
<idea-plugin>
<id>
Scala-Macro-Tools Plugin
</id>
<name>
Scala-Macro-Tools
</name>
<version>
XXX
</version>
<vendor>
Scala Macro Tools
</vendor>
<idea-version
since-build=
"213.0"
/>
<depends>
com.intellij.modules.platform
</depends>
<depends>
com.intellij.modules.lang
</depends>
<depends>
com.intellij.modules.java
</depends>
<depends>
org.intellij.scala
</depends>
<depends>
com.intellij.properties
</depends>
<description>
<![CDATA[ Description will be added by sbt plugin build ]]>
</description>
<change-notes>
<![CDATA[ Change notes will be filled by sbt plugin build ]]>
</change-notes>
<resource-bundle>
messages.PluginBundle
</resource-bundle>
<extensions
defaultExtensionNs=
"com.intellij"
>
<applicationService
serviceImplementation=
"org.bitlap.tools.plugin.ScalaMacroProcessorProvider"
/>
<!-- <lang.psiAugmentProvider implementation="org.bitlap.tools.plugin.ScalaMacroAugmentProvider"/> -->
<notificationGroup
displayType=
"BALLOON"
id=
"Scala-Macro-Tools Plugin"
/>
</extensions>
<extensions
defaultExtensionNs=
"org.intellij.scala"
>
<syntheticMemberInjector
implementation=
"org.bitlap.tools.plugin.ScalaMacroInjector"
/>
</extensions>
</idea-plugin>
intellij-plugin/src/main/resources/META-INF/pluginIcon.png
已删除
100644 → 0
浏览文件 @
11b71226
53.9 KB
intellij-plugin/src/main/resources/META-INF/pluginIcon.svg
已删除
100644 → 0
浏览文件 @
11b71226
<svg
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 404.1418472882417 454"
width=
"808.2836945764834"
height=
"908"
>
<!-- svg-source:excalidraw -->
<defs>
<style>
@font-face {
font-family: "Virgil";
src: url("https://excalidraw.com/Virgil.woff2");
}
@font-face {
font-family: "Cascadia";
src: url("https://excalidraw.com/Cascadia.woff2");
}
</style>
</defs>
<g
transform=
"translate(10 10) rotate(0 191 217)"
><text
x=
"0"
y=
"347"
font-family=
"Helvetica, Segoe UI Emoji"
font-size=
"376.6131465517241px"
fill=
"#000000"
text-anchor=
"start"
style=
"white-space: pre;"
direction=
"ltr"
>
@
</text></g><g
stroke-linecap=
"round"
transform=
"translate(277.4356704536201 239.36519249966955) rotate(0.22204287082016708 57.405888228265724 14.792098641394688)"
><path
d=
"M-0.7 3.08 L112.84 -1.96 L114.46 25.88 L1.17 25.91"
stroke=
"none"
stroke-width=
"0"
fill=
"#ec0009"
></path><path
d=
"M2.08 -2.22 C42.79 -1.5, 91.84 -0.12, 117.52 2.7 M1.29 -0.16 C45.06 1.32, 88.17 2.55, 113.41 1.41 M112.36 1.64 C111.52 12.24, 113.95 14.65, 117.26 30.06 M113.19 -1.49 C114.91 12.05, 115.29 21.36, 115.01 30.93 M116.34 29.32 C77.04 28.67, 42.05 29.17, 1.76 29.13 M114.03 28.2 C80.96 32.9, 49.57 31.18, -1.91 27.73 M-1.41 32.12 C-0.91 15.49, -0.14 10.75, 3.83 -2.81 M1.61 28.82 C0.11 18.86, 1.15 11.04, -1.85 -1.43"
stroke=
"#ec0009"
stroke-width=
"1"
fill=
"none"
></path></g><g
stroke-linecap=
"round"
transform=
"translate(278.2913553485272 281.24147943475646) rotate(0.22204287082016708 57.405888228265724 14.792098641394688)"
><path
d=
"M-1.52 3.42 L113.54 3.68 L117.35 29.9 L-1.08 25.93"
stroke=
"none"
stroke-width=
"0"
fill=
"#ec0009"
></path><path
d=
"M2.82 0.18 C29.17 5.58, 55.15 3.26, 111.46 3.24 M0.24 0.84 C32.29 -0.3, 62 -2.89, 114.77 1.93 M117.51 0.42 C115 12.28, 116.67 18.49, 112.7 27.01 M114.59 -0.28 C115.43 8.98, 113.72 14.24, 113.78 31.56 M111.11 32.46 C75.3 29.51, 40.02 29.92, -1.32 26.49 M113.41 30.03 C82.84 33.24, 50.76 31.02, 0.37 28.4 M-2.85 28.89 C2.92 16.67, -2.12 7.33, -3.71 1.17 M-0.77 29.33 C0.35 22.81, -0.21 16.47, -0.76 -0.59"
stroke=
"#ec0009"
stroke-width=
"1"
fill=
"none"
></path></g><g
stroke-linecap=
"round"
transform=
"translate(279.2731770606068 324.99163674394447) rotate(0.22204287082016708 57.405888228265724 14.792098641394716)"
><path
d=
"M-2.65 -1.82 L112.54 3.17 L115.02 31.42 L0.66 28.27"
stroke=
"none"
stroke-width=
"0"
fill=
"#ec0009"
></path><path
d=
"M-3.67 2.33 C31.39 -2.2, 66.34 0.73, 113.58 0.27 M-0.76 1.71 C29.22 2.52, 60.98 0.83, 114.27 -1.83 M112.05 1.9 C113.16 11.31, 111.39 26.85, 118.36 33.47 M114.03 1.59 C114.62 5.2, 114.04 13.8, 113.13 29.35 M112.78 30.13 C74.57 29.2, 39.14 26.68, -3.97 30.75 M116.75 28.84 C76.89 32.34, 41.81 32.31, -0.92 30.32 M0.46 30.28 C-3.8 26.82, -2.93 19.88, -1.46 -0.39 M-0.93 29.82 C0.55 22.69, -1.05 15.62, -1.36 -0.82"
stroke=
"#ec0009"
stroke-width=
"1"
fill=
"none"
></path></g></svg>
\ No newline at end of file
intellij-plugin/src/main/resources/messages/PluginBundle.properties
已删除
100644 → 0
浏览文件 @
11b71226
### main/scala/org/jetbrains/scala/samples/actions/PopupDialogAction.scala
gettext.selected
=
{0} selected!
selected.element.tostring
=
\n
Selected Element: {0}
### main/scala/org/jetbrains/scala/samples/listeners/FileOpenedListener.scala
file.opened
=
File opened
name.getname
=
Name: {0}
### main/scala/org/jetbrains/scala/samples/services/ApplicationHelloService.scala
hello.this.is.asstring
=
Hello, this is {0}
### main/scala/org/jetbrains/scala/samples/services/ProjectHelloService.scala
hello.from.project.getname
=
Hello from project "{0}"!
### main/scala/org/jetbrains/scala/samples/ui/MyToolWindowFactory.scala
my.cool.tool.window
=
My Cool Tool Window
### resources/META-INF/plugin.xml
action.org.bitlap.tools.plugin.PopupDialogAction.text
=
Action Basics Plugin: Pop Dialog Action
action.org.bitlap.tools.plugin.PopupDialogAction.description
=
SDK action example
intellij-plugin/src/main/resources/patch/change.html
已删除
100644 → 0
浏览文件 @
11b71226
<![CDATA[
<ul> 0.3.4:
<ol>
<li>transfer to bitlap.org</li>
</ol>
</ul>
<ul> 0.3.0:
<ol>
<li>support @equalsAndHashCode</li>
<li>support generic @apply, @builder</li>
</ol>
</ul>
<ul> 0.2.0:
<ol>
<li>support @builder, @log, @json, @apply</li>
</ol>
</ul>
<ul> 0.1.2:
<ol>
<li>First release, support @builder, @log, @json</li>
</ol>
</ul>
]]>
\ No newline at end of file
intellij-plugin/src/main/resources/patch/description.html
已删除
100644 → 0
浏览文件 @
11b71226
<![CDATA[
<h1>Scala Macro Tools plugin for IntelliJ IDEA</h1>
<br/>
<a href="https://github.com/bitlap/scala-macro-tools">GitHub</a> |
<a href="https://github.com/bitlap/scala-macro-tools/issues">Issues</a>
<br/>
<br/>
<b>A plugin that implements Lombok-like functionality with Scala macros</b>
<br/>
<br/>
<b>Features</b>
<ul>
<li>@toString</li>
<li>@json</li>
<li>@builder</li>
<li>@synchronized</li>
<li>@log</li>
<li>@apply</li>
<li>@constructor</li>
</ul>
<br/>
]]>
\ No newline at end of file
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/PluginBundle.scala
已删除
100644 → 0
浏览文件 @
11b71226
package
org.bitlap.tools.plugin
import
com.intellij.DynamicBundle
import
org.jetbrains.annotations.
{
NotNull
,
PropertyKey
}
/**
* Mail: chk19940609@gmail.com
* Created by IceMimosa
* Date: 2021/6/30
*/
class
PluginBundle
extends
DynamicBundle
(
"messages.PluginBundle"
)
object
PluginBundle
{
private
val
INSTANCE
=
new
PluginBundle
()
def
message
(
@NotNull
@PropertyKey
(
resourceBundle
=
"messages.PluginBundle"
)
key
:
String
,
@NotNull
params
:
Any*
)
:
String
=
{
INSTANCE
.
getMessage
(
key
,
params
)
}
}
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/ScalaMacroInjector.scala
已删除
100644 → 0
浏览文件 @
11b71226
package
org.bitlap.tools.plugin
import
com.intellij.openapi.components.ServiceManager
import
org.bitlap.tools.plugin.processor.ProcessType
import
org.bitlap.tools.plugin.processor.ProcessType.ProcessType
import
org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.ScTypeDefinition
import
org.jetbrains.plugins.scala.lang.psi.impl.toplevel.typedef.SyntheticMembersInjector
/**
* Desc: main injector to handle scala macro annotations.
*
* Mail: chk19940609@gmail.com
* Created by IceMimosa
* Date: 2021/7/4
*/
class
ScalaMacroInjector
extends
SyntheticMembersInjector
{
private
lazy
val
provider
=
ServiceManager
.
getService
(
classOf
[
ScalaMacroProcessorProvider
])
override
def
needsCompanionObject
(
source
:
ScTypeDefinition
)
:
Boolean
=
{
provider
.
findProcessors
(
source
).
exists
(
_
.
needCompanion
)
}
override
def
injectFunctions
(
source
:
ScTypeDefinition
)
:
Seq
[
String
]
=
inject
(
source
,
ProcessType
.
Method
)
override
def
injectInners
(
source
:
ScTypeDefinition
)
:
Seq
[
String
]
=
inject
(
source
,
ProcessType
.
Inner
)
override
def
injectMembers
(
source
:
ScTypeDefinition
)
:
Seq
[
String
]
=
inject
(
source
,
ProcessType
.
Field
)
override
def
injectSupers
(
source
:
ScTypeDefinition
)
:
Seq
[
String
]
=
inject
(
source
,
ProcessType
.
Super
)
private
def
inject
(
source
:
ScTypeDefinition
,
typ
:
ProcessType
)
:
Seq
[
String
]
=
{
provider
.
findProcessors
(
source
)
.
flatMap
(
_
.
process
(
source
,
typ
))
.
filter
(
s
=>
s
!=
null
&&
s
.
trim
.
nonEmpty
)
}
}
object
ScalaMacroInjector
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/ScalaMacroNames.scala
已删除
100644 → 0
浏览文件 @
11b71226
package
org.bitlap.tools.plugin
/**
* Mail: chk19940609@gmail.com
* Created by IceMimosa
* Date: 2021/6/30
*/
object
ScalaMacroNames
{
private
val
NS
=
"org.bitlap.tools"
val
BUILDER
=
s
"$NS.builder"
val
LOG
=
s
"$NS.log"
val
APPLY
=
s
"$NS.apply"
val
CONSTRUCTOR
=
s
"$NS.constructor"
val
JSON
=
s
"$NS.json"
val
EQUALS_HASHCODE
=
s
"$NS.equalsAndHashCode"
}
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/ScalaMacroProcessorProvider.scala
已删除
100644 → 0
浏览文件 @
11b71226
package
org.bitlap.tools.plugin
import
com.intellij.openapi.Disposable
import
org.bitlap.tools.plugin.processor.Processor
import
org.bitlap.tools.plugin.processor.clazz.
{
ApplyProcessor
,
BuilderProcessor
,
ConstructorProcessor
,
EqualsAndHashCodeProcessor
,
JsonProcessor
,
LogProcessor
}
import
org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.
{
ScClass
,
ScObject
,
ScTypeDefinition
}
import
scala.collection.mutable
/**
* Mail: chk19940609@gmail.com
* Created by IceMimosa
* Date: 2021/7/1
*/
class
ScalaMacroProcessorProvider
extends
Disposable
{
private
val
processors
=
mutable
.
Map
[
String
,
Processor
]()
regist
(
ScalaMacroNames
.
BUILDER
,
new
BuilderProcessor
())
regist
(
ScalaMacroNames
.
LOG
,
new
LogProcessor
())
regist
(
ScalaMacroNames
.
JSON
,
new
JsonProcessor
())
regist
(
ScalaMacroNames
.
APPLY
,
new
ApplyProcessor
())
regist
(
ScalaMacroNames
.
CONSTRUCTOR
,
new
ConstructorProcessor
())
regist
(
ScalaMacroNames
.
EQUALS_HASHCODE
,
new
EqualsAndHashCodeProcessor
())
override
def
dispose
()
:
Unit
=
{}
def
regist
(
name
:
String
,
p
:
Processor
)
:
ScalaMacroProcessorProvider
=
{
if
(
p
!=
null
)
{
this
.
processors
+=
name
.
trim
->
p
}
this
}
def
findProcessors
(
source
:
ScTypeDefinition
)
:
Seq
[
Processor
]
=
{
processors
.
filter
{
p
=>
source
match
{
case
obj
:
ScObject
=>
obj
.
hasAnnotation
(
p
.
_1
)
||
obj
.
fakeCompanionClassOrCompanionClass
.
hasAnnotation
(
p
.
_1
)
case
clazz
:
ScClass
=>
clazz
.
hasAnnotation
(
p
.
_1
)
case
_
=>
source
.
hasAnnotation
(
p
.
_1
)
}
}.
values
.
toSeq
}
}
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/processor/AbsProcessor.scala
已删除
100644 → 0
浏览文件 @
11b71226
package
org.bitlap.tools.plugin.processor
import
org.jetbrains.plugins.scala.lang.psi.api.base.ScMethodLike
import
org.jetbrains.plugins.scala.lang.psi.api.statements.params.ScClassParameter
import
org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.ScClass
/**
* Mail: chk19940609@gmail.com
* Created by IceMimosa
* Date: 2021/6/30
*/
abstract
class
AbsProcessor
extends
Processor
{
override
def
needCompanion
:
Boolean
=
false
/**
* get constructor parameters
*
* @return name and type
*/
protected
def
getConstructorParameters
(
clazz
:
ScClass
,
withSecond
:
Boolean
=
true
)
:
Seq
[(
String
,
String
)]
=
{
this
.
getConstructorCurryingParameters
(
clazz
,
withSecond
,
withCurrying
=
false
).
head
}
/**
* get constructor parameters with currying
*
* @return
* if `withCurrying` = true, return (name: type, name: type)(name: type)...
* else return (name: type, name: type, name: type, ...)
*/
protected
def
getConstructorCurryingParameters
(
clazz
:
ScClass
,
withSecond
:
Boolean
=
true
,
withCurrying
:
Boolean
=
true
)
:
Seq
[
Seq
[(
String
,
String
)]]
=
{
val
constructors
=
if
(
withSecond
)
{
clazz
.
constructors
.
map
(
Some
(
_
))
}
else
{
Seq
(
clazz
.
constructor
.
map
(
_
.
asInstanceOf
[
ScMethodLike
]))
}
if
(
withCurrying
)
{
constructors
.
flatten
.
flatMap
{
c
=>
c
.
effectiveParameterClauses
.
map
(
_
.
effectiveParameters
.
collect
{
case
p
:
ScClassParameter
=>
p
.
name
->
p
.
`type`
().
toOption
.
map
(
_
.
toString
).
getOrElse
(
"Unit"
)
})
}
}
else
{
Seq
(
constructors
.
flatten
.
flatMap
(
_
.
getParameterList
.
getParameters
)
.
collect
{
case
p
:
ScClassParameter
=>
p
.
name
->
p
.
`type`
().
toOption
.
map
(
_
.
toString
).
getOrElse
(
"Unit"
)
}
)
}
}
/**
* get type param string
*
* @param returnType if it is return type
* @return
* if `returnType` is false, just return typeParamString with bound like [T <: Any, U]
* else return typeParamString without bound like [T, U]
*/
protected
def
getTypeParamString
(
clazz
:
ScClass
,
returnType
:
Boolean
=
false
)
:
String
=
{
if
(!
returnType
||
clazz
.
typeParamString
.
isEmpty
)
{
clazz
.
typeParamString
}
else
{
clazz
.
typeParameters
.
map
(
_
.
name
).
mkString
(
"["
,
", "
,
"]"
)
}
}
}
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/processor/ProcessType.scala
已删除
100644 → 0
浏览文件 @
11b71226
package
org.bitlap.tools.plugin.processor
/**
* Mail: chk19940609@gmail.com
* Created by IceMimosa
* Date: 2021/7/5
*/
object
ProcessType
extends
Enumeration
{
type
ProcessType
=
Value
val
Method
,
Field
,
Inner
,
Super
=
Value
}
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/processor/Processor.scala
已删除
100644 → 0
浏览文件 @
11b71226
package
org.bitlap.tools.plugin.processor
import
org.bitlap.tools.plugin.processor.ProcessType.ProcessType
import
org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.ScTypeDefinition
/**
* Desc: Scala annotation processor
*
* Mail: chk19940609@gmail.com
* Created by IceMimosa
* Date: 2021/6/30
*/
trait
Processor
{
/**
* check this annotation processor should work with companion object
*/
def
needCompanion
:
Boolean
/**
* process generate codes with different `ProcessType`
*/
def
process
(
source
:
ScTypeDefinition
,
typ
:
ProcessType
)
:
Seq
[
String
]
}
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/processor/clazz/ApplyProcessor.scala
已删除
100644 → 0
浏览文件 @
11b71226
package
org.bitlap.tools.plugin.processor.clazz
import
org.bitlap.tools.plugin.processor.ProcessType.ProcessType
import
org.bitlap.tools.plugin.processor.
{
AbsProcessor
,
ProcessType
}
import
org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.
{
ScClass
,
ScObject
,
ScTypeDefinition
}
/**
* Desc: Processor for annotation apply
*
* Mail: chk19940609@gmail.com
* Created by IceMimosa
* Date: 2021/7/8
*/
class
ApplyProcessor
extends
AbsProcessor
{
override
def
needCompanion
:
Boolean
=
true
override
def
process
(
source
:
ScTypeDefinition
,
typ
:
ProcessType
)
:
Seq
[
String
]
=
{
typ
match
{
case
ProcessType
.
Method
=>
source
match
{
case
obj
:
ScObject
=>
val
clazz
=
obj
.
fakeCompanionClassOrCompanionClass
.
asInstanceOf
[
ScClass
]
val
nameAndTypes
=
getConstructorCurryingParameters
(
clazz
,
withSecond
=
false
)
.
map
(
_
.
map
(
o
=>
s
"${o._1}: ${o._2}"
).
mkString
(
"("
,
", "
,
")"
))
.
mkString
val
genericType
=
getTypeParamString
(
clazz
)
val
returnGenericType
=
getTypeParamString
(
clazz
,
returnType
=
true
)
Seq
(
s
"def apply$genericType$nameAndTypes: ${clazz.getName}$returnGenericType = ???"
)
case
_
=>
Nil
}
case
_
=>
Nil
}
}
}
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/processor/clazz/BuilderProcessor.scala
已删除
100644 → 0
浏览文件 @
11b71226
package
org.bitlap.tools.plugin.processor.clazz
import
org.bitlap.tools.plugin.processor.
{
AbsProcessor
,
ProcessType
}
import
org.bitlap.tools.plugin.processor.ProcessType.ProcessType
import
org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.
{
ScClass
,
ScObject
,
ScTypeDefinition
}
/**
* Desc: Processor for annotation builder
*
* Mail: chk19940609@gmail.com
* Created by IceMimosa
* Date: 2021/6/30
*/
class
BuilderProcessor
extends
AbsProcessor
{
private
final
val
builderClassNameSuffix
=
"Builder"
override
def
needCompanion
:
Boolean
=
true
override
def
process
(
source
:
ScTypeDefinition
,
typ
:
ProcessType
)
:
Seq
[
String
]
=
{
typ
match
{
// if companion object, inject builder method
case
ProcessType
.
Method
=>
source
match
{
case
obj
:
ScObject
=>
obj
.
fakeCompanionClassOrCompanionClass
match
{
case
clazz
:
ScClass
=>
val
genericType
=
getTypeParamString
(
clazz
)
val
returnGenericType
=
getTypeParamString
(
clazz
,
returnType
=
true
)
Seq
(
s
"""def builder$genericType(): ${genBuilderName(clazz.getName, returnType = true)}$returnGenericType = ???"""
)
case
_
=>
Nil
}
case
_
=>
Nil
}
// if class, inject builder class
case
ProcessType
.
Inner
=>
source
match
{
case
obj
:
ScObject
=>
val
clazz
=
obj
.
fakeCompanionClassOrCompanionClass
.
asInstanceOf
[
ScClass
]
val
className
=
clazz
.
getName
// support constructor and second constructor
val
nameAndTypes
=
getConstructorParameters
(
clazz
.
asInstanceOf
[
ScClass
])
val
genericType
=
getTypeParamString
(
clazz
)
val
returnGenericType
=
getTypeParamString
(
clazz
,
returnType
=
true
)
val
assignMethods
=
nameAndTypes
.
map
(
term
=>
s
"def ${term._1}(${term._1}: ${term._2}) = this"
)
Seq
(
s
"""
|class ${genBuilderName(className)}$genericType {
| def build(): $className$returnGenericType = ???
| ${assignMethods.mkString("\n")}
|}
|"""
.
stripMargin
)
case
_
=>
Nil
}
case
_
=>
Nil
}
}
/**
* Gen class builder name
*
* @param className base class name
* @param returnType if function or field return type
*/
private
def
genBuilderName
(
className
:
String
,
returnType
:
Boolean
=
false
)
:
String
=
{
if
(
returnType
)
{
s
"$className.$className$builderClassNameSuffix"
}
else
{
s
"$className$builderClassNameSuffix"
}
}
}
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/processor/clazz/ConstructorProcessor.scala
已删除
100644 → 0
浏览文件 @
11b71226
package
org.bitlap.tools.plugin.processor.clazz
import
org.bitlap.tools.plugin.ScalaMacroNames
import
org.bitlap.tools.plugin.processor.ProcessType.ProcessType
import
org.bitlap.tools.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.types.ScLiteralType
/**
* Desc: Processor for annotation constructor
*
* Mail: chk19940609@gmail.com
* Created by IceMimosa
* Date: 2021/7/8
*/
class
ConstructorProcessor
extends
AbsProcessor
{
private
val
excludeFieldsName
=
"excludeFields"
override
def
needCompanion
:
Boolean
=
true
override
def
process
(
source
:
ScTypeDefinition
,
typ
:
ProcessType
)
:
Seq
[
String
]
=
{
typ
match
{
case
ProcessType
.
Method
=>
source
match
{
case
clazz
:
ScClass
=>
val
consFields
=
getConstructorParameters
(
clazz
,
withSecond
=
false
)
val
excludeFields
=
clazz
.
annotations
(
ScalaMacroNames
.
CONSTRUCTOR
).
lastOption
match
{
case
Some
(
an
)
=>
// get excludeFields function call
an
.
getParameterList
.
getAttributes
.
findLast
(
_
.
getAttributeName
==
excludeFieldsName
).
map
(
_
.
getDetachedValue
)
.
collect
{
case
call
:
ScMethodCall
=>
// get call parameters
call
.
argumentExpressions
.
flatMap
(
_
.
`type`
().
toOption
)
.
collect
{
case
str
:
ScLiteralType
=>
str
.
value
.
value
.
toString
}
.
mkString
(
", "
)
}.
getOrElse
(
""
)
case
None
=>
""
}
val
varFields
=
clazz
.
extendsBlock
.
members
.
collect
{
// var, others: ScPatternDefinition, ScFunctionDefinition
case
`var`
:
ScVariableDefinition
=>
`var`
}
.
flatMap
{
v
=>
v
.
declaredNames
.
map
(
n
=>
(
n
,
v
.
`type`
().
toOption
.
map
(
_
.
toString
).
getOrElse
(
"Unit"
)))
}
.
filter
(
v
=>
!
excludeFields
.
contains
(
v
.
_1
))
val
consFieldsStr
=
consFields
.
map
(
_
.
_1
).
mkString
(
", "
)
val
allFieldsStr
=
(
consFields
++
varFields
).
map
(
f
=>
s
"${f._1}: ${f._2}"
).
mkString
(
", "
)
Seq
(
s
"def this($allFieldsStr) = this($consFieldsStr)"
)
case
_
=>
Nil
}
case
_
=>
Nil
}
}
}
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/processor/clazz/EqualsAndHashCodeProcessor.scala
已删除
100644 → 0
浏览文件 @
11b71226
package
org.bitlap.tools.plugin.processor.clazz
import
org.bitlap.tools.plugin.processor.ProcessType.ProcessType
import
org.bitlap.tools.plugin.processor.
{
AbsProcessor
,
ProcessType
}
import
org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.
{
ScClass
,
ScTypeDefinition
}
/**
* Desc: Processor for annotation equalsAndHashCode
*
* Mail: chk19940609@gmail.com
* Created by IceMimosa
* Date: 2021/7/22
*/
class
EqualsAndHashCodeProcessor
extends
AbsProcessor
{
override
def
needCompanion
:
Boolean
=
true
override
def
process
(
source
:
ScTypeDefinition
,
typ
:
ProcessType
)
:
Seq
[
String
]
=
{
typ
match
{
case
ProcessType
.
Method
=>
source
match
{
case
_:
ScClass
=>
Seq
(
s
"def canEqual(that: Any): Boolean = ???"
)
case
_
=>
Nil
}
case
_
=>
Nil
}
}
}
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/processor/clazz/JsonProcessor.scala
已删除
100644 → 0
浏览文件 @
11b71226
package
org.bitlap.tools.plugin.processor.clazz
import
org.bitlap.tools.plugin.processor.ProcessType.ProcessType
import
org.bitlap.tools.plugin.processor.
{
AbsProcessor
,
ProcessType
}
import
org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.
{
ScObject
,
ScTypeDefinition
}
/**
* Desc: Processor for annotation json
*
* Mail: chk19940609@gmail.com
* Created by IceMimosa
* Date: 2021/7/7
*/
class
JsonProcessor
extends
AbsProcessor
{
override
def
needCompanion
:
Boolean
=
true
override
def
process
(
source
:
ScTypeDefinition
,
typ
:
ProcessType
)
:
Seq
[
String
]
=
{
typ
match
{
case
ProcessType
.
Field
=>
source
match
{
case
obj
:
ScObject
=>
val
clazz
=
obj
.
fakeCompanionClassOrCompanionClass
Seq
(
s
"implicit val jsonAnnotationFormat = play.api.libs.json.Json.format[${clazz.getName}]"
)
case
_
=>
Nil
}
case
_
=>
Nil
}
}
}
intellij-plugin/src/main/scala/org/bitlap/tools/plugin/processor/clazz/LogProcessor.scala
已删除
100644 → 0
浏览文件 @
11b71226
package
org.bitlap.tools.plugin.processor.clazz
import
org.bitlap.tools.plugin.ScalaMacroNames
import
org.bitlap.tools.plugin.processor.ProcessType.ProcessType
import
org.bitlap.tools.plugin.processor.
{
AbsProcessor
,
ProcessType
}
import
org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.
{
ScClass
,
ScObject
,
ScTypeDefinition
}
/**
* Desc: Processor for annotation log
*
* Mail: chk19940609@gmail.com
* Created by IceMimosa
* Date: 2021/7/6
*/
class
LogProcessor
extends
AbsProcessor
{
// default log expr
private
def
logExpr
(
log
:
String
=
"java.util.logging.Logger"
)
=
s
"private final val log: $log = ???"
override
def
process
(
source
:
ScTypeDefinition
,
typ
:
ProcessType
)
:
Seq
[
String
]
=
{
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
_
=>
Nil
}
case
_
=>
Nil
}
}
}
project/build.properties
浏览文件 @
c483bf52
sbt.version
=
1.6.1
\ No newline at end of file
sbt.version
=
1.6.0
\ No newline at end of file
project/plugins.sbt
浏览文件 @
c483bf52
...
...
@@ -2,8 +2,6 @@ addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.3")
addSbtPlugin
(
"org.xerial.sbt"
%
"sbt-sonatype"
%
"3.9.10"
)
addSbtPlugin
(
"com.github.sbt"
%
"sbt-pgp"
%
"2.1.2"
)
addSbtPlugin
(
"com.github.gseitz"
%
"sbt-release"
%
"1.0.13"
)
addSbtPlugin
(
"org.jetbrains"
%
"sbt-ide-settings"
%
"1.1.0"
)
addSbtPlugin
(
"org.jetbrains"
%
"sbt-idea-plugin"
%
"3.13.5"
)
addSbtPlugin
(
"de.heikoseeberger"
%
"sbt-header"
%
"5.6.0"
)
addSbtPlugin
(
"org.scoverage"
%
"sbt-scoverage"
%
"1.9.2"
)
addSbtPlugin
(
"org.jmotor.sbt"
%
"sbt-protoc"
%
"1.0.19"
)
\ No newline at end of file
src/main/scala/org/bitlap/tools/logs/BaseLog.scala
浏览文件 @
c483bf52
...
...
@@ -27,7 +27,7 @@ import scala.reflect.macros.whitebox
trait
BaseLog
{
val
typ
:
LogType
val
`
type
`
:
LogType
def
getTemplate
(
c
:
whitebox.Context
)(
logTransferArgument
:
LogTransferArgument
)
:
c.Tree
}
src/main/scala/org/bitlap/tools/logs/JLogImpl.scala
浏览文件 @
c483bf52
...
...
@@ -27,7 +27,7 @@ import scala.reflect.macros.whitebox
object
JLogImpl
extends
BaseLog
{
override
val
typ
:
LogType
=
LogType
.
JLog
override
val
`
type
`
:
LogType
=
LogType
.
JLog
override
def
getTemplate
(
c
:
whitebox.Context
)(
logTransferArgument
:
LogTransferArgument
)
:
c.Tree
=
{
import
c.universe._
...
...
src/main/scala/org/bitlap/tools/logs/Log4J2Impl.scala
浏览文件 @
c483bf52
...
...
@@ -27,7 +27,7 @@ import scala.reflect.macros.whitebox
object
Log4J2Impl
extends
BaseLog
{
override
val
typ
:
LogType
=
LogType
.
Log4j2
override
val
`
type
`
:
LogType
=
LogType
.
Log4j2
override
def
getTemplate
(
c
:
whitebox.Context
)(
logTransferArgument
:
LogTransferArgument
)
:
c.Tree
=
{
import
c.universe._
...
...
src/main/scala/org/bitlap/tools/logs/LogType.scala
浏览文件 @
c483bf52
...
...
@@ -29,12 +29,12 @@ object LogType extends Enumeration {
type
LogType
=
Value
val
JLog
,
Log4j2
,
Slf4j
,
ScalaLoggingLazy
,
ScalaLoggingStrict
=
Value
private
lazy
val
types
=
Map
(
JLog
->
JLogImpl
,
Log4
j2
->
Log4J2Impl
,
Slf4j
->
Slf4jImpl
,
ScalaLoggingStrict
->
ScalaLoggingStrictImpl
,
ScalaLoggingLazy
->
ScalaLoggingLazyImpl
private
lazy
val
types
:
Map
[
LogType
,
BaseLog
]
=
Map
(
JLog
Impl
.
`type`
->
JLogImpl
,
Log4
J2Impl
.
`type`
->
Log4J2Impl
,
Slf4j
Impl
.
`type`
->
Slf4jImpl
,
ScalaLoggingStrict
Impl
.
`type`
->
ScalaLoggingStrictImpl
,
ScalaLoggingLazy
Impl
.
`type`
->
ScalaLoggingLazyImpl
)
def
getLogImpl
(
logType
:
LogType
)
:
BaseLog
=
{
...
...
src/main/scala/org/bitlap/tools/logs/Slf4jImpl.scala
浏览文件 @
c483bf52
...
...
@@ -27,7 +27,7 @@ import scala.reflect.macros.whitebox
object
Slf4jImpl
extends
BaseLog
{
override
val
typ
:
LogType
=
LogType
.
Slf4j
override
val
`
type
`
:
LogType
=
LogType
.
Slf4j
override
def
getTemplate
(
c
:
whitebox.Context
)(
logTransferArgument
:
LogTransferArgument
)
:
c.Tree
=
{
import
c.universe._
...
...
src/main/scala/org/bitlap/tools/logs/extension/ScalaLoggingLazyImpl.scala
浏览文件 @
c483bf52
...
...
@@ -35,7 +35,7 @@ import scala.reflect.macros.whitebox
*/
object
ScalaLoggingLazyImpl
extends
BaseLog
{
override
val
typ
:
LogType
=
LogType
.
ScalaLoggingLazy
override
val
`
type
`
:
LogType
=
LogType
.
ScalaLoggingLazy
override
def
getTemplate
(
c
:
whitebox.Context
)(
logTransferArgument
:
LogTransferArgument
)
:
c.Tree
=
{
import
c.universe._
...
...
src/main/scala/org/bitlap/tools/logs/extension/ScalaLoggingStrictImpl.scala
浏览文件 @
c483bf52
...
...
@@ -35,7 +35,7 @@ import scala.reflect.macros.whitebox
*/
object
ScalaLoggingStrictImpl
extends
BaseLog
{
override
val
typ
:
LogType
=
LogType
.
ScalaLoggingStrict
override
val
`
type
`
:
LogType
=
LogType
.
ScalaLoggingStrict
override
def
getTemplate
(
c
:
whitebox.Context
)(
logTransferArgument
:
LogTransferArgument
)
:
c.Tree
=
{
import
c.universe._
...
...
src/main/scala/org/bitlap/tools/package.scala
浏览文件 @
c483bf52
...
...
@@ -28,5 +28,5 @@ package org.bitlap
* @version 1.0
*/
package
object
tools
{
final
val
PACKAGE
=
"org.bitlap.tools"
final
val
PACKAGE
:
String
=
"org.bitlap.tools"
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录