From 2e2ab0b2b384aaae30a0f77a735d3f6f20ee2d40 Mon Sep 17 00:00:00 2001 From: mattias Date: Tue, 12 Aug 2014 10:44:40 +0000 Subject: [PATCH] codetools: TSourceLog.GetLine: added parameter WithLineEnd git-svn-id: trunk@46039 - --- components/codetools/ccodeparsertool.pas | 2 +- components/codetools/ide/codyidentifiersdlg.pas | 2 +- components/codetools/ide/codynodeinfodlg.pas | 4 ++-- components/codetools/identcompletiontool.pas | 4 ++-- components/codetools/methodjumptool.pas | 2 +- components/codetools/sourcelog.pas | 16 ++++++++++------ debugger/assemblerdlg.pp | 2 +- ide/findrenameidentifier.pas | 2 +- ide/jumphistoryview.pas | 4 ++-- ide/main.pp | 4 ++-- ide/sourceeditprocs.pas | 2 +- 11 files changed, 24 insertions(+), 20 deletions(-) diff --git a/components/codetools/ccodeparsertool.pas b/components/codetools/ccodeparsertool.pas index 0a753aec45..67c986f3a2 100644 --- a/components/codetools/ccodeparsertool.pas +++ b/components/codetools/ccodeparsertool.pas @@ -668,7 +668,7 @@ var MergePos:=1; if not (chfmfIgnoreIncludes in Flags) then begin for i:=0 to Code.LineCount-1 do begin - Line:=Code.GetLine(i); + Line:=Code.GetLine(i,false); if length(Line)'#include' then continue; if not (Line[length('#include')+1] in [' ',#9]) then continue; diff --git a/components/codetools/ide/codyidentifiersdlg.pas b/components/codetools/ide/codyidentifiersdlg.pas index 6b23a2593e..afce5a3ad5 100644 --- a/components/codetools/ide/codyidentifiersdlg.pas +++ b/components/codetools/ide/codyidentifiersdlg.pas @@ -1318,7 +1318,7 @@ begin CurIdentStart:=0; CurIdentEnd:=0; if (CurCodePos.Code<>nil) then begin - Line:=CurCodePos.Code.GetLine(CurCodePos.Y-1); + Line:=CurCodePos.Code.GetLine(CurCodePos.Y-1,false); GetIdentStartEndAtPosition(Line,CurCodePos.X,CurIdentStart,CurIdentEnd); if CurIdentStartnil then begin for i:=0 to Code.LineCount-1 do begin - sl.Add('Line='+dbgs(i+1)+' Start='+dbgs(Code.GetLineStart(i))+' ="'+dbgstr(Code.GetLine(i))+'"'); + sl.Add('Line='+dbgs(i+1)+' Start='+dbgs(Code.GetLineStart(i))+' ="'+dbgstr(Code.GetLine(i,true))+'"'); end; end; CodeBufferMemo.Lines.Assign(sl); @@ -270,7 +270,7 @@ begin sl.Add('Node Src>>>>>>>>>>>>>>>>>>'); SrcCode:=TSourceLog.Create(copy(Tool.Src,Node.StartPos,Node.EndPos-Node.StartPos)); for i:=0 to SrcCode.LineCount-1 do begin - sl.Add('Line='+dbgs(i)+',CleanPos='+dbgs(Node.StartPos+SrcCode.GetLineStart(i)-1)+'="'+dbgstr(SrcCode.GetLine(i))+'"'); + sl.Add('Line='+dbgs(i)+',CleanPos='+dbgs(Node.StartPos+SrcCode.GetLineStart(i)-1)+'="'+dbgstr(SrcCode.GetLine(i,true))+'"'); end; SrcCode.Free; sl.Add('Node Src<<<<<<<<<<<<<<<<<<'); diff --git a/components/codetools/identcompletiontool.pas b/components/codetools/identcompletiontool.pas index 3c17e63898..e3ce49a7cd 100644 --- a/components/codetools/identcompletiontool.pas +++ b/components/codetools/identcompletiontool.pas @@ -1842,7 +1842,7 @@ begin if IgnoreErrorAfterValid then debugln([' IgnoreErrorAfter=',dbgs(IgnoreErrorAfter),' IgnoreErrorAfterCleanedPos=',IgnoreErrorAfterCleanedPos,' CleanPosIsAfterIgnorePos=',CleanPosIsAfterIgnorePos(CleanCursorPos)]); if CursorPos.Y<=CursorPos.Code.LineCount then - debugln([' Line=',dbgstr(CursorPos.Code.GetLine(CursorPos.Y-1),1,CursorPos.X-1),'|',dbgstr(CursorPos.Code.GetLine(CursorPos.Y-1),CursorPos.X,100)]); + debugln([' Line=',dbgstr(CursorPos.Code.GetLine(CursorPos.Y-1,true),1,CursorPos.X-1),'|',dbgstr(CursorPos.Code.GetLine(CursorPos.Y-1,true),CursorPos.X,100)]); CursorNode:=Tree.Root; if CursorNode=nil then begin debugln([' no nodes']); @@ -2057,7 +2057,7 @@ var cm: TCompilerMode; begin Result:=false; - Line:=CursorPos.Code.GetLine(CursorPos.Y-1); + Line:=CursorPos.Code.GetLine(CursorPos.Y-1,false); p:=1; while p<=length(Line) do begin p:=FindNextCompilerDirective(Line,p,Scanner.NestedComments); diff --git a/components/codetools/methodjumptool.pas b/components/codetools/methodjumptool.pas index 1b15c1d67c..138d7644fb 100644 --- a/components/codetools/methodjumptool.pas +++ b/components/codetools/methodjumptool.pas @@ -1107,7 +1107,7 @@ begin NewPos.X:=1; if Identifier<>'' then begin // there is an Identifier => search it in line - CurLine:=LinkCode.GetLine(SourceLine-1); + CurLine:=LinkCode.GetLine(SourceLine-1,false); EndPos:=1; while (EndPos<=length(CurLine)) do begin BasicCodeTools.ReadRawNextPascalAtom(CurLine,EndPos,StartPos, diff --git a/components/codetools/sourcelog.pas b/components/codetools/sourcelog.pas index c5ca8b350b..b580d8d95c 100644 --- a/components/codetools/sourcelog.pas +++ b/components/codetools/sourcelog.pas @@ -133,7 +133,7 @@ type Data: Pointer; LastError: string; function LineCount: integer; - function GetLine(Index: integer): string; // 0-based + function GetLine(Index: integer; WithLineEnd: boolean = true): string; // 0-based function GetLineLength(Index: integer): integer; // 0-based procedure GetLineRange(Index: integer; out LineRange: TLineRange); // 0-based function GetLineStart(Index: integer): integer; // 1-based @@ -362,15 +362,19 @@ begin Result:=fLineCount; end; -function TSourceLog.GetLine(Index: integer): string; +function TSourceLog.GetLine(Index: integer; WithLineEnd: boolean): string; var LineLen: integer; begin BuildLineRanges; if (Index>=0) and (Index0 then System.Move(fSource[fLineRanges[Index].StartPos],Result[1],LineLen); diff --git a/debugger/assemblerdlg.pp b/debugger/assemblerdlg.pp index e6ca3e8f89..93d2be9d6e 100644 --- a/debugger/assemblerdlg.pp +++ b/debugger/assemblerdlg.pp @@ -969,7 +969,7 @@ begin Editor := SourceEditorManager.SourceEditorIntfWithFilename(SrcFileName); if Editor <> nil then SrcLineNumber := Editor.DebugToSourceLine(SrcLineNumber); - Result := Trim(PasSource.GetLine(SrcLineNumber - 1)); + Result := Trim(PasSource.GetLine(SrcLineNumber - 1,false)); end; procedure TAssemblerDlg.UpdateLineData; diff --git a/ide/findrenameidentifier.pas b/ide/findrenameidentifier.pas index 29a1fc478f..29eedd6392 100644 --- a/ide/findrenameidentifier.pas +++ b/ide/findrenameidentifier.pas @@ -345,7 +345,7 @@ begin ANode:=TreeOfPCodeXYPosition.FindHighest; while ANode<>nil do begin CodePos:=PCodeXYPosition(ANode.Data); - CurLine:=TrimRight(CodePos^.Code.GetLine(CodePos^.Y-1)); + CurLine:=TrimRight(CodePos^.Code.GetLine(CodePos^.Y-1,false)); TrimmedLine:=Trim(CurLine); TrimCnt:=length(CurLine)-length(TrimmedLine); //debugln('ShowReferences x=',dbgs(CodePos^.x),' y=',dbgs(CodePos^.y),' ',CurLine); diff --git a/ide/jumphistoryview.pas b/ide/jumphistoryview.pas index 2cf07ac51f..4802e55fe8 100644 --- a/ide/jumphistoryview.pas +++ b/ide/jumphistoryview.pas @@ -139,9 +139,9 @@ begin for i := 0 to Project1.JumpHistory.Count -1 do begin jh_item := Project1.JumpHistory.Items[i]; SrcLine:=''; - CodeBuf:=CodeToolBoss.LoadFile(jh_item.Filename,false,False); + CodeBuf:=CodeToolBoss.LoadFile(jh_item.Filename,true,false); if CodeBuf<>nil then - SrcLine:=CodeBuf.GetLine(jh_item.CaretXY.Y-1); + SrcLine:=CodeBuf.GetLine(jh_item.CaretXY.Y-1,false); Filename:=jh_item.Filename; if Project1<>nil then Filename:=Project1.GetShortFilename(Filename,true); diff --git a/ide/main.pp b/ide/main.pp index 38431b3baf..350304e3d2 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -7351,7 +7351,7 @@ begin if Result<>mrOk then exit; if ActiveUnitInfo.Source.LineCount>0 then - FirstLine:=ActiveUnitInfo.Source.GetLine(0) + FirstLine:=ActiveUnitInfo.Source.GetLine(0,false) else FirstLine:=''; HasShebang:=copy(FirstLine,1,2)='#!'; @@ -9556,7 +9556,7 @@ begin SearchResultsView.BeginUpdate(SearchPageIndex.PageIndex); for i:=0 to ListOfPCodeXYPosition.Count-1 do begin CodePos:=PCodeXYPosition(ListOfPCodeXYPosition[i]); - CurLine:=TrimRight(CodePos^.Code.GetLine(CodePos^.Y-1)); + CurLine:=TrimRight(CodePos^.Code.GetLine(CodePos^.Y-1,false)); if CodePos^.X<=length(CurLine) then Identifier:=GetIdentifier(@CurLine[CodePos^.X]) else diff --git a/ide/sourceeditprocs.pas b/ide/sourceeditprocs.pas index 7cf1501b95..0112a0ed55 100644 --- a/ide/sourceeditprocs.pas +++ b/ide/sourceeditprocs.pas @@ -663,7 +663,7 @@ begin Result:=copy(Result,1,ProcModifierPos-1) +copy(Result,ProcModifierPos+9,length(Result)); StartContextPos:=CodeToolBoss.IdentifierList.StartContextPos; - Line:=StartContextPos.Code.GetLine(StartContextPos.Y-1); + Line:=StartContextPos.Code.GetLine(StartContextPos.Y-1,false); Indent:=StartContextPos.X; //debugln(['GetIdentCompletionValue ',Indent,' "',dbgstr(Line),'" ',GetLineIndent(Line,1),' empty=',InEmptyLine(Line,1),' ',DbgsCXY(StartContextPos)]); if not InEmptyLine(Line,1) then