codetools: searching top most type section

git-svn-id: trunk@29356 -
This commit is contained in:
mattias 2011-02-03 18:19:48 +00:00
parent 9d8f487e25
commit e2de6ffbef
3 changed files with 9 additions and 25 deletions

View File

@ -4820,7 +4820,7 @@ begin
ClassProcs:=nil;
try
// gather body nodes
TypeSectionNode:=CodeCompleteClassNode.GetNodeOfType(ctnTypeSection);
TypeSectionNode:=CodeCompleteClassNode.GetTopMostNodeOfType(ctnTypeSection);
ProcBodyNodes:=GatherProcNodes(TypeSectionNode,
[phpInUpperCase,phpIgnoreForwards,phpOnlyWithClassname],
ExtractClassName(CodeCompleteClassNode,true));
@ -6415,7 +6415,7 @@ var
procedure GatherExistingClassProcBodies;
begin
TypeSectionNode:=CodeCompleteClassNode.GetNodeOfType(ctnTypeSection);
TypeSectionNode:=CodeCompleteClassNode.GetTopMostNodeOfType(ctnTypeSection);
ClassProcs:=nil;
ProcBodyNodes:=GatherProcNodes(TypeSectionNode,
[phpInUpperCase,phpIgnoreForwards,phpOnlyWithClassname],
@ -6616,10 +6616,7 @@ var
StartSearchProc:=ImplementationNode.FirstChild;
end else begin
// class is not in interface section
StartSearchProc:=CodeCompleteClassNode;
while (StartSearchProc.Parent<>nil)
and (StartSearchProc.Desc<>ctnTypeSection) do
StartSearchProc:=StartSearchProc.Parent;
StartSearchProc:=CodeCompleteClassNode.GetTopMostNodeOfType(ctnTypeSection);
end;
case ASourceChangeCache.BeautifyCodeOptions.ForwardProcBodyInsertPolicy of
fpipInFrontOfMethods:
@ -6913,7 +6910,6 @@ var
OldCodePos: TCodePosition;
CursorNode: TCodeTreeNode;
CurClassName: String;
ANode: TCodeTreeNode;
ProcNode: TCodeTreeNode;
begin
Result:=false;
@ -6941,22 +6937,12 @@ begin
CursorNode:=FindDeepestNodeAtPos(CleanPos,true);
// due to insertions in front of the class, the cursor position could
// have changed
while (CursorNode<>nil) do begin
if (CursorNode.Desc=ctnTypeSection)
or ((CursorNode.Parent<>nil) and (CursorNode.Parent.Desc=ctnTypeSection))
then break;
CursorNode:=CursorNode.Parent;
end;
if CursorNode<>nil then
CursorNode:=CursorNode.GetTopMostNodeOfType(ctnTypeSection);
FCodeCompleteClassNode:=FindClassNode(CursorNode,CurClassName,true,false);
if CodeCompleteClassNode=nil then
RaiseException('oops, I lost your class');
ANode:=CodeCompleteClassNode.GetNodeOfTypes(
[ctnTypeDefinition,ctnGenericType]);
if ANode=nil then
RaiseException(ctsClassNodeWithoutParentNode);
if (ANode.Parent<>nil) and (ANode.Parent.Desc=ctnTypeSection) then
ANode:=ANode.Parent;
ProcNode:=FindProcNode(ANode,FJumpToProcName,
ProcNode:=FindProcNode(CursorNode,FJumpToProcName,
[phpInUpperCase,phpIgnoreForwards]);
if ProcNode=nil then
RaiseException(ctsNewProcBodyNotFound);

View File

@ -563,10 +563,7 @@ begin
DebugLn('TMethodJumpingCodeTool.FindJumpPoint 4F ');
{$ENDIF}
// gather method bodies
TypeSectionNode:=ClassNode.Parent;
if (TypeSectionNode<>nil) and (TypeSectionNode.Parent<>nil)
and (TypeSectionNode.Parent.Desc=ctnTypeSection) then
TypeSectionNode:=TypeSectionNode.Parent;
TypeSectionNode:=ClassNode.GetTopMostNodeOfType(ctnTypeSection);
SearchForNodes:=GatherProcNodes(TypeSectionNode,
[phpInUpperCase,phpIgnoreForwards,phpOnlyWithClassname],
ExtractClassName(ClassNode,true));

View File

@ -654,7 +654,7 @@ begin
if ClassNode<>nil then begin
//debugln('TPascalReaderTool.FindCorrespondingProcNode Class');
// in a class definition -> search method body
StartNode:=ClassNode.GetNodeOfType(ctnTypeSection)
StartNode:=ClassNode.GetTopMostNodeOfType(ctnTypeSection)
end else if NodeIsMethodBody(ProcNode) then begin
//debugln('TPascalReaderTool.FindCorrespondingProcNode Method ',ExtractClassNameOfProcNode(ProcNode));
// in a method body -> search in class
@ -1863,6 +1863,7 @@ end;
function TPascalReaderTool.NodeIsIdentifierInInterface(Node: TCodeTreeNode
): boolean;
// true if identifier is visible from other units (without prefixing)
begin
case Node.Desc of
ctnEnumIdentifier: