DeclarationScanner
classin packageklyn.code
public class DeclarationScanner extends Object
└ DeclarationScanner

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
Inherited Properties
propertyInherited Properties from Object: type
Methods
Modifier and Type Member Description
public static findDefinition
findDefinition(source as String, symbol as String, tokenizer as Tokenizer) as ArrayList<Long>
Locates the first declaration of symbol in source using tokenizer.
public static scanDeclarations
scanDeclarations(source as String, tokenizer as Tokenizer) as ArrayList<DeclarationNode>
Scans source using tokenizer and returns an ordered list of extracted DeclarationNodes.
Inherited Methods
methodInherited Methods from Object: deepCopy, fromJson, hash, toDict, toJson, toMap, toString, toXml