mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
TheIDE: ConverToOverrides fix (#375)
This commit is contained in:
parent
2761cbf60e
commit
3776bcd89c
1 changed files with 53 additions and 9 deletions
|
|
@ -268,7 +268,45 @@ void AssistEditor::Virtuals()
|
||||||
|
|
||||||
void AssistEditor::ConvertToOverrides()
|
void AssistEditor::ConvertToOverrides()
|
||||||
{
|
{
|
||||||
Make([](String& out) {
|
// Returns insertion point after trailing qualifiers and sets has_final
|
||||||
|
auto SkipTrailingQualifiers = [](const char *start, bool& hasfinal) -> const char* {
|
||||||
|
const char *ins = start;
|
||||||
|
hasfinal = false;
|
||||||
|
for(;;) {
|
||||||
|
const char *q = ins;
|
||||||
|
while(*q == ' ' || *q == '\t' || *q == '\n' || *q == '\r') // Multiline support
|
||||||
|
q++;
|
||||||
|
if(memcmp(q, "const", 5) == 0 && !iscid(q[5]))
|
||||||
|
ins = q + 5;
|
||||||
|
else
|
||||||
|
if(memcmp(q, "noexcept", 8) == 0 && !iscid(q[8]))
|
||||||
|
ins = q + 8;
|
||||||
|
else
|
||||||
|
if(memcmp(q, "final", 5) == 0 && !iscid(q[5])) {
|
||||||
|
ins = q + 5;
|
||||||
|
hasfinal = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if(*q == '&' || *q == '*')
|
||||||
|
ins = q + 1;
|
||||||
|
else
|
||||||
|
if(*q == '[') { // attributes [[...]]
|
||||||
|
int depth = 1;
|
||||||
|
q++;
|
||||||
|
while(*q && depth) {
|
||||||
|
if(*q == '[') depth++;
|
||||||
|
else if(*q == ']') depth--;
|
||||||
|
q++;
|
||||||
|
}
|
||||||
|
ins = q;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return ins;
|
||||||
|
};
|
||||||
|
|
||||||
|
Make([&](String& out) {
|
||||||
String r;
|
String r;
|
||||||
const char *s = out;
|
const char *s = out;
|
||||||
bool virt = false;
|
bool virt = false;
|
||||||
|
|
@ -281,7 +319,7 @@ void AssistEditor::ConvertToOverrides()
|
||||||
if(len == 7 && memcmp(b, "virtual", 7) == 0) {
|
if(len == 7 && memcmp(b, "virtual", 7) == 0) {
|
||||||
virt = true;
|
virt = true;
|
||||||
lvl = 0;
|
lvl = 0;
|
||||||
while(*s == ' ' || *s == '\t')
|
while(*s == ' ' || *s == '\t' || *s == '\n' || *s == '\r') // Multiline support
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -292,15 +330,21 @@ void AssistEditor::ConvertToOverrides()
|
||||||
if(*s == ')') {
|
if(*s == ')') {
|
||||||
lvl = max(lvl - 1, 0);
|
lvl = max(lvl - 1, 0);
|
||||||
if(lvl == 0 && virt) {
|
if(lvl == 0 && virt) {
|
||||||
r << " override";
|
bool hasfinal = false;
|
||||||
|
const char *q = SkipTrailingQualifiers(s + 1, hasfinal);
|
||||||
|
// Append everything up to insertion point
|
||||||
|
r.Cat(s + 1, q - (s + 1));
|
||||||
|
// Insert override if not final
|
||||||
|
if(!hasfinal)
|
||||||
|
r.Cat(" override");
|
||||||
|
s = q;
|
||||||
virt = false;
|
virt = false;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out = r;
|
out = r;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue