From b64abcbd7abaada3a5e690eb500316a74c592c7d Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 16 Nov 2009 00:39:35 +0000 Subject: [PATCH] codetools: parsing objccategory git-svn-id: trunk@22611 - --- components/codetools/codecompletiontool.pas | 2 +- components/codetools/codetree.pas | 11 +++++++---- components/codetools/customcodetool.pas | 3 ++- components/codetools/finddeclarationtool.pas | 14 +++++++------- components/codetools/identcompletiontool.pas | 4 ++-- components/codetools/methodjumptool.pas | 6 ++++-- components/codetools/pascalparsertool.pas | 11 ++++++++--- components/codetools/stdcodetools.pas | 3 ++- ide/codebrowser.pas | 9 ++++++--- ide/codeexplorer.pas | 6 ++++-- 10 files changed, 43 insertions(+), 26 deletions(-) diff --git a/components/codetools/codecompletiontool.pas b/components/codetools/codecompletiontool.pas index 6fddbf4657..c42a239314 100644 --- a/components/codetools/codecompletiontool.pas +++ b/components/codetools/codecompletiontool.pas @@ -4102,7 +4102,7 @@ function TCodeCompletionCodeTool.BuildUnitDefinitionGraph(out end; ctnRecordType, ctnClassInterface, ctnClass, ctnObject, - ctnObjCClass, ctnObjCProtocol, ctnCPPClass: + ctnObjCClass, ctnObjCCategory, ctnObjCProtocol, ctnCPPClass: begin ChildNode:=SubNode.FirstChild; while (ChildNode<>nil) and (ChildNode.HasAsParent(SubNode)) do begin diff --git a/components/codetools/codetree.pas b/components/codetools/codetree.pas index 20ecd3b379..c5d9cc68de 100644 --- a/components/codetools/codetree.pas +++ b/components/codetools/codetree.pas @@ -84,8 +84,9 @@ const ctnClassInterface = 31; ctnObject = 32; ctnObjCClass = 33; - ctnObjCProtocol = 34; - ctnCPPClass = 35; + ctnObjCCategory = 34; + ctnObjCProtocol = 35; + ctnCPPClass = 36; ctnClassAbstract = 40; ctnClassSealed = 41; @@ -164,10 +165,11 @@ const AllClassSections = AllClassBaseSections+AllClassTypeSections+AllClassVarSections; AllClasses = - [ctnClass,ctnClassInterface,ctnObject,ctnObjCClass,ctnObjCProtocol, + [ctnClass,ctnClassInterface,ctnObject, + ctnObjCClass,ctnObjCCategory,ctnObjCProtocol, ctnCPPClass]; AllClassInterfaces = [ctnClassInterface,ctnObjCProtocol]; - AllClassObjects = [ctnClass,ctnObject,ctnObjCClass,ctnCPPClass]; + AllClassObjects = [ctnClass,ctnObject,ctnObjCClass,ctnObjCCategory,ctnCPPClass]; AllClassModifiers = [ctnClassAbstract, ctnClassSealed]; AllDefinitionSections = [ctnTypeSection,ctnVarSection,ctnConstSection,ctnResStrSection, @@ -367,6 +369,7 @@ begin ctnClassInterface: Result:='Class Interface'; ctnObject: Result:='Object'; ctnObjCClass: Result:='ObjCClass'; + ctnObjCCategory: Result:='ObjCCategory'; ctnObjCProtocol: Result:='ObjCProtocol'; ctnCPPClass: Result:='CPPClass'; diff --git a/components/codetools/customcodetool.pas b/components/codetools/customcodetool.pas index 765252d46b..a1497f0f8e 100644 --- a/components/codetools/customcodetool.pas +++ b/components/codetools/customcodetool.pas @@ -539,7 +539,8 @@ begin begin if (SubDesc and ctnsNeedJITParsing)>0 then Result:=ctsUnparsed; end; - ctnClass,ctnObject,ctnObjCClass,ctnClassInterface,ctnObjCProtocol,ctnCPPClass: + ctnClass,ctnObject,ctnObjCClass,ctnObjCCategory,ctnObjCProtocol, + ctnCPPClass,ctnClassInterface: begin Result:=''; if (SubDesc and ctnsForwardDeclaration)>0 then Result:=ctsForward; diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index 317dbf4eaa..d67585886b 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -2107,7 +2107,7 @@ begin if TypeNode<>nil then begin case TypeNode.Desc of ctnIdentifier, ctnClass, ctnClassInterface, ctnObject, - ctnObjCClass, ctnObjCProtocol, ctnCPPClass: + ctnObjCClass, ctnObjCCategory, ctnObjCProtocol, ctnCPPClass: begin NewTool.MoveCursorToNodeStart(TypeNode); NewTool.ReadNextAtom; @@ -2866,7 +2866,7 @@ var ; ctnClass, ctnClassInterface, ctnObject, - ctnObjCClass, ctnObjCProtocol, ctnCPPClass, + ctnObjCClass, ctnObjCCategory, ctnObjCProtocol, ctnCPPClass, ctnRecordType, ctnRecordCase: // do not search again in this node, go on ... ; @@ -2976,7 +2976,7 @@ begin ctnClassTypePublished,ctnClassTypePublic,ctnClassTypeProtected,ctnClassTypePrivate, ctnClassVarPublished,ctnClassVarPublic,ctnClassVarProtected,ctnClassVarPrivate, ctnClass, ctnClassInterface, ctnObject, - ctnObjCClass, ctnObjCProtocol, ctnCPPClass, + ctnObjCClass, ctnObjCCategory, ctnObjCProtocol, ctnCPPClass, ctnRecordType, ctnRecordVariant, ctnParameterList: // these nodes build a parent-child relationship. But in pascal @@ -4350,7 +4350,7 @@ begin Result:=InNodeIdentifier(CurPos.StartPos); end; - ctnBeginBlock,ctnClass,ctnObject,ctnObjCClass,ctnCPPClass: + ctnBeginBlock,ctnClass,ctnObject,ctnObjCClass,ctnObjCCategory,ctnCPPClass: if (Node.SubDesc and ctnsForwardDeclaration)>0 then RaiseException('TFindDeclarationTool.CleanPosIsDeclarationIdentifier Node not expanded'); @@ -6497,7 +6497,7 @@ var ExprType.Context.Node.FirstChild); ctnClass, ctnClassInterface, ctnObject, - ctnObjCClass, ctnObjCProtocol, ctnCPPClass, + ctnObjCClass, ctnObjCCategory, ctnObjCProtocol, ctnCPPClass, ctnProperty, ctnGlobalProperty: begin if ExprType.Context.Node.Desc in AllClasses then begin @@ -7991,7 +7991,7 @@ begin case ExprNode.Desc of ctnClass,ctnClassInterface, ctnObject, - ctnObjCClass, ctnObjCProtocol, ctnCPPClass: + ctnObjCClass, ctnObjCCategory, ctnObjCProtocol, ctnCPPClass: // check, if ExpressionType.Context is descend of TargetContext if ContextIsDescendOf(ExpressionType.Context, TargetType.Context,Params) @@ -9525,7 +9525,7 @@ begin end; ctnClass, ctnClassInterface, ctnObject, - ctnObjCClass, ctnObjCProtocol, ctnCPPClass: + ctnObjCClass, ctnObjCCategory, ctnObjCProtocol, ctnCPPClass: if (FindContext.Node.Parent<>nil) and (FindContext.Node.Parent.Desc in [ctnTypeDefinition,ctnGenericType]) then diff --git a/components/codetools/identcompletiontool.pas b/components/codetools/identcompletiontool.pas index a33f3c1daf..c6e52c1552 100644 --- a/components/codetools/identcompletiontool.pas +++ b/components/codetools/identcompletiontool.pas @@ -1260,7 +1260,7 @@ begin CurrentIdentifierList.Add(NewItem); end; if (UpAtomIs('READ') or UpAtomIs('WRITE')) - and (Context.Node.GetNodeOfTypes([ctnClass,ctnObject,ctnObjCClass,ctnCPPClass])<>nil) + and (Context.Tool.FindClassOrInterfaceNode(Context.Node)<>nil) then begin // add the default class completion 'read'/'write' specifier variable NewItem:=TIdentifierListItem.Create( @@ -1421,7 +1421,7 @@ var begin Node:=Context.Node; case Node.Desc of - ctnClass,ctnObject,ctnObjCClass, + ctnClass,ctnObject,ctnObjCCategory,ctnObjCClass, ctnClassPrivate,ctnClassProtected,ctnClassPublic,ctnClassPublished: begin Add('public'); diff --git a/components/codetools/methodjumptool.pas b/components/codetools/methodjumptool.pas index 29e2f29fb5..8fc8ccc156 100644 --- a/components/codetools/methodjumptool.pas +++ b/components/codetools/methodjumptool.pas @@ -351,7 +351,8 @@ begin DebugLn('TMethodJumpingCodeTool.FindJumpPoint C ',NodeDescriptionAsString(CursorNode.Desc)); {$ENDIF} // 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 // cursor is in class/object definition // search in all implemented class procedures for the body @@ -796,7 +797,8 @@ begin cmp:=false; end; 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)<>'') then cmp:=false; diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas index 84c2421dac..db0f5d883c 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -389,7 +389,8 @@ begin if CompareSrcIdentifiers('LABEL',p) then exit(KeyWordFuncTypeLabel); 'O': if CompareSrcIdentifiers('OBJECT',p) - or CompareSrcIdentifiers('OBJCCLASS',p) then exit(KeyWordFuncClass); + or CompareSrcIdentifiers('OBJCCLASS',p) + or CompareSrcIdentifiers('OBJCCATEGORY',p) then exit(KeyWordFuncClass); 'P': case UpChars[p[1]] of 'A': if CompareSrcIdentifiers('PACKED',p) then exit(KeyWordFuncTypePacked); @@ -701,7 +702,8 @@ begin ReadNextAtom; if UpAtomIs('PACKED') or (UpAtomIs('BITPACKED')) then ReadNextAtom; 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 RaiseClassKeyWordExpected; ReadNextAtom; @@ -3399,6 +3401,8 @@ begin ClassDesc:=ctnObject else if UpAtomIs('OBJCCLASS') then ClassDesc:=ctnObjCClass + else if UpAtomIs('OBJCCATEGORY') then + ClassDesc:=ctnObjCCategory else if UpAtomIs('CPPCLASS') then ClassDesc:=ctnCPPClass else @@ -4572,7 +4576,8 @@ procedure TPascalParserTool.BuildSubTree(ANode: TCodeTreeNode); begin if ANode=nil then exit; case ANode.Desc of - ctnClass,ctnClassInterface,ctnObject,ctnObjCClass,ctnObjCProtocol,ctnCPPClass: + ctnClass,ctnClassInterface,ctnObject, + ctnObjCClass,ctnObjCCategory,ctnObjCProtocol,ctnCPPClass: BuildSubTreeForClass(ANode); ctnProcedure,ctnProcedureHead: BuildSubTreeForProcHead(ANode); diff --git a/components/codetools/stdcodetools.pas b/components/codetools/stdcodetools.pas index e2aa8f48a5..bdf569c766 100644 --- a/components/codetools/stdcodetools.pas +++ b/components/codetools/stdcodetools.pas @@ -6587,7 +6587,8 @@ begin Node:=Tree.Root; while Node<>nil do begin case Node.Desc of - ctnClass,ctnClassInterface,ctnObject,ctnObjCClass,ctnObjCProtocol,ctnCPPClass: + ctnClass,ctnClassInterface,ctnObject, + ctnObjCClass,ctnObjCCategory,ctnObjCProtocol,ctnCPPClass: BuildSubTreeForClass(Node); ctnProcedure,ctnProcedureHead: BuildSubTreeForProcHead(Node); diff --git a/ide/codebrowser.pas b/ide/codebrowser.pas index b317ec9058..70f3346cd3 100644 --- a/ide/codebrowser.pas +++ b/ide/codebrowser.pas @@ -1901,7 +1901,8 @@ var Description:='type '+Identifier; if CTNode.FirstChild<>nil then begin case CTNode.FirstChild.Desc of - ctnClass,ctnClassInterface,ctnObject,ctnObjCClass,ctnObjCProtocol, + ctnClass,ctnClassInterface,ctnObject, + ctnObjCClass,ctnObjCCategory,ctnObjCProtocol, ctnCPPClass: begin case CTNode.FirstChild.Desc of @@ -1911,6 +1912,8 @@ var Description:=Description+' = object'; ctnObjCClass: Description:=Description+' = objcclass'; + ctnObjCCategory: + Description:=Description+' = objccategory'; ctnObjCProtocol: Description:=Description+' = objcprotocol'; ctnCPPClass: @@ -2403,7 +2406,7 @@ begin Result:=ImgIDProgramCode; ctnUnit: Result:=ImgIDUnitCode; - ctnInterface,ctnObjCProtocol: + ctnInterface: Result:=ImgIDInterfaceSection; ctnImplementation: Result:=ImgIDImplementation; @@ -2423,7 +2426,7 @@ begin Result:=ImgIDConstSection; ctnConstDefinition: Result:=ImgIDConst; - ctnClass,ctnObject,ctnObjCClass,ctnCPPClass: + ctnClass,ctnObject,ctnObjCClass,ctnObjCCategory,ctnObjCProtocol,ctnCPPClass: Result:=ImgIDClass; ctnProcedure: Result:=ImgIDProc; diff --git a/ide/codeexplorer.pas b/ide/codeexplorer.pas index a8c16da676..bc24472f9e 100644 --- a/ide/codeexplorer.pas +++ b/ide/codeexplorer.pas @@ -529,7 +529,8 @@ begin ctnTypeDefinition,ctnVarDefinition,ctnConstDefinition,ctnUseUnit: Result:=ACodeTool.ExtractIdentifier(CodeNode.StartPos); - ctnClass,ctnObject,ctnObjCClass,ctnObjCProtocol,ctnInterface,ctnCPPClass: + ctnClass,ctnObject,ctnObjCClass,ctnObjCCategory,ctnObjCProtocol, + ctnInterface,ctnCPPClass: Result:='('+ACodeTool.ExtractClassInheritance(CodeNode,[])+')'; ctnEnumIdentifier: @@ -604,7 +605,8 @@ begin ctnVarDefinition: Result:=ImgIDVariable; ctnConstSection,ctnResStrSection: Result:=ImgIDSection; ctnConstDefinition: Result:=ImgIDConst; - ctnClass,ctnClassInterface,ctnObject,ctnObjCClass,ctnObjCProtocol,ctnCPPClass: + ctnClass,ctnClassInterface,ctnObject, + ctnObjCClass,ctnObjCProtocol,ctnObjCCategory,ctnCPPClass: Result:=ImgIDClass; ctnProcedure: if Tool.NodeIsFunction(CodeNode) then Result:=ImgIDFunction