Skip to content

Commit 825ee04

Browse files
committed
feat(documentation): better support for attributes
Towards #7
1 parent 9078d27 commit 825ee04

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/main/kotlin/org/tonstudio/tact/ide/documentation/documentation.kt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package org.tonstudio.tact.ide.documentation
33
import com.intellij.lang.documentation.DocumentationMarkup
44
import com.intellij.openapi.editor.markup.TextAttributes
55
import com.intellij.psi.PsiElement
6-
import com.intellij.psi.util.PsiTreeUtil
76
import org.tonstudio.tact.ide.documentation.DocumentationUtils.asKeyword
87
import org.tonstudio.tact.ide.documentation.DocumentationUtils.line
98
import org.tonstudio.tact.ide.documentation.DocumentationUtils.part
@@ -213,7 +212,23 @@ private fun generateDocForConstantModifiers(attrs: List<TactConstantModifier>):
213212
}
214213

215214
private fun TactAttribute.generateDoc(): String {
216-
return colorize("@", asAttribute) + (attributeExpression?.text ?: "")
215+
val plainAttribute = attributeExpression?.plainAttribute ?: return ""
216+
val name = plainAttribute.attributeKey.text ?: ""
217+
val arguments = plainAttribute.argumentList?.expressionList ?: emptyList()
218+
return buildString {
219+
colorize("@", asAttribute)
220+
colorize(name, asAttribute)
221+
if (arguments.isNotEmpty()) {
222+
colorize("(", asParen)
223+
arguments.forEachIndexed { index, argument ->
224+
append(argument.generateDoc())
225+
if (index != arguments.size - 1) {
226+
append(", ")
227+
}
228+
}
229+
colorize(")", asParen)
230+
}
231+
}
217232
}
218233

219234
fun TactStructDeclaration.generateDoc(): String {

0 commit comments

Comments
 (0)