mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-19 05:19:25 +02:00
MG: fixed find declaration: resolving type of property
git-svn-id: trunk@3479 -
This commit is contained in:
parent
f97109b666
commit
a9f177849b
@ -65,6 +65,9 @@ interface
|
||||
{ $DEFINE ShowCacheDependencies}
|
||||
{ $DEFINE ShowCollect}
|
||||
|
||||
{$IFDEF CTDEBUG}{$DEFINE DebugPrefix}{$ENDIF}
|
||||
{$IFDEF ShowTriedIdentifiers}{$DEFINE DebugPrefix}{$ENDIF}
|
||||
|
||||
// new features
|
||||
{ $DEFINE IgnoreErrorAfterCursor}
|
||||
|
||||
@ -402,7 +405,7 @@ type
|
||||
FDependsOnCodeTools: TAVLTree;// the codetools, that this codetool depends on
|
||||
FClearingDependentNodeCaches: boolean;
|
||||
FCheckingNodeCacheDependencies: boolean;
|
||||
{$IFDEF CTDEBUG}
|
||||
{$IFDEF DebugPrefix}
|
||||
DebugPrefix: string;
|
||||
procedure IncPrefix;
|
||||
procedure DecPrefix;
|
||||
@ -2487,7 +2490,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{$IFDEF CTDEBUG}
|
||||
{$IFDEF DebugPrefix}
|
||||
procedure TFindDeclarationTool.DecPrefix;
|
||||
begin
|
||||
DebugPrefix:=copy(DebugPrefix,1,length(DebugPrefix)-2);
|
||||
@ -3029,6 +3032,7 @@ begin
|
||||
Params.SetIdentifier(Self,PChar(SystemAlias),nil);
|
||||
Result:=FindIdentifierInUsedUnit(SystemAlias,Params);
|
||||
finally
|
||||
// always reset input, because the string SystemAlias is freed
|
||||
Params.Load(OldInput);
|
||||
end;
|
||||
end;
|
||||
@ -3506,7 +3510,8 @@ var
|
||||
|
||||
procedure RaiseTypeIdentNotFound;
|
||||
begin
|
||||
RaiseExceptionFmt(ctsStrExpectedButAtomFound,[ctsTypeIdentifier,GetAtom]);
|
||||
CurContext.Tool.RaiseExceptionFmt(ctsStrExpectedButAtomFound,
|
||||
[ctsTypeIdentifier,CurContext.Tool.GetAtom]);
|
||||
end;
|
||||
|
||||
procedure RaiseIdentInCurContextNotFound;
|
||||
@ -3546,45 +3551,39 @@ var
|
||||
if CurContext.Node.Desc=ctnClass then begin
|
||||
// search default property in class
|
||||
Params.Save(OldInput);
|
||||
try
|
||||
Params.Flags:=[fdfSearchInAncestors,fdfExceptionOnNotFound]
|
||||
+fdfGlobals*Params.Flags
|
||||
+fdfAllClassVisibilities*Params.Flags;
|
||||
// special identifier for default property
|
||||
Params.SetIdentifier(CurContext.Tool,'[',nil);
|
||||
Params.ContextNode:=CurContext.Node;
|
||||
CurContext.Tool.FindIdentifierInContext(Params);
|
||||
CurContext:=CreateFindContext(Params);
|
||||
finally
|
||||
Params.Load(OldInput);
|
||||
end;
|
||||
Params.Flags:=[fdfSearchInAncestors,fdfExceptionOnNotFound]
|
||||
+fdfGlobals*Params.Flags
|
||||
+fdfAllClassVisibilities*Params.Flags;
|
||||
// special identifier for default property
|
||||
Params.SetIdentifier(CurContext.Tool,'[',nil);
|
||||
Params.ContextNode:=CurContext.Node;
|
||||
CurContext.Tool.FindIdentifierInContext(Params);
|
||||
CurContext:=CreateFindContext(Params);
|
||||
Params.Load(OldInput);
|
||||
end;
|
||||
// find base type of property
|
||||
if CurContext.Tool.ReadTilTypeOfProperty(CurContext.Node) then begin
|
||||
// property has type
|
||||
Params.Save(OldInput);
|
||||
try
|
||||
Params.SetIdentifier(CurContext.Tool,
|
||||
@CurContext.Tool.Src[CurPos.StartPos],nil);
|
||||
Params.Flags:=[fdfSearchInParentNodes,fdfExceptionOnNotFound]
|
||||
+(fdfGlobals*Params.Flags)
|
||||
-[fdfIgnoreUsedUnits];
|
||||
Params.ContextNode:=CurContext.Node.Parent;
|
||||
if FindIdentifierInContext(Params) then begin
|
||||
if Params.NewNode.Desc in [ctnTypeDefinition] then begin
|
||||
CurContext:=Params.NewCodeTool.FindBaseTypeOfNode(Params,
|
||||
Params.NewNode)
|
||||
end else begin
|
||||
// not a type
|
||||
CurContext.Tool.ReadTilTypeOfProperty(CurContext.Node);
|
||||
RaiseTypeIdentNotFound;
|
||||
end;
|
||||
with CurContext.Tool do
|
||||
Params.SetIdentifier(CurContext.Tool,@Src[CurPos.StartPos],nil);
|
||||
Params.Flags:=[fdfSearchInParentNodes,fdfExceptionOnNotFound]
|
||||
+(fdfGlobals*Params.Flags)
|
||||
-[fdfIgnoreUsedUnits];
|
||||
Params.ContextNode:=CurContext.Node.Parent;
|
||||
if CurContext.Tool.FindIdentifierInContext(Params) then begin
|
||||
if Params.NewNode.Desc in [ctnTypeDefinition] then begin
|
||||
CurContext:=Params.NewCodeTool.FindBaseTypeOfNode(Params,
|
||||
Params.NewNode)
|
||||
end else begin
|
||||
// predefined identifier
|
||||
// not a type
|
||||
CurContext.Tool.ReadTilTypeOfProperty(CurContext.Node);
|
||||
RaiseTypeIdentNotFound;
|
||||
end;
|
||||
finally
|
||||
Params.Load(OldInput);
|
||||
end else begin
|
||||
// predefined identifier
|
||||
end;
|
||||
Params.Load(OldInput);
|
||||
end else
|
||||
RaiseIdentInCurContextNotFound;
|
||||
end;
|
||||
|
@ -1629,31 +1629,33 @@ procedure TKeyCommandRelationList.AssignTo(
|
||||
ASynEditKeyStrokes:TSynEditKeyStrokes; Areas: TCommandAreas);
|
||||
var
|
||||
a,b,MaxKeyCnt,KeyCnt:integer;
|
||||
Key:TSynEditKeyStroke;
|
||||
Key: TSynEditKeyStroke;
|
||||
CurRelation: TKeyCommandRelation;
|
||||
begin
|
||||
for a:=0 to FRelations.Count-1 do begin
|
||||
if (Relations[a].Key1=VK_UNKNOWN)
|
||||
or ((Relations[a].Parent.Areas*Areas)=[]) then
|
||||
CurRelation:=Relations[a];
|
||||
if (CurRelation.Key1=VK_UNKNOWN)
|
||||
or ((CurRelation.Parent.Areas*Areas)=[]) then
|
||||
MaxKeyCnt:=0
|
||||
else if Relations[a].Key2=VK_UNKNOWN then
|
||||
else if CurRelation.Key2=VK_UNKNOWN then
|
||||
MaxKeyCnt:=1
|
||||
else
|
||||
MaxKeyCnt:=2;
|
||||
KeyCnt:=1;
|
||||
b:=0;
|
||||
while b<ASynEditKeyStrokes.Count do begin
|
||||
if ASynEditKeyStrokes[b].Command=Relations[a].Command then begin
|
||||
if ASynEditKeyStrokes[b].Command=CurRelation.Command then begin
|
||||
if KeyCnt>MaxKeyCnt then begin
|
||||
ASynEditKeyStrokes[b].Free;
|
||||
end else if KeyCnt=1 then begin
|
||||
ASynEditKeyStrokes[b].Key:=Relations[a].Key1;
|
||||
ASynEditKeyStrokes[b].Shift:=Relations[a].Shift1;
|
||||
ASynEditKeyStrokes[b].Key:=CurRelation.Key1;
|
||||
ASynEditKeyStrokes[b].Shift:=CurRelation.Shift1;
|
||||
ASynEditKeyStrokes[b].Key2:=VK_UNKNOWN;
|
||||
ASynEditKeyStrokes[b].Shift2:=[];
|
||||
inc(b);
|
||||
end else if KeyCnt=2 then begin
|
||||
ASynEditKeyStrokes[b].Key:=Relations[a].Key2;
|
||||
ASynEditKeyStrokes[b].Shift:=Relations[a].Shift2;
|
||||
ASynEditKeyStrokes[b].Key:=CurRelation.Key2;
|
||||
ASynEditKeyStrokes[b].Shift:=CurRelation.Shift2;
|
||||
ASynEditKeyStrokes[b].Key2:=VK_UNKNOWN;
|
||||
ASynEditKeyStrokes[b].Shift2:=[];
|
||||
inc(b);
|
||||
@ -1663,13 +1665,13 @@ begin
|
||||
end;
|
||||
while KeyCnt<=MaxKeyCnt do begin
|
||||
Key:=ASynEditKeyStrokes.Add;
|
||||
Key.Command:=Relations[a].Command;
|
||||
Key.Command:=CurRelation.Command;
|
||||
if KeyCnt=1 then begin
|
||||
Key.Key:=Relations[a].Key1;
|
||||
Key.Shift:=Relations[a].Shift1;
|
||||
Key.Key:=CurRelation.Key1;
|
||||
Key.Shift:=CurRelation.Shift1;
|
||||
end else begin
|
||||
Key.Key:=Relations[a].Key2;
|
||||
Key.Shift:=Relations[a].Shift2;
|
||||
Key.Key:=CurRelation.Key2;
|
||||
Key.Shift:=CurRelation.Shift2;
|
||||
end;
|
||||
Key.Key2:=VK_UNKNOWN;
|
||||
Key.Shift2:=[];
|
||||
|
Loading…
Reference in New Issue
Block a user