mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 20:49:24 +02:00
codetools: implemented objcclass
git-svn-id: trunk@21689 -
This commit is contained in:
parent
08ed127d0f
commit
ddad9c8091
@ -125,7 +125,7 @@ type
|
||||
TCodeCompletionCodeTool = class(TMethodJumpingCodeTool)
|
||||
private
|
||||
ASourceChangeCache: TSourceChangeCache;
|
||||
FCodeCompleteClassNode: TCodeTreeNode; // the class that is to be completed (ctnClass or ctnClassInterface)
|
||||
FCodeCompleteClassNode: TCodeTreeNode; // the class that is to be completed (ctnClass, ...)
|
||||
FCompletingStartNode: TCodeTreeNode; // the first variable/method/GUID node in FCodeCompleteClassNode
|
||||
FAddInheritedCodeToOverrideMethod: boolean;
|
||||
FCompleteProperties: boolean;
|
||||
@ -3973,7 +3973,7 @@ function TCodeCompletionCodeTool.BuildUnitDefinitionGraph(out
|
||||
end;
|
||||
end;
|
||||
|
||||
ctnRecordType, ctnClassInterface, ctnClass:
|
||||
ctnRecordType, ctnClassInterface, ctnClass, ctnObject, ctnObjCClass:
|
||||
begin
|
||||
ChildNode:=SubNode.FirstChild;
|
||||
while (ChildNode<>nil) and (ChildNode.HasAsParent(SubNode)) do begin
|
||||
@ -5039,7 +5039,8 @@ begin
|
||||
ClassSectionNode:=ClassSectionNode.NextBrother;
|
||||
end else if ANodeExt.Node<>nil then begin
|
||||
// search a section of the same Visibility in front of the node
|
||||
if FCodeCompleteClassNode.Desc=ctnClass then begin
|
||||
if FCodeCompleteClassNode.Desc in [ctnClass,ctnObject,ctnObjCClass] then
|
||||
begin
|
||||
ClassSectionNode:=ANodeExt.Node.Parent.PriorBrother;
|
||||
while (ClassSectionNode<>nil)
|
||||
and (ClassSectionNode.Desc<>ClassSectionNodeType[Visibility]) do
|
||||
@ -6228,7 +6229,7 @@ var CleanCursorPos, Indent, insertPos: integer;
|
||||
{$IFDEF CTDEBUG}
|
||||
DebugLn('TCodeCompletionCodeTool.CompleteCode Complete Properties ... ');
|
||||
{$ENDIF}
|
||||
if FCodeCompleteClassNode.Desc=ctnClass then
|
||||
if FCodeCompleteClassNode.Desc in [ctnClass,ctnObject,ctnObjCClass] then
|
||||
SectionNode:=FCodeCompleteClassNode.FirstChild
|
||||
else
|
||||
SectionNode:=FCodeCompleteClassNode;
|
||||
@ -6734,7 +6735,8 @@ begin
|
||||
if ImplementationNode=nil then ImplementationNode:=Tree.Root;
|
||||
|
||||
// test if in a class
|
||||
AClassNode:=CursorNode.GetNodeOfTypes([ctnClass,ctnClassInterface]);
|
||||
AClassNode:=CursorNode.GetNodeOfTypes(
|
||||
[ctnClass,ctnClassInterface,ctnObject,ctnObjCClass]);
|
||||
if AClassNode<>nil then begin
|
||||
CompleteClass(AClassNode);
|
||||
exit;
|
||||
@ -6929,8 +6931,9 @@ begin
|
||||
else if CursorNode.Desc=ctnGenericType then
|
||||
CursorNode:=CursorNode.LastChild
|
||||
else
|
||||
CursorNode:=CursorNode.GetNodeOfTypes([ctnClass,ctnClassInterface]);
|
||||
if (CursorNode=nil) or (CursorNode.Desc<>ctnClass) then begin
|
||||
CursorNode:=CursorNode.GetNodeOfTypes(
|
||||
[ctnClass,ctnClassInterface,ctnObject,ctnObjCClass]);
|
||||
if (CursorNode=nil) or (not (CursorNode.Desc in AllClasses)) then begin
|
||||
DebugLn(['TIdentCompletionTool.AddMethods cursor not in a class']);
|
||||
exit;
|
||||
end;
|
||||
|
@ -82,20 +82,22 @@ const
|
||||
|
||||
ctnClass = 30;
|
||||
ctnClassInterface = 31;
|
||||
ctnClassInheritance = 32;
|
||||
ctnClassGUID = 33;
|
||||
ctnClassTypePrivate = 34;
|
||||
ctnClassTypeProtected = 35;
|
||||
ctnClassTypePublic = 36;
|
||||
ctnClassTypePublished = 37;
|
||||
ctnClassVarPrivate = 38;
|
||||
ctnClassVarProtected = 39;
|
||||
ctnClassVarPublic = 40;
|
||||
ctnClassVarPublished = 41;
|
||||
ctnClassPrivate = 42;
|
||||
ctnClassProtected = 43;
|
||||
ctnClassPublic = 44;
|
||||
ctnClassPublished = 45;
|
||||
ctnObject = 32;
|
||||
ctnObjCClass = 33;
|
||||
ctnClassInheritance = 34;
|
||||
ctnClassGUID = 35;
|
||||
ctnClassTypePrivate = 36;
|
||||
ctnClassTypeProtected = 37;
|
||||
ctnClassTypePublic = 38;
|
||||
ctnClassTypePublished = 39;
|
||||
ctnClassVarPrivate = 40;
|
||||
ctnClassVarProtected = 41;
|
||||
ctnClassVarPublic = 42;
|
||||
ctnClassVarPublished = 43;
|
||||
ctnClassPrivate = 44;
|
||||
ctnClassProtected = 45;
|
||||
ctnClassPublic = 46;
|
||||
ctnClassPublished = 47;
|
||||
|
||||
ctnProperty = 50;
|
||||
ctnMethodMap = 51;
|
||||
@ -159,7 +161,7 @@ const
|
||||
AllClassSections =
|
||||
AllClassBaseSections+AllClassTypeSections+AllClassVarSections;
|
||||
AllClasses =
|
||||
[ctnClass,ctnClassInterface];
|
||||
[ctnClass,ctnClassInterface,ctnObject,ctnObjCClass];
|
||||
AllDefinitionSections =
|
||||
[ctnTypeSection,ctnVarSection,ctnConstSection,ctnResStrSection,
|
||||
ctnLabelSection];
|
||||
@ -168,7 +170,8 @@ const
|
||||
AllSimpleIdentifierDefinitions =
|
||||
[ctnTypeDefinition,ctnVarDefinition,ctnConstDefinition];
|
||||
AllPascalTypes =
|
||||
[ctnClass,ctnClassInterface,ctnGenericType,ctnSpecialize,
|
||||
AllClasses+
|
||||
[ctnGenericType,ctnSpecialize,
|
||||
ctnIdentifier,ctnOpenArrayType,ctnRangedArrayType,ctnRecordType,
|
||||
ctnRecordCase,ctnRecordVariant,
|
||||
ctnProcedureType,ctnSetType,ctnRangeType,ctnEnumerationType,
|
||||
@ -176,8 +179,8 @@ const
|
||||
ctnClassOfType,ctnVariantType,ctnConstant];
|
||||
AllPascalStatements = [ctnBeginBlock,ctnWithStatement,ctnWithVariable,
|
||||
ctnOnBlock,ctnOnIdentifier,ctnOnStatement];
|
||||
AllFindContextDescs = AllIdentifierDefinitions + AllCodeSections +
|
||||
[ctnClass,ctnClassInterface,ctnProcedure];
|
||||
AllFindContextDescs = AllIdentifierDefinitions + AllCodeSections + AllClasses +
|
||||
[ctnProcedure];
|
||||
|
||||
|
||||
// CodeTreeNodeSubDescriptors
|
||||
@ -355,6 +358,8 @@ begin
|
||||
|
||||
ctnClass: Result:='Class';
|
||||
ctnClassInterface: Result:='Class Interface';
|
||||
ctnObject: Result:='Object';
|
||||
ctnObjCClass: Result:='ObjCClass';
|
||||
ctnClassInheritance: Result:='Class inheritance';
|
||||
ctnClassGUID: Result:='GUID';
|
||||
ctnClassPublished: Result:='Published';
|
||||
|
@ -539,7 +539,7 @@ begin
|
||||
begin
|
||||
if (SubDesc and ctnsNeedJITParsing)>0 then Result:=ctsUnparsed;
|
||||
end;
|
||||
ctnClass:
|
||||
ctnClass,ctnObject,ctnObjCClass,ctnClassInterface:
|
||||
begin
|
||||
Result:='';
|
||||
if (SubDesc and ctnsForwardDeclaration)>0 then Result:=ctsForward;
|
||||
|
@ -48,7 +48,7 @@ begin
|
||||
end;
|
||||
Node:=Tool.Tree.Root;
|
||||
while (Node<>nil) do begin
|
||||
if (Node.Desc=ctnClass)
|
||||
if (Node.Desc in [ctnClass,ctnObject,ctnObjCClass])
|
||||
and ((Node.SubDesc and ctnsForwardDeclaration)=0) then begin
|
||||
CurClassName:=Tool.ExtractClassName(Node,false);
|
||||
writeln(CurClassName);
|
||||
|
@ -108,7 +108,7 @@ type
|
||||
}
|
||||
const
|
||||
AllNodeCacheDescs =
|
||||
[ctnClass, ctnClassInterface, ctnProcedure, ctnRecordType, ctnWithStatement];
|
||||
AllClasses+[ctnProcedure, ctnRecordType, ctnWithStatement];
|
||||
|
||||
type
|
||||
TNodeCacheEntryFlag = (ncefSearchedInParents, ncefSearchedInAncestors);
|
||||
|
@ -1227,7 +1227,7 @@ var CleanCursorPos: integer;
|
||||
if CursorNode.Desc in [ctnTypeDefinition,ctnGenericType] then begin
|
||||
TypeNode:=FindTypeNodeOfDefinition(CursorNode);
|
||||
if (TypeNode<>nil)
|
||||
and (TypeNode.Desc in [ctnClass,ctnClassInterface])
|
||||
and (TypeNode.Desc in AllClasses)
|
||||
and ((TypeNode.SubDesc and ctnsForwardDeclaration)>0) then
|
||||
begin
|
||||
DirectSearch:=true;
|
||||
@ -1249,7 +1249,7 @@ var CleanCursorPos: integer;
|
||||
if SkipChecks then exit;
|
||||
ClassNode:=CursorNode;
|
||||
while (ClassNode<>nil)
|
||||
and (not (ClassNode.Desc in [ctnClass,ctnClassInterface]))
|
||||
and (not (ClassNode.Desc in AllClasses))
|
||||
do
|
||||
ClassNode:=ClassNode.Parent;
|
||||
if ClassNode<>nil then begin
|
||||
@ -1587,7 +1587,7 @@ begin
|
||||
// then search the properties
|
||||
repeat
|
||||
//DebugLn('TFindDeclarationTool.FindDeclarationOfPropertyPath ',Context.Node.DescAsString);
|
||||
if (not (Context.Node.Desc in [ctnClass,ctnClassInterface,ctnRecordType]))
|
||||
if (not (Context.Node.Desc in (AllClasses+[ctnRecordType])))
|
||||
then
|
||||
exit;
|
||||
Params.Flags:=[fdfExceptionOnNotFound,fdfSearchInAncestors];
|
||||
@ -1616,7 +1616,8 @@ begin
|
||||
//DebugLn(['TFindDeclarationTool.FindDeclarationOfPropertyPath has not type, searching next ...']);
|
||||
Params.SetIdentifier(Self,PChar(Pointer(Identifier)),nil);
|
||||
Params.ContextNode:=
|
||||
Context.Node.GetNodeOfTypes([ctnClass,ctnClassInterface]);
|
||||
Context.Node.GetNodeOfTypes(
|
||||
[ctnClass,ctnClassInterface,ctnObject,ctnObjCClass]);
|
||||
if Params.ContextNode=nil then
|
||||
Params.ContextNode:=Context.Node;
|
||||
Params.Flags:=[fdfExceptionOnNotFound,fdfSearchInAncestors,
|
||||
@ -2050,7 +2051,7 @@ begin
|
||||
Result:=Result+'published ';
|
||||
end;
|
||||
break;
|
||||
end else if ANode.Desc in [ctnParameterList,ctnClass,ctnClassInterface] then
|
||||
end else if ANode.Desc in ([ctnParameterList]+AllClasses) then
|
||||
break;
|
||||
ANode:=ANode.Parent;
|
||||
end;
|
||||
@ -2077,7 +2078,7 @@ begin
|
||||
TypeNode:=NewTool.FindTypeNodeOfDefinition(NewNode);
|
||||
if TypeNode<>nil then begin
|
||||
case TypeNode.Desc of
|
||||
ctnIdentifier, ctnClass, ctnClassInterface:
|
||||
ctnIdentifier, ctnClass, ctnClassInterface, ctnObject, ctnObjCClass:
|
||||
begin
|
||||
NewTool.MoveCursorToNodeStart(TypeNode);
|
||||
NewTool.ReadNextAtom;
|
||||
@ -2197,7 +2198,7 @@ begin
|
||||
Params.Flags:=Params.Flags+[fdfFunctionResult,fdfFindChilds];
|
||||
FindContext:=FindBaseTypeOfNode(Params,ANode);
|
||||
if (FindContext.Node<>nil)
|
||||
and (FindContext.Node.Desc in [ctnRecordType,ctnClass,ctnClassInterface])
|
||||
and ((FindContext.Node.Desc in ([ctnRecordType]+AllClasses)))
|
||||
and (FindContext.Node.FirstChild<>nil)
|
||||
then
|
||||
Result:=true;
|
||||
@ -2545,7 +2546,7 @@ var
|
||||
|
||||
procedure MoveContextNodeToChilds;
|
||||
begin
|
||||
if ContextNode.Desc in [ctnClass,ctnClassInterface] then begin
|
||||
if ContextNode.Desc in AllClasses then begin
|
||||
// just-in-time parsing for class node
|
||||
BuildSubTreeForClass(ContextNode);
|
||||
end;
|
||||
@ -2610,7 +2611,7 @@ var
|
||||
if not (fdfCollect in Params.Flags) then begin
|
||||
if (fdfSkipClassForward in Params.Flags)
|
||||
and (ContextNode.FirstChild<>nil)
|
||||
and (ContextNode.FirstChild.Desc in [ctnClass,ctnClassInheritance])
|
||||
and (ContextNode.FirstChild.Desc in AllClasses)
|
||||
and ((ctnsForwardDeclaration and ContextNode.FirstChild.SubDesc)<>0)
|
||||
then begin
|
||||
FindNonForwardClass(Params);
|
||||
@ -2707,7 +2708,7 @@ var
|
||||
if (not (fdfSearchInParentNodes in Params.Flags)) then begin
|
||||
// searching in any parent context is not permitted
|
||||
if not ((fdfSearchInAncestors in Params.Flags)
|
||||
and (ContextNode.Desc in [ctnClass,ctnClassInterface])) then begin
|
||||
and (ContextNode.Desc in AllClasses)) then begin
|
||||
// even searching in ancestors contexts is not permitted
|
||||
// -> there is no prior context accessible any more
|
||||
// -> identifier not found
|
||||
@ -2743,7 +2744,7 @@ var
|
||||
end;
|
||||
end;
|
||||
|
||||
if (ContextNode.Desc in [ctnClass,ctnClassInterface])
|
||||
if (ContextNode.Desc in AllClasses)
|
||||
and (fdfSearchInAncestors in Params.Flags) then begin
|
||||
// after searching in a class definiton, search in its ancestors
|
||||
|
||||
@ -2835,7 +2836,8 @@ var
|
||||
// of the prior node
|
||||
;
|
||||
|
||||
ctnClass, ctnClassInterface, ctnRecordType, ctnRecordCase:
|
||||
ctnClass, ctnClassInterface, ctnObject, ctnObjCClass,
|
||||
ctnRecordType, ctnRecordCase:
|
||||
// do not search again in this node, go on ...
|
||||
;
|
||||
|
||||
@ -2943,7 +2945,7 @@ begin
|
||||
ctnClassPublic, ctnClassPrivate, ctnClassProtected, ctnClassPublished,
|
||||
ctnClassTypePublished,ctnClassTypePublic,ctnClassTypeProtected,ctnClassTypePrivate,
|
||||
ctnClassVarPublished,ctnClassVarPublic,ctnClassVarProtected,ctnClassVarPrivate,
|
||||
ctnClass, ctnClassInterface,
|
||||
ctnClass, ctnClassInterface, ctnObject, ctnObjCClass,
|
||||
ctnRecordType, ctnRecordVariant,
|
||||
ctnParameterList:
|
||||
// these nodes build a parent-child relationship. But in pascal
|
||||
@ -3072,7 +3074,7 @@ begin
|
||||
Result:=false;
|
||||
if Params.ContextNode=nil then exit;
|
||||
CurContextNode:=Params.ContextNode;
|
||||
if CurContextNode.Desc=ctnClass then
|
||||
if CurContextNode.Desc in AllClasses then
|
||||
BuildSubTreeForClass(CurContextNode);
|
||||
CurContextNode:=CurContextNode.FirstChild;
|
||||
while CurContextNode<>nil do begin
|
||||
@ -3228,7 +3230,7 @@ begin
|
||||
break;
|
||||
Result.Node:=DummyNode;
|
||||
end else
|
||||
if (Result.Node.Desc in [ctnClass,ctnClassInterface])
|
||||
if (Result.Node.Desc in AllClasses)
|
||||
and ((Result.Node.SubDesc and ctnsForwardDeclaration)>0) then
|
||||
begin
|
||||
// this is a forward defined class
|
||||
@ -3723,7 +3725,8 @@ begin
|
||||
{$IFDEF CheckNodeTool}CheckNodeTool(ClassNode);{$ENDIF}
|
||||
Result:=false;
|
||||
ListOfPFindContext:=nil;
|
||||
if (ClassNode=nil) or (ClassNode.Desc<>ctnClass) or (ClassNode.Parent=nil)
|
||||
if (ClassNode=nil) or (not (ClassNode.Desc in AllClasses))
|
||||
or (ClassNode.Parent=nil)
|
||||
or (not (ClassNode.Parent.Desc in [ctnTypeDefinition,ctnGenericType])) then
|
||||
exit;
|
||||
|
||||
@ -3744,7 +3747,7 @@ begin
|
||||
CurTool:=Params.NewCodeTool;
|
||||
ClassNode:=Params.NewNode;
|
||||
if (ClassNode=nil)
|
||||
or (not (ClassNode.Desc in [ctnClass,ctnClassInterface])) then
|
||||
or (not (ClassNode.Desc in AllClasses)) then
|
||||
break;
|
||||
end;
|
||||
Result:=true;
|
||||
@ -3762,7 +3765,7 @@ end;
|
||||
function TFindDeclarationTool.FindContextClassAndAncestors(
|
||||
const CursorPos: TCodeXYPosition; var ListOfPFindContext: TFPList
|
||||
): boolean;
|
||||
// returns a list of nodes of ctnClass
|
||||
// returns a list of nodes of AllClasses (ctnClass, ...)
|
||||
var
|
||||
CleanCursorPos: integer;
|
||||
ANode: TCodeTreeNode;
|
||||
@ -4316,7 +4319,7 @@ begin
|
||||
Result:=InNodeIdentifier(CurPos.StartPos);
|
||||
end;
|
||||
|
||||
ctnBeginBlock,ctnClass:
|
||||
ctnBeginBlock,ctnClass,ctnObject,ctnObjCClass:
|
||||
if (Node.SubDesc and ctnsForwardDeclaration)>0 then
|
||||
RaiseException('TFindDeclarationTool.CleanPosIsDeclarationIdentifier Node not expanded');
|
||||
|
||||
@ -4416,7 +4419,7 @@ begin
|
||||
exit;
|
||||
TypeNode:=FindTypeNodeOfDefinition(Node);
|
||||
if TypeNode=nil then exit;
|
||||
if TypeNode.Desc=ctnClass then begin
|
||||
if TypeNode.Desc in AllClasses then begin
|
||||
if (TypeNode.SubDesc and ctnsForwardDeclaration)>0 then begin
|
||||
Result:=true;
|
||||
exit;
|
||||
@ -4504,10 +4507,9 @@ begin
|
||||
DebugLn('[TFindDeclarationTool.FindIdentifierInClassOfMethod] Proc="',copy(src,ProcContextNode.StartPos,30),'" searching class of method class="',ExtractIdentifier(ClassNameAtom.StartPos),'"');
|
||||
{$ENDIF}
|
||||
FindIdentifierInContext(Params);
|
||||
ClassContext:=Params.NewCodeTool.FindBaseTypeOfNode(
|
||||
Params,Params.NewNode);
|
||||
ClassContext:=Params.NewCodeTool.FindBaseTypeOfNode(Params,Params.NewNode);
|
||||
if (ClassContext.Node=nil)
|
||||
or (ClassContext.Node.Desc<>ctnClass) then begin
|
||||
or (not (ClassContext.Node.Desc in AllClasses)) then begin
|
||||
MoveCursorToCleanPos(ClassNameAtom.StartPos);
|
||||
RaiseException(ctsClassIdentifierExpected);
|
||||
end;
|
||||
@ -4598,7 +4600,7 @@ begin
|
||||
Params.Flags:=Params.Flags+[fdfFindChilds];
|
||||
ClassContext:=FindBaseTypeOfNode(Params,Params.NewNode);
|
||||
if (ClassContext.Node=nil)
|
||||
or (ClassContext.Node.Desc<>ctnClass) then begin
|
||||
or (not (ClassContext.Node.Desc in AllClasses)) then begin
|
||||
MoveCursorToCleanPos(ClassNameAtom.StartPos);
|
||||
RaiseException(ctsClassIdentifierExpected);
|
||||
end;
|
||||
@ -4626,7 +4628,7 @@ var
|
||||
AncestorContext: TFindContext;
|
||||
begin
|
||||
{$IFDEF CheckNodeTool}CheckNodeTool(ClassNode);{$ENDIF}
|
||||
if (ClassNode=nil) or (not (ClassNode.Desc in [ctnClass,ctnClassInterface]))
|
||||
if (ClassNode=nil) or (not (ClassNode.Desc in AllClasses))
|
||||
then
|
||||
RaiseException('[TFindDeclarationTool.FindAncestorOfClass] '
|
||||
+' invalid classnode');
|
||||
@ -4656,13 +4658,14 @@ begin
|
||||
if ClassNode.Desc=ctnClass then begin
|
||||
// if this class is not TObject, TObject is class ancestor
|
||||
SearchBaseClass:=not CompareSrcIdentifiers(ClassIdentNode.StartPos,'TObject');
|
||||
end else begin
|
||||
end else if ClassNode.Desc=ctnClassInterface then begin
|
||||
// Delphi has as default interface IInterface
|
||||
// FPC has as default interface IUnknown and an alias IInterface = IUnknown
|
||||
SearchBaseClass:=
|
||||
(not CompareSrcIdentifiers(ClassIdentNode.StartPos,'IInterface'))
|
||||
and (not CompareSrcIdentifiers(ClassIdentNode.StartPos,'IUnknown'));
|
||||
end;
|
||||
end else
|
||||
exit;
|
||||
if not SearchBaseClass then exit;
|
||||
|
||||
{$IFDEF ShowTriedContexts}
|
||||
@ -4678,8 +4681,10 @@ begin
|
||||
-[fdfTopLvlResolving];
|
||||
if ClassNode.Desc=ctnClass then
|
||||
Params.SetIdentifier(Self,'TObject',nil)
|
||||
else if ClassNode.Desc=ctnClassInterface then
|
||||
Params.SetIdentifier(Self,'IInterface',nil)
|
||||
else
|
||||
Params.SetIdentifier(Self,'IInterface',nil);
|
||||
exit;
|
||||
Params.ContextNode:=ClassNode;
|
||||
if not FindIdentifierInContext(Params) then begin
|
||||
MoveCursorToNodeStart(ClassNode);
|
||||
@ -4709,8 +4714,8 @@ begin
|
||||
Params.SetResult(AncestorContext);
|
||||
|
||||
// check result
|
||||
if not (Params.NewNode.Desc in [ctnClass,ctnClassInterface]) then
|
||||
begin
|
||||
if not (Params.NewNode.Desc in [ctnClass,ctnClassInterface])
|
||||
then begin
|
||||
MoveCursorToNodeStart(ClassNode);
|
||||
if ClassNode.Desc=ctnClass then
|
||||
RaiseException(ctsDefaultClassAncestorTObjectNotFound)
|
||||
@ -4795,7 +4800,7 @@ begin
|
||||
Params.SetResult(AncestorContext);
|
||||
|
||||
// check result
|
||||
if not (Params.NewNode.Desc in [ctnClass,ctnClassInterface]) then
|
||||
if not (Params.NewNode.Desc in AllClasses) then
|
||||
begin
|
||||
MoveCursorToCleanPos(AncestorStartPos);
|
||||
ReadNextAtom;
|
||||
@ -4884,7 +4889,7 @@ begin
|
||||
exit;
|
||||
Node:=Node.FirstChild;
|
||||
if (Node=nil)
|
||||
or (not (Node.Desc in [ctnClass,ctnClassInterface]))
|
||||
or (not (Node.Desc in AllClasses))
|
||||
or ((ctnsForwardDeclaration and Node.SubDesc)=0) then
|
||||
exit;
|
||||
Node:=Params.NewNode;
|
||||
@ -4938,7 +4943,7 @@ begin
|
||||
or (WithVarExpr.Context.Node=nil)
|
||||
or (WithVarExpr.Context.Node=OldInput.ContextNode)
|
||||
or (not (WithVarExpr.Context.Node.Desc
|
||||
in [ctnClass,ctnClassInterface,ctnRecordType]))
|
||||
in (AllClasses+[ctnRecordType])))
|
||||
then begin
|
||||
MoveCursorToCleanPos(WithVarNode.StartPos);
|
||||
RaiseException(ctsExprTypeMustBeClassOrRecord);
|
||||
@ -6445,9 +6450,10 @@ var
|
||||
ExprType.Context:=ExprType.Context.Tool.FindBaseTypeOfNode(Params,
|
||||
ExprType.Context.Node.FirstChild);
|
||||
|
||||
ctnClass, ctnClassInterface, ctnProperty, ctnGlobalProperty:
|
||||
ctnClass, ctnClassInterface, ctnObject, ctnObjCClass,
|
||||
ctnProperty, ctnGlobalProperty:
|
||||
begin
|
||||
if ExprType.Context.Node.Desc in [ctnClass,ctnClassInterface] then begin
|
||||
if ExprType.Context.Node.Desc in AllClasses then begin
|
||||
// search default property of the class / interface
|
||||
Params.Save(OldInput);
|
||||
Params.Flags:=[fdfSearchInAncestors,fdfExceptionOnNotFound]
|
||||
@ -7876,7 +7882,7 @@ function TFindDeclarationTool.ContextIsDescendOf(const DescendContext,
|
||||
var CurContext: TFindContext;
|
||||
OldInput: TFindDeclarationInput;
|
||||
begin
|
||||
if not (DescendContext.Node.Desc in [ctnClass,ctnClassInterface]) then
|
||||
if not (DescendContext.Node.Desc in AllClasses) then
|
||||
RaiseInternalError;
|
||||
{$IFDEF ShowExprEval}
|
||||
DebugLn('[TFindDeclarationTool.ContextIsDescendOf] ',
|
||||
@ -7935,7 +7941,7 @@ begin
|
||||
// same context type
|
||||
case ExprNode.Desc of
|
||||
|
||||
ctnClass,ctnClassInterface:
|
||||
ctnClass,ctnClassInterface, ctnObject, ctnObjCClass:
|
||||
// check, if ExpressionType.Context is descend of TargetContext
|
||||
if ContextIsDescendOf(ExpressionType.Context,
|
||||
TargetType.Context,Params)
|
||||
@ -7960,7 +7966,7 @@ begin
|
||||
|
||||
end else if ((TargetType.Desc=xtPointer)
|
||||
and (ExpressionType.Desc=xtContext)
|
||||
and (ExpressionType.Context.Node.Desc in [ctnClass,ctnClassInterface]))
|
||||
and (ExpressionType.Context.Node.Desc in AllClasses))
|
||||
then begin
|
||||
// assigning a class to a pointer
|
||||
Result:=tcExact;
|
||||
@ -7983,8 +7989,7 @@ begin
|
||||
Result:=tcCompatible
|
||||
else if (TargetType.Desc=xtContext) then begin
|
||||
TargetNode:=TargetType.Context.Node;
|
||||
if ((TargetNode.Desc
|
||||
in [ctnClass,ctnClassInterface,ctnProcedure])
|
||||
if ((TargetNode.Desc in (AllClasses+[ctnProcedure]))
|
||||
and (ExpressionType.Desc=xtNil))
|
||||
or ((TargetNode.Desc in [ctnOpenArrayType,ctnRangedArrayType])
|
||||
and (TargetNode.LastChild<>nil)
|
||||
@ -9015,8 +9020,11 @@ begin
|
||||
Result:=GetIdentifier(@FindContext.Tool.Src[ANode.StartPos]);
|
||||
end;
|
||||
|
||||
ctnClass, ctnClassInterface:
|
||||
Result:=GetIdentifier(
|
||||
ctnClass, ctnClassInterface, ctnObject, ctnObjCClass:
|
||||
if (FindContext.Node.Parent<>nil)
|
||||
and (FindContext.Node.Parent.Desc in [ctnTypeDefinition,ctnGenericType])
|
||||
then
|
||||
Result:=GetIdentifier(
|
||||
@FindContext.Tool.Src[FindContext.Node.Parent.StartPos]);
|
||||
|
||||
ctnEnumerationType:
|
||||
|
@ -161,7 +161,7 @@ begin
|
||||
while ParentCodeNode<>nil do begin
|
||||
//DebugLn(['TDeclarationOverloadsGraph.AddContext ',ParentCodeNode.DescAsString]);
|
||||
if ParentCodeNode.Desc in
|
||||
AllSourceTypes+[ctnClass,ctnClassInterface,ctnRecordType]
|
||||
AllSourceTypes+AllClasses+[ctnRecordType]
|
||||
then begin
|
||||
//DebugLn(['TDeclarationOverloadsGraph.AddContext ADD parent']);
|
||||
ParentGraphNode:=AddContext(Tool,ParentCodeNode);
|
||||
@ -177,7 +177,7 @@ begin
|
||||
// add ancestors, interfaces
|
||||
if (CodeNode.Desc=ctnTypeDefinition)
|
||||
and (CodeNode.FirstChild<>nil)
|
||||
and (CodeNode.FirstChild.Desc in [ctnClass,ctnClassInterface]) then begin
|
||||
and (CodeNode.FirstChild.Desc in AllClasses) then begin
|
||||
//DebugLn(['TDeclarationOverloadsGraph.AddContext a class or interface']);
|
||||
// a class or class interface
|
||||
ClassNode:=CodeNode.FirstChild;
|
||||
|
@ -887,7 +887,7 @@ var
|
||||
// => all protected ancestor classes are allowed as well.
|
||||
CurClassNode:=FoundContext.Node;
|
||||
while (CurClassNode<>nil)
|
||||
and (not (CurClassNode.Desc in [ctnClass,ctnClassInterface])) do
|
||||
and (not (CurClassNode.Desc in AllClasses)) do
|
||||
CurClassNode:=CurClassNode.Parent;
|
||||
if CurClassNode=nil then exit;
|
||||
p:=CreateFindContext(Params.NewCodeTool,CurClassNode);
|
||||
@ -1005,7 +1005,7 @@ begin
|
||||
Ident:=@FoundContext.Tool.Src[Node.StartPos];
|
||||
end;
|
||||
if (Node<>nil)
|
||||
and (Node.Desc in [ctnClass,ctnClassInterface])
|
||||
and (Node.Desc in AllClasses)
|
||||
and ((ctnsForwardDeclaration and Node.SubDesc)>0)
|
||||
then begin
|
||||
// forward definition of a class
|
||||
@ -1260,7 +1260,8 @@ begin
|
||||
CurrentIdentifierList.Add(NewItem);
|
||||
end;
|
||||
if (UpAtomIs('READ') or UpAtomIs('WRITE'))
|
||||
and (Context.Node.GetNodeOfType(ctnClass)<>nil) then begin
|
||||
and (Context.Node.GetNodeOfTypes([ctnClass,ctnObject,ctnObjCClass])<>nil)
|
||||
then begin
|
||||
// add the default class completion 'read'/'write' specifier variable
|
||||
NewItem:=TIdentifierListItem.Create(
|
||||
icompUnknown,true,0,
|
||||
@ -1420,7 +1421,8 @@ var
|
||||
begin
|
||||
Node:=Context.Node;
|
||||
case Node.Desc of
|
||||
ctnClass,ctnClassPrivate,ctnClassProtected,ctnClassPublic,ctnClassPublished:
|
||||
ctnClass,ctnObject,ctnObjCClass,
|
||||
ctnClassPrivate,ctnClassProtected,ctnClassPublic,ctnClassPublished:
|
||||
begin
|
||||
Add('public');
|
||||
Add('private');
|
||||
@ -1433,6 +1435,12 @@ begin
|
||||
Add('destructor');
|
||||
end;
|
||||
|
||||
ctnClassInterface:
|
||||
begin
|
||||
Add('procedure');
|
||||
Add('function');
|
||||
end;
|
||||
|
||||
ctnInterface,ctnImplementation:
|
||||
begin
|
||||
if (Node.FirstChild=nil)
|
||||
@ -1573,7 +1581,7 @@ begin
|
||||
or ((GatherContext.Node.Parent<>nil)
|
||||
and (GatherContext.Node.Parent.Desc=ctnClassInheritance))
|
||||
then begin
|
||||
while not (GatherContext.Node.Desc in [ctnClass,ctnClassInterface]) do
|
||||
while not (GatherContext.Node.Desc in AllClasses) do
|
||||
GatherContext.Node:=GatherContext.Node.Parent;
|
||||
GatherContext.Node:=GatherContext.Node.Parent;
|
||||
IgnoreCurContext:=true;
|
||||
@ -1809,7 +1817,7 @@ begin
|
||||
Params.Flags:=[fdfSearchInAncestors,fdfCollect,fdfFindVariable];
|
||||
if not StartInSubContext then
|
||||
Include(Params.Flags,fdfSearchInParentNodes);
|
||||
if Params.ContextNode.Desc in [ctnClass,ctnClassInterface] then
|
||||
if Params.ContextNode.Desc in AllClasses then
|
||||
Exclude(Params.Flags,fdfSearchInParentNodes);
|
||||
{$IFDEF CTDEBUG}
|
||||
DebugLn('TIdentCompletionTool.GatherIdentifiers F');
|
||||
@ -2175,8 +2183,10 @@ begin
|
||||
else if CursorNode.Desc=ctnGenericType then
|
||||
CursorNode:=CursorNode.LastChild
|
||||
else
|
||||
CursorNode:=CursorNode.GetNodeOfTypes([ctnClass,ctnClassInterface]);
|
||||
if (CursorNode=nil) or (CursorNode.Desc<>ctnClass)
|
||||
CursorNode:=CursorNode.GetNodeOfTypes(
|
||||
[ctnClass,ctnClassInterface,ctnObject,ctnObjCClass]);
|
||||
if (CursorNode=nil)
|
||||
or (not (CursorNode.Desc in [ctnClass,ctnObject,ctnObjCClass]))
|
||||
or ((CursorNode.SubDesc and ctnsForwardDeclaration)>0) then begin
|
||||
MoveCursorToCleanPos(CleanCursorPos);
|
||||
RaiseException('TIdentCompletionTool.FindAbstractMethods cursor is not in a class');
|
||||
@ -2537,7 +2547,7 @@ var
|
||||
ANode: TCodeTreeNode;
|
||||
begin
|
||||
Result:=false;
|
||||
if GetDesc in [ctnClass,ctnRecordType,ctnClassInterface] then begin
|
||||
if GetDesc in (AllClasses+[ctnRecordType]) then begin
|
||||
Result:=true;
|
||||
exit;
|
||||
end;
|
||||
@ -2546,8 +2556,7 @@ begin
|
||||
UpdateBaseContext;
|
||||
if (BaseExprType.Desc=xtContext)
|
||||
and (BaseExprType.Context.Node<>nil)
|
||||
and (BaseExprType.Context.Node.Desc
|
||||
in [ctnClass,ctnRecordType,ctnClassInterface])
|
||||
and (BaseExprType.Context.Node.Desc in (AllClasses+[ctnRecordType]))
|
||||
then
|
||||
Include(Flags,iliHasChilds);
|
||||
end;
|
||||
|
@ -351,7 +351,7 @@ begin
|
||||
DebugLn('TMethodJumpingCodeTool.FindJumpPoint C ',NodeDescriptionAsString(CursorNode.Desc));
|
||||
{$ENDIF}
|
||||
// first test if in a class
|
||||
ClassNode:=CursorNode.GetNodeOfType(ctnClass);
|
||||
ClassNode:=CursorNode.GetNodeOfTypes([ctnClass,ctnObject,ctnObjCClass]);
|
||||
if ClassNode<>nil then begin
|
||||
// cursor is in class/object definition
|
||||
// search in all implemented class procedures for the body
|
||||
@ -796,7 +796,7 @@ begin
|
||||
cmp:=false;
|
||||
end;
|
||||
if cmp and (phpIgnoreMethods in Attr) then begin
|
||||
if ANode.HasParentOfType(ctnClass)
|
||||
if (ANode.GetNodeOfTypes([ctnClass,ctnObject,ctnObjCClass])<>nil)
|
||||
or (ExtractClassNameOfProcNode(ANode)<>'')
|
||||
then
|
||||
cmp:=false;
|
||||
|
@ -385,7 +385,8 @@ begin
|
||||
'L':
|
||||
if CompareSrcIdentifiers('LABEL',p) then exit(KeyWordFuncTypeLabel);
|
||||
'O':
|
||||
if CompareSrcIdentifiers('OBJECT',p) then exit(KeyWordFuncClass);
|
||||
if CompareSrcIdentifiers('OBJECT',p)
|
||||
or CompareSrcIdentifiers('OBJCCLASS',p) then exit(KeyWordFuncClass);
|
||||
'P':
|
||||
case UpChars[p[1]] of
|
||||
'A': if CompareSrcIdentifiers('PACKED',p) then exit(KeyWordFuncTypePacked);
|
||||
@ -682,7 +683,7 @@ begin
|
||||
try
|
||||
if ClassNode=nil then
|
||||
RaiseClassNodeNil;
|
||||
if ClassNode.Desc<>ctnClass then
|
||||
if not (ClassNode.Desc in [ctnClass,ctnObject,ctnObjCClass]) then
|
||||
RaiseClassDescInvalid;
|
||||
// set CursorPos after class head
|
||||
MoveCursorToNodeStart(ClassNode);
|
||||
@ -695,7 +696,9 @@ begin
|
||||
// read the "class"/"object" keyword
|
||||
ReadNextAtom;
|
||||
if UpAtomIs('PACKED') or (UpAtomIs('BITPACKED')) then ReadNextAtom;
|
||||
if (not UpAtomIs('CLASS')) and (not UpAtomIs('OBJECT')) then
|
||||
if not (UpAtomIs('CLASS') or UpAtomIs('OBJECT') or UpAtomIs('OBJCCLASS')
|
||||
or UpAtomIs('INTERFACE'))
|
||||
then
|
||||
RaiseClassKeyWordExpected;
|
||||
ReadNextAtom;
|
||||
if CurPos.Flag=cafRoundBracketOpen then
|
||||
@ -3330,6 +3333,7 @@ var
|
||||
IsForward: Boolean;
|
||||
p: PChar;
|
||||
BracketLvl: Integer;
|
||||
ClassDesc: TCodeTreeNodeDesc;
|
||||
begin
|
||||
ContextDesc:=CurNode.Desc;
|
||||
if not (ContextDesc in [ctnTypeDefinition,ctnGenericType,
|
||||
@ -3344,10 +3348,18 @@ begin
|
||||
ClassAtomPos:=CurPos;
|
||||
end;
|
||||
// class or 'class of' start found
|
||||
ChildCreated:=(UpAtomIs('CLASS')) or (UpAtomIs('OBJECT'));
|
||||
if UpAtomIs('CLASS') then
|
||||
ClassDesc:=ctnClass
|
||||
else if UpAtomIs('OBJECT') then
|
||||
ClassDesc:=ctnObject
|
||||
else if UpAtomIs('OBJCCLASS') then
|
||||
ClassDesc:=ctnObjCClass
|
||||
else
|
||||
ClassDesc:=ctnNone;
|
||||
ChildCreated:=ClassDesc<>ctnNone;
|
||||
if ChildCreated then begin
|
||||
CreateChildNode;
|
||||
CurNode.Desc:=ctnClass;
|
||||
CurNode.Desc:=ClassDesc;
|
||||
CurNode.StartPos:=ClassAtomPos.StartPos;
|
||||
end;
|
||||
// find end of class
|
||||
@ -3377,16 +3389,18 @@ begin
|
||||
ReadNextAtom;
|
||||
end;
|
||||
if CurPos.Flag=cafSemicolon then begin
|
||||
if ChildCreated and (CurNode.Desc=ctnClass) and IsForward then begin
|
||||
// forward class definition found
|
||||
CurNode.SubDesc:=CurNode.SubDesc+ctnsForwardDeclaration;
|
||||
end else begin
|
||||
// very short class found e.g. = class(TAncestor);
|
||||
if ChildCreated and (CurNode.Desc=ctnClass) then
|
||||
if ChildCreated and (ClassDesc in [ctnClass,ctnObject,ctnObjCClass]) then
|
||||
begin
|
||||
if IsForward then begin
|
||||
// forward class definition found
|
||||
CurNode.SubDesc:=CurNode.SubDesc+ctnsForwardDeclaration;
|
||||
end else begin
|
||||
// very short class found e.g. = class(TAncestor);
|
||||
CurNode.SubDesc:=CurNode.SubDesc+ctnsNeedJITParsing; // will not create sub nodes now
|
||||
end;
|
||||
end;
|
||||
end else begin
|
||||
if ChildCreated and (CurNode.Desc=ctnClass) then
|
||||
if ChildCreated and (ClassDesc in [ctnClass,ctnObject,ctnObjCClass]) then
|
||||
CurNode.SubDesc:=CurNode.SubDesc+ctnsNeedJITParsing; // will not create sub nodes now
|
||||
// read til end or any suspicious keyword
|
||||
Level:=1;
|
||||
@ -4364,7 +4378,8 @@ begin
|
||||
OldPhase:=CurrentPhase;
|
||||
CurrentPhase:=CodeToolPhaseParse;
|
||||
try
|
||||
IsMethod:=ProcNode.HasParentOfType(ctnClass);
|
||||
IsMethod:=ProcNode.GetNodeOfTypes(
|
||||
[ctnClass,ctnClassInterface,ctnObject,ctnObjCClass])<>nil;
|
||||
MoveCursorToNodeStart(ProcNode);
|
||||
ReadNextAtom;
|
||||
if UpAtomIs('CLASS') then
|
||||
@ -4432,7 +4447,7 @@ procedure TPascalParserTool.BuildSubTree(ANode: TCodeTreeNode);
|
||||
begin
|
||||
if ANode=nil then exit;
|
||||
case ANode.Desc of
|
||||
ctnClass,ctnClassInterface:
|
||||
ctnClass,ctnClassInterface,ctnObject,ctnObjCClass:
|
||||
BuildSubTreeForClass(ANode);
|
||||
ctnProcedure,ctnProcedureHead:
|
||||
BuildSubTreeForProcHead(ANode);
|
||||
@ -4446,8 +4461,7 @@ function TPascalParserTool.NodeNeedsBuildSubTree(ANode: TCodeTreeNode
|
||||
begin
|
||||
Result:=false;
|
||||
if ANode=nil then exit;
|
||||
case ANode.Desc of
|
||||
ctnClass,ctnClassInterface,ctnProcedureHead,ctnBeginBlock:
|
||||
if ANode.Desc in (AllClasses+[ctnProcedureHead,ctnBeginBlock]) then begin
|
||||
Result:=(ANode.SubDesc and ctnsNeedJITParsing)>0;
|
||||
end;
|
||||
end;
|
||||
|
@ -373,7 +373,8 @@ begin
|
||||
IsProcType:=(ProcNode.Desc=ctnProcedureType);
|
||||
if (phpAddClassname in Attr) then begin
|
||||
TheClassName:='';
|
||||
TypeDefNode:=ProcNode.GetNodeOfTypes([ctnClass,ctnClassInterface]);
|
||||
TypeDefNode:=ProcNode.GetNodeOfTypes(
|
||||
[ctnClass,ctnClassInterface,ctnObject,ctnObjCClass]);
|
||||
if TypeDefNode<>nil then begin
|
||||
TheClassName:=ExtractClassName(TypeDefNode,phpInUpperCase in Attr);
|
||||
end;
|
||||
@ -495,17 +496,10 @@ var
|
||||
DefNode: TCodeTreeNode;
|
||||
begin
|
||||
if ClassNode<>nil then begin
|
||||
if ClassNode.Desc <> ctnClass then
|
||||
begin
|
||||
// find class of node
|
||||
repeat
|
||||
ClassNode := ClassNode.Parent;
|
||||
if (ClassNode = nil) or (ClassNode.Desc in AllCodeSections) then
|
||||
begin
|
||||
Result := '';
|
||||
Exit;
|
||||
end;
|
||||
until ClassNode.Desc = ctnClass;
|
||||
ClassNode:=ClassNode.GetNodeOfTypes([ctnClass,ctnObject,ctnObjCClass]);
|
||||
if (ClassNode = nil) then begin
|
||||
Result := '';
|
||||
Exit;
|
||||
end;
|
||||
|
||||
DefNode:=ClassNode.Parent;
|
||||
@ -528,11 +522,14 @@ function TPascalReaderTool.ExtractClassInheritance(
|
||||
ClassNode: TCodeTreeNode; Attr: TProcHeadAttributes): string;
|
||||
begin
|
||||
Result:='';
|
||||
if (ClassNode=nil) or (ClassNode.Desc<>ctnClass) then exit;
|
||||
if (ClassNode=nil) or (not (ClassNode.Desc in AllClasses)) then exit;
|
||||
MoveCursorToNodeStart(ClassNode);
|
||||
ReadNextAtom; // class
|
||||
if UpAtomIs('PACKED') then ReadNextAtom;
|
||||
if not UpAtomIs('CLASS') then exit;
|
||||
if not (UpAtomIs('CLASS') or UpAtomIs('OBJECT') or UpAtomIs('OBJCLASS')
|
||||
or (UpAtomIs('INTERFACE')))
|
||||
then
|
||||
exit;
|
||||
ReadNextAtom; // '('
|
||||
if CurPos.Flag<>cafRoundBracketOpen then exit;
|
||||
ReadNextAtom;
|
||||
@ -618,7 +615,7 @@ begin
|
||||
|
||||
// check proc kind
|
||||
//debugln('TPascalReaderTool.FindCorrespondingProcNode Check kind');
|
||||
ClassNode:=ProcNode.GetNodeOfType(ctnClass);
|
||||
ClassNode:=ProcNode.GetNodeOfTypes([ctnClass,ctnObject,ctnObjCClass]);
|
||||
if ClassNode<>nil then begin
|
||||
//debugln('TPascalReaderTool.FindCorrespondingProcNode Class');
|
||||
// in a class definition -> search method body
|
||||
@ -629,7 +626,7 @@ begin
|
||||
StartNode:=FindClassNodeInUnit(ExtractClassNameOfProcNode(ProcNode),true,
|
||||
false,false,true);
|
||||
BuildSubTreeForClass(StartNode);
|
||||
if (StartNode<>nil) and (StartNode.Desc in [ctnClass,ctnClassInterface])
|
||||
if (StartNode<>nil) and (StartNode.Desc in AllClasses)
|
||||
then begin
|
||||
StartNode:=StartNode.FirstChild;
|
||||
while (StartNode<>nil) and (not (StartNode.Desc in AllClassBaseSections))
|
||||
@ -1270,7 +1267,8 @@ begin
|
||||
while (ANode<>nil) do begin
|
||||
if ANode.Desc in [ctnTypeDefinition,ctnGenericType] then begin
|
||||
CurClassNode:=FindTypeNodeOfDefinition(ANode);
|
||||
if (CurClassNode<>nil) and (CurClassNode.Desc=ctnClass) then begin
|
||||
if (CurClassNode<>nil)
|
||||
and (CurClassNode.Desc in [ctnClass,ctnObject,ctnObjCClass]) then begin
|
||||
if (not (IgnoreForwards
|
||||
and ((CurClassNode.SubDesc and ctnsForwardDeclaration)>0)))
|
||||
and (not (IgnoreNonForwards
|
||||
@ -1320,7 +1318,8 @@ begin
|
||||
while ANode<>nil do begin
|
||||
if ANode.Desc=ctnTypeDefinition then begin
|
||||
CurClassNode:=ANode.FirstChild;
|
||||
if (CurClassNode<>nil) and (CurClassNode.Desc=ctnClass) then begin
|
||||
if (CurClassNode<>nil)
|
||||
and (CurClassNode.Desc in [ctnClass,ctnObject,ctnObjCClass]) then begin
|
||||
if (not (IgnoreForwards
|
||||
and ((CurClassNode.SubDesc and ctnsForwardDeclaration)>0)))
|
||||
and (not (IgnoreNonForwards
|
||||
@ -1352,7 +1351,7 @@ function TPascalReaderTool.FindClassNode(CursorNode: TCodeTreeNode
|
||||
): TCodeTreeNode;
|
||||
begin
|
||||
while CursorNode<>nil do begin
|
||||
if CursorNode.Desc=ctnClass then begin
|
||||
if CursorNode.Desc in [ctnClass,ctnObject,ctnObjCClass] then begin
|
||||
Result:=CursorNode;
|
||||
exit;
|
||||
end else if NodeIsMethodBody(CursorNode) then begin
|
||||
@ -1472,13 +1471,7 @@ end;
|
||||
|
||||
function TPascalReaderTool.IsClassNode(Node: TCodeTreeNode): boolean;
|
||||
begin
|
||||
if Node.Desc<>ctnClass then exit(false);
|
||||
MoveCursorToNodeStart(Node);
|
||||
ReadNextAtom;
|
||||
if UpAtomIs('PACKED') then
|
||||
ReadNextAtom;
|
||||
if UpAtomIs('CLASS') then exit(true);
|
||||
Result:=false;
|
||||
Result:=(Node<>nil) and (Node.Desc=ctnClass);
|
||||
end;
|
||||
|
||||
function TPascalReaderTool.ExtractRecordCaseType(RecordCaseNode: TCodeTreeNode
|
||||
|
@ -2067,7 +2067,8 @@ var
|
||||
Result:=false;
|
||||
IdentContext:=CleanFindContext;
|
||||
IsPublished:=false;
|
||||
if (ClassContext.Node=nil) or (ClassContext.Node.Desc<>ctnClass) then begin
|
||||
if (ClassContext.Node=nil)
|
||||
or (not (ClassContext.Node.Desc in AllClasses)) then begin
|
||||
DebugLn('TStandardCodeTool.CheckLFM.FindLFMIdentifier Internal error');
|
||||
exit;
|
||||
end;
|
||||
@ -2186,7 +2187,8 @@ var
|
||||
if StartTool.FindIdentifierInContext(Params) then begin
|
||||
Params.Load(OldInput,true);
|
||||
Result:=Params.NewCodeTool.FindBaseTypeOfNode(Params,Params.NewNode);
|
||||
if (Result.Node=nil) or (Result.Node.Desc<>ctnClass) then
|
||||
if (Result.Node=nil)
|
||||
or (not (Result.Node.Desc in AllClasses)) then
|
||||
Result:=CleanFindContext;
|
||||
end;
|
||||
except
|
||||
@ -2239,7 +2241,8 @@ var
|
||||
if FindIdentifierInContext(Params) then begin
|
||||
Params.Load(OldInput,true);
|
||||
Result:=Params.NewCodeTool.FindBaseTypeOfNode(Params,Params.NewNode);
|
||||
if (Result.Node=nil) or (Result.Node.Desc<>ctnClass) then
|
||||
if (Result.Node=nil)
|
||||
or (not (Result.Node.Desc in AllClasses)) then
|
||||
Result:=CleanFindContext;
|
||||
end;
|
||||
except
|
||||
@ -4705,7 +4708,8 @@ function TStandardCodeTool.GatherPublishedClassElements(
|
||||
begin
|
||||
Result:=false;
|
||||
ClassNode:=AFindContext^.Node;
|
||||
if (ClassNode=nil) or (ClassNode.Desc<>ctnClass) then exit;
|
||||
if (ClassNode=nil)
|
||||
or (not (ClassNode.Desc in AllClasses)) then exit;
|
||||
CurTool:=AFindContext^.Tool;
|
||||
CurTool.BuildSubTreeForClass(ClassNode);
|
||||
SectionNode:=ClassNode.FirstChild;
|
||||
@ -6471,7 +6475,7 @@ begin
|
||||
Node:=Tree.Root;
|
||||
while Node<>nil do begin
|
||||
case Node.Desc of
|
||||
ctnClass,ctnClassInterface:
|
||||
ctnClass,ctnClassInterface,ctnObject,ctnObjCClass:
|
||||
BuildSubTreeForClass(Node);
|
||||
ctnProcedure,ctnProcedureHead:
|
||||
BuildSubTreeForProcHead(Node);
|
||||
|
@ -328,9 +328,9 @@ begin
|
||||
else if ClassNode.Desc=ctnGenericType then
|
||||
ClassNode:=ClassNode.LastChild
|
||||
else
|
||||
ClassNode:=ClassNode.GetNodeOfTypes([ctnClass,ctnClassInterface]);
|
||||
if (ClassNode=nil) or (not (ClassNode.Desc in [ctnClass,ctnClassInterface]))
|
||||
then begin
|
||||
ClassNode:=ClassNode.GetNodeOfTypes(
|
||||
[ctnClass,ctnClassInterface,ctnObject,ctnObjCClass]);
|
||||
if (ClassNode=nil) then begin
|
||||
DebugLn(['TAbstractMethodsDialog.Init no class node at cursor ',CodePos.Code.Filename,' ',CodePos.X,',',CodePos.Y]);
|
||||
exit;
|
||||
end;
|
||||
|
@ -1890,9 +1890,18 @@ var
|
||||
Description:='type '+Identifier;
|
||||
if CTNode.FirstChild<>nil then begin
|
||||
case CTNode.FirstChild.Desc of
|
||||
ctnClass,ctnClassInterface:
|
||||
ctnClass,ctnClassInterface,ctnObject,ctnObjCClass:
|
||||
begin
|
||||
Description:=Description+' = class';
|
||||
case CTNode.FirstChild.Desc of
|
||||
ctnClassInterface:
|
||||
Description:=Description+' = interface';
|
||||
ctnObject:
|
||||
Description:=Description+' = object';
|
||||
ctnObjCClass:
|
||||
Description:=Description+' = objcclass';
|
||||
else
|
||||
Description:=Description+' = class';
|
||||
end;
|
||||
Inheritance:=Tool.ExtractClassInheritance(CTNode.FirstChild,[]);
|
||||
if Inheritance<>'' then
|
||||
Description:=Description+'('+Inheritance+')';
|
||||
@ -1962,8 +1971,7 @@ var
|
||||
|
||||
if (CTNode.Desc=ctnTypeDefinition)
|
||||
and (CTNode.FirstChild<>nil)
|
||||
and (CTNode.FirstChild.Desc in [ctnClass,ctnClassInterface,ctnRecordType,
|
||||
ctnEnumerationType])
|
||||
and (CTNode.FirstChild.Desc in AllClasses+[ctnRecordType,ctnEnumerationType])
|
||||
then begin
|
||||
// add child nodes
|
||||
ChildCTNode:=CTNode.FirstChild;
|
||||
@ -2399,7 +2407,7 @@ begin
|
||||
Result:=ImgIDConstSection;
|
||||
ctnConstDefinition:
|
||||
Result:=ImgIDConst;
|
||||
ctnClass:
|
||||
ctnClass,ctnObject,ctnObjCClass:
|
||||
Result:=ImgIDClass;
|
||||
ctnProcedure:
|
||||
Result:=ImgIDProc;
|
||||
|
@ -529,7 +529,7 @@ begin
|
||||
ctnTypeDefinition,ctnVarDefinition,ctnConstDefinition,ctnUseUnit:
|
||||
Result:=ACodeTool.ExtractIdentifier(CodeNode.StartPos);
|
||||
|
||||
ctnClass:
|
||||
ctnClass,ctnObject,ctnObjCClass,ctnInterface:
|
||||
Result:='('+ACodeTool.ExtractClassInheritance(CodeNode,[])+')';
|
||||
|
||||
ctnEnumIdentifier:
|
||||
@ -594,7 +594,8 @@ begin
|
||||
ctnTypeSection: Result:=ImgIDSection;
|
||||
ctnTypeDefinition:
|
||||
begin
|
||||
if (CodeNode.FirstChild <> nil) and (CodeNode.FirstChild.Desc = ctnClass) then
|
||||
if (CodeNode.FirstChild <> nil)
|
||||
and (CodeNode.FirstChild.Desc in AllClasses) then
|
||||
Result := ImgIDClass
|
||||
else
|
||||
Result := ImgIDType;
|
||||
@ -603,7 +604,8 @@ begin
|
||||
ctnVarDefinition: Result:=ImgIDVariable;
|
||||
ctnConstSection,ctnResStrSection: Result:=ImgIDSection;
|
||||
ctnConstDefinition: Result:=ImgIDConst;
|
||||
ctnClass: Result:=ImgIDClass;
|
||||
ctnClass,ctnClassInterface,
|
||||
ctnObject,ctnObjCClass: Result:=ImgIDClass;
|
||||
ctnProcedure: if Tool.NodeIsFunction(CodeNode) then
|
||||
Result:=ImgIDFunction
|
||||
else
|
||||
@ -662,13 +664,14 @@ begin
|
||||
end;
|
||||
// don't show forward class definitions
|
||||
if (CodeNode.Desc=ctnTypeDefinition)
|
||||
and (CodeNode.FirstChild<>nil) and (CodeNode.FirstChild.Desc=ctnClass)
|
||||
and (CodeNode.FirstChild<>nil)
|
||||
and (CodeNode.FirstChild.Desc in AllClasses)
|
||||
and ((CodeNode.FirstChild.SubDesc and ctnsForwardDeclaration)>0) then begin
|
||||
ShowNode:=false;
|
||||
ShowChilds:=false;
|
||||
end;
|
||||
// don't show class node (the type node is already shown)
|
||||
if (CodeNode.Desc in [ctnClass,ctnClassInterface]) then begin
|
||||
if (CodeNode.Desc in AllClasses) then begin
|
||||
ShowNode:=false;
|
||||
end;
|
||||
|
||||
|
@ -551,8 +551,10 @@ begin
|
||||
then
|
||||
Exclude(ProcHeadFlags,phpWithStart);
|
||||
Result:=IdentItem.Tool.ExtractProcHead(IdentItem.Node,ProcHeadFlags);
|
||||
ClassNode:=IdentItem.Node.GetNodeOfTypes([ctnClass,ctnClassInterface]);
|
||||
if (ClassNode<>nil) and (IdentItem.Tool.IsClassNode(ClassNode)) then begin
|
||||
ClassNode:=IdentItem.Node.GetNodeOfTypes(
|
||||
[ctnClass,ctnClassInterface,ctnObject,ctnObjCClass]);
|
||||
if (ClassNode<>nil)
|
||||
and (ClassNode.Desc in [ctnClass,ctnObjCClass]) then begin
|
||||
// replace virtual and dynamic with override
|
||||
ProcModifierPos:=System.Pos('VIRTUAL;',UpperCaseStr(Result));
|
||||
if ProcModifierPos<1 then
|
||||
|
Loading…
Reference in New Issue
Block a user