functiongetDefUseChains

Information

Returns the def-use chains of the names in className as JSON: for every name used in it or declared in it, where it's declared and everywhere in scope it's used. If className is a component, e.g. P.Base.x, only the chain of that component is returned.

The names are looked up with the new frontend like the instantiation would, through imports, base classes and redeclares, but without instantiating anything, so it also works for packages, partial classes and classes that can't be instantiated. A name looked up through a replaceable class is also looked up in the classes it's redeclared as, and those uses are marked as candidate.

The JSON has the definitions, each with its name, kind (class, component or iterator), its source span and the position of its name, and its uses. A use has the position of the name, the text as written, the part of a qualified name that refers to the definition, the class it's used in and its role (type, extends, modifier, binding, dimension, condition, constrainedby, equation, algorithm, argument, import, annotation, classExtends, redeclare, end). If the name isn't found in the source, exact is false and the position is the span of what it's used in. The names that couldn't be looked up are listed under unresolved.

Inputs

TypeNameDefaultDescription
TypeNameclassNameA class, or a component declared in a class.
StringfileName""The file to write the JSON to, if not empty.
TypeNamescope$Code(AllLoadedClasses)The class to look for the uses in.
BooleanprettyPrintfalse

Outputs

TypeNameDefaultDescription
StringchainsThe JSON, or the file name if it was written to a file.