virtual tokens between cursor
This commit is contained in:
+32
-23
@@ -580,29 +580,10 @@ abstract class Cpp2BeefGenerator
|
|||||||
bool first = true;
|
bool first = true;
|
||||||
for (let token in tokens)
|
for (let token in tokens)
|
||||||
{
|
{
|
||||||
bool isWritingQueuedToken = false;
|
if (!FilterTokensBetweenCursors(token, let isWritingQueuedToken))
|
||||||
switch (Clang.GetTokenKind(token))
|
continue;
|
||||||
{
|
if (isWritingQueuedToken && fileInfo.queuedTokens == .None)
|
||||||
case .Comment:
|
block = @block;
|
||||||
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;
|
|
||||||
}
|
|
||||||
let location = Clang.GetTokenLocation(unit, token);
|
let location = Clang.GetTokenLocation(unit, token);
|
||||||
Clang.GetFileLocation(location, ?, let startLine, ?, ?);
|
Clang.GetFileLocation(location, ?, let startLine, ?, ?);
|
||||||
WriteLinesUntil!(startLine, location);
|
WriteLinesUntil!(startLine, location);
|
||||||
@@ -621,6 +602,34 @@ abstract class Cpp2BeefGenerator
|
|||||||
if (@block.HasValue) WriteBlock(@block.Value);
|
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 enum TypeParamMode { None, InParam, OutParam }
|
||||||
protected virtual void Type(CXType type, TypeParamMode paramMode = .None)
|
protected virtual void Type(CXType type, TypeParamMode paramMode = .None)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user