mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 16:19:28 +02:00
codetools: find declaration: inherited;
git-svn-id: trunk@30920 -
This commit is contained in:
parent
a999b71d2c
commit
a75a29091c
@ -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
|
||||
|
||||
|
@ -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
|
||||
ExprType.Context:=CreateFindContext(Params);
|
||||
if (not HasIdentifier) then begin
|
||||
// the keyword 'inherited' is the last atom
|
||||
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[CurAtom.StartPos],@CheckSrcIdentifier);
|
||||
Params.ContextNode:=Params.NewNode;
|
||||
Params.SetIdentifier(Self,@Src[CurPos.StartPos],@CheckSrcIdentifier);
|
||||
Params.ContextNode:=ExprType.Context.Node;
|
||||
Params.Flags:=Params.Flags-[fdfSearchInParentNodes]
|
||||
+[fdfExceptionOnNotFound,fdfSearchInAncestors];
|
||||
Params.NewCodeTool.FindIdentifierInContext(Params);
|
||||
ExprType.Context.Tool.FindIdentifierInContext(Params);
|
||||
ExprType.Context:=CreateFindContext(Params);
|
||||
Params.Load(OldInput,true);
|
||||
|
||||
ResolveBaseTypeOfIdentifier;
|
||||
end else begin
|
||||
// the keyword 'inherited' is the last atom
|
||||
// return the ancestor class context
|
||||
ExprType.Context:=CreateFindContext(Params);
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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 ""
|
||||
|
@ -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"
|
||||
|
@ -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 "ההגדרה של סוג המתודה לא נמצאה"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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 ""
|
||||
|
@ -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"
|
||||
|
@ -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 ""
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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 "не найдено описание типа метода"
|
||||
|
@ -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 ""
|
||||
|
@ -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 "не знайдений опис типу методу"
|
||||
|
@ -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 类型定义"
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user