Skip to content

Commit fabf843

Browse files
committed
* fixed project and completion icons being converted to 16 color bitmaps
* completion box now displays appropriate icons and tooltip with dparser * tool tips now expand some Ddoc macros for better readability
1 parent f622232 commit fabf843

File tree

18 files changed

+654
-48
lines changed

18 files changed

+654
-48
lines changed

CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,9 +597,13 @@ unreleased Version 0.3.38
597597
* updated to mago 0.9
598598
- bugzilla 11547: remove error message when stopping debugging
599599
- bugzilla 11437: debug info rejected if records don't have "recommended" order
600+
- bugzilla 11030: set breakpoint in all template instances
600601
* updated dparser to 08f760b6181d1e40a29f3e03a7eafcd40bf4dc34
601602
- added options to enable/disable mixin analysis and UFCS expansions
602603
* added support for string import dependencies (needs dmd 2.065)
603604
* fixed default library path for x64 (contained spaces, but were not quoted,
604605
added default for 8.1 SDK)
605606
* fixed passing quoted library paths to linker
607+
* fixed project and completion icons being converted to 16 color bitmaps
608+
* completion box now displays appropriate icons and tooltip with dparser
609+
* tool tips now expand some Ddoc macros for better readability

TODO

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ Project:
3737
- pass import path from static lib project to dependent projects
3838
- single file compilation for file configuration
3939
- custom command: quotes in dependencies not supported
40-
- property pages don't follow resize
40+
- VS2013: property pages don't follow resize
41+
- custom command: writes build batch to souce folder
4142

4243
Language service:
4344
-----------------

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
#define VERSION_MINOR 3
33
#define VERSION_REVISION 38
44
#define VERSION_BETA -beta
5-
#define VERSION_BUILD 1
5+
#define VERSION_BUILD 2

