Thread overview
Refactoring D as an MSc Project
Mar 02, 2015
Jamie
Mar 02, 2015
Brian Schott
Mar 02, 2015
Jamie
Mar 03, 2015
Jamie
Mar 03, 2015
John Colvin
Mar 03, 2015
Brian Schott
Mar 03, 2015
Rikki Cattermole
Mar 03, 2015
Etienne Cimon
Mar 03, 2015
Jonas Drewsen
March 02, 2015
Hello all!

This is my first post on the forums. I'm interested in possibly creating a refactoring tool for D for my MSc dissertation (I notice there is currently no refactoring in D?). I wanted to ask if this is possible with D's current state?

More specifically:
- Can I easily access things such as the AST?
March 02, 2015
On Monday, 2 March 2015 at 21:50:46 UTC, Jamie wrote:
> Hello all!
>
> This is my first post on the forums. I'm interested in possibly creating a refactoring tool for D for my MSc dissertation (I notice there is currently no refactoring in D?). I wanted to ask if this is possible with D's current state?
>
> More specifically:
> - Can I easily access things such as the AST?

This should save you a lot of time: https://github.com/Hackerpilot/libdparse
March 02, 2015
Thanks, I'll give it a look :)
March 03, 2015
On 3/03/2015 10:50 a.m., Jamie wrote:
> Hello all!
>
> This is my first post on the forums. I'm interested in possibly creating
> a refactoring tool for D for my MSc dissertation (I notice there is
> currently no refactoring in D?). I wanted to ask if this is possible
> with D's current state?
>
> More specifically:
> - Can I easily access things such as the AST?

You may also be interested in SDC[0].

[0] https://github.com/deadalnix/SDC
March 03, 2015
On Monday, 2 March 2015 at 21:54:05 UTC, Brian Schott wrote:
> On Monday, 2 March 2015 at 21:50:46 UTC, Jamie wrote:
>> Hello all!
>>
>> This is my first post on the forums. I'm interested in possibly creating a refactoring tool for D for my MSc dissertation (I notice there is currently no refactoring in D?). I wanted to ask if this is possible with D's current state?
>>
>> More specifically:
>> - Can I easily access things such as the AST?
>
> This should save you a lot of time: https://github.com/Hackerpilot/libdparse

I've had a look around and it seems promising, however are there any usage examples poking around somewhere I could look at? Also, does the produced AST have location information?
March 03, 2015
On 2015-03-02 16:50, Jamie wrote:
> Hello all!
>
> This is my first post on the forums. I'm interested in possibly creating
> a refactoring tool for D for my MSc dissertation (I notice there is
> currently no refactoring in D?). I wanted to ask if this is possible
> with D's current state?
>
> More specifically:
> - Can I easily access things such as the AST?

If you can write C#, it would be interesting to add it as a feature in Mono-D

https://github.com/aBothe/Mono-D/

It's an IDE engine, there is also a parser (written in C#) called D_Parser as a submodule. I use mono-d all the time to work on my libraries. Currently the refactoring feature in monodevelop is pretty much useless because nobody implemented it I guess.


March 03, 2015
On Tuesday, 3 March 2015 at 01:17:33 UTC, Jamie wrote:
> On Monday, 2 March 2015 at 21:54:05 UTC, Brian Schott wrote:
>> On Monday, 2 March 2015 at 21:50:46 UTC, Jamie wrote:
>>> Hello all!
>>>
>>> This is my first post on the forums. I'm interested in possibly creating a refactoring tool for D for my MSc dissertation (I notice there is currently no refactoring in D?). I wanted to ask if this is possible with D's current state?
>>>
>>> More specifically:
>>> - Can I easily access things such as the AST?
>>
>> This should save you a lot of time: https://github.com/Hackerpilot/libdparse
>
> I've had a look around and it seems promising, however are there any usage examples poking around somewhere I could look at?

https://github.com/Hackerpilot/Dscanner uses it. Walking the AST is done with the visitor pattern, so if you're familiar with that it should make sense.
March 03, 2015
On Monday, 2 March 2015 at 21:50:46 UTC, Jamie wrote:
> Hello all!
>
> This is my first post on the forums. I'm interested in possibly creating a refactoring tool for D for my MSc dissertation (I notice there is currently no refactoring in D?). I wanted to ask if this is possible with D's current state?
>
> More specifically:
> - Can I easily access things such as the AST?

I have planned to do refactoring tools myself for D for use in Deadcode (an editor). I'm currently using libdparse myself for other things, but the overview given for SDC last dconf looked very promising.

I would be very interested in following what you do and be an early adopter if possible.

/Jonas
March 03, 2015
On Tuesday, 3 March 2015 at 01:17:33 UTC, Jamie wrote:
> On Monday, 2 March 2015 at 21:54:05 UTC, Brian Schott wrote:
>> On Monday, 2 March 2015 at 21:50:46 UTC, Jamie wrote:
>>> Hello all!
>>>
>>> This is my first post on the forums. I'm interested in possibly creating a refactoring tool for D for my MSc dissertation (I notice there is currently no refactoring in D?). I wanted to ask if this is possible with D's current state?
>>>
>>> More specifically:
>>> - Can I easily access things such as the AST?
>>
>> This should save you a lot of time: https://github.com/Hackerpilot/libdparse
>
> I've had a look around and it seems promising, however are there any usage examples poking around somewhere I could look at? Also, does the produced AST have location information?

Not all AST nodes have location information right now. I've mostly been adding that as I need it for other projects. Any field of an AST class that has a type "Token" will have line, column and byte offsets.

These projects use libdparse:

https://github.com/Hackerpilot/DCD
https://github.com/Hackerpilot/Dscanner
https://github.com/Hackerpilot/dfmt
https://github.com/economicmodeling/harbored