codetools: parsing objccategory

git-svn-id: trunk@22611 -
This commit is contained in:
mattias 2009-11-16 00:39:35 +00:00
parent bc85444eab
commit b64abcbd7a
10 changed files with 43 additions and 26 deletions

View File

@ -4102,7 +4102,7 @@ function TCodeCompletionCodeTool.BuildUnitDefinitionGraph(out
end; end;
ctnRecordType, ctnClassInterface, ctnClass, ctnObject, ctnRecordType, ctnClassInterface, ctnClass, ctnObject,
ctnObjCClass, ctnObjCProtocol, ctnCPPClass: ctnObjCClass, ctnObjCCategory, ctnObjCProtocol, ctnCPPClass:
begin begin
ChildNode:=SubNode.FirstChild; ChildNode:=SubNode.FirstChild;
while (ChildNode<>nil) and (ChildNode.HasAsParent(SubNode)) do begin while (ChildNode<>nil) and (ChildNode.HasAsParent(SubNode)) do begin

View File

@ -84,8 +84,9 @@ const
ctnClassInterface = 31; ctnClassInterface = 31;
ctnObject = 32; ctnObject = 32;
ctnObjCClass = 33; ctnObjCClass = 33;
ctnObjCProtocol = 34; ctnObjCCategory = 34;
ctnCPPClass = 35; ctnObjCProtocol = 35;
ctnCPPClass = 36;
ctnClassAbstract = 40; ctnClassAbstract = 40;
ctnClassSealed = 41; ctnClassSealed = 41;
@ -164,10 +165,11 @@ const
AllClassSections = AllClassSections =
AllClassBaseSections+AllClassTypeSections+AllClassVarSections; AllClassBaseSections+AllClassTypeSections+AllClassVarSections;
AllClasses = AllClasses =
[ctnClass,ctnClassInterface,ctnObject,ctnObjCClass,ctnObjCProtocol, [ctnClass,ctnClassInterface,ctnObject,
ctnObjCClass,ctnObjCCategory,ctnObjCProtocol,
ctnCPPClass]; ctnCPPClass];
AllClassInterfaces = [ctnClassInterface,ctnObjCProtocol]; AllClassInterfaces = [ctnClassInterface,ctnObjCProtocol];
AllClassObjects = [ctnClass,ctnObject,ctnObjCClass,ctnCPPClass]; AllClassObjects = [ctnClass,ctnObject,ctnObjCClass,ctnObjCCategory,ctnCPPClass];
AllClassModifiers = [ctnClassAbstract, ctnClassSealed]; AllClassModifiers = [ctnClassAbstract, ctnClassSealed];
AllDefinitionSections = AllDefinitionSections =
[ctnTypeSection,ctnVarSection,ctnConstSection,ctnResStrSection, [ctnTypeSection,ctnVarSection,ctnConstSection,ctnResStrSection,
@ -367,6 +369,7 @@ begin
ctnClassInterface: Result:='Class Interface'; ctnClassInterface: Result:='Class Interface';
ctnObject: Result:='Object'; ctnObject: Result:='Object';
ctnObjCClass: Result:='ObjCClass'; ctnObjCClass: Result:='ObjCClass';
ctnObjCCategory: Result:='ObjCCategory';
ctnObjCProtocol: Result:='ObjCProtocol'; ctnObjCProtocol: Result:='ObjCProtocol';
ctnCPPClass: Result:='CPPClass'; ctnCPPClass: Result:='CPPClass';

View File

@ -539,7 +539,8 @@ begin
begin begin
if (SubDesc and ctnsNeedJITParsing)>0 then Result:=ctsUnparsed; if (SubDesc and ctnsNeedJITParsing)>0 then Result:=ctsUnparsed;
end; end;
ctnClass,ctnObject,ctnObjCClass,ctnClassInterface,ctnObjCProtocol,ctnCPPClass: ctnClass,ctnObject,ctnObjCClass,ctnObjCCategory,ctnObjCProtocol,
ctnCPPClass,ctnClassInterface:
begin begin
Result:=''; Result:='';
if (SubDesc and ctnsForwardDeclaration)>0 then Result:=ctsForward; if (SubDesc and ctnsForwardDeclaration)>0 then Result:=ctsForward;

View File

@ -2107,7 +2107,7 @@ begin
if TypeNode<>nil then begin if TypeNode<>nil then begin
case TypeNode.Desc of case TypeNode.Desc of
ctnIdentifier, ctnClass, ctnClassInterface, ctnObject, ctnIdentifier, ctnClass, ctnClassInterface, ctnObject,
ctnObjCClass, ctnObjCProtocol, ctnCPPClass: ctnObjCClass, ctnObjCCategory, ctnObjCProtocol, ctnCPPClass:
begin begin
NewTool.MoveCursorToNodeStart(TypeNode); NewTool.MoveCursorToNodeStart(TypeNode);
NewTool.ReadNextAtom; NewTool.ReadNextAtom;
@ -2866,7 +2866,7 @@ var
; ;
ctnClass, ctnClassInterface, ctnObject, ctnClass, ctnClassInterface, ctnObject,
ctnObjCClass, ctnObjCProtocol, ctnCPPClass, ctnObjCClass, ctnObjCCategory, ctnObjCProtocol, ctnCPPClass,
ctnRecordType, ctnRecordCase: ctnRecordType, ctnRecordCase:
// do not search again in this node, go on ... // do not search again in this node, go on ...
; ;
@ -2976,7 +2976,7 @@ begin
ctnClassTypePublished,ctnClassTypePublic,ctnClassTypeProtected,ctnClassTypePrivate, ctnClassTypePublished,ctnClassTypePublic,ctnClassTypeProtected,ctnClassTypePrivate,
ctnClassVarPublished,ctnClassVarPublic,ctnClassVarProtected,ctnClassVarPrivate, ctnClassVarPublished,ctnClassVarPublic,ctnClassVarProtected,ctnClassVarPrivate,
ctnClass, ctnClassInterface, ctnObject, ctnClass, ctnClassInterface, ctnObject,
ctnObjCClass, ctnObjCProtocol, ctnCPPClass, ctnObjCClass, ctnObjCCategory, ctnObjCProtocol, ctnCPPClass,
ctnRecordType, ctnRecordVariant, ctnRecordType, ctnRecordVariant,
ctnParameterList: ctnParameterList:
// these nodes build a parent-child relationship. But in pascal // these nodes build a parent-child relationship. But in pascal
@ -4350,7 +4350,7 @@ begin
Result:=InNodeIdentifier(CurPos.StartPos); Result:=InNodeIdentifier(CurPos.StartPos);
end; end;
ctnBeginBlock,ctnClass,ctnObject,ctnObjCClass,ctnCPPClass: ctnBeginBlock,ctnClass,ctnObject,ctnObjCClass,ctnObjCCategory,ctnCPPClass:
if (Node.SubDesc and ctnsForwardDeclaration)>0 then if (Node.SubDesc and ctnsForwardDeclaration)>0 then
RaiseException('TFindDeclarationTool.CleanPosIsDeclarationIdentifier Node not expanded'); RaiseException('TFindDeclarationTool.CleanPosIsDeclarationIdentifier Node not expanded');
@ -6497,7 +6497,7 @@ var
ExprType.Context.Node.FirstChild); ExprType.Context.Node.FirstChild);
ctnClass, ctnClassInterface, ctnObject, ctnClass, ctnClassInterface, ctnObject,
ctnObjCClass, ctnObjCProtocol, ctnCPPClass, ctnObjCClass, ctnObjCCategory, ctnObjCProtocol, ctnCPPClass,
ctnProperty, ctnGlobalProperty: ctnProperty, ctnGlobalProperty:
begin begin
if ExprType.Context.Node.Desc in AllClasses then begin if ExprType.Context.Node.Desc in AllClasses then begin
@ -7991,7 +7991,7 @@ begin
case ExprNode.Desc of case ExprNode.Desc of
ctnClass,ctnClassInterface, ctnObject, ctnClass,ctnClassInterface, ctnObject,
ctnObjCClass, ctnObjCProtocol, ctnCPPClass: ctnObjCClass, ctnObjCCategory, ctnObjCProtocol, ctnCPPClass:
// check, if ExpressionType.Context is descend of TargetContext // check, if ExpressionType.Context is descend of TargetContext
if ContextIsDescendOf(ExpressionType.Context, if ContextIsDescendOf(ExpressionType.Context,
TargetType.Context,Params) TargetType.Context,Params)
@ -9525,7 +9525,7 @@ begin
end; end;
ctnClass, ctnClassInterface, ctnObject, ctnClass, ctnClassInterface, ctnObject,
ctnObjCClass, ctnObjCProtocol, ctnCPPClass: ctnObjCClass, ctnObjCCategory, ctnObjCProtocol, ctnCPPClass:
if (FindContext.Node.Parent<>nil) if (FindContext.Node.Parent<>nil)
and (FindContext.Node.Parent.Desc in [ctnTypeDefinition,ctnGenericType]) and (FindContext.Node.Parent.Desc in [ctnTypeDefinition,ctnGenericType])
then then

View File

@ -1260,7 +1260,7 @@ begin
CurrentIdentifierList.Add(NewItem); CurrentIdentifierList.Add(NewItem);
end; end;
if (UpAtomIs('READ') or UpAtomIs('WRITE')) if (UpAtomIs('READ') or UpAtomIs('WRITE'))
and (Context.Node.GetNodeOfTypes([ctnClass,ctnObject,ctnObjCClass,ctnCPPClass])<>nil) and (Context.Tool.FindClassOrInterfaceNode(Context.Node)<>nil)
then begin then begin
// add the default class completion 'read'/'write' specifier variable // add the default class completion 'read'/'write' specifier variable
NewItem:=TIdentifierListItem.Create( NewItem:=TIdentifierListItem.Create(
@ -1421,7 +1421,7 @@ var
begin begin
Node:=Context.Node; Node:=Context.Node;
case Node.Desc of case Node.Desc of
ctnClass,ctnObject,ctnObjCClass, ctnClass,ctnObject,ctnObjCCategory,ctnObjCClass,
ctnClassPrivate,ctnClassProtected,ctnClassPublic,ctnClassPublished: ctnClassPrivate,ctnClassProtected,ctnClassPublic,ctnClassPublished:
begin begin
Add('public'); Add('public');

View File

@ -351,7 +351,8 @@ begin
DebugLn('TMethodJumpingCodeTool.FindJumpPoint C ',NodeDescriptionAsString(CursorNode.Desc)); DebugLn('TMethodJumpingCodeTool.FindJumpPoint C ',NodeDescriptionAsString(CursorNode.Desc));
{$ENDIF} {$ENDIF}
// first test if in a class // first test if in a class
ClassNode:=CursorNode.GetNodeOfTypes([ctnClass,ctnObject,ctnObjCClass,ctnCPPClass]); ClassNode:=CursorNode.GetNodeOfTypes([ctnClass,ctnObject,
ctnObjCClass,ctnObjCCategory,ctnCPPClass]);
if ClassNode<>nil then begin if ClassNode<>nil then begin
// cursor is in class/object definition // cursor is in class/object definition
// search in all implemented class procedures for the body // search in all implemented class procedures for the body
@ -796,7 +797,8 @@ begin
cmp:=false; cmp:=false;
end; end;
if cmp and (phpIgnoreMethods in Attr) then begin if cmp and (phpIgnoreMethods in Attr) then begin
if (ANode.GetNodeOfTypes([ctnClass,ctnObject,ctnObjCClass,ctnCPPClass])<>nil) if (ANode.GetNodeOfTypes([ctnClass,ctnObject,
ctnObjCClass,ctnObjCCategory,ctnCPPClass])<>nil)
or (ExtractClassNameOfProcNode(ANode)<>'') or (ExtractClassNameOfProcNode(ANode)<>'')
then then
cmp:=false; cmp:=false;

View File

@ -389,7 +389,8 @@ begin
if CompareSrcIdentifiers('LABEL',p) then exit(KeyWordFuncTypeLabel); if CompareSrcIdentifiers('LABEL',p) then exit(KeyWordFuncTypeLabel);
'O': 'O':
if CompareSrcIdentifiers('OBJECT',p) if CompareSrcIdentifiers('OBJECT',p)
or CompareSrcIdentifiers('OBJCCLASS',p) then exit(KeyWordFuncClass); or CompareSrcIdentifiers('OBJCCLASS',p)
or CompareSrcIdentifiers('OBJCCATEGORY',p) then exit(KeyWordFuncClass);
'P': 'P':
case UpChars[p[1]] of case UpChars[p[1]] of
'A': if CompareSrcIdentifiers('PACKED',p) then exit(KeyWordFuncTypePacked); 'A': if CompareSrcIdentifiers('PACKED',p) then exit(KeyWordFuncTypePacked);
@ -701,7 +702,8 @@ begin
ReadNextAtom; ReadNextAtom;
if UpAtomIs('PACKED') or (UpAtomIs('BITPACKED')) then ReadNextAtom; if UpAtomIs('PACKED') or (UpAtomIs('BITPACKED')) then ReadNextAtom;
if not (UpAtomIs('CLASS') or UpAtomIs('OBJECT') or UpAtomIs('OBJCCLASS') if not (UpAtomIs('CLASS') or UpAtomIs('OBJECT') or UpAtomIs('OBJCCLASS')
or UpAtomIs('CPPCLASS') or UpAtomIs('INTERFACE')) or UpAtomIs('OBJCCATEGORY') or UpAtomIs('CPPCLASS')
or UpAtomIs('INTERFACE') or UpAtomIs('OBJCPROTOCOL'))
then then
RaiseClassKeyWordExpected; RaiseClassKeyWordExpected;
ReadNextAtom; ReadNextAtom;
@ -3399,6 +3401,8 @@ begin
ClassDesc:=ctnObject ClassDesc:=ctnObject
else if UpAtomIs('OBJCCLASS') then else if UpAtomIs('OBJCCLASS') then
ClassDesc:=ctnObjCClass ClassDesc:=ctnObjCClass
else if UpAtomIs('OBJCCATEGORY') then
ClassDesc:=ctnObjCCategory
else if UpAtomIs('CPPCLASS') then else if UpAtomIs('CPPCLASS') then
ClassDesc:=ctnCPPClass ClassDesc:=ctnCPPClass
else else
@ -4572,7 +4576,8 @@ procedure TPascalParserTool.BuildSubTree(ANode: TCodeTreeNode);
begin begin
if ANode=nil then exit; if ANode=nil then exit;
case ANode.Desc of case ANode.Desc of
ctnClass,ctnClassInterface,ctnObject,ctnObjCClass,ctnObjCProtocol,ctnCPPClass: ctnClass,ctnClassInterface,ctnObject,
ctnObjCClass,ctnObjCCategory,ctnObjCProtocol,ctnCPPClass:
BuildSubTreeForClass(ANode); BuildSubTreeForClass(ANode);
ctnProcedure,ctnProcedureHead: ctnProcedure,ctnProcedureHead:
BuildSubTreeForProcHead(ANode); BuildSubTreeForProcHead(ANode);

View File

@ -6587,7 +6587,8 @@ begin
Node:=Tree.Root; Node:=Tree.Root;
while Node<>nil do begin while Node<>nil do begin
case Node.Desc of case Node.Desc of
ctnClass,ctnClassInterface,ctnObject,ctnObjCClass,ctnObjCProtocol,ctnCPPClass: ctnClass,ctnClassInterface,ctnObject,
ctnObjCClass,ctnObjCCategory,ctnObjCProtocol,ctnCPPClass:
BuildSubTreeForClass(Node); BuildSubTreeForClass(Node);
ctnProcedure,ctnProcedureHead: ctnProcedure,ctnProcedureHead:
BuildSubTreeForProcHead(Node); BuildSubTreeForProcHead(Node);

View File

@ -1901,7 +1901,8 @@ var
Description:='type '+Identifier; Description:='type '+Identifier;
if CTNode.FirstChild<>nil then begin if CTNode.FirstChild<>nil then begin
case CTNode.FirstChild.Desc of case CTNode.FirstChild.Desc of
ctnClass,ctnClassInterface,ctnObject,ctnObjCClass,ctnObjCProtocol, ctnClass,ctnClassInterface,ctnObject,
ctnObjCClass,ctnObjCCategory,ctnObjCProtocol,
ctnCPPClass: ctnCPPClass:
begin begin
case CTNode.FirstChild.Desc of case CTNode.FirstChild.Desc of
@ -1911,6 +1912,8 @@ var
Description:=Description+' = object'; Description:=Description+' = object';
ctnObjCClass: ctnObjCClass:
Description:=Description+' = objcclass'; Description:=Description+' = objcclass';
ctnObjCCategory:
Description:=Description+' = objccategory';
ctnObjCProtocol: ctnObjCProtocol:
Description:=Description+' = objcprotocol'; Description:=Description+' = objcprotocol';
ctnCPPClass: ctnCPPClass:
@ -2403,7 +2406,7 @@ begin
Result:=ImgIDProgramCode; Result:=ImgIDProgramCode;
ctnUnit: ctnUnit:
Result:=ImgIDUnitCode; Result:=ImgIDUnitCode;
ctnInterface,ctnObjCProtocol: ctnInterface:
Result:=ImgIDInterfaceSection; Result:=ImgIDInterfaceSection;
ctnImplementation: ctnImplementation:
Result:=ImgIDImplementation; Result:=ImgIDImplementation;
@ -2423,7 +2426,7 @@ begin
Result:=ImgIDConstSection; Result:=ImgIDConstSection;
ctnConstDefinition: ctnConstDefinition:
Result:=ImgIDConst; Result:=ImgIDConst;
ctnClass,ctnObject,ctnObjCClass,ctnCPPClass: ctnClass,ctnObject,ctnObjCClass,ctnObjCCategory,ctnObjCProtocol,ctnCPPClass:
Result:=ImgIDClass; Result:=ImgIDClass;
ctnProcedure: ctnProcedure:
Result:=ImgIDProc; Result:=ImgIDProc;

View File

@ -529,7 +529,8 @@ begin
ctnTypeDefinition,ctnVarDefinition,ctnConstDefinition,ctnUseUnit: ctnTypeDefinition,ctnVarDefinition,ctnConstDefinition,ctnUseUnit:
Result:=ACodeTool.ExtractIdentifier(CodeNode.StartPos); Result:=ACodeTool.ExtractIdentifier(CodeNode.StartPos);
ctnClass,ctnObject,ctnObjCClass,ctnObjCProtocol,ctnInterface,ctnCPPClass: ctnClass,ctnObject,ctnObjCClass,ctnObjCCategory,ctnObjCProtocol,
ctnInterface,ctnCPPClass:
Result:='('+ACodeTool.ExtractClassInheritance(CodeNode,[])+')'; Result:='('+ACodeTool.ExtractClassInheritance(CodeNode,[])+')';
ctnEnumIdentifier: ctnEnumIdentifier:
@ -604,7 +605,8 @@ begin
ctnVarDefinition: Result:=ImgIDVariable; ctnVarDefinition: Result:=ImgIDVariable;
ctnConstSection,ctnResStrSection: Result:=ImgIDSection; ctnConstSection,ctnResStrSection: Result:=ImgIDSection;
ctnConstDefinition: Result:=ImgIDConst; ctnConstDefinition: Result:=ImgIDConst;
ctnClass,ctnClassInterface,ctnObject,ctnObjCClass,ctnObjCProtocol,ctnCPPClass: ctnClass,ctnClassInterface,ctnObject,
ctnObjCClass,ctnObjCProtocol,ctnObjCCategory,ctnCPPClass:
Result:=ImgIDClass; Result:=ImgIDClass;
ctnProcedure: if Tool.NodeIsFunction(CodeNode) then ctnProcedure: if Tool.NodeIsFunction(CodeNode) then
Result:=ImgIDFunction Result:=ImgIDFunction