Missing language service feature

Topics: General
Mar 2, 2013 at 12:56 PM
First of, I think that the languages services are a great idea and make it relatively easy to build some kind of IDE. Of course some documentation would be welcome (like what does the resident flag really do). I'm surprised how stable the API has been so far. Whenever I update my project with a new release, almost everything keeps on working.

What I'm missing however is some kind or mirror/reflection/inspection API. Almost all of the language services are "cursor/file" based functions. Like code-completion or code-formatting. What I'm looking for is something different, just to give a few examples:

1) give me all the defined classes in this project
2) For a given interface, give me all of its methods (even if defined in multiple files).
3) or for this module, what external modules are imported.
4) and so on

I guess with the AST API available I could make some smart iterators that do what I want, but I was hoping a slightly higher level API. Does such a thing exist (perhaps somewhere hidden in the current API) or is it on the agenda?

Some use cases:

1) Create a visual dependency tracker between modules
2) Generated some UML class diagrams
3) Some more advanced refactoring than just rename
Mar 3, 2013 at 11:39 PM
I voted for http://typescript.codeplex.com/workitem/116 for macros. I think macros would be a great way to solve reflection. I know it's not quite the same thing as what you're asking, but it would be a huge step forward.
Mar 4, 2013 at 12:42 PM
Just to make sure, what I was asking for is a reflection API on compile time, not runtime. I guess that macros would also be resolved at compile time and translated into plain JS and thus would be complementary to the reflection API.

IMHO I think (too many) macros can make the code less understandable to new team members. Another way to extends the language is to use some type of annotations/decoration. Not as powerful, but much easier to understand and implement. There even is already a nice pull request for this: http://typescript.codeplex.com/SourceControl/network/forks/rbuckton/Decorators/contribution/3840


On 03/04/2013 01:39 AM, cretz wrote:

From: cretz

I voted for http://typescript.codeplex.com/workitem/116 for macros. I think macros would be a great way to solve reflection. I know it's not quite the same thing as what you're asking, but it would be a huge step forward.