stdext/ddocmacros.d

Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
module stdext.ddocmacros;
2+
3+
import std.traits;
4+
import std.range;
5+
import std.ascii;
6+
import std.string;
7+
8+
// version = LOG;
9+
10+
version(LOG) import std.stdio;
11+
12+
C[][] ddocArgs(C,S)(ref S src)
13+
{
14+
C[][] args;
15+
C[] arg;
16+
17+
if(!src.empty && src.front.isWhite)
18+
src.popFront;
19+
20+
int parens = 0;
21+
while(!src.empty)
22+
{
23+
auto c = src.front;
24+
src.popFront;
25+
26+
switch(c)
27+
{
28+
case ')':
29+
if(parens == 0)
30+
{
31+
args ~= arg;
32+
return args;
33+
}
34+
parens--;
35+
goto default;
36+
case '(':
37+
parens++;
38+
goto default;
39+
40+
case ',':
41+
if(parens == 0)
42+
{
43+
args ~= arg;
44+
arg = arg.init;
45+
if(!src.empty && src.front.isWhite)
46+
src.popFront;
47+
break;
48+
}
49+
goto default;
50+
default:
51+
arg ~= c;
52+
break;
53+
}
54+
}
55+
version(LOG) writeln("ddocArgs = ", args);
56+
return args;
57+
}
58+
59+
K ddocIdent(K, S)(ref S src)
60+
{
61+
alias C = ElementEncodingType!S;
62+
K id;
63+
while(!src.empty)
64+
{
65+
C c = src.front;
66+
if(isAlpha(c) || c == '_' || isDigit(c))
67+
{
68+
id ~= c;
69+
src.popFront;
70+
}
71+
else
72+
break;
73+
}
74+
version(LOG) writeln("ddocIdent = ", id);
75+
return id;
76+
}
77+
78+
C[] joinArgs(C)(C[][] args, size_t first)
79+
{
80+
C[] s; // use joiner?
81+
if(args.length > first)
82+
{
83+
s = args[first];
84+
foreach(a; args[first + 1 .. $])
85+
{
86+
s ~= ',';
87+
s ~= a;
88+
}
89+
}
90+
return s;
91+
}
92+
93+
struct RangeStack(R)
94+
{
95+
alias E = ElementType!R;
96+
alias C = ElementEncodingType!R;
97+
98+
R[] stack;
99+
C[][][] arguments;
100+
101+
@property bool empty() const { return stack.empty; }
102+
@property E front() const { return stack[$-1].front; }
103+
@property void popFront()
104+
{
105+
stack[$-1].popFront;
106+
if(stack[$-1].empty)
107+
{
108+
stack.length--;
109+
arguments.length--;
110+
}
111+
}
112+
void push(ref R r, C[][] args)
113+
{
114+
version(LOG) writeln("push = ", r);
115+
if(!r.empty)
116+
{
117+
stack ~= r.save;
118+
arguments ~= args;
119+
}
120+
}
121+
R getArg(dchar n)
122+
{
123+
if(arguments.empty)
124+
return null;
125+
126+
if(n == '0')
127+
return joinArgs(arguments[$-1], 0);
128+
if(n == '+')
129+
return joinArgs(arguments[$-1], 1);
130+
size_t a = n - '0';
131+
if(a <= arguments[$-1].length)
132+
return arguments[$-1][a - 1];
133+
return null;
134+
}
135+
}
136+
137+
S ddocExpand(S,AA)(S s, AA defs, bool keepUnknown) if(isInputRange!S)
138+
{
139+
alias C = ElementEncodingType!S;
140+
alias K = KeyType!AA;
141+
alias V = ValueType!AA;
142+
143+
RangeStack!S src;
144+
src.push(s, null);
145+
146+
S res;
147+
while(!src.empty)
148+
{
149+
auto c = src.front;
150+
src.popFront;
151+
152+
switch(c)
153+
{
154+
case '$':
155+
auto d = src.front;
156+
if(d == '(')
157+
{
158+
src.popFront;
159+
auto id = ddocIdent!(K)(src);
160+
auto args = ddocArgs!C(src);
161+
if(auto p = id in defs)
162+
{
163+
src.push(*p, args);
164+
}
165+
else if(keepUnknown)
166+
{
167+
res ~= c;
168+
res ~= d;
169+
res ~= id;
170+
string keepArgs = " $0)";
171+
src.push(keepArgs, args);
172+
}
173+
break;
174+
}
175+
else if(isAlpha(d))
176+
{
177+
auto id = ddocIdent!(K)(src);
178+
if(auto p = id in defs)
179+
{
180+
src.push(*p, null);
181+
}
182+
else if(keepUnknown)
183+
{
184+
res ~= c;
185+
res ~= id;
186+
}
187+
break;
188+
}
189+
else if(isDigit(d) || d == '+')
190+
{
191+
auto arg = src.getArg(d);
192+
src.popFront;
193+
src.push(arg, null);
194+
break;
195+
}
196+
goto default;
197+
default:
198+
res ~= c;
199+
break;
200+
}
201+
}
202+
return res;
203+
}
204+
205+
string phobosDdocExpand(string txt)
206+
{
207+
string[string] macros =
208+
[
209+
"D" : "`$0`",
210+
"LINK" : "$0",
211+
"LINK2" : "$2",
212+
"XREF" : "$2",
213+
"UL" : "\n$0",
214+
"LI" : "\n* $0",
215+
];
216+
return ddocExpand(txt, macros, true);
217+
}
218+
219+
unittest
220+
{
221+
import std.stdio;
222+
223+
string txt = "$(D d-code)";
224+
string[string] macros = [ "D" : "$0", "LINK" : `<a href="$1">$+</a>` ];
225+
string res = ddocExpand(txt, macros);
226+
version(LOG) writeln(res);
227+
assert(strip(res) == "d-code");
228+
229+
res = ddocExpand("link = $(LINK 1,2, 3,4)", macros);
230+
version(LOG) writeln(res);
231+
assert(strip(res) == `link = <a href="1">2,3,4</a>`);
232+
}
233+
234+
version(unittest) {}
235+
void main() {}

stdext/stdext.visualdproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,7 @@
11321132
<File path="array.d" />
11331133
<File path="com.d" />
11341134
<File path="container.d" />
1135+
<File path="ddocmacros.d" />
11351136
<File path="file.d" />
11361137
<File path="httpget.d" />
11371138
<File path="path.d" />

0 commit comments

Comments
 (0)