Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No node for typedefs #3628

Open
jodinathan opened this issue Dec 22, 2023 · 4 comments
Open

No node for typedefs #3628

jodinathan opened this issue Dec 22, 2023 · 4 comments
Labels
contributions-welcome Contributions welcome to help resolve this (the resolution is expected to be clear from the issue)

Comments

@jodinathan
Copy link

jodinathan commented Dec 22, 2023

ParsedLibraryResult.getElementDeclaration(someTypeAliasElementImplVar) returns null only for typedef.

It seems for me that this is a bug.

How can I know the node for TypeAliasElementImpl elements?

Dart SDK version: 3.2.2 (stable) (Tue Nov 28 11:22:54 2023 +0000) on "macos_x64"

@jakemac53
Copy link
Contributor

cc @scheglov

@scheglov scheglov added the contributions-welcome Contributions welcome to help resolve this (the resolution is expected to be clear from the issue) label Jan 10, 2024
@jodinathan
Copy link
Author

is this a bug?

@natebosch
Copy link
Member

natebosch commented Jan 26, 2024

From my reading of the docs getElementDeclaration returns null for synthetic elements - you might check if someTypeAliasElementImplVar.isSynthetic is true, and if so see if nonSynthetic property gets you to an Element that works with this API.

https://pub.dev/documentation/analyzer/latest/dart_element_element/Element/nonSynthetic.html

@jodinathan
Copy link
Author

no, typedefs are not synthetic, they are solid nodes.

I could find out the node for the typedef by looping through all nodes and check for node.element == myTypedefElement.

So the node and typedef element connection is there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributions-welcome Contributions welcome to help resolve this (the resolution is expected to be clear from the issue)
Projects
None yet
Development

No branches or pull requests

4 participants