File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
src/main/kotlin/platform/mcp/ct Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ class CtAnnotator : Annotator {
4646 }
4747
4848 if (element.accessElement.text.startsWith(" transitive-" ) &&
49- element.containingFile?.childOfType<CtHeader >()?.versionString == " v1 "
49+ element.containingFile?.childOfType<CtHeader >()?.effectiveVersion == 1
5050 ) {
5151 holder.newAnnotation(HighlightSeverity .ERROR , " Transitive accesses were introduced in v2" ).create()
5252 }
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ import com.demonwav.mcdev.platform.mcp.ct.psi.CtElement
2424
2525interface CtHeaderMixin : CtElement {
2626
27+ val nameString: String
2728 val versionString: String?
2829 val namespaceString: String?
30+ val effectiveVersion: Int?
2931}
Original file line number Diff line number Diff line change @@ -24,13 +24,33 @@ import com.demonwav.mcdev.platform.mcp.ct.gen.psi.CtTypes
2424import com.demonwav.mcdev.platform.mcp.ct.psi.mixins.CtHeaderMixin
2525import com.intellij.extapi.psi.ASTWrapperPsiElement
2626import com.intellij.lang.ASTNode
27+ import com.intellij.openapi.diagnostic.logger
2728import com.intellij.psi.PsiElement
2829
2930abstract class CtHeaderImplMixin (node : ASTNode ) : ASTWrapperPsiElement(node), CtHeaderMixin {
31+ companion object {
32+ private val LOG = logger<CtHeaderImplMixin >()
33+ }
34+
35+ override val nameString: String
36+ get() = findNotNullChildByType<PsiElement >(CtTypes .HEADER_NAME ).text
3037
3138 override val versionString: String?
3239 get() = findChildByType<PsiElement >(CtTypes .HEADER_VERSION_ELEMENT )?.text
3340
3441 override val namespaceString: String?
3542 get() = findChildByType<PsiElement >(CtTypes .HEADER_NAMESPACE_ELEMENT )?.text
43+
44+ override val effectiveVersion: Int?
45+ get() {
46+ val version = versionString?.removePrefix(" v" )?.toIntOrNull() ? : return null
47+ return when (nameString) {
48+ " accessWidener" -> version
49+ " classTweaker" -> version + 2
50+ else -> {
51+ LOG .error(" Unknown header name: $nameString " )
52+ null
53+ }
54+ }
55+ }
3656}
You can’t perform that action at this time.
0 commit comments