File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
exts/devins-lang/src/main
kotlin/cc/unitmesh/devti/language/lints Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ package cc.unitmesh.devti.language.lints
2
+
3
+ import cc.unitmesh.devti.language.psi.DevInTypes
4
+ import cc.unitmesh.devti.language.psi.DevInUsed
5
+ import cc.unitmesh.devti.language.psi.DevInVisitor
6
+ import com.intellij.codeInspection.LocalInspectionTool
7
+ import com.intellij.codeInspection.ProblemsHolder
8
+ import com.intellij.psi.PsiElementVisitor
9
+ import com.intellij.psi.util.elementType
10
+
11
+ class DevInsDuplicateAgentInspection : LocalInspectionTool () {
12
+ override fun getDisplayName () = " Duplicate agent calling"
13
+
14
+ override fun buildVisitor (holder : ProblemsHolder , isOnTheFly : Boolean ): PsiElementVisitor {
15
+ return DevInsDuplicateAgentVisitor (holder)
16
+ }
17
+
18
+ private class DevInsDuplicateAgentVisitor (val holder : ProblemsHolder ) : DevInVisitor() {
19
+ private var agentIds: MutableSet <String > = mutableSetOf ()
20
+
21
+ override fun visitUsed (o : DevInUsed ) {
22
+ o.firstChild.let { next ->
23
+ if (next.nextSibling.elementType == DevInTypes .AGENT_ID ) {
24
+ if (agentIds.contains(next.text)) {
25
+ holder.registerProblem(next, " Duplicate agent calling" )
26
+ } else {
27
+ agentIds.add(next.text)
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
Original file line number Diff line number Diff line change 41
41
id =" devinsDocumentationProvider"
42
42
implementationClass =" cc.unitmesh.devti.language.documentation.DevInsDocumentationProvider" />
43
43
<documentationProvider implementation =" cc.unitmesh.devti.language.documentation.DevInsDocumentationProvider" />
44
+
45
+ <localInspection language =" DevIn" groupPath =" DevIn" groupName =" Lints"
46
+ displayName =" Duplicate agent declaration"
47
+ enabledByDefault =" true"
48
+ level =" ERROR"
49
+ implementationClass =" cc.unitmesh.devti.language.lints.DevInsDuplicateAgentInspection" />
44
50
</extensions >
45
51
46
52
<actions >
You can’t perform that action at this time.
0 commit comments