aBothe / Mono-D

D Add-In for MonoDevelop
http://wiki.dlang.org/Mono-D
Other
113 stars 26 forks source link

Resolve interfaces #554

Open etcimon opened 9 years ago

etcimon commented 9 years ago

I've been writing some features related to interface implementations. The polymorphic objects used in my code can sometimes resolve to a single implementation, but when going to the declaration it's only resolve to the interface. It could be more appropriate to resolve to the only implementation instead.

e.g. https://github.com/rejectedsoftware/vibe.d/tree/master/examples/echoserver

The function listenTCP resolves to this: https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/core/net.d#L57

The returned object TCPListener resolves to this: https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/core/net.d#L243

However the only implementation that isn't versioned out is this: https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/core/drivers/libevent2.d#L310

It seems to me that the resolver should resolve to the actual implementation, unless you're trying to resolve the inherited interface of the implementation here: https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/core/drivers/libevent2.d#L61

This issue could also be tackled by looking up all the possible implementations and putting them in a queue, where every time you hit the "Go to declaration" it picks up the next entry in the list, and loops back when you're at the last.

aBothe commented 9 years ago

If I'm getting you right, this depends on the location where the identifier that shall be resolved is located at. Of course, if you're in a class definition that inherits Libevent2Driver (which is not possible because final), listenTCP should resolve to inherited/local definitions first, that's for sure.

That echoserver example with its resolution to vibe.core.net.d totally makes sense to me, so no misbehaviour recognizable there. Stuff in libevent2.d furthermore got version(VibeLibeventDriver) on top, so you probably should elaborate this a bit further :)

etcimon commented 9 years ago

Yes, i think the right example would be here https://www.jetbrains.com/resharper/documentation/reviewers_guide.html go to inheriter . The webstorm IDE actually moves to the inheritors after the interface. It's often more convenient when you want to see how it is implemented. Otherwise, find usages could also do but I'm not sure if it should actually be working right now..