From 9d8f487e250c3ce6147bbe6b504bccb4014ca067 Mon Sep 17 00:00:00 2001 From: mattias Date: Thu, 3 Feb 2011 18:06:02 +0000 Subject: [PATCH] codetools: ctnClassInterface: do not add visibility nodes git-svn-id: trunk@29355 - --- components/codetools/codetree.pas | 15 +++++++++++++++ components/codetools/methodjumptool.pas | 13 ++++++++----- components/codetools/pascalparsertool.pas | 7 ------- ide/main.pp | 9 +++++---- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/components/codetools/codetree.pas b/components/codetools/codetree.pas index 29b843f03d..02d5a3f561 100644 --- a/components/codetools/codetree.pas +++ b/components/codetools/codetree.pas @@ -241,6 +241,7 @@ type function HasAsRoot(RootNode: TCodeTreeNode): boolean; function GetNodeOfType(ADesc: TCodeTreeNodeDesc): TCodeTreeNode; function GetNodeOfTypes(Descriptors: array of TCodeTreeNodeDesc): TCodeTreeNode; + function GetTopMostNodeOfType(ADesc: TCodeTreeNodeDesc): TCodeTreeNode; function GetFindContextParent: TCodeTreeNode; function GetLevel: integer; function DescAsString: string; @@ -744,6 +745,20 @@ begin end; end; +function TCodeTreeNode.GetTopMostNodeOfType(ADesc: TCodeTreeNodeDesc + ): TCodeTreeNode; +var + Node: TCodeTreeNode; +begin + Result:=nil; + Node:=Self; + while Node<>nil do begin + if Node.Desc=ADesc then + Result:=Node; + Node:=Node.Parent; + end; +end; + function TCodeTreeNode.GetFindContextParent: TCodeTreeNode; begin Result:=Parent; diff --git a/components/codetools/methodjumptool.pas b/components/codetools/methodjumptool.pas index 6dfd8fb94f..dbfb01962e 100644 --- a/components/codetools/methodjumptool.pas +++ b/components/codetools/methodjumptool.pas @@ -349,11 +349,14 @@ begin DebugLn('TMethodJumpingCodeTool.FindJumpPoint C ',NodeDescriptionAsString(CursorNode.Desc)); {$ENDIF} // first test if in a class - ClassNode:=CursorNode.GetNodeOfTypes([ctnClass,ctnObject, - ctnObjCClass,ctnObjCCategory,ctnCPPClass]); + ClassNode:=CursorNode.GetNodeOfTypes([ctnClass,ctnClassInterface, + ctnDispinterface,ctnObject,ctnObjCClass,ctnObjCCategory,ctnObjCProtocol, + ctnCPPClass]); if ClassNode<>nil then begin - // cursor is in class/object definition - // search in all implemented class procedures for the body + // cursor is in class/object/interface definition + // Interfaces have no method bodies, but if the class was refactored it has + // and then jumping is a nide feature + // => search in all implemented class procedures for the body {$IFDEF CTDEBUG} DebugLn('TMethodJumpingCodeTool.FindJumpPoint D ',NodeDescriptionAsString(ClassNode.Desc)); {$ENDIF} @@ -362,7 +365,7 @@ begin {$IFDEF CTDEBUG} DebugLn('TMethodJumpingCodeTool.FindJumpPoint E ',dbgs(CleanCursorPos),', |',copy(Src,CleanCursorPos,8)); {$ENDIF} - TypeSectionNode:=ClassNode.GetNodeOfType(ctnTypeSection); + TypeSectionNode:=ClassNode.GetTopMostNodeOfType(ctnTypeSection); // search the method node under the cursor CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true). GetNodeOfType(ctnProcedure); diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas index 2f05c63f76..1607c2bc06 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -3797,10 +3797,6 @@ begin ReadClassInheritance(true); end else UndoReadNextAtom; - // start the first class section (always published) - CreateChildNode; - CurNode.Desc:=ctnClassPublished; - CurNode.StartPos:=CurPos.EndPos; // behind 'class' including the space ReadNextAtom; if CurPos.Flag=cafEdgedBracketOpen then ReadGUID; @@ -3814,9 +3810,6 @@ begin end; ReadNextAtom; until false; - // end last class section (public, private, ...) - CurNode.EndPos:=CurPos.StartPos; - EndChildNode; end else begin // forward definition CurNode.SubDesc:=CurNode.SubDesc+ctnsForwardDeclaration; diff --git a/ide/main.pp b/ide/main.pp index 49dfa013b3..e03e4f9d84 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -970,7 +970,7 @@ type deprecated {$IFDEF VER2_5}'use method with EditorObject'{$ENDIF}; // deprecated in 0.9.29 March 2010 function SaveSourceEditorChangesToCodeCache(AEditor: TSourceEditorInterface): boolean; override; procedure ApplyCodeToolChanges; - procedure DoJumpToProcedureSection; + procedure DoJumpToOtherProcedureSection; procedure DoFindDeclarationAtCursor; procedure DoFindDeclarationAtCaret(const LogCaretXY: TPoint); function DoFindRenameIdentifier(Rename: boolean): TModalResult; @@ -3104,7 +3104,7 @@ begin ecFindProcedureDefinition, ecFindProcedureMethod: - DoJumpToProcedureSection; + DoJumpToOtherProcedureSection; ecFindDeclaration: DoFindDeclarationAtCursor; @@ -14522,7 +14522,7 @@ begin CodeToolBoss.SourceCache.ClearAllSourceLogEntries; end; -procedure TMainIDE.DoJumpToProcedureSection; +procedure TMainIDE.DoJumpToOtherProcedureSection; var ActiveSrcEdit: TSourceEditor; ActiveUnitInfo: TUnitInfo; NewSource: TCodeBuffer; @@ -14542,8 +14542,9 @@ begin begin DoJumpToCodePos(ActiveSrcEdit, ActiveUnitInfo, NewSource, NewX, NewY, NewTopLine, not RevertableJump); - end else + end else begin DoJumpToCodeToolBossError; + end; end; procedure TMainIDE.DoJumpToCodeToolBossError;