virtual tokens between cursor
This commit is contained in:
+29
-20
@@ -580,7 +580,31 @@ abstract class Cpp2BeefGenerator
|
||||
bool first = true;
|
||||
for (let token in tokens)
|
||||
{
|
||||
bool isWritingQueuedToken = false;
|
||||
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);
|
||||
if (!isWritingQueuedToken)
|
||||
{
|
||||
if (first) Block();
|
||||
first = false;
|
||||
}
|
||||
WriteToken(token);
|
||||
for (let c in GetTokenSpelling!(token))
|
||||
if (c == '\n')
|
||||
line++;
|
||||
Flush();
|
||||
}
|
||||
WriteLinesUntil!(curLine, writeUntil);
|
||||
if (@block.HasValue) WriteBlock(@block.Value);
|
||||
}
|
||||
|
||||
protected virtual bool FilterTokensBetweenCursors(CXToken token, out bool isWritingQueuedToken)
|
||||
{
|
||||
isWritingQueuedToken = false;
|
||||
switch (Clang.GetTokenKind(token))
|
||||
{
|
||||
case .Comment:
|
||||
@@ -599,26 +623,11 @@ abstract class Cpp2BeefGenerator
|
||||
if (!fileInfo.queuedTokens.HasFlag(.RSquirly))
|
||||
QueuedToken!(decltype(fileInfo.queuedTokens).Semicolon, ";");
|
||||
|
||||
if (!isWritingQueuedToken) continue;
|
||||
if (fileInfo.queuedTokens == .None) block = @block;
|
||||
default: continue;
|
||||
if (!isWritingQueuedToken) return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
let location = Clang.GetTokenLocation(unit, token);
|
||||
Clang.GetFileLocation(location, ?, let startLine, ?, ?);
|
||||
WriteLinesUntil!(startLine, location);
|
||||
if (!isWritingQueuedToken)
|
||||
{
|
||||
if (first) Block();
|
||||
first = false;
|
||||
}
|
||||
WriteToken(token);
|
||||
for (let c in GetTokenSpelling!(token))
|
||||
if (c == '\n')
|
||||
line++;
|
||||
Flush();
|
||||
}
|
||||
WriteLinesUntil!(curLine, writeUntil);
|
||||
if (@block.HasValue) WriteBlock(@block.Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected enum TypeParamMode { None, InParam, OutParam }
|
||||
|
||||
Reference in New Issue
Block a user