From a75a29091ce583e84104d48062fa1769f96258ac Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 27 May 2011 05:41:52 +0000 Subject: [PATCH] codetools: find declaration: inherited; git-svn-id: trunk@30920 - --- components/codetools/codetoolsstrconsts.pas | 51 ++++++++------- components/codetools/finddeclarationtool.pas | 64 +++++++++++-------- .../languages/codetoolsstrconsts.ca.po | 4 ++ .../languages/codetoolsstrconsts.cs.po | 4 ++ .../languages/codetoolsstrconsts.de.po | 4 ++ .../languages/codetoolsstrconsts.es.po | 4 ++ .../languages/codetoolsstrconsts.esutf.po | 4 ++ .../languages/codetoolsstrconsts.fi.po | 4 ++ .../languages/codetoolsstrconsts.fr.po | 4 ++ .../languages/codetoolsstrconsts.he.po | 4 ++ .../languages/codetoolsstrconsts.id.po | 4 ++ .../languages/codetoolsstrconsts.it.po | 4 ++ .../languages/codetoolsstrconsts.lt.po | 4 ++ .../languages/codetoolsstrconsts.nl.po | 4 ++ .../languages/codetoolsstrconsts.pl.po | 4 ++ .../codetools/languages/codetoolsstrconsts.po | 4 ++ .../languages/codetoolsstrconsts.pt.po | 4 ++ .../languages/codetoolsstrconsts.pt_BR.po | 4 ++ .../languages/codetoolsstrconsts.ru.po | 4 ++ .../languages/codetoolsstrconsts.sk.po | 4 ++ .../languages/codetoolsstrconsts.uk.po | 4 ++ .../languages/codetoolsstrconsts.zh_CN.po | 4 ++ components/codetools/pascalreadertool.pas | 8 +++ 23 files changed, 153 insertions(+), 50 deletions(-) diff --git a/components/codetools/codetoolsstrconsts.pas b/components/codetools/codetoolsstrconsts.pas index ff2ec47f34..de29f69fa7 100644 --- a/components/codetools/codetoolsstrconsts.pas +++ b/components/codetools/codetoolsstrconsts.pas @@ -96,6 +96,7 @@ ResourceString '; expected after "%s" property specifier, but %s found'; ctsUnknownSectionKeyword = 'unknown section keyword %s found'; ctsIllegalQualifier = 'illegal qualifier %s found'; + ctsMethodSignatureSNotFoundInClass = 'Method signature %s not found in class'; ctsUnexpectedEndOfSource = 'unexpected end of source'; ctsEndofSourceExpectedButAtomFound = 'expected end., but %s found'; ctsPointStartAt = '. start at '; @@ -147,6 +148,30 @@ ResourceString ctsQualifierExpectedButAtomFound = 'qualifier expected but %s found'; ctsIncompatibleTypesGotExpected = 'incompatibles types: expected "%s" but got "%s"'; ctsDefaultPropertyNotFound = 'default property not found'; + ctsFunctionGetEnumeratorNotFoundInThisClass = 'function GetEnumerator not ' + +'found in this class'; + ctsFunctionGetEnumeratorNotFoundInThisClass2 = 'function GetEnumerator not ' + +'found in this class'; + ctsResultTypeOfFunctionGetEnumeratorNotFound = 'result type of function ' + +'GetEnumerator not found'; + ctsPropertyCurrentNotFound = 'property Current not found'; + ctsEnumerationType = 'enumeration type'; + ctsType = 'type'; + ctsExpectedStatementButFound = 'expected statement, but found %s'; + ctsUnexpectedKeyword2 = 'unexpected keyword %s'; + ctsBeginAtWithoutEnd = 'begin at %s without end'; + ctsThenExpectedButFound = 'then expected, but %s found'; + ctsExpectedButFound = 'expected (, but found %s'; + ctsExpectedIdentifierButFound = 'expected identifier, but found %s'; + ctsExpectedButFound2 = 'expected ), but found %s'; + ctsMissing = 'missing :='; + ctsExpectedButFound3 = 'expected :=, but %s found'; + ctsCharacterConstantOutOfRange = 'character constant out of range'; + ctsOperatorExpectedButFound = 'operator expected but %s found'; + ctsOperandExpectedButFound = 'operand expected but %s found'; + ctsOperandExpectedButFound2 = 'operand expected, but %s found'; + ctsInvalidOperator = 'invalid operator %s'; + ctsOperatorExpectedButFound2 = 'operator expected, but %s found'; // codecompletion ctsPropertySpecifierAlreadyDefined = 'property specifier already defined: %s'; @@ -269,32 +294,10 @@ ResourceString ctsInsufficientMemory = 'insufficient memory'; ctsFileHasCircularSymLink = '%s has a circular symbolic link'; ctsFileIsNotExecutable = '%s is not executable'; + + // misc ctsSrcPathForCompiledUnits = 'src path for compiled units'; ctsTCodeToolManagerConsistencyCheck = 'TCodeToolManager.ConsistencyCheck=%d'; - ctsFunctionGetEnumeratorNotFoundInThisClass = 'function GetEnumerator not ' - +'found in this class'; - ctsFunctionGetEnumeratorNotFoundInThisClass2 = 'function GetEnumerator not ' - +'found in this class'; - ctsResultTypeOfFunctionGetEnumeratorNotFound = 'result type of function ' - +'GetEnumerator not found'; - ctsPropertyCurrentNotFound = 'property Current not found'; - ctsEnumerationType = 'enumeration type'; - ctsType = 'type'; - ctsExpectedStatementButFound = 'expected statement, but found %s'; - ctsUnexpectedKeyword2 = 'unexpected keyword %s'; - ctsBeginAtWithoutEnd = 'begin at %s without end'; - ctsThenExpectedButFound = 'then expected, but %s found'; - ctsExpectedButFound = 'expected (, but found %s'; - ctsExpectedIdentifierButFound = 'expected identifier, but found %s'; - ctsExpectedButFound2 = 'expected ), but found %s'; - ctsMissing = 'missing :='; - ctsExpectedButFound3 = 'expected :=, but %s found'; - ctsCharacterConstantOutOfRange = 'character constant out of range'; - ctsOperatorExpectedButFound = 'operator expected but %s found'; - ctsOperandExpectedButFound = 'operand expected but %s found'; - ctsOperandExpectedButFound2 = 'operand expected, but %s found'; - ctsInvalidOperator = 'invalid operator %s'; - ctsOperatorExpectedButFound2 = 'operator expected, but %s found'; implementation diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index 2a57b1c221..d3e7f3f30a 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -7193,14 +7193,16 @@ var end; procedure ResolveINHERITED; + // for example: inherited A; inherited; + // inherited skips the class and begins to search in the ancestor class var ProcNode: TCodeTreeNode; - ClassOfMethodContext: TFindContext; + ClassNodeOfMethod: TCodeTreeNode; HasIdentifier: Boolean; Context: TFindContext; + var + DefProcNode: TCodeTreeNode; begin - // for example: inherited A; - // inherited skips the class and begins to search in the ancestor class if ExprType.Desc=xtNone then Context:=CreateFindContext(Self,StartNode) else @@ -7210,7 +7212,8 @@ var MoveCursorToCleanPos(CurAtom.StartPos); RaiseIllegalQualifierFound; end; - if (not NodeIsInAMethod(Context.Node)) then begin + ProcNode:=GetMethodOfBody(Context.Node); + if ProcNode=nil then begin MoveCursorToCleanPos(CurAtom.StartPos); RaiseException(ctsInheritedKeywordOnlyAllowedInMethods); end; @@ -7231,38 +7234,47 @@ var ' CurAtom="',copy(Src,CurAtom.StartPos,CurAtom.EndPos-CurAtom.StartPos),'"'); {$ENDIF} - // find ancestor of class of method - ProcNode:=Context.Node.GetNodeOfType(ctnProcedure); + // find class of method Params.Save(OldInput); Params.Flags:=[fdfExceptionOnNotFound] +fdfGlobals*Params.Flags; - Context.Tool.FindClassOfMethod(ProcNode,Params,true); - ClassOfMethodContext:=CreateFindContext(Params); + FindClassOfMethod(ProcNode,Params,true); + ClassNodeOfMethod:=Params.NewNode; // find class ancestor Params.Flags:=[fdfSearchInParentNodes,fdfExceptionOnNotFound] +fdfGlobals*Params.Flags; - ClassOfMethodContext.Tool.FindAncestorOfClass(ClassOfMethodContext.Node, - Params,true); + FindAncestorOfClass(ClassNodeOfMethod,Params,true); ExprType.Desc:=xtContext; - if HasIdentifier then begin - // search identifier only in class ancestor - Params.Load(OldInput,false); - Params.SetIdentifier(Self,@Src[CurAtom.StartPos],@CheckSrcIdentifier); - Params.ContextNode:=Params.NewNode; - Params.Flags:=Params.Flags-[fdfSearchInParentNodes] - +[fdfExceptionOnNotFound,fdfSearchInAncestors]; - Params.NewCodeTool.FindIdentifierInContext(Params); - ExprType.Context:=CreateFindContext(Params); - Params.Load(OldInput,true); - - ResolveBaseTypeOfIdentifier; - end else begin + ExprType.Context:=CreateFindContext(Params); + if (not HasIdentifier) then begin // the keyword 'inherited' is the last atom - // return the ancestor class context - ExprType.Context:=CreateFindContext(Params); - end; + if StartFlags*[fdfFindChilds,fdfFindVariable]=[fdfFindVariable] then begin + // for example: inherited; search the method, not the context + DefProcNode:=FindCorrespondingProcNode(ProcNode); + if DefProcNode=nil then begin + MoveCursorToProcName(ProcNode,true); + RaiseExceptionFmt(ctsMethodSignatureSNotFoundInClass, [GetAtom]); + end; + MoveCursorToProcName(DefProcNode,true); + end else begin + // for example: inherited | + // return the ancestor class context + exit; + end; + end else + MoveCursorToCleanPos(CurAtom.StartPos); + + // search identifier only in class ancestor + Params.Load(OldInput,false); + Params.SetIdentifier(Self,@Src[CurPos.StartPos],@CheckSrcIdentifier); + Params.ContextNode:=ExprType.Context.Node; + Params.Flags:=Params.Flags-[fdfSearchInParentNodes] + +[fdfExceptionOnNotFound,fdfSearchInAncestors]; + ExprType.Context.Tool.FindIdentifierInContext(Params); + ExprType.Context:=CreateFindContext(Params); + Params.Load(OldInput,true); end; begin diff --git a/components/codetools/languages/codetoolsstrconsts.ca.po b/components/codetools/languages/codetoolsstrconsts.ca.po index 31a0d6a49f..99458d5f9d 100644 --- a/components/codetools/languages/codetoolsstrconsts.ca.po +++ b/components/codetools/languages/codetoolsstrconsts.ca.po @@ -601,6 +601,10 @@ msgstr "Fonts del Lazarus" msgid "method name" msgstr "nom del mètode" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "no s'ha trobat la definició del tipus del mètode" diff --git a/components/codetools/languages/codetoolsstrconsts.cs.po b/components/codetools/languages/codetoolsstrconsts.cs.po index 87bbb0a35a..170b2d8a8e 100644 --- a/components/codetools/languages/codetoolsstrconsts.cs.po +++ b/components/codetools/languages/codetoolsstrconsts.cs.po @@ -602,6 +602,10 @@ msgstr "Zdroje Lazarusu" msgid "method name" msgstr "jméno metody" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "definice typu metody nenalezena" diff --git a/components/codetools/languages/codetoolsstrconsts.de.po b/components/codetools/languages/codetoolsstrconsts.de.po index e16d65c87e..54ab067974 100644 --- a/components/codetools/languages/codetoolsstrconsts.de.po +++ b/components/codetools/languages/codetoolsstrconsts.de.po @@ -604,6 +604,10 @@ msgstr "Lazarus-Quellen" msgid "method name" msgstr "Methodenname" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "Methodentypdefinition nicht gefunden" diff --git a/components/codetools/languages/codetoolsstrconsts.es.po b/components/codetools/languages/codetoolsstrconsts.es.po index 49152e60d4..9e567353a2 100644 --- a/components/codetools/languages/codetoolsstrconsts.es.po +++ b/components/codetools/languages/codetoolsstrconsts.es.po @@ -601,6 +601,10 @@ msgstr "Fuentes de Lazarus" msgid "method name" msgstr "nombre de método" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "definición de tipo de método no encontrado" diff --git a/components/codetools/languages/codetoolsstrconsts.esutf.po b/components/codetools/languages/codetoolsstrconsts.esutf.po index a4099086d6..52733987e8 100644 --- a/components/codetools/languages/codetoolsstrconsts.esutf.po +++ b/components/codetools/languages/codetoolsstrconsts.esutf.po @@ -600,6 +600,10 @@ msgstr "Fuentes de Lazarus" msgid "method name" msgstr "nombre de método" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "definición de tipo de método no encontrado" diff --git a/components/codetools/languages/codetoolsstrconsts.fi.po b/components/codetools/languages/codetoolsstrconsts.fi.po index b999573354..5906561d32 100644 --- a/components/codetools/languages/codetoolsstrconsts.fi.po +++ b/components/codetools/languages/codetoolsstrconsts.fi.po @@ -594,6 +594,10 @@ msgstr "" msgid "method name" msgstr "" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "" diff --git a/components/codetools/languages/codetoolsstrconsts.fr.po b/components/codetools/languages/codetoolsstrconsts.fr.po index 4e7ec5fb0d..57f3aeffb3 100644 --- a/components/codetools/languages/codetoolsstrconsts.fr.po +++ b/components/codetools/languages/codetoolsstrconsts.fr.po @@ -602,6 +602,10 @@ msgstr "Sources de Lazarus" msgid "method name" msgstr "nom de méthode" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "définition de la méthode non trouvée" diff --git a/components/codetools/languages/codetoolsstrconsts.he.po b/components/codetools/languages/codetoolsstrconsts.he.po index 900b7e33ad..2d12019766 100644 --- a/components/codetools/languages/codetoolsstrconsts.he.po +++ b/components/codetools/languages/codetoolsstrconsts.he.po @@ -601,6 +601,10 @@ msgstr "הקוד של לזארוס" msgid "method name" msgstr "שם מתודה" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "ההגדרה של סוג המתודה לא נמצאה" diff --git a/components/codetools/languages/codetoolsstrconsts.id.po b/components/codetools/languages/codetoolsstrconsts.id.po index daf8d3c176..fe5c0ecaf5 100644 --- a/components/codetools/languages/codetoolsstrconsts.id.po +++ b/components/codetools/languages/codetoolsstrconsts.id.po @@ -602,6 +602,10 @@ msgstr "Sumber Lazarus" msgid "method name" msgstr "nama method" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "definisi tipe method tidak ditemukan" diff --git a/components/codetools/languages/codetoolsstrconsts.it.po b/components/codetools/languages/codetoolsstrconsts.it.po index f2bfa015f0..6692f86858 100644 --- a/components/codetools/languages/codetoolsstrconsts.it.po +++ b/components/codetools/languages/codetoolsstrconsts.it.po @@ -599,6 +599,10 @@ msgstr "Sorgenti di Lazarus" msgid "method name" msgstr "nome metodo" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "definizione del tipo di metodo non trovata" diff --git a/components/codetools/languages/codetoolsstrconsts.lt.po b/components/codetools/languages/codetoolsstrconsts.lt.po index 3b228d3883..3976982330 100644 --- a/components/codetools/languages/codetoolsstrconsts.lt.po +++ b/components/codetools/languages/codetoolsstrconsts.lt.po @@ -603,6 +603,10 @@ msgstr "Lazarus pirminis kodas" msgid "method name" msgstr "metodo pavadinimas" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "nerasta metodo tipo apibrėžtis" diff --git a/components/codetools/languages/codetoolsstrconsts.nl.po b/components/codetools/languages/codetoolsstrconsts.nl.po index 724cd0db98..e9d6e00b85 100644 --- a/components/codetools/languages/codetoolsstrconsts.nl.po +++ b/components/codetools/languages/codetoolsstrconsts.nl.po @@ -601,6 +601,10 @@ msgstr "" msgid "method name" msgstr "" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "" diff --git a/components/codetools/languages/codetoolsstrconsts.pl.po b/components/codetools/languages/codetoolsstrconsts.pl.po index ce0956c5ce..e4e105da0e 100644 --- a/components/codetools/languages/codetoolsstrconsts.pl.po +++ b/components/codetools/languages/codetoolsstrconsts.pl.po @@ -605,6 +605,10 @@ msgstr "źródła lazarusa" msgid "method name" msgstr "nazwa metody" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "nie znaleziono definicji typu metody" diff --git a/components/codetools/languages/codetoolsstrconsts.po b/components/codetools/languages/codetoolsstrconsts.po index d068e05b65..8a887c5068 100644 --- a/components/codetools/languages/codetoolsstrconsts.po +++ b/components/codetools/languages/codetoolsstrconsts.po @@ -594,6 +594,10 @@ msgstr "" msgid "method name" msgstr "" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "" diff --git a/components/codetools/languages/codetoolsstrconsts.pt.po b/components/codetools/languages/codetoolsstrconsts.pt.po index bd52ba33c2..6d762b7f82 100644 --- a/components/codetools/languages/codetoolsstrconsts.pt.po +++ b/components/codetools/languages/codetoolsstrconsts.pt.po @@ -601,6 +601,10 @@ msgstr "Fontes do Lazarus" msgid "method name" msgstr "nome de método" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "método tipo de definição não encontrado" diff --git a/components/codetools/languages/codetoolsstrconsts.pt_BR.po b/components/codetools/languages/codetoolsstrconsts.pt_BR.po index bd52ba33c2..6d762b7f82 100644 --- a/components/codetools/languages/codetoolsstrconsts.pt_BR.po +++ b/components/codetools/languages/codetoolsstrconsts.pt_BR.po @@ -601,6 +601,10 @@ msgstr "Fontes do Lazarus" msgid "method name" msgstr "nome de método" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "método tipo de definição não encontrado" diff --git a/components/codetools/languages/codetoolsstrconsts.ru.po b/components/codetools/languages/codetoolsstrconsts.ru.po index 9d8fa930b3..ea58ab110a 100644 --- a/components/codetools/languages/codetoolsstrconsts.ru.po +++ b/components/codetools/languages/codetoolsstrconsts.ru.po @@ -600,6 +600,10 @@ msgstr "Исходный код Lazarus" msgid "method name" msgstr "имя метода" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "не найдено описание типа метода" diff --git a/components/codetools/languages/codetoolsstrconsts.sk.po b/components/codetools/languages/codetoolsstrconsts.sk.po index 4a9d94774e..bee9165976 100644 --- a/components/codetools/languages/codetoolsstrconsts.sk.po +++ b/components/codetools/languages/codetoolsstrconsts.sk.po @@ -600,6 +600,10 @@ msgstr "" msgid "method name" msgstr "" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "" diff --git a/components/codetools/languages/codetoolsstrconsts.uk.po b/components/codetools/languages/codetoolsstrconsts.uk.po index 8dde06ad15..db5e35beee 100644 --- a/components/codetools/languages/codetoolsstrconsts.uk.po +++ b/components/codetools/languages/codetoolsstrconsts.uk.po @@ -599,6 +599,10 @@ msgstr "Коди lazarus" msgid "method name" msgstr "ім'я методу" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "не знайдений опис типу методу" diff --git a/components/codetools/languages/codetoolsstrconsts.zh_CN.po b/components/codetools/languages/codetoolsstrconsts.zh_CN.po index 230c60041a..aa9c5fe3e4 100644 --- a/components/codetools/languages/codetoolsstrconsts.zh_CN.po +++ b/components/codetools/languages/codetoolsstrconsts.zh_CN.po @@ -604,6 +604,10 @@ msgstr "Lazarus 源代码" msgid "method name" msgstr "method 名称" +#: codetoolsstrconsts.ctsmethodsignaturesnotfoundinclass +msgid "Method signature %s not found in class" +msgstr "" + #: codetoolsstrconsts.ctsmethodtypedefinitionnotfound msgid "method type definition not found" msgstr "未找到 methond 类型定义" diff --git a/components/codetools/pascalreadertool.pas b/components/codetools/pascalreadertool.pas index 0f56503c22..5f94d8a9ca 100644 --- a/components/codetools/pascalreadertool.pas +++ b/components/codetools/pascalreadertool.pas @@ -129,6 +129,7 @@ type Parse: boolean = true): TCodeTreeNode; function NodeIsInAMethod(Node: TCodeTreeNode): boolean; function NodeIsMethodBody(ProcNode: TCodeTreeNode): boolean; + function GetMethodOfBody(Node: TCodeTreeNode): TCodeTreeNode; function NodeIsFunction(ProcNode: TCodeTreeNode): boolean; function NodeIsConstructor(ProcNode: TCodeTreeNode): boolean; function NodeIsDestructor(ProcNode: TCodeTreeNode): boolean; @@ -1919,6 +1920,13 @@ begin end; end; +function TPascalReaderTool.GetMethodOfBody(Node: TCodeTreeNode): TCodeTreeNode; +begin + Result:=Node; + while (Result<>nil) and not NodeIsMethodBody(Result) do + Result:=Result.Parent; +end; + function TPascalReaderTool.NodeIsFunction(ProcNode: TCodeTreeNode): boolean; begin Result:=false;