mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 00:19:22 +02:00
improved phpAddClassName and fixed consistency error in msgview
git-svn-id: trunk@8817 -
This commit is contained in:
parent
f5b827c8f7
commit
7ce27416cc
@ -344,21 +344,18 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
IsProcType:=(ProcNode.Desc=ctnProcedureType);
|
IsProcType:=(ProcNode.Desc=ctnProcedureType);
|
||||||
if (phpAddClassname in Attr) then begin
|
if (phpAddClassname in Attr) then begin
|
||||||
TypeDefNode:=ProcNode.Parent;
|
TheClassName:='';
|
||||||
if TypeDefNode=nil then exit;
|
TypeDefNode:=ProcNode.GetNodeOfType(ctnClass);
|
||||||
TypeDefNode:=TypeDefNode.Parent;
|
if TypeDefNode<>nil then begin
|
||||||
if (TypeDefNode=nil) or (TypeDefNode.Desc<>ctnClass) then exit;
|
TypeDefNode:=TypeDefNode.GetNodeOfType(ctnTypeDefinition);
|
||||||
TypeDefNode:=TypeDefNode.Parent;
|
if TypeDefNode<>nil then begin
|
||||||
if TypeDefNode.Desc=ctnGenericType then begin
|
|
||||||
TypeDefNode:=TypeDefNode.Parent;
|
|
||||||
if TypeDefNode=nil then exit;
|
|
||||||
end;
|
|
||||||
if TypeDefNode.Desc<>ctnTypeDefinition then exit;
|
|
||||||
MoveCursorToCleanPos(TypeDefNode.StartPos);
|
MoveCursorToCleanPos(TypeDefNode.StartPos);
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
if not AtomIsIdentifier(false) then exit;
|
if not AtomIsIdentifier(false) then exit;
|
||||||
TheClassName:=GetAtom;
|
TheClassName:=GetAtom;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
InitExtraction;
|
InitExtraction;
|
||||||
// reparse the clean source
|
// reparse the clean source
|
||||||
MoveCursorToNodeStart(ProcNode);
|
MoveCursorToNodeStart(ProcNode);
|
||||||
@ -394,7 +391,7 @@ begin
|
|||||||
ExtractNextAtom(not (phpWithoutName in Attr),Attr);
|
ExtractNextAtom(not (phpWithoutName in Attr),Attr);
|
||||||
end else begin
|
end else begin
|
||||||
// read name
|
// read name
|
||||||
if not (phpAddClassname in Attr) then begin
|
if (not (phpAddClassname in Attr)) or (TheClassName='') then begin
|
||||||
ExtractNextAtom(not (phpWithoutName in Attr),Attr);
|
ExtractNextAtom(not (phpWithoutName in Attr),Attr);
|
||||||
end else begin
|
end else begin
|
||||||
// add class name
|
// add class name
|
||||||
@ -540,7 +537,7 @@ var CurProcHead: string;
|
|||||||
begin
|
begin
|
||||||
Result:=StartNode;
|
Result:=StartNode;
|
||||||
while (Result<>nil) do begin
|
while (Result<>nil) do begin
|
||||||
//DebugLn('TPascalParserTool.FindProcNode A "',NodeDescriptionAsString(Result.Desc),'"');
|
//DebugLn('TPascalReaderTool.FindProcNode A "',NodeDescriptionAsString(Result.Desc),'"');
|
||||||
if Result.Desc=ctnProcedure then begin
|
if Result.Desc=ctnProcedure then begin
|
||||||
if (not ((phpIgnoreForwards in Attr)
|
if (not ((phpIgnoreForwards in Attr)
|
||||||
and ((Result.SubDesc and ctnsForwardDeclaration)>0)))
|
and ((Result.SubDesc and ctnsForwardDeclaration)>0)))
|
||||||
@ -548,7 +545,7 @@ begin
|
|||||||
and (FindProcBody(Result)<>nil))) then
|
and (FindProcBody(Result)<>nil))) then
|
||||||
begin
|
begin
|
||||||
CurProcHead:=ExtractProcHead(Result,Attr);
|
CurProcHead:=ExtractProcHead(Result,Attr);
|
||||||
//DebugLn('TPascalParserTool.FindProcNode B "',CurProcHead,'" =? "',AProcHead,'"');
|
//DebugLn('TPascalReaderTool.FindProcNode B "',CurProcHead,'" =? "',AProcHead,'"');
|
||||||
if (CurProcHead<>'')
|
if (CurProcHead<>'')
|
||||||
and (CompareTextIgnoringSpace(CurProcHead,AProcHead,false)=0) then
|
and (CompareTextIgnoringSpace(CurProcHead,AProcHead,false)=0) then
|
||||||
exit;
|
exit;
|
||||||
@ -568,7 +565,7 @@ var
|
|||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
// get ctnProcedure
|
// get ctnProcedure
|
||||||
//debugln('TPascalReaderTool.FindCorrespondingProcNode A');
|
//debugln('TPascalReaderTool.FindCorrespondingProcNode Start');
|
||||||
if (ProcNode=nil) then exit;
|
if (ProcNode=nil) then exit;
|
||||||
if ProcNode.Desc=ctnProcedureHead then begin
|
if ProcNode.Desc=ctnProcedureHead then begin
|
||||||
ProcNode:=ProcNode.Parent;
|
ProcNode:=ProcNode.Parent;
|
||||||
@ -577,14 +574,14 @@ begin
|
|||||||
if ProcNode.Desc<>ctnProcedure then exit;
|
if ProcNode.Desc<>ctnProcedure then exit;
|
||||||
|
|
||||||
// check proc kind
|
// check proc kind
|
||||||
//debugln('TPascalReaderTool.FindCorrespondingProcNode B');
|
//debugln('TPascalReaderTool.FindCorrespondingProcNode Check kind');
|
||||||
ClassNode:=ProcNode.GetNodeOfType(ctnClass);
|
ClassNode:=ProcNode.GetNodeOfType(ctnClass);
|
||||||
if ClassNode<>nil then begin
|
if ClassNode<>nil then begin
|
||||||
//debugln('TPascalReaderTool.FindCorrespondingProcNode C');
|
//debugln('TPascalReaderTool.FindCorrespondingProcNode Class');
|
||||||
// in a class definition -> search method body
|
// in a class definition -> search method body
|
||||||
StartNode:=ClassNode.GetNodeOfType(ctnTypeSection)
|
StartNode:=ClassNode.GetNodeOfType(ctnTypeSection)
|
||||||
end else if NodeIsMethodBody(ProcNode) then begin
|
end else if NodeIsMethodBody(ProcNode) then begin
|
||||||
//debugln('TPascalReaderTool.FindCorrespondingProcNode D');
|
//debugln('TPascalReaderTool.FindCorrespondingProcNode Method');
|
||||||
// in a method body -> search class
|
// in a method body -> search class
|
||||||
StartNode:=FindClassNodeInUnit(ExtractClassNameOfProcNode(ProcNode),true,
|
StartNode:=FindClassNodeInUnit(ExtractClassNameOfProcNode(ProcNode),true,
|
||||||
false,false,true);
|
false,false,true);
|
||||||
@ -592,16 +589,18 @@ begin
|
|||||||
while (StartNode<>nil)
|
while (StartNode<>nil)
|
||||||
and (StartNode.Desc in [ctnClass,ctnClassInterface]+AllClassSections) do
|
and (StartNode.Desc in [ctnClass,ctnClassInterface]+AllClassSections) do
|
||||||
StartNode:=StartNode.FirstChild;
|
StartNode:=StartNode.FirstChild;
|
||||||
//debugln('TPascalReaderTool.FindCorrespondingProcNode D2 ',StartNode.DescAsString);
|
end else begin
|
||||||
end else
|
//DebugLn('TPascalReaderTool.FindCorrespondingProcNode Normal');
|
||||||
// else: search on same lvl
|
// else: search on same lvl
|
||||||
StartNode:=FindFirstNodeOnSameLvl(ProcNode);
|
StartNode:=FindFirstNodeOnSameLvl(ProcNode);
|
||||||
|
end;
|
||||||
if StartNode=nil then exit;
|
if StartNode=nil then exit;
|
||||||
|
|
||||||
//debugln('TPascalReaderTool.FindCorrespondingProcNode E');
|
//debugln('TPascalReaderTool.FindCorrespondingProcNode StartNode=',StartNode.DescAsString);
|
||||||
ProcHead:=ExtractProcHead(ProcNode,Attr);
|
ProcHead:=ExtractProcHead(ProcNode,Attr);
|
||||||
Result:=FindProcNode(StartNode,ProcHead,Attr);
|
Result:=FindProcNode(StartNode,ProcHead,Attr);
|
||||||
if Result=ProcNode then begin
|
if Result=ProcNode then begin
|
||||||
|
// found itself -> search further
|
||||||
StartNode:=FindNextNodeOnSameLvl(Result);
|
StartNode:=FindNextNodeOnSameLvl(Result);
|
||||||
Result:=FindProcNode(StartNode,ProcHead,Attr);
|
Result:=FindProcNode(StartNode,ProcHead,Attr);
|
||||||
end;
|
end;
|
||||||
|
@ -84,6 +84,9 @@ begin
|
|||||||
then begin
|
then begin
|
||||||
LazarusIDE.DoJumpToCodeToolBossError;
|
LazarusIDE.DoJumpToCodeToolBossError;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// message fixed
|
||||||
|
Msg.Msg:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetMsgLineFilename(Msg: TIDEMessageLine; out CodeBuf: TCodeBuffer
|
function GetMsgLineFilename(Msg: TIDEMessageLine; out CodeBuf: TCodeBuffer
|
||||||
|
@ -119,6 +119,7 @@ type
|
|||||||
function FindNextItem(const Filename: string;
|
function FindNextItem(const Filename: string;
|
||||||
FirstLine, LineCount: integer): TAVLTreeNode;
|
FirstLine, LineCount: integer): TAVLTreeNode;
|
||||||
procedure UpdateMsgSrcPos(Line: TLazMessageLine);
|
procedure UpdateMsgSrcPos(Line: TLazMessageLine);
|
||||||
|
procedure ConsistencyCheck;
|
||||||
public
|
public
|
||||||
constructor Create(TheOwner: TComponent); override;
|
constructor Create(TheOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -348,6 +349,7 @@ begin
|
|||||||
if Line.VisiblePosition > VisibleIndex then
|
if Line.VisiblePosition > VisibleIndex then
|
||||||
Line.VisiblePosition:=Line.VisiblePosition-1;
|
Line.VisiblePosition:=Line.VisiblePosition-1;
|
||||||
end;
|
end;
|
||||||
|
//ConsistencyCheck;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -375,7 +377,7 @@ begin
|
|||||||
|
|
||||||
NewMsg.Msg := Msg;
|
NewMsg.Msg := Msg;
|
||||||
NewMsg.Directory := CurDir;
|
NewMsg.Directory := CurDir;
|
||||||
NewMsg.Position := FItems.Count;
|
NewMsg.Position := FItems.Count-1;
|
||||||
NewMsg.OriginalIndex := OriginalIndex;
|
NewMsg.OriginalIndex := OriginalIndex;
|
||||||
//DebugLn('TMessagesView.Add FItems.Count=',dbgs(FItems.Count),' OriginalIndex=',dbgs(OriginalIndex));
|
//DebugLn('TMessagesView.Add FItems.Count=',dbgs(FItems.Count),' OriginalIndex=',dbgs(OriginalIndex));
|
||||||
|
|
||||||
@ -397,6 +399,7 @@ begin
|
|||||||
FLastLineIsProgress := ProgressLine;
|
FLastLineIsProgress := ProgressLine;
|
||||||
MessageListBox.TopIndex := MessageListBox.Items.Count - 1;
|
MessageListBox.TopIndex := MessageListBox.Items.Count - 1;
|
||||||
end;
|
end;
|
||||||
|
//ConsistencyCheck;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMessagesView.AddMsg(const Msg, CurDir: string; OriginalIndex: integer);
|
procedure TMessagesView.AddMsg(const Msg, CurDir: string; OriginalIndex: integer);
|
||||||
@ -809,6 +812,7 @@ const
|
|||||||
cLeftSpacer = 3;
|
cLeftSpacer = 3;
|
||||||
begin
|
begin
|
||||||
MessageListBox.Canvas.FillRect(ARect);
|
MessageListBox.Canvas.FillRect(ARect);
|
||||||
|
//DebugLn('TMessagesView.MessageViewDrawItem Index=',dbgs(Index),' Count=',dbgs(MessageListBox.Items.Count));
|
||||||
TheText := MessageListBox.Items[Index];
|
TheText := MessageListBox.Items[Index];
|
||||||
|
|
||||||
cl := MessageListBox.Canvas.Font.Color; // save original color
|
cl := MessageListBox.Canvas.Font.Color; // save original color
|
||||||
@ -863,10 +867,19 @@ begin
|
|||||||
QuickFixItem:=TIDEMsgQuickFixItem(FQuickFixItems[i]);
|
QuickFixItem:=TIDEMsgQuickFixItem(FQuickFixItems[i]);
|
||||||
if (QuickFixItem.Caption=(Sender as TIDEMenuItem).Caption)
|
if (QuickFixItem.Caption=(Sender as TIDEMenuItem).Caption)
|
||||||
and (imqfoMenuItem in QuickFixItem.Steps) then begin
|
and (imqfoMenuItem in QuickFixItem.Steps) then begin
|
||||||
|
//ConsistencyCheck;
|
||||||
|
DebugLn('TMessagesView.OnQuickFixClick ',Msg.Msg,' ',dbgs(Msg.VisiblePosition),' ',dbgs(Msg.Position),' ',Items[Msg.Position].Msg);
|
||||||
QuickFixItem.Execute(Msg,imqfoMenuItem);
|
QuickFixItem.Execute(Msg,imqfoMenuItem);
|
||||||
|
if Msg.Msg='' then begin
|
||||||
|
// messages fixed -> delete
|
||||||
|
DebugLn('TMessagesView.OnQuickFixClick ',dbgs(Msg.VisiblePosition),' ',dbgs(Msg.Position));
|
||||||
|
DeleteLine(Msg.Position);
|
||||||
|
end else begin
|
||||||
UpdateMsgSrcPos(Msg);
|
UpdateMsgSrcPos(Msg);
|
||||||
UpdateMsgLineInListBox(Msg);
|
UpdateMsgLineInListBox(Msg);
|
||||||
end;
|
end;
|
||||||
|
//ConsistencyCheck;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -939,6 +952,29 @@ begin
|
|||||||
Line.Node:=FSrcPositions.Add(Line);
|
Line.Node:=FSrcPositions.Add(Line);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMessagesView.ConsistencyCheck;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
Line: TLazMessageLine;
|
||||||
|
begin
|
||||||
|
if FSrcPositions.ConsistencyCheck<>0 then
|
||||||
|
RaiseGDBException('TMessagesView.ConsistencyCheck FSrcPositions.ConsistencyCheck');
|
||||||
|
for i:=0 to FItems.Count-1 do begin
|
||||||
|
Line:=Items[i];
|
||||||
|
if Line.Position<>i then
|
||||||
|
RaiseGDBException('TMessagesView.ConsistencyCheck i='+dbgs(i)+' "'+Line.Msg+'" Position='+dbgs(Line.Position));
|
||||||
|
if (Line.VisiblePosition>=0) and (VisibleItems[Line.VisiblePosition]<>Line) then
|
||||||
|
RaiseGDBException('TMessagesView.ConsistencyCheck i='+dbgs(i)+' "'+Line.Msg+'" VisiblePosition='+dbgs(Line.VisiblePosition)+' '+VisibleItems[Line.VisiblePosition].Msg);
|
||||||
|
if (Line.VisiblePosition>=0) and (MessageListBox.Items[Line.VisiblePosition]<>Line.Msg) then
|
||||||
|
RaiseGDBException('TMessagesView.ConsistencyCheck i='+dbgs(i)+' "'+Line.Msg+'" VisiblePosition='+dbgs(Line.VisiblePosition)+' Listbox="'+MessageListBox.Items[Line.VisiblePosition]+'"');
|
||||||
|
end;
|
||||||
|
for i:=0 to FVisibleItems.Count-1 do begin
|
||||||
|
Line:=VisibleItems[i];
|
||||||
|
if (Line.VisiblePosition<>i) then
|
||||||
|
RaiseGDBException('TMessagesView.ConsistencyCheck Visible i='+dbgs(i)+' "'+Line.Msg+'" VisiblePosition='+dbgs(Line.VisiblePosition));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TMessagesView.FindNextItem(const Filename: string; FirstLine,
|
function TMessagesView.FindNextItem(const Filename: string; FirstLine,
|
||||||
LineCount: integer): TAVLTreeNode;
|
LineCount: integer): TAVLTreeNode;
|
||||||
var
|
var
|
||||||
|
Loading…
Reference in New Issue
Block a user