mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 22:39:21 +02:00
codetools: fixed find enumerator in class helper
git-svn-id: trunk@50014 -
This commit is contained in:
parent
8dd0d53d28
commit
fb472b1555
@ -340,7 +340,7 @@ type
|
||||
OverrideMod, CallInherited, CallInheritedOnlyInElse: boolean;
|
||||
SourceChanger: TSourceChangeCache;
|
||||
out NewPos: TCodeXYPosition; out NewTopLine: integer;
|
||||
LocalVarName: string = '' // default aSource
|
||||
LocalVarName: string = '' // default is 'aSource'
|
||||
): boolean;
|
||||
|
||||
// local variables
|
||||
@ -354,7 +354,7 @@ type
|
||||
function GuessTypeOfIdentifier(CursorPos: TCodeXYPosition;
|
||||
out IsKeyword, IsSubIdentifier: boolean;
|
||||
out ExistingDefinition: TFindContext; // if it already exists
|
||||
out ListOfPFindContext: TFPList; // possible classes
|
||||
out ListOfPFindContext: TFPList; // possible classes for adding as sub identifier
|
||||
out NewExprType: TExpressionType; out NewType: string): boolean; // false = not at an identifier
|
||||
function DeclareVariableNearBy(InsertPos: TCodeXYPosition;
|
||||
const VariableName, NewType, NewUnitName: string;
|
||||
@ -6390,16 +6390,15 @@ function TCodeCompletionCodeTool.GuessTypeOfIdentifier(
|
||||
aclass.identifier:=<something>
|
||||
<something>:=aclass.identifier
|
||||
<something>:=<something>+aclass.identifier
|
||||
<proc>(,,aclass.identifier)
|
||||
for identifier in <something>
|
||||
ToDo: <proc>(,,aclass.identifier)
|
||||
|
||||
checks where the identifier is already defined
|
||||
checks where the identifier is already defined or is a keyword
|
||||
checks if the identifier is a sub identifier (e.g. A.identifier)
|
||||
creates the list of possible locations and notes
|
||||
checks if it is the target of an assignment and guess the type
|
||||
checks if it is the source of an for in and guess the type
|
||||
ToDo: checks if it is the target of an assignment and guess the type
|
||||
ToDo: checks if it is a parameter and guess the type
|
||||
creates the list of possible insert locations
|
||||
checks if it is the target of an assignment and guesses the type
|
||||
checks if it is the run variable of an for in and guesses the type
|
||||
ToDo: checks if it is a parameter and guesses the type
|
||||
}
|
||||
var
|
||||
CleanCursorPos: integer;
|
||||
@ -6500,7 +6499,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
// find assignment operator
|
||||
// find assignment operator :=
|
||||
MoveCursorToAtomPos(IdentifierAtom);
|
||||
ReadNextAtom;
|
||||
if AtomIs(':=') then begin
|
||||
|
@ -542,6 +542,7 @@ type
|
||||
Identifier: PChar;
|
||||
StartTool: TFindDeclarationTool;
|
||||
StartNode: TCodeTreeNode;
|
||||
Parent: TFindDeclarationParams;
|
||||
ContextNode: TCodeTreeNode;
|
||||
OnIdentifierFound: TOnIdentifierFound;
|
||||
IdentifierTool: TFindDeclarationTool;
|
||||
@ -12010,14 +12011,10 @@ begin
|
||||
end;
|
||||
|
||||
constructor TFindDeclarationParams.Create(ParentParams: TFindDeclarationParams);
|
||||
var
|
||||
HelperKind: TFDHelpersListKind;
|
||||
begin
|
||||
inherited Create;
|
||||
Clear;
|
||||
if ParentParams<>nil then
|
||||
for HelperKind in TFDHelpersListKind do
|
||||
FHelpers[HelperKind] := ParentParams.FHelpers[HelperKind];
|
||||
Parent:=ParentParams;
|
||||
end;
|
||||
|
||||
constructor TFindDeclarationParams.Create(Tool: TFindDeclarationTool;
|
||||
@ -12046,7 +12043,7 @@ begin
|
||||
FreeFoundProc(FFoundProcStackFirst,true);
|
||||
for HelperKind in TFDHelpersListKind do
|
||||
if FFreeHelpers[HelperKind] then
|
||||
FHelpers[HelperKind].Free;
|
||||
FreeAndNil(FHelpers[HelperKind]);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
@ -12216,6 +12213,8 @@ end;
|
||||
function TFindDeclarationParams.GetHelpers(HelperKind: TFDHelpersListKind;
|
||||
CreateIfNotExists: boolean): TFDHelpersList;
|
||||
begin
|
||||
if Parent<>nil then
|
||||
exit(Parent.GetHelpers(HelperKind,CreateIfNotExists));
|
||||
if FNeedHelpers then
|
||||
StartTool.FindHelpersInContext(Self); // beware: this calls GetHelpers
|
||||
Result:=FHelpers[HelperKind];
|
||||
|
@ -199,9 +199,9 @@ begin
|
||||
end;
|
||||
end else if Marker='guesstype' then begin
|
||||
ExpectedType:=copy(Src,PathPos,CommentP-1-PathPos);
|
||||
{ $IFDEF VerboseFindDeclarationTests}
|
||||
{$IFDEF VerboseFindDeclarationTests}
|
||||
debugln(['TTestFindDeclaration.FindDeclarations "',Marker,'" at ',Tool.CleanPosToStr(NameStartPos-1),' ExpectedType=',ExpectedType]);
|
||||
{ $ENDIF}
|
||||
{$ENDIF}
|
||||
Tool.CleanPosToCaret(IdentifierStartPos,CursorPos);
|
||||
|
||||
// test GuessTypeOfIdentifier
|
||||
@ -214,13 +214,6 @@ begin
|
||||
if ExpectedType<>'' then
|
||||
AssertEquals('GuessTypeOfIdentifier failed at '+Tool.CleanPosToStr(IdentifierStartPos,true)+': '+CodeToolBoss.ErrorMessage,false,true);
|
||||
continue;
|
||||
end else if ExistingDefinition.Node<>nil then begin
|
||||
// already defined, no guessing needed
|
||||
AssertEquals('GuessTypeOfIdentifier wrong at '
|
||||
+Tool.CleanPosToStr(IdentifierStartPos,true),
|
||||
'cannot find definition',
|
||||
'found definition: '+ExistingDefinition.Tool.CleanPosToStr(
|
||||
ExistingDefinition.Node.StartPos,true));
|
||||
end else begin
|
||||
//debugln(['TTestFindDeclaration.FindDeclarations FoundPath=',FoundPath]);
|
||||
AssertEquals('GuessTypeOfIdentifier wrong at '+Tool.CleanPosToStr(IdentifierStartPos,true),LowerCase(ExpectedType),LowerCase(NewType));
|
||||
|
Loading…
Reference in New Issue
Block a user