codetools: CheckLFM: variable type with unit name

This commit is contained in:
mattias 2023-04-07 14:03:40 +02:00
parent 7dec126e98
commit a7f2330310
3 changed files with 9 additions and 14 deletions

View File

@ -987,9 +987,13 @@ begin
PrependStr:=PrependStr+'noTree';
end;}
if PrependStr<>'' then begin
if Result<>'' then
Result:='/'+Result;
Result:=PrependStr+Result;
if Result<>'' then begin
if ANode is TLFMObjectNode then
Result:='.'+Result
else
Result:='/'+Result;
end;
Result:=PrependStr+Result;
end;
ANode:=ANode.Parent;
end;

View File

@ -2372,8 +2372,6 @@ var
const VarPropContext: TFindContext): TFindContext;
var
Params: TFindDeclarationParams;
Identifier: PChar;
OldInput: TFindDeclarationInput;
TypeNode: TCodeTreeNode;
VariableTypeName, AnUnitName, TypeName: String;
begin
@ -2390,11 +2388,9 @@ var
LFMObject.NamePosition);
end;
VariableTypeName:=VarPropContext.Tool.ExtractDefinitionNodeType(VarPropContext.Node);
Identifier:=@VarPropContext.Tool.Src[TypeNode.StartPos]
end else if (VarPropContext.Node.Desc=ctnProperty) then begin
TypeNode:=VarPropContext.Node;
VariableTypeName:=VarPropContext.Tool.ExtractPropType(TypeNode,false,false);
Identifier:=VarPropContext.Tool.GetPropertyTypeIdentifier(TypeNode);
end else begin
LFMTree.AddError(lfmeObjectIncompatible,LFMObject,
LFMObject.Name+' is not a variable'
@ -2410,13 +2406,8 @@ var
fdfExceptionOnPredefinedIdent,fdfIgnoreMissingParams,
fdfIgnoreOverloadedProcs,fdfIgnoreCurContextNode];
Params.ContextNode:=TypeNode;
Params.SetIdentifier(VarPropContext.Tool,Identifier,nil);
try
Params.Save(OldInput);
if VarPropContext.Tool.FindIdentifierInContext(Params) then begin
Params.Load(OldInput,true);
Result:=Params.NewCodeTool.FindBaseTypeOfNode(Params,Params.NewNode);
end;
Result:=VarPropContext.Tool.FindBaseTypeOfNode(Params,TypeNode);
except
// ignore search/parse errors
on E: ECodeToolError do begin

View File

@ -304,7 +304,7 @@ end;
procedure TTestLFMTrees.LFMUnitname;
begin
AddControls;
AddFormUnit(['Button1: TButton']);
AddFormUnit(['Button1: Controls.TButton']);
FLFMCode:=AddSource('unit1.lfm',LinesToStr([
'object Form1: unit1/TForm1',
' object Button1: Controls/TButton',