mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-10 06:58:21 +02:00
codetools: improved heuristic for protected properties, bug #14027
git-svn-id: trunk@20970 -
This commit is contained in:
parent
de301ed56c
commit
ff0557c43f
@ -891,7 +891,7 @@ var
|
|||||||
exit(true);
|
exit(true);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
//DebugLn(['ProtectedNodeIsInAllowedClass hidden: ',FindContextToString(FoundContext)]);
|
DebugLn(['ProtectedNodeIsInAllowedClass hidden: ',FindContextToString(FoundContext)]);
|
||||||
|
|
||||||
Result:=false;
|
Result:=false;
|
||||||
end;
|
end;
|
||||||
@ -948,27 +948,39 @@ begin
|
|||||||
// identifier is in the same unit
|
// identifier is in the same unit
|
||||||
//DebugLn('::: COLLECT IDENT in SELF ',FoundContext.Node.DescAsString,
|
//DebugLn('::: COLLECT IDENT in SELF ',FoundContext.Node.DescAsString,
|
||||||
// ' "',StringToPascalConst(copy(FoundContext.Tool.Src,FoundContext.Node.StartPos,50)),'"'
|
// ' "',StringToPascalConst(copy(FoundContext.Tool.Src,FoundContext.Node.StartPos,50)),'"'
|
||||||
// ,' '+dbgs(fdfIgnoreUsedUnits in Params.Flags));
|
// ,' fdfIgnoreUsedUnits='+dbgs(fdfIgnoreUsedUnits in Params.Flags));
|
||||||
end else begin
|
end else begin
|
||||||
// identifier is in another unit
|
// identifier is in another unit
|
||||||
if (FoundContext.Node.Parent<>nil) then begin
|
if (FoundContext.Node.Parent<>nil) then begin
|
||||||
if (FoundContext.Node.Parent.Desc=ctnClassPrivate) then begin
|
case FoundContext.Node.Parent.Desc of
|
||||||
|
ctnClassPrivate:
|
||||||
|
begin
|
||||||
// skip private definitions in other units
|
// skip private definitions in other units
|
||||||
|
if (FoundContext.Node.Desc=ctnProperty) then begin
|
||||||
|
// private property: maybe the visibility was raised => continue
|
||||||
|
//debugln('TIdentCompletionTool.CollectAllIdentifiers MAYBE Private made Public '+StringToPascalConst(copy(FoundContext.Tool.Src,FoundContext.Node.StartPos,50)));
|
||||||
|
end;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if (FoundContext.Node.Parent.Desc=ctnClassProtected) then begin
|
ctnClassProtected:
|
||||||
// protected defnitions are only accessible from descendants
|
begin
|
||||||
|
// protected definitions are only accessible from descendants
|
||||||
|
// or if visibility was raised (e.g. property)
|
||||||
if ProtectedNodeIsInAllowedClass then begin
|
if ProtectedNodeIsInAllowedClass then begin
|
||||||
|
// protected node in an ancestor => allowed
|
||||||
//debugln('TIdentCompletionTool.CollectAllIdentifiers ALLOWED Protected in ANCESTOR '+StringToPascalConst(copy(FoundContext.Tool.Src,FoundContext.Node.StartPos,50)));
|
//debugln('TIdentCompletionTool.CollectAllIdentifiers ALLOWED Protected in ANCESTOR '+StringToPascalConst(copy(FoundContext.Tool.Src,FoundContext.Node.StartPos,50)));
|
||||||
end else if (FoundContext.Node.Desc=ctnProperty) then begin
|
end else if (FoundContext.Node.Desc=ctnProperty) then begin
|
||||||
|
// protected property: maybe the visibility was raised => continue
|
||||||
//debugln('TIdentCompletionTool.CollectAllIdentifiers MAYBE Protected made Public '+StringToPascalConst(copy(FoundContext.Tool.Src,FoundContext.Node.StartPos,50)));
|
//debugln('TIdentCompletionTool.CollectAllIdentifiers MAYBE Protected made Public '+StringToPascalConst(copy(FoundContext.Tool.Src,FoundContext.Node.StartPos,50)));
|
||||||
end else begin
|
end else begin
|
||||||
|
// otherwise: treat as private
|
||||||
//debugln('TIdentCompletionTool.CollectAllIdentifiers FORBIDDEN Protected '+StringToPascalConst(copy(FoundContext.Tool.Src,FoundContext.Node.StartPos,50)));
|
//debugln('TIdentCompletionTool.CollectAllIdentifiers FORBIDDEN Protected '+StringToPascalConst(copy(FoundContext.Tool.Src,FoundContext.Node.StartPos,50)));
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
Ident:=nil;
|
Ident:=nil;
|
||||||
case FoundContext.Node.Desc of
|
case FoundContext.Node.Desc of
|
||||||
@ -1008,10 +1020,16 @@ begin
|
|||||||
if FoundContext.Node.Parent.Desc in [ctnClassPublic,ctnClassPublished]
|
if FoundContext.Node.Parent.Desc in [ctnClassPublic,ctnClassPublished]
|
||||||
then
|
then
|
||||||
SavePublicPublishedProperty;
|
SavePublicPublishedProperty;
|
||||||
|
// do not show properties without types (e.g. property Color;)
|
||||||
|
// only show the real definition, which will follow in the ancestor
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if (FoundContext.Node.Parent.Desc in [ctnClassPrivate,ctnClassProtected])
|
if (FoundContext.Node.Parent.Desc in [ctnClassPrivate,ctnClassProtected])
|
||||||
|
and (FoundContext.Tool<>Self)
|
||||||
and (not PropertyIsOverridenPublicPublish) then begin
|
and (not PropertyIsOverridenPublicPublish) then begin
|
||||||
|
// a private/protected property in another unit, that was not
|
||||||
|
// made public/publish later
|
||||||
|
// => skip
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user