codetools: CheckLFM: check types even if parent types was not found

git-svn-id: trunk@25847 -
This commit is contained in:
mattias 2010-06-02 19:20:22 +00:00
parent 577d90a496
commit a15b25d274
2 changed files with 24 additions and 25 deletions

View File

@ -837,4 +837,3 @@ msgstr "Valdiklių aplankas"
msgid "\"%s\" not found" msgid "\"%s\" not found"
msgstr "„%s“ nerastas" msgstr "„%s“ nerastas"

View File

@ -135,7 +135,7 @@ type
SourceChangeCache: TSourceChangeCache): boolean; SourceChangeCache: TSourceChangeCache): boolean;
function CheckLFM(LFMBuf: TCodeBuffer; out LFMTree: TLFMTree; function CheckLFM(LFMBuf: TCodeBuffer; out LFMTree: TLFMTree;
const OnFindDefineProperty: TOnFindDefinePropertyForContext; const OnFindDefineProperty: TOnFindDefinePropertyForContext;
RootMustBeClassInIntf, ObjectsMustExists: boolean): boolean; RootMustBeClassInIntf, ObjectsMustExist: boolean): boolean;
// Application.Createform statements // Application.Createform statements
function FindCreateFormStatement(StartPos: integer; function FindCreateFormStatement(StartPos: integer;
@ -2056,12 +2056,12 @@ end;
function TStandardCodeTool.CheckLFM(LFMBuf: TCodeBuffer; out LFMTree: TLFMTree; function TStandardCodeTool.CheckLFM(LFMBuf: TCodeBuffer; out LFMTree: TLFMTree;
const OnFindDefineProperty: TOnFindDefinePropertyForContext; const OnFindDefineProperty: TOnFindDefinePropertyForContext;
RootMustBeClassInIntf, ObjectsMustExists: boolean): boolean; RootMustBeClassInIntf, ObjectsMustExist: boolean): boolean;
var var
RootContext: TFindContext; RootContext: TFindContext;
function CheckLFMObjectValues(LFMObject: TLFMObjectNode; function CheckLFMObjectValues(LFMObject: TLFMObjectNode;
const ClassContext: TFindContext): boolean; forward; const ClassContext: TFindContext; ContextIsDefault: boolean): boolean; forward;
function FindNonPublishedDefineProperty(LFMNode: TLFMTreeNode; function FindNonPublishedDefineProperty(LFMNode: TLFMTreeNode;
DefaultErrorPosition: integer; DefaultErrorPosition: integer;
@ -2334,13 +2334,15 @@ var
end; end;
procedure CheckLFMChildObject(LFMObject: TLFMObjectNode; procedure CheckLFMChildObject(LFMObject: TLFMObjectNode;
const ParentContext: TFindContext; SearchAlsoInDefineProperties: boolean); const ParentContext: TFindContext;
SearchAlsoInDefineProperties, ContextIsDefault: boolean);
var var
LFMObjectName: String; LFMObjectName: String;
ChildContext: TFindContext; ChildContext: TFindContext;
VariableTypeName: String; VariableTypeName: String;
DefinitionNode: TCodeTreeNode; DefinitionNode: TCodeTreeNode;
ClassContext: TFindContext; ClassContext: TFindContext;
IdentifierFound: Boolean;
begin begin
// find variable for object // find variable for object
@ -2353,16 +2355,13 @@ var
exit; exit;
end; end;
if not FindLFMIdentifier(LFMObject,LFMObject.NamePosition, IdentifierFound:=(not ContextIsDefault) and
LFMObjectName,RootContext,SearchAlsoInDefineProperties,ObjectsMustExists, FindLFMIdentifier(LFMObject,LFMObject.NamePosition,
ChildContext) LFMObjectName,RootContext,SearchAlsoInDefineProperties,ObjectsMustExist,
then begin ChildContext);
// object name not found
if ObjectsMustExists then
exit;
end;
if ObjectsMustExists or (ChildContext.Node<>nil) then begin if IdentifierFound and (ObjectsMustExist or (ChildContext.Node<>nil)) then
begin
if ChildContext.Node=nil then begin if ChildContext.Node=nil then begin
// this is an extra entry, created via DefineProperties. // this is an extra entry, created via DefineProperties.
// There is no generic way to test such things // There is no generic way to test such things
@ -2411,7 +2410,7 @@ var
exit; exit;
end; end;
// check if variable/property type exists // ToDo: check if variable/property type exists
end; end;
@ -2427,13 +2426,13 @@ var
LFMTree.AddError(lfmeIdentifierNotFound,LFMObject, LFMTree.AddError(lfmeIdentifierNotFound,LFMObject,
'type '+LFMObject.TypeName+' not found', 'type '+LFMObject.TypeName+' not found',
LFMObject.TypeNamePosition); LFMObject.TypeNamePosition);
exit;
end; end;
end; end;
if ClassContext.Node=nil then exit;
// check child LFM nodes // check child LFM nodes
CheckLFMObjectValues(LFMObject,ClassContext); if ClassContext.Node<>nil then
CheckLFMObjectValues(LFMObject,ClassContext,false)
else
CheckLFMObjectValues(LFMObject,ParentContext,true);
end; end;
function FindClassNodeForPropertyType(LFMProperty: TLFMPropertyNode; function FindClassNodeForPropertyType(LFMProperty: TLFMPropertyNode;
@ -2483,7 +2482,7 @@ var
SearchContext: TFindContext; SearchContext: TFindContext;
begin begin
// find complete property name // find complete property name
//DebugLn('CheckLFMProperty A LFMProperty Name="',LFMProperty.CompleteName,'"'); //DebugLn('CheckLFMProperty A LFMProperty Name="',LFMProperty.CompleteName,'" ParentContext=',FindContextToString(ParentContext));
if LFMProperty.CompleteName='' then begin if LFMProperty.CompleteName='' then begin
LFMTree.AddError(lfmePropertyNameMissing,LFMProperty, LFMTree.AddError(lfmePropertyNameMissing,LFMProperty,
@ -2515,12 +2514,11 @@ var
end; end;
SearchContext:=CurPropertyContext; SearchContext:=CurPropertyContext;
end; end;
// ToDo: check value // ToDo: check value
end; end;
function CheckLFMObjectValues(LFMObject: TLFMObjectNode; function CheckLFMObjectValues(LFMObject: TLFMObjectNode;
const ClassContext: TFindContext): boolean; const ClassContext: TFindContext; ContextIsDefault: boolean): boolean;
var var
CurLFMNode: TLFMTreeNode; CurLFMNode: TLFMTreeNode;
begin begin
@ -2531,9 +2529,11 @@ var
case CurLFMNode.TheType of case CurLFMNode.TheType of
lfmnObject: lfmnObject:
CheckLFMChildObject(TLFMObjectNode(CurLFMNode),ClassContext,false); CheckLFMChildObject(TLFMObjectNode(CurLFMNode),ClassContext,false,
ContextIsDefault);
lfmnProperty: lfmnProperty:
if not ContextIsDefault then
CheckLFMProperty(TLFMPropertyNode(CurLFMNode),ClassContext); CheckLFMProperty(TLFMPropertyNode(CurLFMNode),ClassContext);
end; end;
@ -2581,7 +2581,7 @@ var
LookupRootLFMNode.TypeNamePosition); LookupRootLFMNode.TypeNamePosition);
exit; exit;
end; end;
Result:=CheckLFMObjectValues(LookupRootLFMNode,RootContext); Result:=CheckLFMObjectValues(LookupRootLFMNode,RootContext,false);
end; end;
var var