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,8 +987,12 @@ begin
PrependStr:=PrependStr+'noTree'; PrependStr:=PrependStr+'noTree';
end;} end;}
if PrependStr<>'' then begin if PrependStr<>'' then begin
if Result<>'' then if Result<>'' then begin
if ANode is TLFMObjectNode then
Result:='.'+Result
else
Result:='/'+Result; Result:='/'+Result;
end;
Result:=PrependStr+Result; Result:=PrependStr+Result;
end; end;
ANode:=ANode.Parent; ANode:=ANode.Parent;

View File

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

View File

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