Open uschuster opened 8 years ago
For repeat the following fix will work:
procedure TPasSyntaxTreeBuilder.RepeatStatement;
begin
// FStack.Push(ntRepeat);
// try
// inherited;
// finally
// FStack.Pop;
// end;
FStack.PushCompoundSyntaxNode(ntRepeat);
try
inherited;
SetCurrentCompoundNodesEndPosition;
finally
FStack.Pop;
end;
end;
I'm not sure the CompoundSyntaxNode is the fix for all problems.
The while can be a single do statement or a compound statement, so that is sort of covered.
89 was about correct position information for "begin end", repeat and while loops, for "begin end" it was fixed, but repeat and while are of type TSyntaxNode and do not have an end.
Each syntax node should have a begin and an end position. For example a node of type ntUnit starts often at 1:1, but where does it end? The number of whitespaces between "unit" and the unit name itself can be greater than one and guessing the end works only for nodes without whitespaces.
Checking out https://github.com/uschuster/DelphiAST/tree/master/SynEditTest might help to understand the issue. Make sure you compile it with define WITH_SYNTAX_TREE and against VirtualTrees 5.x.