libdparse
libdparse copied to clipboard
Parameter types
Hi.
Are there any specific reason why it doesn't parse any parameter data types? And also, it would be neat to have functions that generated the signature as string for stuff like functions, variables, etc.
Can you provide a test case showing what you did, what you expected, and what you got ?
Well the thing is, I'm not sure what I should do? What is the recommended way to access types? Return types, parameter types, variable types, etc.
Like how would I get a Type
's "pretty" value?
I'm not sure what you mean with a Type's "pretty" value.
If you are looking for something interpreting symbol types from source code you are instead looking for dsymbol instead of libdparse or you want to use dmd as a library. However dsymbol will lose some AST information or make it hard to access (such as how exactly you written a type in the definition)
libdparse will just give you the AST from some source code input to traverse over yourself, not anything more.
If you want to transform the AST back into code strings use dparse.formatter
, example API usage: https://github.com/Pure-D/workspace-d/blob/9cf3d6424f2118a99f043cfd43eec20037190fa9/source/workspaced/dparseext.d#L19
I'm not sure what you mean with a Type's "pretty" value.
I mean the attribute from fx. dscanner on Type
called pretty
dparse.formatter
can be used to format whole things, e.g. you could unset the functionBody before calling it.
Alternatively you can access the .tokens
slice on the FunctionDeclaration to get the raw tokens that make up the whole function declaration.
Parameters are parsed normally and can be visited.
Closing this issue since there doesn't seem to be anything to do on the libdparse side.