mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-22 12:29:39 +01:00
identifier completion now shows enums
git-svn-id: trunk@7566 -
This commit is contained in:
parent
0c8bf07ec3
commit
1f63c9f2f7
@ -2190,7 +2190,8 @@ var
|
|||||||
// identifier found
|
// identifier found
|
||||||
Params.SetResult(Self,ContextNode);
|
Params.SetResult(Self,ContextNode);
|
||||||
Result:=CheckResult(true,true);
|
Result:=CheckResult(true,true);
|
||||||
exit;
|
if not (fdfCollect in Params.Flags) then
|
||||||
|
exit;
|
||||||
end;
|
end;
|
||||||
// search for enums
|
// search for enums
|
||||||
Params.ContextNode:=ContextNode;
|
Params.ContextNode:=ContextNode;
|
||||||
@ -2589,35 +2590,45 @@ function TFindDeclarationTool.FindEnumInContext(
|
|||||||
true, if enum found
|
true, if enum found
|
||||||
}
|
}
|
||||||
var OldContextNode, CurContextNode: TCodeTreeNode;
|
var OldContextNode, CurContextNode: TCodeTreeNode;
|
||||||
|
CollectResult: TIdentifierFoundResult;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
if Params.ContextNode=nil then exit;
|
if Params.ContextNode=nil then exit;
|
||||||
OldContextNode:=Params.ContextNode;
|
CurContextNode:=Params.ContextNode;
|
||||||
CurContextNode:=OldContextNode;
|
|
||||||
if CurContextNode.Desc=ctnClass then
|
if CurContextNode.Desc=ctnClass then
|
||||||
BuildSubTreeForClass(CurContextNode);
|
BuildSubTreeForClass(CurContextNode);
|
||||||
CurContextNode:=CurContextNode.FirstChild;
|
CurContextNode:=CurContextNode.FirstChild;
|
||||||
while CurContextNode<>nil do begin
|
while CurContextNode<>nil do begin
|
||||||
if (CurContextNode.Desc in [ctnEnumIdentifier])
|
if (CurContextNode.Desc=ctnEnumIdentifier) then begin
|
||||||
and ((fdfCollect in Params.Flags)
|
if (fdfCollect in Params.Flags) then begin
|
||||||
or CompareSrcIdentifiers(CurContextNode.StartPos,Params.Identifier))
|
//debugln('TFindDeclarationTool.FindEnumInContext ',GetIdentifier(@Src[CurContextNode.StartPos]));
|
||||||
then begin
|
CollectResult:=DoOnIdentifierFound(Params,CurContextNode);
|
||||||
// identifier found
|
if CollectResult=ifrAbortSearch then begin
|
||||||
|
Result:=false;
|
||||||
// ToDo: fdfCollect
|
exit;
|
||||||
|
end else if CollectResult=ifrSuccess then begin
|
||||||
Result:=true;
|
Result:=true;
|
||||||
Params.SetResult(Self,CurContextNode);
|
Params.SetResult(Self,CurContextNode);
|
||||||
exit;
|
exit;
|
||||||
|
end;
|
||||||
|
end else if CompareSrcIdentifiers(CurContextNode.StartPos,Params.Identifier)
|
||||||
|
then begin
|
||||||
|
// identifier found
|
||||||
|
Result:=true;
|
||||||
|
Params.SetResult(Self,CurContextNode);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
OldContextNode:=Params.ContextNode;
|
OldContextNode:=Params.ContextNode;
|
||||||
try
|
if OldContextNode.FirstChild<>nil then begin
|
||||||
Params.ContextNode:=CurContextNode;
|
try
|
||||||
Result:=FindEnumInContext(Params);
|
Params.ContextNode:=CurContextNode;
|
||||||
finally
|
Result:=FindEnumInContext(Params);
|
||||||
Params.ContextNode:=OldContextNode;
|
finally
|
||||||
|
Params.ContextNode:=OldContextNode;
|
||||||
|
end;
|
||||||
|
if Result then exit;
|
||||||
end;
|
end;
|
||||||
if Result then exit;
|
|
||||||
CurContextNode:=CurContextNode.NextBrother;
|
CurContextNode:=CurContextNode.NextBrother;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -6242,9 +6253,6 @@ function TFindDeclarationTool.DoOnIdentifierFound(
|
|||||||
// this internal function is called, whenever an identifier is found
|
// this internal function is called, whenever an identifier is found
|
||||||
var IsTopLvlIdent: boolean;
|
var IsTopLvlIdent: boolean;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
// ToDo: check if identifier is in a forbidden class visibility section
|
|
||||||
|
|
||||||
IsTopLvlIdent:=(fdfTopLvlResolving in Params.Flags);
|
IsTopLvlIdent:=(fdfTopLvlResolving in Params.Flags);
|
||||||
if Assigned(Params.OnIdentifierFound) then
|
if Assigned(Params.OnIdentifierFound) then
|
||||||
Result:=Params.OnIdentifierFound(Params,CreateFindContext(Self,FoundNode))
|
Result:=Params.OnIdentifierFound(Params,CreateFindContext(Self,FoundNode))
|
||||||
|
|||||||
@ -656,7 +656,7 @@ begin
|
|||||||
{$IFDEF ShowFoundIdents}
|
{$IFDEF ShowFoundIdents}
|
||||||
DebugLn('::: COLLECT IDENT ',FoundContext.Node.DescAsString,
|
DebugLn('::: COLLECT IDENT ',FoundContext.Node.DescAsString,
|
||||||
' "',StringToPascalConst(copy(FoundContext.Tool.Src,FoundContext.Node.StartPos,50)),'"'
|
' "',StringToPascalConst(copy(FoundContext.Tool.Src,FoundContext.Node.StartPos,50)),'"'
|
||||||
,' ',fdfIgnoreUsedUnits in Params.Flags);
|
,' '+dbgs(fdfIgnoreUsedUnits in Params.Flags));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
CurContextParent:=FoundContext.Node.GetFindContextParent;
|
CurContextParent:=FoundContext.Node.GetFindContextParent;
|
||||||
@ -666,7 +666,12 @@ begin
|
|||||||
inc(LastGatheredIdentLevel);
|
inc(LastGatheredIdentLevel);
|
||||||
end;
|
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
|
// 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
|
if (FoundContext.Node.Parent.Desc=ctnClassPrivate) then begin
|
||||||
|
|||||||
@ -3921,6 +3921,7 @@ begin
|
|||||||
ObjectInspector1.EventGrid.ItemIndex:=-1;
|
ObjectInspector1.EventGrid.ItemIndex:=-1;
|
||||||
ObjectInspector1.FavouriteGrid.ItemIndex:=-1;
|
ObjectInspector1.FavouriteGrid.ItemIndex:=-1;
|
||||||
end;
|
end;
|
||||||
|
debugln('TMainIDE.DoRemoveDanglingEvents ',AnUnitInfo.Filename,' ',dbgsName(AnUnitInfo.Component));
|
||||||
// remove dangling methods
|
// remove dangling methods
|
||||||
Result:=RemoveDanglingEvents(AnUnitInfo.Component,AnUnitInfo.Source,true,
|
Result:=RemoveDanglingEvents(AnUnitInfo.Component,AnUnitInfo.Source,true,
|
||||||
ComponentModified);
|
ComponentModified);
|
||||||
|
|||||||
@ -143,7 +143,7 @@ begin
|
|||||||
s:='var';
|
s:='var';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ctnTypeDefinition:
|
ctnTypeDefinition, ctnEnumerationType:
|
||||||
begin
|
begin
|
||||||
AColor:=clDkGray;
|
AColor:=clDkGray;
|
||||||
s:='type';
|
s:='type';
|
||||||
@ -154,7 +154,7 @@ begin
|
|||||||
AColor:=clOlive;
|
AColor:=clOlive;
|
||||||
s:='const';
|
s:='const';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ctnProcedure:
|
ctnProcedure:
|
||||||
if (IdentItem.Node<>nil)
|
if (IdentItem.Node<>nil)
|
||||||
and IdentItem.Tool.NodeIsFunction(IdentItem.Node) then begin
|
and IdentItem.Tool.NodeIsFunction(IdentItem.Node) then begin
|
||||||
@ -170,6 +170,12 @@ begin
|
|||||||
AColor:=clPurple;
|
AColor:=clPurple;
|
||||||
s:='property';
|
s:='property';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
ctnEnumIdentifier:
|
||||||
|
begin
|
||||||
|
AColor:=clOlive;
|
||||||
|
s:='enum';
|
||||||
|
end;
|
||||||
|
|
||||||
else
|
else
|
||||||
AColor:=clGray;
|
AColor:=clGray;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user