mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 00:59:31 +02:00
codetools: TSourceLog.GetLine: added parameter WithLineEnd
git-svn-id: trunk@46039 -
This commit is contained in:
parent
79cefdc9de
commit
2e2ab0b2b3
@ -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)<length('#include')+2 then continue;
|
||||
if copy(Line,1,length('#include'))<>'#include' then continue;
|
||||
if not (Line[length('#include')+1] in [' ',#9]) then continue;
|
||||
|
@ -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 CurIdentStart<CurIdentEnd then
|
||||
CurIdentifier:=copy(Line,CurIdentStart,CurIdentEnd-CurIdentStart);
|
||||
|
@ -199,7 +199,7 @@ begin
|
||||
sl:=TStringList.Create;
|
||||
if Code<>nil 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<<<<<<<<<<<<<<<<<<');
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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 (Index<fLineCount) then begin
|
||||
if Index<fLineCount-1 then
|
||||
LineLen:=fLineRanges[Index+1].StartPos-fLineRanges[Index].StartPos
|
||||
else
|
||||
LineLen:=fSrcLen-fLineRanges[Index].StartPos+1;
|
||||
if WithLineEnd then begin
|
||||
if Index<fLineCount-1 then
|
||||
LineLen:=fLineRanges[Index+1].StartPos-fLineRanges[Index].StartPos
|
||||
else
|
||||
LineLen:=fSrcLen-fLineRanges[Index].StartPos+1;
|
||||
end else begin
|
||||
LineLen:=fLineRanges[Index].EndPos-fLineRanges[Index].StartPos
|
||||
end;
|
||||
SetLength(Result,LineLen);
|
||||
if LineLen>0 then
|
||||
System.Move(fSource[fLineRanges[Index].StartPos],Result[1],LineLen);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user