Skip to content

[FAQ] How to get object references? (Rust SDK) #397

Open
@patrycju

Description

@patrycju

How to get object references? (Rust SDK)

Hey! Hope you're doing well! I have a quick questions surrounding Rust SDK.

Let's say I have following KCL file:

schema File:
  name: str
  path: Path

schema Path:
  p: str

ext = "txt"
file_name = "hello.${ext}"
path = Path { p = "/tmp" }

f = File { name = file_name, path = path }

I need to extract references to other identifiers used in any field or value of given object, so for example, based on above file I need to get:

f -> ["file_name", "path"]
file_name -> ["ext"]

Now, I checked Rust SDK and even tried to find it in non-public APIs like Parser or Evaluator, but no luck. I'm slowly learning internals of KCL, but it's very complex and I'm feeling little lost.

Can you please share where can I get this information or at what level should I intercept compilation to get this?

Thank you in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions