From dbdbd492a7cd2cb25ef1ab5695acb31427e75138 Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 16 Feb 2008 20:28:28 +0000 Subject: [PATCH] codetools: fixed remvong redefinitions of connected sections git-svn-id: trunk@14163 - --- components/codetools/codecompletiontool.pas | 12 +++++++----- components/h2pas/h2pasconvert.pas | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/components/codetools/codecompletiontool.pas b/components/codetools/codecompletiontool.pas index 3499882797..42ff9e6b90 100644 --- a/components/codetools/codecompletiontool.pas +++ b/components/codetools/codecompletiontool.pas @@ -1752,6 +1752,7 @@ begin AVLNode:=TreeOfCodeTreeNodeExt.FindLowest; while AVLNode<>nil do begin Node:=TCodeTreeNodeExtension(AVLNode.Data).Node; + DebugLn(['TCodeCompletionCodeTool.RemoveRedefinitions AAA1 ',GetRedefinitionNodeText(Node)]); NodesToDo.Add(Node); AVLNode:=TreeOfCodeTreeNodeExt.FindSuccessor(AVLNode); end; @@ -1760,7 +1761,7 @@ begin while NodesToDo.Count>0 do begin // find a block of redefinitions StartNode:=TCodeTreeNode(NodesToDo.Root.Data); - //DebugLn(['TCodeCompletionCodeTool.RemoveRedefinitions ',StartNode.StartPos,' ',GetRedefinitionNodeText(StartNode)]); + DebugLn(['TCodeCompletionCodeTool.RemoveRedefinitions ',StartNode.StartPos,' ',GetRedefinitionNodeText(StartNode)]); EndNode:=StartNode; while (StartNode.PriorBrother<>nil) and (NodesToDo.Find(StartNode.PriorBrother)<>nil) do @@ -1768,10 +1769,10 @@ begin while (EndNode.NextBrother<>nil) and (NodesToDo.Find(EndNode.NextBrother)<>nil) do EndNode:=EndNode.NextBrother; - //DebugLn(['TCodeCompletionCodeTool.RemoveRedefinitions Start=',StartNode.StartPos,' ',GetRedefinitionNodeText(StartNode),' End=',EndNode.StartPos,' ',GetRedefinitionNodeText(EndNode)]); + DebugLn(['TCodeCompletionCodeTool.RemoveRedefinitions Start=',StartNode.StartPos,' ',GetRedefinitionNodeText(StartNode),' End=',EndNode.StartPos,' ',GetRedefinitionNodeText(EndNode)]); // check if a whole section is deleted - if (StartNode.PriorBrother=nil) and (EndNode.PriorBrother=nil) + if (StartNode.PriorBrother=nil) and (EndNode.NextBrother=nil) and (StartNode.Parent<>nil) and (StartNode.Parent.Desc in AllDefinitionSections) then begin StartNode:=StartNode.Parent; @@ -1789,8 +1790,9 @@ begin // a,delete, delete: char; -> a: char; // delete,delete,c: char; -> c: char; // a,delete,delete,c: char; -> a,c:char; - IsListStart:=(StartNode.PriorBrother<>nil) - and (StartNode.PriorBrother.FirstChild<>nil); + IsListStart:=(StartNode.PriorBrother=nil) + or ((StartNode.PriorBrother<>nil) + and (StartNode.PriorBrother.FirstChild<>nil)); IsListEnd:=(EndNode.FirstChild<>nil); if IsListStart and IsListEnd then begin // case 1: delete, delete: char; -> delete whole diff --git a/components/h2pas/h2pasconvert.pas b/components/h2pas/h2pasconvert.pas index 35787a4066..f670255713 100644 --- a/components/h2pas/h2pasconvert.pas +++ b/components/h2pas/h2pasconvert.pas @@ -4316,7 +4316,7 @@ var if IdentifierIsDefined(@Tool.Src[Position+Level]) then break; inc(Level); end; - DebugLn(['CheckIdentifier ',GetIdentifier(Identifier),' Level=',Level]); + //DebugLn(['CheckIdentifier ',GetIdentifier(Identifier),' Level=',Level]); if Level=0 then begin // the identifier is defined exit;