diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index d25bf3eb11..13b0adad0a 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -666,6 +666,8 @@ type var ListOfPCodeXYPosition: TList): boolean; function FindReferences(const CursorPos: TCodeXYPosition; SkipComments: boolean; var ListOfPCodeXYPosition: TList): boolean; + function CleanPosIsDeclaration(CleanPos: integer; + Node: TCodeTreeNode): boolean; function JumpToNode(ANode: TCodeTreeNode; var NewPos: TCodeXYPosition; var NewTopLine: integer; @@ -991,32 +993,6 @@ var CleanCursorPos: integer; end; end; - function CursorOnDeclaration: boolean; - - function InNodeIdentifier: boolean; - var - IdentStartPos, IdentEndPos: integer; - begin - GetIdentStartEndAtPosition(Src,CleanCursorPos,IdentStartPos,IdentEndPos); - if (IdentEndPos>IdentStartPos) and (IdentStartPos=CursorNode.StartPos) - then begin - NewTool:=Self; - NewNode:=CursorNode; - Result:=JumpToNode(CursorNode,NewPos,NewTopLine,false); - end; - end; - - begin - Result:=false; - if CursorNode=nil then exit; - if (CursorNode.Desc in AllIdentifierDefinitions) then begin - if NodeIsForwardDeclaration(CursorNode) then exit; - Result:=InNodeIdentifier; - end else if (CursorNode.Desc=ctnProcedureHead) then begin - Result:=InNodeIdentifier; - end; - end; - var CleanPosInFront: integer; CursorAtIdentifier: boolean; @@ -1039,10 +1015,14 @@ begin {$ENDIF} // find CodeTreeNode at cursor if (Tree.Root<>nil) and (Tree.Root.StartPos<=CleanCursorPos) then begin - CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true); - if (fsfFindMainDeclaration in SearchSmartFlags) and CursorOnDeclaration + CursorNode:=BuildSubTreeAndFindDeepestNodeAtPos(Tree.Root,CleanCursorPos, + true); + if (fsfFindMainDeclaration in SearchSmartFlags) + and CleanPosIsDeclaration(CleanCursorPos,CursorNode) then begin - Result:=true; + NewTool:=Self; + NewNode:=CursorNode; + Result:=JumpToNode(CursorNode,NewPos,NewTopLine,false); exit; end; CleanPosInFront:=CursorNode.StartPos; @@ -2981,31 +2961,6 @@ var //debugln('TFindDeclarationTool.FindReferences.AddCodePosition line=',dbgs(NewCodePos.Y),' col=',dbgs(NewCodePos.X)); end; - function CursorOnDeclaration: boolean; - - function InNodeIdentifier: boolean; - var - IdentStartPos, IdentEndPos: integer; - begin - GetIdentStartEndAtPosition(Src,StartPos,IdentStartPos,IdentEndPos); - //debugln('InNodeIdentifier ',dbgs(StartPos),' ',dbgs(IdentStartPos),' ',dbgs(IdentEndPos),' ',dbgs(CursorNode.StartPos)); - if (IdentEndPos>IdentStartPos) and (IdentStartPos=CursorNode.StartPos) - then begin - Result:=true; - end; - end; - - begin - Result:=false; - if CursorNode=nil then exit; - if (CursorNode.Desc in AllIdentifierDefinitions) then begin - if NodeIsForwardDeclaration(CursorNode) then exit; - Result:=InNodeIdentifier; - end else if (CursorNode.Desc=ctnProcedureHead) then begin - Result:=InNodeIdentifier; - end; - end; - begin Result:=false; ListOfPCodeXYPosition:=nil; @@ -3047,7 +3002,7 @@ begin if (DeclarationTool=Self) and (StartPos=CleanDeclCursorPos) then // declaration itself found AddReference - else if CursorOnDeclaration then + else if CleanPosIsDeclaration(StartPos,CursorNode) then // this identifier is another declaration with the same name else begin // find declaration @@ -3098,6 +3053,54 @@ begin Result:=true; end; +{------------------------------------------------------------------------------- + function TFindDeclarationTool.CleanPosIsDeclaration(CleanPos: integer; + Node: TCodeTreeNode): boolean; + + Node should be the deepest node at CleanPos, and all sub trees built. + See BuildSubTree +-------------------------------------------------------------------------------} +function TFindDeclarationTool.CleanPosIsDeclaration(CleanPos: integer; + Node: TCodeTreeNode): boolean; + + function InNodeIdentifier: boolean; + var + IdentStartPos, IdentEndPos: integer; + NodeIdentStartPos: Integer; + begin + NodeIdentStartPos:=Node.StartPos; + if Node.Desc in [ctnProperty,ctnGlobalProperty] then begin + if not MoveCursorToPropName(Node) then exit; + NodeIdentStartPos:=CurPos.StartPos; + end; + GetIdentStartEndAtPosition(Src,CleanPos,IdentStartPos,IdentEndPos); + if (IdentEndPos>IdentStartPos) and (IdentStartPos=NodeIdentStartPos) + then begin + Result:=true; + end; + end; + +begin + Result:=false; + if Node=nil then exit; + case Node.Desc of + + ctnTypeDefinition,ctnVarDefinition,ctnConstDefinition: + begin + if NodeIsForwardDeclaration(Node) then exit; + Result:=InNodeIdentifier; + end; + + ctnProcedureHead, ctnProperty, ctnGlobalProperty: + Result:=InNodeIdentifier; + + ctnBeginBlock,ctnClass,ctnProcedure: + if (Node.SubDesc and ctnsForwardDeclaration)>0 then + RaiseException('TFindDeclarationTool.CleanPosIsDeclaration Node not expanded'); + + end; +end; + function TFindDeclarationTool.JumpToNode(ANode: TCodeTreeNode; var NewPos: TCodeXYPosition; var NewTopLine: integer; IgnoreJumpCentered: boolean): boolean; diff --git a/components/codetools/pascalreadertool.pas b/components/codetools/pascalreadertool.pas index d404f5a259..f5f16897c4 100644 --- a/components/codetools/pascalreadertool.pas +++ b/components/codetools/pascalreadertool.pas @@ -63,6 +63,7 @@ type function ExtractPropType(PropNode: TCodeTreeNode; InUpperCase, EmptyIfIndexed: boolean): string; function MoveCursorToPropType(PropNode: TCodeTreeNode): boolean; + function MoveCursorToPropName(PropNode: TCodeTreeNode): boolean; function ExtractPropName(PropNode: TCodeTreeNode; InUpperCase: boolean): string; function ExtractProperty(PropNode: TCodeTreeNode; @@ -642,6 +643,22 @@ begin AtomIsIdentifier(true); end; +function TPascalReaderTool.MoveCursorToPropName(PropNode: TCodeTreeNode + ): boolean; +begin + Result:=false; + if (PropNode=nil) + or ((PropNode.Desc<>ctnProperty) and (PropNode.Desc<>ctnGlobalProperty)) then + exit; + MoveCursorToNodeStart(PropNode); + ReadNextAtom; + if (PropNode.Desc=ctnProperty) then begin + if (not UpAtomIs('PROPERTY')) then exit; + ReadNextAtom; + end; + AtomIsIdentifier(true); +end; + function TPascalReaderTool.ProcNodeHasSpecifier(ProcNode: TCodeTreeNode; ProcSpec: TProcedureSpecifier): boolean; begin @@ -709,16 +726,7 @@ function TPascalReaderTool.ExtractPropName(PropNode: TCodeTreeNode; InUpperCase: boolean): string; begin Result:=''; - if (PropNode=nil) - or ((PropNode.Desc<>ctnProperty) and (PropNode.Desc<>ctnGlobalProperty)) then - exit; - MoveCursorToNodeStart(PropNode); - ReadNextAtom; - if (PropNode.Desc=ctnProperty) then begin - if (not UpAtomIs('PROPERTY')) then exit; - ReadNextAtom; - end; - AtomIsIdentifier(true); + if not MoveCursorToPropName(PropNode) then exit; if InUpperCase then Result:=GetUpAtom else diff --git a/tools/install/create_lazarus_rpm.sh b/tools/install/create_lazarus_rpm.sh index 20de77f1b2..35cf812156 100644 --- a/tools/install/create_lazarus_rpm.sh +++ b/tools/install/create_lazarus_rpm.sh @@ -16,7 +16,7 @@ if [ "x$FPCRPM" = "x" ]; then fi Date=$Year$Month$Day -LazVersion=0.9.2.1 +LazVersion=0.9.2.2 LazRelease=`echo $FPCRPM | sed -e 's/-/_/g'` SrcTGZ=lazarus-$Date.tgz TmpDir=/tmp/lazarus$LazVersion