public class DeclarationScanner extends Object
Multi-language structural declaration scanner and go-to-definition locator.
Extracts top-level and nested symbol declarations (DeclarationNode) and resolves symbol definitions across Klyn, Python, Java, C/C++, C#, JavaScript/TypeScript, SQL, HTML/XML, and CSS/QSS source code while ignoring matches inside comments and strings.
import klyn.code
import klyn.code.ast
source = "public class Calculator:\n public add(a as Int, b as Int) as Int:\n return a + b\n"
profile = LanguageProfile("klyn", "Klyn").withDefinitionMode("klyn").withLineComments(["#"])
tokenizer = CodeTokenizer(profile)
nodes = DeclarationScanner.scanDeclarations(source, tokenizer)
assert nodes.size >= 1| Modifier and Type | Member | Description |
|---|---|---|
| public static | findDefinition | Locates the first declaration of symbol in source using tokenizer. |
| public static | scanDeclarationsscanDeclarations(source as String, tokenizer as Tokenizer) as ArrayList<DeclarationNode> |
Scans source using tokenizer and returns an ordered list of extracted DeclarationNodes. |