Author Topic: Codecompletion for D  (Read 21457 times)

Offline nocide

  • Multiple posting newcomer
  • *
  • Posts: 23
Codecompletion for D
« on: April 10, 2010, 10:42:55 pm »
I tinkered with the idea to implement codecompletion for D.
Since the current completionsupport is only based on the analogy of D to C.
I think there would be 3 possibilities to implement this.

a) Implement it in the same Parser-classes as cpp
b) Implement in the same codecompletion plugin, but with it's own parser-framwork
c) completly independent plugin for D-Parser

re a) I think this would be not a good idea. Specifically when we want implement more languages, this will become a nighmare of if/else blocks
re b) I have seen, that cpp-related code is not only in the parser-subfolder, but also in the main-folder of this plugin. But this would probably be the easiest way to go.
re c) IMHO this would be the cleanest implementation. But for now, I have no clue how this can be loaded or managed in parallel with the cpp-codecompletion plugin.

So what are your thoughts?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Codecompletion for D
« Reply #1 on: April 11, 2010, 04:08:45 pm »
Code
re b) I have seen, that cpp-related code is not only in the parser-subfolder, but also in the main-folder of this plugin. But this would probably be the easiest way to go. 

Sorry, I have never used D language.

But I have some kind of familiar with the current CC plug-in's code. :D

There are two major parts of CC, the first part (we say part A) was collecting tags. we use the parser class and other helper classes(all the code was under parser- subfolder as you said) to analyze all the source code, then we store all the tags(some times, we call Tokens).

The second part( we say Part B) was doing the completion and other UI tips( eg, when the mouse hover on some ids, there is a function tip or when you enter some text, then there is a completion list prompt below your caret), it need to resolve the current code statement syntax.

Currently CC's code is quite mixing. So, if you want to implement a D language, you need to implement a part A for D language, and only modify some code in Part B.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline nocide

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Codecompletion for D
« Reply #2 on: April 11, 2010, 05:50:53 pm »
Ah I see, that makes now more sense to me.

So I make a DParser class with the same interface as Parser, and we can load the correct parser related to the opened file/project?


Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Codecompletion for D
« Reply #3 on: April 11, 2010, 06:19:18 pm »
The best thing will be to extract part B and put it in the cb's sdk... but I suppose this will be tough...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline JGM

  • Lives here!
  • ****
  • Posts: 518
  • Got to practice :)
Re: Codecompletion for D
« Reply #4 on: April 12, 2010, 07:44:39 pm »
whoa I have been throwing an eye to D language and there are no IDE for it as I now that supports CC would be of great help since D seems to come after C and the future will change got it? A B C D  :lol:

Also I have read that D is easier to parse!

Offline nocide

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Codecompletion for D
« Reply #5 on: April 12, 2010, 09:58:35 pm »
Yeah, D is indeed a very powerful language. And the dmd compiler is really fast.
Today Andrei Alexandrescu posted a measurement about D-compiletime as a comparsion to google's go language.
And the result is amazing :)
The std-library of D (88KLOC) in 1.24 sec.
http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=108831

At work I code in C++ and when I try to compile my really small projects, I can go for a coffee, or two ...  :D

But as you mentioned, D lacks on support with really good GUI-tools such as IDE's, ...
But then codeblocks come into play ...

Offline JGM

  • Lives here!
  • ****
  • Posts: 518
  • Got to practice :)
Re: Codecompletion for D
« Reply #6 on: April 13, 2010, 01:14:01 am »
Interesting almost like running a php script  :)

Offline Aelxx

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Codecompletion for D
« Reply #7 on: April 13, 2010, 04:35:25 pm »
DMD D compiler generates tags itself with using option -X in JSON format, but as for now it doesn't generate tags for local variables. Maybe it's needed to ask for this feature to the developers of D.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Codecompletion for D
« Reply #8 on: April 13, 2010, 04:43:50 pm »
Ah I see, that makes now more sense to me.

So I make a DParser class with the same interface as Parser, and we can load the correct parser related to the opened file/project?



For the Part A step, I think (suggest) you could try our "parserthread test project", which only do the batch parsing on only one file, and you can test you own D Parser.

See here:ParserTester for codecompletion plugin

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline nocide

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Codecompletion for D
« Reply #9 on: April 13, 2010, 08:35:24 pm »
Oh cool,
I will try it out!

Offline wangdong1226

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Codecompletion for D
« Reply #10 on: February 10, 2011, 08:45:22 am »
Oh cool,
I will try it out!

Dear Nocide,

I would like to know that you have finished the codecompletion for D or not.

I'm looking for this also, but I'm not so skilled in patching or improving codeblocks source files; so if you can provide the solution will be a great good news for me and other ones who like D Language.


waiting for your kindly feedback.


Sincerely yours,

Daivd.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Codecompletion for D
« Reply #11 on: February 10, 2011, 10:59:39 pm »
... but I'm not so skilled in patching or improving codeblocks source files...
Have you tried? The codebase is not that big and not that hard to work with. You only need to know C++ at decent level.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline wangdong1226

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Codecompletion for D
« Reply #12 on: February 11, 2011, 02:25:38 am »
... but I'm not so skilled in patching or improving codeblocks source files...
Have you tried? The codebase is not that big and not that hard to work with. You only need to know C++ at decent level.

Dear oBFusCATed,
I only knows a little bit about C Language, I'm not familiar with C++   :(

I recognized that the D Language is as good as C (or C++) and has more important properties than C (and C++). Personally thinking, it will be one of the most popular and important languages in future after D2 is soon formally released out. (D core developers are working very hard every day.)

Here is a CHM file about D Language for your reference.
https://docs.google.com/leaf?id=0B38se3xzJrbuMjNlMTQ5MzUtYTM1NC00M2UyLWJjODctMDZlM2Y2ZWQwYjlm&hl=en&authkey=CPvh1ZoG

More and more people foucing and learning it.
So, if CodeBlocks fully support it will be a very good strategetic decision.
(even C++0x really released out, I don't think C++0x will be more better than D.)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Codecompletion for D
« Reply #13 on: February 11, 2011, 02:32:45 am »
I have open that CHM, and look at the first page containing a minimal d language sample code, it seems D language is much like c/c++, but has some special keyword or grammar.

So, If you are familiar with D, you can quickly familiar with C/c++.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline wangdong1226

  • Multiple posting newcomer
  • *
  • Posts: 46
« Last Edit: February 12, 2011, 01:35:43 am by wangdong1226 »