DeclarationNode
classin packageklyn.code.ast
public class DeclarationNode extends Object
└ DeclarationNode

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"
Properties
Modifier and Type Member Description
public property baseType
baseType as String
Declared base/super type for class and interface declarations.
public readonly property children Nested child declarations (e.g.
public property docComment
docComment as String
Leading documentation comment attached to this declaration.
public readonly property interfaces
interfaces as ArrayList<String>
Implemented or extended interfaces for type declarations.
public readonly property kind Structural kind of this declaration.
public readonly property modifiers
modifiers as ArrayList<String>
Additional declaration modifiers ("static", "abstract", "override", "virtual", "native", etc.).
public readonly property name
name as String
Simple identifier name of this declaration.
public readonly property parameters
parameters as ArrayList<String>
Parameter declarations for callable nodes.
public property range
range as SourceRange
Source range spanned by this declaration.
public property returnType
returnType as String
Declared return or field type name.
public readonly property signature
signature as String
Header signature text of this declaration.
public property visibility
visibility as String
Visibility modifier ("public", "protected", "private", or "").
Inherited Properties
propertyInherited Properties from Object: type
Constructors
Modifier and Type Member Description
public DeclarationNode
DeclarationNode( kind as DeclarationKind, name as String, signature as String, range as SourceRange, visibility as String = "", returnType as String = "", docComment as String = "" )
Constructs a DeclarationNode.
Methods
Modifier and Type Member Description
public addChild
addChild(child as DeclarationNode) as Void
Appends a child declaration node.
public qualifiedName
qualifiedName(parentName as String = "") as String
Formats a dot-qualified symbol name given an optional parentName.
Inherited Methods
methodInherited Methods from Object: deepCopy, fromJson, hash, toDict, toJson, toMap, toString, toXml