mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-27 23:09:45 +02:00
codetools: stdcodetools: use GetIndentStr of beautifier
git-svn-id: trunk@40820 -
This commit is contained in:
parent
3c5846fe89
commit
f1b6abfac5
@ -4092,6 +4092,7 @@ const
|
|||||||
NodeMovedFlag = 1;
|
NodeMovedFlag = 1;
|
||||||
var
|
var
|
||||||
NodeMoves: TCodeGraph;// an edge means, move the FromNode in front of the ToNode
|
NodeMoves: TCodeGraph;// an edge means, move the FromNode in front of the ToNode
|
||||||
|
Beauty: TBeautifyCodeOptions;
|
||||||
|
|
||||||
procedure InitNodeMoves;
|
procedure InitNodeMoves;
|
||||||
begin
|
begin
|
||||||
@ -4147,8 +4148,7 @@ var
|
|||||||
if MoveNode then begin
|
if MoveNode then begin
|
||||||
FromPos:=FindLineEndOrCodeInFrontOfPosition(Node.StartPos);
|
FromPos:=FindLineEndOrCodeInFrontOfPosition(Node.StartPos);
|
||||||
ToPos:=FindLineEndOrCodeAfterPosition(Node.EndPos);
|
ToPos:=FindLineEndOrCodeAfterPosition(Node.EndPos);
|
||||||
NodeSrc:=SourceChangeCache.BeautifyCodeOptions.GetIndentStr(Indent)
|
NodeSrc:=Beauty.GetIndentStr(Indent)+Trim(copy(Src,FromPos,ToPos-FromPos));
|
||||||
+Trim(copy(Src,FromPos,ToPos-FromPos));
|
|
||||||
// remove
|
// remove
|
||||||
if (Node.PriorBrother=nil)
|
if (Node.PriorBrother=nil)
|
||||||
and (Node.Parent<>nil) and (Node.Parent.Desc in AllDefinitionSections)
|
and (Node.Parent<>nil) and (Node.Parent.Desc in AllDefinitionSections)
|
||||||
@ -4252,6 +4252,7 @@ begin
|
|||||||
NodeMoves:=nil;
|
NodeMoves:=nil;
|
||||||
Definitions:=nil;
|
Definitions:=nil;
|
||||||
Graph:=nil;
|
Graph:=nil;
|
||||||
|
Beauty:=SourceChangeCache.BeautifyCodeOptions;
|
||||||
try
|
try
|
||||||
// move the pointer types to the same type sections
|
// move the pointer types to the same type sections
|
||||||
if not BuildUnitDefinitionGraph(Definitions,Graph,false) then exit;
|
if not BuildUnitDefinitionGraph(Definitions,Graph,false) then exit;
|
||||||
|
@ -668,7 +668,7 @@ var
|
|||||||
end else begin
|
end else begin
|
||||||
// add new line
|
// add new line
|
||||||
Lines[Lines.Count-1]:=Line;
|
Lines[Lines.Count-1]:=Line;
|
||||||
Line:=GetIndentStr(Indent)+NewUses;
|
Line:=Beauty.GetIndentStr(Indent)+NewUses;
|
||||||
Lines.Add(Line);
|
Lines.Add(Line);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -3909,6 +3909,8 @@ end;
|
|||||||
|
|
||||||
function TStandardCodeTool.ConvertDelphiToLazarusSource(AddLRSCode: boolean;
|
function TStandardCodeTool.ConvertDelphiToLazarusSource(AddLRSCode: boolean;
|
||||||
SourceChangeCache: TSourceChangeCache): boolean;
|
SourceChangeCache: TSourceChangeCache): boolean;
|
||||||
|
var
|
||||||
|
Beauty: TBeautifyCodeOptions;
|
||||||
|
|
||||||
function AddModeDelphiDirective: boolean;
|
function AddModeDelphiDirective: boolean;
|
||||||
var
|
var
|
||||||
@ -4022,15 +4024,15 @@ function TStandardCodeTool.ConvertDelphiToLazarusSource(AddLRSCode: boolean;
|
|||||||
end;
|
end;
|
||||||
if Tree.Root.Desc=ctnUnit then begin
|
if Tree.Root.Desc=ctnUnit then begin
|
||||||
InitializationNode:=FindInitializationNode;
|
InitializationNode:=FindInitializationNode;
|
||||||
NewCode:=GetIndentStr(SourceChangeCache.BeautifyCodeOptions.Indent)
|
NewCode:=Beauty.GetIndentStr(Beauty.Indent)
|
||||||
+'{$i '+LRSFilename+'}';
|
+'{$i '+LRSFilename+'}';
|
||||||
if InitializationNode=nil then begin
|
if InitializationNode=nil then begin
|
||||||
// add also an initialization section
|
// add also an initialization section
|
||||||
ImplementationNode:=FindImplementationNode;
|
ImplementationNode:=FindImplementationNode;
|
||||||
InsertPos:=ImplementationNode.EndPos;
|
InsertPos:=ImplementationNode.EndPos;
|
||||||
NewCode:=SourceChangeCache.BeautifyCodeOptions.BeautifyKeyWord(
|
NewCode:=Beauty.BeautifyKeyWord(
|
||||||
'initialization')
|
'initialization')
|
||||||
+SourceChangeCache.BeautifyCodeOptions.LineEnd
|
+Beauty.LineEnd
|
||||||
+NewCode;
|
+NewCode;
|
||||||
if not SourceChangeCache.Replace(gtEmptyLine,gtEmptyLine,
|
if not SourceChangeCache.Replace(gtEmptyLine,gtEmptyLine,
|
||||||
InsertPos,InsertPos,
|
InsertPos,InsertPos,
|
||||||
@ -4053,6 +4055,7 @@ begin
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
if SourceChangeCache=nil then exit;
|
if SourceChangeCache=nil then exit;
|
||||||
SourceChangeCache.MainScanner:=Scanner;
|
SourceChangeCache.MainScanner:=Scanner;
|
||||||
|
Beauty:=SourceChangeCache.BeautifyCodeOptions;
|
||||||
DebugLn('ConvertDelphiToLazarusSource AddModeDelphiDirective');
|
DebugLn('ConvertDelphiToLazarusSource AddModeDelphiDirective');
|
||||||
if not AddModeDelphiDirective then exit;
|
if not AddModeDelphiDirective then exit;
|
||||||
DebugLn('ConvertDelphiToLazarusSource RemoveDFMResourceDirective');
|
DebugLn('ConvertDelphiToLazarusSource RemoveDFMResourceDirective');
|
||||||
@ -6272,7 +6275,7 @@ begin
|
|||||||
if NewSrc<>'' then
|
if NewSrc<>'' then
|
||||||
AddSrc:=NewSrc
|
AddSrc:=NewSrc
|
||||||
else
|
else
|
||||||
AddSrc:=GetIndentStr(Indent)+'{$R '+Filename+'}';
|
AddSrc:=Beauty.GetIndentStr(Indent)+'{$R '+Filename+'}';
|
||||||
if not SourceChangeCache.Replace(gtEmptyLine,gtEmptyLine,InsertPos,InsertPos,
|
if not SourceChangeCache.Replace(gtEmptyLine,gtEmptyLine,InsertPos,InsertPos,
|
||||||
AddSrc) then exit;
|
AddSrc) then exit;
|
||||||
if not SourceChangeCache.Apply then exit;
|
if not SourceChangeCache.Apply then exit;
|
||||||
@ -6368,7 +6371,7 @@ begin
|
|||||||
if NewSrc<>'' then
|
if NewSrc<>'' then
|
||||||
AddSrc:=NewSrc
|
AddSrc:=NewSrc
|
||||||
else
|
else
|
||||||
AddSrc:=GetIndentStr(Indent)+'{$I '+Filename+'}';
|
AddSrc:=Beauty.GetIndentStr(Indent)+'{$I '+Filename+'}';
|
||||||
if not SourceChangeCache.Replace(gtNewLine,gtNewLine,InsertPos,InsertPos,
|
if not SourceChangeCache.Replace(gtNewLine,gtNewLine,InsertPos,InsertPos,
|
||||||
AddSrc) then exit;
|
AddSrc) then exit;
|
||||||
if not SourceChangeCache.Apply then exit;
|
if not SourceChangeCache.Apply then exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user