JavaParser
classin packageklyn.code.java
public class JavaParser extends Object
└ JavaParser

Lightweight structural parser for Java source files (.java).

Extracts package and import declarations, classes, interfaces, enums, records, constructors, methods, and Javadoc comments into DeclarationNode trees.

import klyn.code.java

src = "package com.demo;\npublic class Service {\n    public int compute(int x) {\n        return x + 1;\n    }\n}\n"
nodes = JavaParser.parseDeclarations(src)
assert nodes.size == 1
assert nodes[0].name == "Service"
assert nodes[0].children.size == 1
assert nodes[0].children[0].name == "compute"
Inherited Properties
propertyInherited Properties from Object: type
Methods
Modifier and Type Member Description
public static parseDeclarations
parseDeclarations(source as String) as ArrayList<DeclarationNode>
Parses top-level Java type declarations and their nested member methods/constructors.
Inherited Methods
methodInherited Methods from Object: deepCopy, fromJson, hash, toDict, toJson, toMap, toString, toXml