Update deps to get doc comment parsing fixes
This commit is contained in:
parent
20477ad803
commit
823b93f0f7
2
dsymbol
2
dsymbol
|
@ -1 +1 @@
|
||||||
Subproject commit 5232fcc3cae19f2776073590d9c972eefedbca96
|
Subproject commit 0605a90a84ac287f879530420c7046cded566b74
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8230f207912b40a46e5eae84e50ee59215b7c67f
|
Subproject commit 65d771b81240683511c868e0ba05590c6e66bf16
|
|
@ -65,8 +65,48 @@ public AutocompleteResponse getDoc(const AutocompleteRequest request,
|
||||||
allocator, cache, moduleCache);
|
allocator, cache, moduleCache);
|
||||||
if (stuff.symbols.length == 0)
|
if (stuff.symbols.length == 0)
|
||||||
warning("Could not find symbol");
|
warning("Could not find symbol");
|
||||||
else foreach (symbol; stuff.symbols.filter!(a => !a.doc.empty))
|
else
|
||||||
response.docComments ~= formatComment(symbol.doc);
|
{
|
||||||
|
struct Escaper(O)
|
||||||
|
{
|
||||||
|
this(O* or)
|
||||||
|
{
|
||||||
|
this.outputRange = or;
|
||||||
|
}
|
||||||
|
|
||||||
|
void put(string s)
|
||||||
|
{
|
||||||
|
foreach (c; s)
|
||||||
|
put(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void put(char c)
|
||||||
|
{
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case '\n':
|
||||||
|
outputRange.put('\\');
|
||||||
|
outputRange.put('n');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
outputRange.put(c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
O* outputRange;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto app = appender!(char[])();
|
||||||
|
auto e = Escaper!(typeof(app))(&app);
|
||||||
|
foreach (symbol; stuff.symbols.filter!(a => !a.doc.empty))
|
||||||
|
{
|
||||||
|
app.clear();
|
||||||
|
foreach(c; symbol.doc)
|
||||||
|
e.put(c);
|
||||||
|
response.docComments ~= cast(string) app.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1258,33 +1298,6 @@ bool shouldSwapWithType(CompletionType completionType, CompletionKind kind,
|
||||||
|| (completionType == completionType.calltips && kind == CompletionKind.variableName)) ;
|
|| (completionType == completionType.calltips && kind == CompletionKind.variableName)) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Params:
|
|
||||||
* comment = the comment to format
|
|
||||||
* Returns
|
|
||||||
* the comment with the comment characters removed
|
|
||||||
*/
|
|
||||||
string formatComment(string comment)
|
|
||||||
{
|
|
||||||
import std.regex : replaceFirst, replaceAll, regex;
|
|
||||||
enum tripleSlashRegex = `(?:\t )*///`;
|
|
||||||
enum slashStarRegex = `(?:^/\*\*+)|(?:\n?\s*\*+/$)|(?:(?<=\n)\s*\* ?)`;
|
|
||||||
enum slashPlusRegex = `(?:^/\+\++)|(?:\n?\s*\++/$)|(?:(?<=\n)\s*\+ ?)`;
|
|
||||||
if (comment.length < 3)
|
|
||||||
return null;
|
|
||||||
string re;
|
|
||||||
if (comment[0 .. 3] == "///")
|
|
||||||
re = tripleSlashRegex;
|
|
||||||
else if (comment[1] == '+')
|
|
||||||
re = slashPlusRegex;
|
|
||||||
else
|
|
||||||
re = slashStarRegex;
|
|
||||||
return (comment.replaceAll(regex(re), ""))
|
|
||||||
.replaceFirst(regex("^\n"), "")
|
|
||||||
.replaceAll(regex(`\\`), `\\`)
|
|
||||||
.replaceAll(regex("\n"), `\n`).outdent();
|
|
||||||
}
|
|
||||||
|
|
||||||
istring stringToken()(auto ref const Token a)
|
istring stringToken()(auto ref const Token a)
|
||||||
{
|
{
|
||||||
return internString(a.text is null ? str(a.type) : a.text);
|
return internString(a.text is null ? str(a.type) : a.text);
|
||||||
|
|
Loading…
Reference in New Issue