virtual tokens between cursor
This commit is contained in:
+32
-23
@@ -580,29 +580,10 @@ abstract class Cpp2BeefGenerator
|
||||
bool first = true;
|
||||
for (let token in tokens)
|
||||
{
|
||||
bool isWritingQueuedToken = false;
|
||||
switch (Clang.GetTokenKind(token))
|
||||
{
|
||||
case .Comment:
|
||||
case .Punctuation:
|
||||
mixin QueuedToken(var queuedToken, StringView spelling)
|
||||
{
|
||||
if (fileInfo.queuedTokens.HasFlag(queuedToken) && GetTokenSpelling!(token) == spelling)
|
||||
{
|
||||
fileInfo.queuedTokens ^= queuedToken;
|
||||
isWritingQueuedToken = true;
|
||||
}
|
||||
}
|
||||
|
||||
QueuedToken!(decltype(fileInfo.queuedTokens).LSquirly, "{");
|
||||
QueuedToken!(decltype(fileInfo.queuedTokens).RSquirly, "}");
|
||||
if (!fileInfo.queuedTokens.HasFlag(.RSquirly))
|
||||
QueuedToken!(decltype(fileInfo.queuedTokens).Semicolon, ";");
|
||||
|
||||
if (!isWritingQueuedToken) continue;
|
||||
if (fileInfo.queuedTokens == .None) block = @block;
|
||||
default: continue;
|
||||
}
|
||||
if (!FilterTokensBetweenCursors(token, let isWritingQueuedToken))
|
||||
continue;
|
||||
if (isWritingQueuedToken && fileInfo.queuedTokens == .None)
|
||||
block = @block;
|
||||
let location = Clang.GetTokenLocation(unit, token);
|
||||
Clang.GetFileLocation(location, ?, let startLine, ?, ?);
|
||||
WriteLinesUntil!(startLine, location);
|
||||
@@ -621,6 +602,34 @@ abstract class Cpp2BeefGenerator
|
||||
if (@block.HasValue) WriteBlock(@block.Value);
|
||||
}
|
||||
|
||||
protected virtual bool FilterTokensBetweenCursors(CXToken token, out bool isWritingQueuedToken)
|
||||
{
|
||||
isWritingQueuedToken = false;
|
||||
switch (Clang.GetTokenKind(token))
|
||||
{
|
||||
case .Comment:
|
||||
case .Punctuation:
|
||||
mixin QueuedToken(var queuedToken, StringView spelling)
|
||||
{
|
||||
if (fileInfo.queuedTokens.HasFlag(queuedToken) && GetTokenSpelling!(token) == spelling)
|
||||
{
|
||||
fileInfo.queuedTokens ^= queuedToken;
|
||||
isWritingQueuedToken = true;
|
||||
}
|
||||
}
|
||||
|
||||
QueuedToken!(decltype(fileInfo.queuedTokens).LSquirly, "{");
|
||||
QueuedToken!(decltype(fileInfo.queuedTokens).RSquirly, "}");
|
||||
if (!fileInfo.queuedTokens.HasFlag(.RSquirly))
|
||||
QueuedToken!(decltype(fileInfo.queuedTokens).Semicolon, ";");
|
||||
|
||||
if (!isWritingQueuedToken) return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected enum TypeParamMode { None, InParam, OutParam }
|
||||
protected virtual void Type(CXType type, TypeParamMode paramMode = .None)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user