-
Notifications
You must be signed in to change notification settings - Fork 22
Conversation
Yeah, seems good.
Yeah, this is true. They shouldn't have children, they probably will be children, though.
💯 Could you add tests please? |
For the tests you would want to put something under this directory here. I think something like def_kind.rs would be a good thing and then just create every type of @projektir does that make sense? Anything I can clear up with my explanation? |
@mgattozzi |
tests/source/macros.rs
Outdated
@@ -0,0 +1,9 @@ | |||
#![crate_type = "lib"] | |||
|
|||
// @has /data/relationships/macros/data/0 'macro' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't get this to pick up at all. It doesn't seem to see macros. I have the same issue with unions and I imagine would have the same issue with statics and consts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@steveklabnik what about this problem?
I'm seeing in #7 a comment"After a quick look at generated JSON, it looks like the exported macros (and their doc comments) are not included.". So that kind of seems like a problem. And I've also seen the same issue with unions.
I'm going to tweak the lib.rs
file with all these things and see what it actually generates because it doesn't seem like a lot right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds like maybe the same thing as impls, I'm not sure.
tests/source/methods.rs
Outdated
pub struct UnitStruct; | ||
|
||
impl UnitStruct { | ||
pub fn method_function() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since to create a method it needs to be attached to some object, I need to identify it somehow, but nothing seems to work. Am I misunderstanding that this is not actually a child of a struct or such? Is there some intermediate type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nrc, I don't know anything about this, maybe you do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, basically nothing with impls (and thus methods) is going to work very well yet. We need some work in rustc to add support and that is a bit non-trivial in the general case. We could add support for inherent impls pretty easily, if someone wanted to hack on that I could give instructions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And actually, I thought inherent impls worked, but maybe I was just wrong about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which case it might just be best for now if we put tests for what works, mark what doesn't (but still keep the code there), and have the tests written for whatever works. Thoughts @steveklabnik?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove the code for the stuff that doesn't work, and go with a _ =>
. But yeah, otherwise, let's do that, @projektir . It might also be worth noting this over at #7
Thanks @nrc
Looking at it a bit more, it seems the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's see what nick says about this
tests/source/methods.rs
Outdated
pub struct UnitStruct; | ||
|
||
impl UnitStruct { | ||
pub fn method_function() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nrc, I don't know anything about this, maybe you do?
Yeah it might just something with rls-analysis or something in your code (which I doubt). |
All right, so I added everything that I could figure out. I'd like to say that the following DefKinds can be marked as done for #121: I've also added various examples to the example The new Here's the resulting Seeing a few weird things:
|
tests/source/fields.rs
Outdated
// @has /included/0/attributes/docs '' | ||
|
||
// This will fail, the type of 'fields::StructWithFields::integer' is 'struct' | ||
// has /included/0/relationships/child_structs/data/0/type 'field' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect this to be a field
, but it's a struct
. It seems "children" of something all get set to have the type as the parent, which of course is not true for complex types like Structs or Enums.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, that seems... less than ideal.
// @has /included/1/type 'struct' | ||
// @has /included/1/id 'structs::ContainerStruct' | ||
// @has /included/1/attributes/name 'ContainerStruct' | ||
// @has /included/1/attributes/docs 'A struct that contains another struct.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you can see there's no "Docs for the ContainerStruct." here. That part of the documentation just seems to disappear.
tests/source/enums.rs
Outdated
|
||
/// An enum. | ||
pub enum SampleEnum { | ||
/// An enum variant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No way to see these docs that I can find.
Yeah, so I was doing the |
I think that I would avoid surfacing 'children' to the user at all - it's a bit vague and doesn't reflect any term in the code. I would use different terms for different structures - variants of an enum, fields of a struct, etc. Internally, it makes sense to use children, at least for save-analysis where we try to abstract things as much as possible. It seems like there are a few rough edges with the save-analysis data. I think they should mostly be easy to fix (unions, docs for enum variants, etc.). If you could file issues on the rls-analysis repo it is easier for me than the Rust repo (just too many notifications). I'll try and fix them or organise an impl period/mentoring effort around them when I get back from parental leave. |
@nrc I'd be happy to try to work on those issues, as well. |
@projektir thanks for filing the issues! It would be great to have you work on some of them. I'm currently on parental leave, but I'll write some instructions when I get back in a couple of weeks. |
@nrc if there's instructions left I can take a crack at them as well so we can get this PR moving. |
Question: since this has been a while, do we want to merge, with the understanding that some stuff doesn't work yet, rather than block this on upstream work? |
src/json/mod.rs
Outdated
@@ -88,6 +101,19 @@ pub fn create_json(host: &AnalysisHost, crate_name: &str) -> Result<String> { | |||
let (ty, child_ty) = match def.kind { | |||
DefKind::Mod => (String::from("module"), String::from("child_modules")), | |||
DefKind::Struct => (String::from("struct"), String::from("child_structs")), | |||
DefKind::Enum => (String::from("enum"), String::from("child_enums")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, there's no real reason that we need the child
stuff here; i was cargo-culting from modules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this also means that this block and the one above are identical except for modules, which is annoying
Okay, so more thorough review today; we should cut the stuff that doesn't work yet, and leave in the stuff that does. wrt the child stuff, let's make it so that only |
Appveyor is failing on traits, but not for me or @projektir locally :/ |
Update: needed to rebase the branch; appveyor basically does this. Fixed that up. Now to figure out enums... |
This adds as much stuff as we can so far; some issues like rust-dev-tools/rls-analysis#98 mean that we can't do everything. Fixes #121
🎊 |
@projektir Hey, are you still interested in working on some rls-analysis issues? I'm back from leave now, so you can ping me anytime in #rust-dev-tools or @Rustc. Some basic instructions for how to tackle these issues:
|
previous comment also for @mgattozzi |
@nrc I need to find some time hopefully soon I've been busier than expected but if I can I'd like to take a crack at it. I'll ping you whenever I have the time. |
Addresses #121.
This excludes
Local
, which means it needs to be deliberately skipped. Maybe it should be more specific likeDefKind::Local => continue
in case something else is added in the future?I'm not sure if it makes sense for
Static
orConst
and such to have children?I believe the idea is to set this boilerplate up and then we can move on to actually implementing things in the frontend?