mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-03 00:38:24 +02:00
codetools: complete record block
git-svn-id: trunk@20132 -
This commit is contained in:
parent
e97ed3191c
commit
ec7adf6c05
@ -5497,6 +5497,39 @@ var
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
function ReadRecord(var Stack: TBlockStack): Boolean;
|
||||
{ type
|
||||
TMyClass = record
|
||||
|
|
||||
}
|
||||
var
|
||||
LastIndent: LongInt;
|
||||
Indent: LongInt;
|
||||
InsertPos: LongInt;
|
||||
NewCode: String;
|
||||
begin
|
||||
Result:=false;
|
||||
if CleanCursorPos<StartNode.StartPos then exit;
|
||||
LastIndent:=GetLineIndent(Src,StartNode.StartPos);
|
||||
MoveCursorToNodeStart(StartNode);
|
||||
ReadNextAtom;
|
||||
if CleanCursorPos<CurPos.EndPos then exit(true);
|
||||
ReadNextAtom;
|
||||
if CurPos.Flag=cafEnd then exit(true);
|
||||
if CleanCursorPos<=CurPos.StartPos then begin
|
||||
Indent:=GetLineIndent(Src,CurPos.StartPos);
|
||||
if Indent<LastIndent then begin
|
||||
InsertPos:=CleanCursorPos;
|
||||
NewCode:=SourceChangeCache.BeautifyCodeOptions.BeautifyStatement(
|
||||
'end;',LastIndent,[bcfIndentExistingLineBreaks]);
|
||||
if not SourceChangeCache.Replace(gtNewLine,gtEmptyLine,
|
||||
InsertPos,InsertPos,NewCode) then exit;
|
||||
if not SourceChangeCache.Apply then exit;
|
||||
end;
|
||||
end;
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
var
|
||||
Stack: TBlockStack;
|
||||
begin
|
||||
@ -5522,6 +5555,9 @@ begin
|
||||
if StartNode.Desc=ctnClassInterface then begin
|
||||
if not ReadClassInterface(Stack) then exit;
|
||||
end;
|
||||
if StartNode.Desc=ctnRecordType then begin
|
||||
if not ReadRecord(Stack) then exit;
|
||||
end;
|
||||
finally
|
||||
FreeStack(Stack);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user