From 3efe784a258356041e5366b9a76d5e8902d173c9 Mon Sep 17 00:00:00 2001 From: lazarus Date: Wed, 5 Jun 2002 19:46:46 +0000 Subject: [PATCH] MG: fixed collect declarations git-svn-id: trunk@1732 - --- components/codetools/codetoolmanager.pas | 24 ++++++++--------- components/codetools/eventcodetool.pas | 2 -- components/codetools/finddeclarationcache.pas | 2 +- components/codetools/finddeclarationtool.pas | 27 +++++++++++++------ 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/components/codetools/codetoolmanager.pas b/components/codetools/codetoolmanager.pas index 495f7b27df..676e79c953 100644 --- a/components/codetools/codetoolmanager.pas +++ b/components/codetools/codetoolmanager.pas @@ -1246,9 +1246,9 @@ function TCodeToolManager.ListAllCreateFormStatements( Code: TCodeBuffer): TStrings; begin Result:=nil; -{$IFDEF CTDEBUG} -writeln('TCodeToolManager.ListAllCreateFormStatements A ',Code.Filename); -{$ENDIF} + {$IFDEF CTDEBUG} + writeln('TCodeToolManager.ListAllCreateFormStatements A ',Code.Filename); + {$ENDIF} if not InitCurCodeTool(Code) then exit; try Result:=FCurCodeTool.ListAllCreateFormStatements; @@ -1261,9 +1261,9 @@ function TCodeToolManager.SetAllCreateFromStatements(Code: TCodeBuffer; List: TStrings): boolean; begin Result:=false; -{$IFDEF CTDEBUG} -writeln('TCodeToolManager.SetAllCreateFromStatements A ',Code.Filename); -{$ENDIF} + {$IFDEF CTDEBUG} + writeln('TCodeToolManager.SetAllCreateFromStatements A ',Code.Filename); + {$ENDIF} if not InitCurCodeTool(Code) then exit; try Result:=FCurCodeTool.SetAllCreateFromStatements(List,SourceChangeCache); @@ -1276,9 +1276,9 @@ function TCodeToolManager.PublishedVariableExists(Code: TCodeBuffer; const AClassName, AVarName: string): boolean; begin Result:=false; -{$IFDEF CTDEBUG} -writeln('TCodeToolManager.PublishedVariableExists A ',Code.Filename,' ',AClassName,':',AVarName); -{$ENDIF} + {$IFDEF CTDEBUG} + writeln('TCodeToolManager.PublishedVariableExists A ',Code.Filename,' ',AClassName,':',AVarName); + {$ENDIF} if not InitCurCodeTool(Code) then exit; try Result:=FCurCodeTool.FindPublishedVariable(UpperCaseStr(AClassName), @@ -1292,9 +1292,9 @@ function TCodeToolManager.AddPublishedVariable(Code: TCodeBuffer; const AClassName, VarName, VarType: string): boolean; begin Result:=false; -{$IFDEF CTDEBUG} -writeln('TCodeToolManager.AddPublishedVariable A ',Code.Filename,' ',AClassName,':',VarName); -{$ENDIF} + {$IFDEF CTDEBUG} + writeln('TCodeToolManager.AddPublishedVariable A ',Code.Filename,' ',AClassName,':',VarName); + {$ENDIF} if not InitCurCodeTool(Code) then exit; try Result:=FCurCodeTool.AddPublishedVariable(UpperCaseStr(AClassName), diff --git a/components/codetools/eventcodetool.pas b/components/codetools/eventcodetool.pas index b8f8eaaa10..40dcc9a61a 100644 --- a/components/codetools/eventcodetool.pas +++ b/components/codetools/eventcodetool.pas @@ -227,7 +227,6 @@ begin Params:=TFindDeclarationParams.Create; try Params.ContextNode:=ClassNode.Parent; - writeln('BBB1'); SearchedExprList:=CreateExprListFromMethodTypeData(TypeData,Params); // create compatibility list CompListSize:=SizeOf(TTypeCompatibility)*SearchedExprList.Count; @@ -417,7 +416,6 @@ begin // convert the TypeData to an expression type list Params.ContextNode:=Params.NewNode; - writeln('AAA1'); SearchedExprList:=CreateExprListFromMethodTypeData(TypeData,Params); // create compatibility list CompListSize:=SizeOf(TTypeCompatibility)*SearchedExprList.Count; diff --git a/components/codetools/finddeclarationcache.pas b/components/codetools/finddeclarationcache.pas index b9f7f99f16..70a138b769 100644 --- a/components/codetools/finddeclarationcache.pas +++ b/components/codetools/finddeclarationcache.pas @@ -784,7 +784,7 @@ begin raise Exception.Create('[TCodeTreeNodeCache.FindNearestAVLNode]' +' internal error: CleanStartPos>CleanEndPos'); end; - if FItems<>nil then begin + if (FItems<>nil) and (Identifier<>nil) then begin Result:=FItems.Root; while Result<>nil do begin Entry:=PCodeTreeNodeCacheEntry(Result.Data); diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index 6ed5e2b07e..9506982069 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -1130,6 +1130,9 @@ var NodeCache: TCodeTreeNodeCache; begin Result:=false; + // the node cache is identifier based + if (fdfCollect in Params.Flags) then exit; + NodeCache:=GetNodeCache(ContextNode,false); if (NodeCache<>LastNodeCache) then begin // NodeCache changed -> search nearest cache entry for the identifier @@ -1210,7 +1213,8 @@ var exit; end; if not (fdfExceptionOnNotFound in Params.Flags) then exit; - if WordIsPredefinedIdentifier.DoIt(Params.Identifier) + if (Params.Identifier<>nil) + and WordIsPredefinedIdentifier.DoIt(Params.Identifier) and not (fdfExceptionOnPredefinedIdent in Params.Flags) then exit; // identifier was not found and exception is wanted // -> raise exception @@ -1239,7 +1243,8 @@ var // false if search should continue begin Result:=false; - if CompareSrcIdentifiers(ContextNode.StartPos,Params.Identifier) + if (fdfCollect in Params.Flags) + or CompareSrcIdentifiers(ContextNode.StartPos,Params.Identifier) then begin {$IFDEF ShowTriedIdentifiers} writeln(' Definition Identifier found="',GetIdentifier(Params.Identifier),'"'); @@ -1263,7 +1268,8 @@ var MoveCursorToNodeStart(ContextNode); ReadNextAtom; // read keyword ReadNextAtom; // read name - if CompareSrcIdentifiers(CurPos.StartPos,Params.Identifier) then + if (fdfCollect in Params.Flags) + or CompareSrcIdentifiers(CurPos.StartPos,Params.Identifier) then begin // identifier found {$IFDEF ShowTriedIdentifiers} @@ -1282,12 +1288,13 @@ var // false if search should continue begin Result:=false; - if (Params.Identifier[0]<>'[') then begin + if (fdfCollect in Params.Flags) + or (Params.Identifier[0]<>'[') then begin MoveCursorToNodeStart(ContextNode); ReadNextAtom; // read keyword 'property' ReadNextAtom; // read name - if CompareSrcIdentifiers(CurPos.StartPos,Params.Identifier) then - begin + if (fdfCollect in Params.Flags) + or CompareSrcIdentifiers(CurPos.StartPos,Params.Identifier) then begin // identifier found {$IFDEF ShowTriedIdentifiers} writeln(' Property Identifier found="',GetIdentifier(Params.Identifier),'"'); @@ -1454,7 +1461,7 @@ var begin Result:=false; InitNodesAndCacheAccess; - + {$IFDEF ShowTriedContexts} writeln('[TFindDeclarationTool.FindIdentifierInContext] Start Ident=', '"',GetIdentifier(Params.Identifier),'"', @@ -1603,9 +1610,13 @@ begin CurContextNode:=CurContextNode.FirstChild; while CurContextNode<>nil do begin if (CurContextNode.Desc in [ctnEnumIdentifier]) - and CompareSrcIdentifiers(CurContextNode.StartPos,Params.Identifier) + and ((fdfCollect in Params.Flags) + or CompareSrcIdentifiers(CurContextNode.StartPos,Params.Identifier)) then begin // identifier found + + // ToDo: fdfCollect + Result:=true; Params.SetResult(Self,CurContextNode); exit;