public class DeclarationNode extends Object
Represents a structural declaration node (class, interface, enum, method, function, property, field) in a lightweight language-agnostic outline tree.
import klyn.code.ast
cls = DeclarationNode(DeclarationKind.CLASS, "UserService", "public class UserService", SourceRange(0, 0, 10, 0))
method = DeclarationNode(DeclarationKind.METHOD, "findById", "public findById(id as Long) as User", SourceRange(2, 4, 8, 0))
cls.addChild(method)
assert cls.children.size == 1
assert method.qualifiedName("UserService") == "UserService.findById"| Modifier and Type | Member | Description |
|---|---|---|
| public property | baseTypebaseType as String |
Declared base/super type for class and interface declarations. |
| public readonly property | childrenchildren as ArrayList<DeclarationNode> |
Nested child declarations (e.g. |
| public property | docCommentdocComment as String |
Leading documentation comment attached to this declaration. |
| public readonly property | interfaces | Implemented or extended interfaces for type declarations. |
| public readonly property | kindkind as DeclarationKind |
Structural kind of this declaration. |
| public readonly property | modifiers | Additional declaration modifiers ("static", "abstract", "override", "virtual", "native", etc.). |
| public readonly property | namename as String |
Simple identifier name of this declaration. |
| public readonly property | parameters | Parameter declarations for callable nodes. |
| public property | rangerange as SourceRange |
Source range spanned by this declaration. |
| public property | returnTypereturnType as String |
Declared return or field type name. |
| public readonly property | signaturesignature as String |
Header signature text of this declaration. |
| public property | visibilityvisibility as String |
Visibility modifier ("public", "protected", "private", or ""). |
| Modifier and Type | Member | Description |
|---|---|---|
| public | DeclarationNodeDeclarationNode(
kind as DeclarationKind,
name as String,
signature as String,
range as SourceRange,
visibility as String = "",
returnType as String = "",
docComment as String = ""
) |
Constructs a DeclarationNode. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | addChildaddChild(child as DeclarationNode) as Void |
Appends a child declaration node. |
| public | qualifiedName | Formats a dot-qualified symbol name given an optional parentName. |