mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 08:59:10 +02:00
implemented "class of" for find declaration
git-svn-id: trunk@4435 -
This commit is contained in:
parent
ecb2e71b12
commit
5aa288de16
@ -102,6 +102,7 @@ ResourceString
|
|||||||
'inherited keyword only allowed in methods';
|
'inherited keyword only allowed in methods';
|
||||||
ctsCircleInDefinitions = 'circle in definitions';
|
ctsCircleInDefinitions = 'circle in definitions';
|
||||||
ctsForwardClassDefinitionNotResolved = 'Forward class definition not resolved: %s';
|
ctsForwardClassDefinitionNotResolved = 'Forward class definition not resolved: %s';
|
||||||
|
ctsClassOfDefinitionNotResolved = '"class of" definition not resolved: %s';
|
||||||
ctsTypeIdentifier = 'type identifier';
|
ctsTypeIdentifier = 'type identifier';
|
||||||
ctsAncestorIsNotProperty = 'ancestor of untyped property is not a property';
|
ctsAncestorIsNotProperty = 'ancestor of untyped property is not a property';
|
||||||
ctsBaseTypeOfNotFound = 'base type of "%s" not found';
|
ctsBaseTypeOfNotFound = 'base type of "%s" not found';
|
||||||
|
@ -2324,6 +2324,12 @@ function TFindDeclarationTool.FindBaseTypeOfNode(Params: TFindDeclarationParams;
|
|||||||
RaiseExceptionFmt(ctsBaseTypeOfNotFound,[GetIdentifier(Params.Identifier)]);
|
RaiseExceptionFmt(ctsBaseTypeOfNotFound,[GetIdentifier(Params.Identifier)]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure RaiseClassOfWithoutIdentifier;
|
||||||
|
begin
|
||||||
|
RaiseExceptionFmt(ctsBaseTypeOfNotFound+' ("class of")',
|
||||||
|
[GetIdentifier(Params.Identifier)]);
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
OldInput: TFindDeclarationInput;
|
OldInput: TFindDeclarationInput;
|
||||||
ClassIdentNode, DummyNode: TCodeTreeNode;
|
ClassIdentNode, DummyNode: TCodeTreeNode;
|
||||||
@ -2338,6 +2344,14 @@ var
|
|||||||
ClassIdentNode.EndPos-ClassIdentNode.StartPos)]);
|
ClassIdentNode.EndPos-ClassIdentNode.StartPos)]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure RaiseClassOfNotResolved;
|
||||||
|
begin
|
||||||
|
MoveCursorToNodeStart(ClassIdentNode);
|
||||||
|
RaiseExceptionFmt(ctsClassOfDefinitionNotResolved,
|
||||||
|
[copy(Src,ClassIdentNode.StartPos,
|
||||||
|
ClassIdentNode.EndPos-ClassIdentNode.StartPos)]);
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result.Node:=Node;
|
Result.Node:=Node;
|
||||||
Result.Tool:=Self;
|
Result.Tool:=Self;
|
||||||
@ -2405,6 +2419,38 @@ begin
|
|||||||
Params.Load(OldInput);
|
Params.Load(OldInput);
|
||||||
exit;
|
exit;
|
||||||
end else
|
end else
|
||||||
|
if (Result.Node.Desc=ctnClassOfType) then
|
||||||
|
begin
|
||||||
|
// this is a 'class of' type
|
||||||
|
// -> search the real class
|
||||||
|
{$IFDEF ShowTriedBaseContexts}
|
||||||
|
writeln('[TFindDeclarationTool.FindBaseTypeOfNode] "Class Of"');
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
// ToDo: check for circles in ancestor chain
|
||||||
|
|
||||||
|
ClassIdentNode:=Result.Node.FirstChild;
|
||||||
|
if (ClassIdentNode=nil) or (not (ClassIdentNode.Desc=ctnIdentifier))
|
||||||
|
then begin
|
||||||
|
MoveCursorToCleanPos(Result.Node.StartPos);
|
||||||
|
RaiseClassOfWithoutIdentifier;
|
||||||
|
end;
|
||||||
|
Params.Save(OldInput);
|
||||||
|
Params.SetIdentifier(Self,@Src[ClassIdentNode.StartPos],
|
||||||
|
@CheckSrcIdentifier);
|
||||||
|
Params.Flags:=[fdfSearchInParentNodes,fdfExceptionOnNotFound,
|
||||||
|
fdfIgnoreCurContextNode]
|
||||||
|
+(fdfGlobals*Params.Flags);
|
||||||
|
Params.ContextNode:=Result.Node.Parent;
|
||||||
|
FindIdentifierInContext(Params);
|
||||||
|
if (Params.NewNode.Desc<>ctnTypeDefinition) then begin
|
||||||
|
MoveCursorToCleanPos(Result.Node.StartPos);
|
||||||
|
RaiseClassOfNotResolved;
|
||||||
|
end;
|
||||||
|
Result:=Params.NewCodeTool.FindBaseTypeOfNode(Params,Params.NewNode);
|
||||||
|
Params.Load(OldInput);
|
||||||
|
exit;
|
||||||
|
end else
|
||||||
if (Result.Node.Desc=ctnIdentifier) then begin
|
if (Result.Node.Desc=ctnIdentifier) then begin
|
||||||
// this type is just an alias for another type
|
// this type is just an alias for another type
|
||||||
// -> search the basic type
|
// -> search the basic type
|
||||||
|
@ -2551,17 +2551,24 @@ begin
|
|||||||
// find end of class
|
// find end of class
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
if UpAtomIs('OF') then begin
|
if UpAtomIs('OF') then begin
|
||||||
|
if ChildCreated then CurNode.Desc:=ctnClassOfType;
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
AtomIsIdentifier(true);
|
AtomIsIdentifier(true);
|
||||||
|
if ChildCreated then begin
|
||||||
|
CreateChildNode;
|
||||||
|
CurNode.Desc:=ctnIdentifier;
|
||||||
|
CurNode.EndPos:=CurPos.EndPos;
|
||||||
|
EndChildNode;
|
||||||
|
end;
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
if CurPos.Flag<>cafSemicolon then
|
if CurPos.Flag<>cafSemicolon then
|
||||||
RaiseCharExpectedButAtomFound(';');
|
RaiseCharExpectedButAtomFound(';');
|
||||||
if ChildCreated then CurNode.Desc:=ctnClassOfType;
|
|
||||||
end else if (CurPos.Flag=cafRoundBracketOpen) then begin
|
end else if (CurPos.Flag=cafRoundBracketOpen) then begin
|
||||||
// read inheritage brackets
|
// read inheritage brackets
|
||||||
ReadTilBracketClose(true);
|
ReadTilBracketClose(true);
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
end;
|
end;
|
||||||
|
if ChildCreated and (CurNode.Desc=ctnClass) then
|
||||||
CurNode.SubDesc:=ctnsNeedJITParsing; // will not create sub nodes now
|
CurNode.SubDesc:=ctnsNeedJITParsing; // will not create sub nodes now
|
||||||
if CurPos.Flag=cafSemicolon then begin
|
if CurPos.Flag=cafSemicolon then begin
|
||||||
if ChildCreated and (CurNode.Desc=ctnClass) then begin
|
if ChildCreated and (CurNode.Desc=ctnClass) then begin
|
||||||
|
Loading…
Reference in New Issue
Block a user