The best way to write IDE helper tool
unDEFER
undefer at gmail.com
Thu Dec 20 14:17:11 UTC 2018
Hello!
I know there is IDE tools like DCD, but I don't like it because
it hasn't UCFS-suggestions.
So I have written my own patches to DMD to decide this problem.
The patches adds the "-interp" option to compiler. In this mode
the compiler is interrupted after semantic3 stage and displays
the next prompt:
INTERPRETER MODE
Write here short commands like:
<modulename>:line - as the first line to setup scope of the
command
pragma(msg, "message");
templatename!(args)();
<empty line> - to start interpreter
exit - to finish interpreter mode
Also the patches adds 2 traits "isUFCSCallable" and
"locationOfDeclaration".
All is good, my text editor calls after changes the modified dmd
and writes to it's stdin short programs like this:
import std.algorithm.searching: startsWith;
static if (__traits(compiles, rhs.stringof.startsWith("module "))
&&
rhs.stringof.startsWith("module "))
allMembersOfModule!("rhs");
else static if (__traits(compiles, isType!(rhs)) && isType!(rhs))
allMembersOfType!(rhs, "aliasthis");
else static if (__traits(compiles, typeof(rhs)))
allMembersOfType!(typeof(rhs), "aliasthis");
else static if (__traits(compiles, typeof(rhs())))
allMembersOfType!(typeof(rhs()), "aliasthis");
else pragma(msg, "Can't find type of expression");
To find what to suggest after a user writes "rhs.".
allMembersOfModule and allMembersOfType declared in my
autocompletion_routines module and inserts in each module by
other new option of the modified compiler "-importtoall=".
So the problem of this approach is that the parsing of whole
project is performed after EVERY edit of code.
What I want is to make "interp" mode better and add command to
insert/remove lines to it's AST.
I see that I need to add to AST also fields like "dependencies"
("using") to each declaration.. But seems there will problems
with approach which uses the compiler. It rewrites "foreach" as
"for" if it not in template and so on.. Don't sure that after
this changes will be possible easy change lines in AST.
libdparse also doesn't work for me. It doesn't do CTFE so limits
to UCFS suggestion like "isRange" will not work.
How you see what the best existing tools can help me finish this
task?
More information about the Digitalmars-d
mailing list