diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index 8fe792e64d..6753f7ac39 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -2190,7 +2190,8 @@ var // identifier found Params.SetResult(Self,ContextNode); Result:=CheckResult(true,true); - exit; + if not (fdfCollect in Params.Flags) then + exit; end; // search for enums Params.ContextNode:=ContextNode; @@ -2589,35 +2590,45 @@ function TFindDeclarationTool.FindEnumInContext( true, if enum found } var OldContextNode, CurContextNode: TCodeTreeNode; + CollectResult: TIdentifierFoundResult; begin Result:=false; if Params.ContextNode=nil then exit; - OldContextNode:=Params.ContextNode; - CurContextNode:=OldContextNode; + CurContextNode:=Params.ContextNode; if CurContextNode.Desc=ctnClass then BuildSubTreeForClass(CurContextNode); CurContextNode:=CurContextNode.FirstChild; while CurContextNode<>nil do begin - if (CurContextNode.Desc in [ctnEnumIdentifier]) - and ((fdfCollect in Params.Flags) - or CompareSrcIdentifiers(CurContextNode.StartPos,Params.Identifier)) - then begin - // identifier found - - // ToDo: fdfCollect - - Result:=true; - Params.SetResult(Self,CurContextNode); - exit; + if (CurContextNode.Desc=ctnEnumIdentifier) then begin + if (fdfCollect in Params.Flags) then begin + //debugln('TFindDeclarationTool.FindEnumInContext ',GetIdentifier(@Src[CurContextNode.StartPos])); + CollectResult:=DoOnIdentifierFound(Params,CurContextNode); + if CollectResult=ifrAbortSearch then begin + Result:=false; + exit; + end else if CollectResult=ifrSuccess then begin + Result:=true; + Params.SetResult(Self,CurContextNode); + exit; + end; + end else if CompareSrcIdentifiers(CurContextNode.StartPos,Params.Identifier) + then begin + // identifier found + Result:=true; + Params.SetResult(Self,CurContextNode); + exit; + end; end; OldContextNode:=Params.ContextNode; - try - Params.ContextNode:=CurContextNode; - Result:=FindEnumInContext(Params); - finally - Params.ContextNode:=OldContextNode; + if OldContextNode.FirstChild<>nil then begin + try + Params.ContextNode:=CurContextNode; + Result:=FindEnumInContext(Params); + finally + Params.ContextNode:=OldContextNode; + end; + if Result then exit; end; - if Result then exit; CurContextNode:=CurContextNode.NextBrother; end; end; @@ -6242,9 +6253,6 @@ function TFindDeclarationTool.DoOnIdentifierFound( // this internal function is called, whenever an identifier is found var IsTopLvlIdent: boolean; begin - - // ToDo: check if identifier is in a forbidden class visibility section - IsTopLvlIdent:=(fdfTopLvlResolving in Params.Flags); if Assigned(Params.OnIdentifierFound) then Result:=Params.OnIdentifierFound(Params,CreateFindContext(Self,FoundNode)) diff --git a/components/codetools/identcompletiontool.pas b/components/codetools/identcompletiontool.pas index c99cfdf5b5..c78f2455d8 100644 --- a/components/codetools/identcompletiontool.pas +++ b/components/codetools/identcompletiontool.pas @@ -656,7 +656,7 @@ begin {$IFDEF ShowFoundIdents} DebugLn('::: COLLECT IDENT ',FoundContext.Node.DescAsString, ' "',StringToPascalConst(copy(FoundContext.Tool.Src,FoundContext.Node.StartPos,50)),'"' - ,' ',fdfIgnoreUsedUnits in Params.Flags); + ,' '+dbgs(fdfIgnoreUsedUnits in Params.Flags)); {$ENDIF} CurContextParent:=FoundContext.Node.GetFindContextParent; @@ -666,7 +666,12 @@ begin inc(LastGatheredIdentLevel); end; - if FoundContext.Tool<>Self then begin + if FoundContext.Tool=Self then begin + // identifier is in the same unit + //DebugLn('::: COLLECT IDENT in SELF ',FoundContext.Node.DescAsString, + // ' "',StringToPascalConst(copy(FoundContext.Tool.Src,FoundContext.Node.StartPos,50)),'"' + // ,' '+dbgs(fdfIgnoreUsedUnits in Params.Flags)); + end else begin // identifier is in another unit if (FoundContext.Node.Parent<>nil) then begin if (FoundContext.Node.Parent.Desc=ctnClassPrivate) then begin diff --git a/ide/main.pp b/ide/main.pp index e7b4a1a22b..3abe34ad31 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -3921,6 +3921,7 @@ begin ObjectInspector1.EventGrid.ItemIndex:=-1; ObjectInspector1.FavouriteGrid.ItemIndex:=-1; end; + debugln('TMainIDE.DoRemoveDanglingEvents ',AnUnitInfo.Filename,' ',dbgsName(AnUnitInfo.Component)); // remove dangling methods Result:=RemoveDanglingEvents(AnUnitInfo.Component,AnUnitInfo.Source,true, ComponentModified); diff --git a/ide/sourceeditprocs.pas b/ide/sourceeditprocs.pas index eecb64a3f7..71d1a75d0f 100644 --- a/ide/sourceeditprocs.pas +++ b/ide/sourceeditprocs.pas @@ -143,7 +143,7 @@ begin s:='var'; end; - ctnTypeDefinition: + ctnTypeDefinition, ctnEnumerationType: begin AColor:=clDkGray; s:='type'; @@ -154,7 +154,7 @@ begin AColor:=clOlive; s:='const'; end; - + ctnProcedure: if (IdentItem.Node<>nil) and IdentItem.Tool.NodeIsFunction(IdentItem.Node) then begin @@ -170,6 +170,12 @@ begin AColor:=clPurple; s:='property'; end; + + ctnEnumIdentifier: + begin + AColor:=clOlive; + s:='enum'; + end; else AColor:=clGray;