diff --git a/components/codetools/codecompletiontool.pas b/components/codetools/codecompletiontool.pas index 897e09df2d..f8cdd3da4e 100644 --- a/components/codetools/codecompletiontool.pas +++ b/components/codetools/codecompletiontool.pas @@ -4092,7 +4092,8 @@ const NodeMovedFlag = 1; var NodeMoves: TCodeGraph;// an edge means, move the FromNode in front of the ToNode - + Beauty: TBeautifyCodeOptions; + procedure InitNodeMoves; begin if NodeMoves=nil then @@ -4147,8 +4148,7 @@ var if MoveNode then begin FromPos:=FindLineEndOrCodeInFrontOfPosition(Node.StartPos); ToPos:=FindLineEndOrCodeAfterPosition(Node.EndPos); - NodeSrc:=SourceChangeCache.BeautifyCodeOptions.GetIndentStr(Indent) - +Trim(copy(Src,FromPos,ToPos-FromPos)); + NodeSrc:=Beauty.GetIndentStr(Indent)+Trim(copy(Src,FromPos,ToPos-FromPos)); // remove if (Node.PriorBrother=nil) and (Node.Parent<>nil) and (Node.Parent.Desc in AllDefinitionSections) @@ -4252,6 +4252,7 @@ begin NodeMoves:=nil; Definitions:=nil; Graph:=nil; + Beauty:=SourceChangeCache.BeautifyCodeOptions; try // move the pointer types to the same type sections if not BuildUnitDefinitionGraph(Definitions,Graph,false) then exit; diff --git a/components/codetools/stdcodetools.pas b/components/codetools/stdcodetools.pas index 96a7907d05..089c805885 100644 --- a/components/codetools/stdcodetools.pas +++ b/components/codetools/stdcodetools.pas @@ -668,7 +668,7 @@ var end else begin // add new line Lines[Lines.Count-1]:=Line; - Line:=GetIndentStr(Indent)+NewUses; + Line:=Beauty.GetIndentStr(Indent)+NewUses; Lines.Add(Line); end; end; @@ -3909,6 +3909,8 @@ end; function TStandardCodeTool.ConvertDelphiToLazarusSource(AddLRSCode: boolean; SourceChangeCache: TSourceChangeCache): boolean; +var + Beauty: TBeautifyCodeOptions; function AddModeDelphiDirective: boolean; var @@ -4022,15 +4024,15 @@ function TStandardCodeTool.ConvertDelphiToLazarusSource(AddLRSCode: boolean; end; if Tree.Root.Desc=ctnUnit then begin InitializationNode:=FindInitializationNode; - NewCode:=GetIndentStr(SourceChangeCache.BeautifyCodeOptions.Indent) + NewCode:=Beauty.GetIndentStr(Beauty.Indent) +'{$i '+LRSFilename+'}'; if InitializationNode=nil then begin // add also an initialization section ImplementationNode:=FindImplementationNode; InsertPos:=ImplementationNode.EndPos; - NewCode:=SourceChangeCache.BeautifyCodeOptions.BeautifyKeyWord( + NewCode:=Beauty.BeautifyKeyWord( 'initialization') - +SourceChangeCache.BeautifyCodeOptions.LineEnd + +Beauty.LineEnd +NewCode; if not SourceChangeCache.Replace(gtEmptyLine,gtEmptyLine, InsertPos,InsertPos, @@ -4053,6 +4055,7 @@ begin Result:=false; if SourceChangeCache=nil then exit; SourceChangeCache.MainScanner:=Scanner; + Beauty:=SourceChangeCache.BeautifyCodeOptions; DebugLn('ConvertDelphiToLazarusSource AddModeDelphiDirective'); if not AddModeDelphiDirective then exit; DebugLn('ConvertDelphiToLazarusSource RemoveDFMResourceDirective'); @@ -6272,7 +6275,7 @@ begin if NewSrc<>'' then AddSrc:=NewSrc else - AddSrc:=GetIndentStr(Indent)+'{$R '+Filename+'}'; + AddSrc:=Beauty.GetIndentStr(Indent)+'{$R '+Filename+'}'; if not SourceChangeCache.Replace(gtEmptyLine,gtEmptyLine,InsertPos,InsertPos, AddSrc) then exit; if not SourceChangeCache.Apply then exit; @@ -6368,7 +6371,7 @@ begin if NewSrc<>'' then AddSrc:=NewSrc else - AddSrc:=GetIndentStr(Indent)+'{$I '+Filename+'}'; + AddSrc:=Beauty.GetIndentStr(Indent)+'{$I '+Filename+'}'; if not SourceChangeCache.Replace(gtNewLine,gtNewLine,InsertPos,InsertPos, AddSrc) then exit; if not SourceChangeCache.Apply then exit;