mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 10:52:22 +02:00
added DefineProperties check for check lfm
git-svn-id: trunk@5160 -
This commit is contained in:
parent
4565731a0f
commit
34f25d506b
@ -43,8 +43,8 @@ uses
|
||||
Classes, SysUtils, FileProcs, BasicCodeTools, CodeToolsStrConsts,
|
||||
EventCodeTool, CodeTree, CodeAtom, SourceChanger, DefineTemplates, CodeCache,
|
||||
ExprEval, LinkScanner, KeywordFuncLists, TypInfo, AVL_Tree, LFMTrees,
|
||||
CustomCodeTool, FindDeclarationTool, IdentCompletionTool, ResourceCodeTool,
|
||||
CodeToolsStructs, CodeTemplatesTool, ExtractProcTool;
|
||||
CustomCodeTool, FindDeclarationTool, IdentCompletionTool, StdCodeTools,
|
||||
ResourceCodeTool, CodeToolsStructs, CodeTemplatesTool, ExtractProcTool;
|
||||
|
||||
type
|
||||
TCodeToolManager = class;
|
||||
@ -341,6 +341,7 @@ type
|
||||
// resources
|
||||
function FindLFMFileName(Code: TCodeBuffer): string;
|
||||
function CheckLFM(UnitCode, LFMBuf: TCodeBuffer;
|
||||
OnGetDefineProperties: TOnGetDefineProperties;
|
||||
var LFMTree: TLFMTree): boolean;
|
||||
function FindNextResourceFile(Code: TCodeBuffer;
|
||||
var LinkIndex: integer): TCodeBuffer;
|
||||
@ -1958,6 +1959,7 @@ begin
|
||||
end;
|
||||
|
||||
function TCodeToolManager.CheckLFM(UnitCode, LFMBuf: TCodeBuffer;
|
||||
OnGetDefineProperties: TOnGetDefineProperties;
|
||||
var LFMTree: TLFMTree): boolean;
|
||||
begin
|
||||
Result:=false;
|
||||
@ -1966,7 +1968,7 @@ begin
|
||||
{$ENDIF}
|
||||
if not InitCurCodeTool(UnitCode) then exit;
|
||||
try
|
||||
Result:=FCurCodeTool.CheckLFM(LFMBuf,LFMTree);
|
||||
Result:=FCurCodeTool.CheckLFM(LFMBuf,LFMTree,OnGetDefineProperties);
|
||||
except
|
||||
on e: Exception do HandleException(e);
|
||||
end;
|
||||
|
@ -73,7 +73,9 @@ type
|
||||
NamePosition: integer;
|
||||
TypeName: string;
|
||||
TypeNamePosition: integer;
|
||||
DefineProperties: TSTrings;
|
||||
constructor CreateVirtual; override;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
{ TLFMNameParts }
|
||||
@ -615,6 +617,12 @@ begin
|
||||
TheType:=lfmnObject;
|
||||
end;
|
||||
|
||||
destructor TLFMObjectNode.Destroy;
|
||||
begin
|
||||
DefineProperties.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
{ TLFMPropertyNode }
|
||||
|
||||
constructor TLFMPropertyNode.CreateVirtual;
|
||||
|
@ -53,6 +53,11 @@ uses
|
||||
TypInfo, LFMTrees, SourceChanger, CustomCodeTool, CodeToolsStructs;
|
||||
|
||||
type
|
||||
TOnGetDefineProperties = procedure(Sender: TObject;
|
||||
const ClassContext: TFindContext; LFMNode: TLFMTreeNode;
|
||||
const IdentName: string; var DefineProperties: TStrings) of object;
|
||||
|
||||
|
||||
TStandardCodeTool = class(TIdentCompletionTool)
|
||||
private
|
||||
CachedSourceName: string;
|
||||
@ -110,7 +115,8 @@ type
|
||||
function RenameInclude(LinkIndex: integer; const NewFilename: string;
|
||||
KeepPath: boolean;
|
||||
SourceChangeCache: TSourceChangeCache): boolean;
|
||||
function CheckLFM(LFMBuf: TCodeBuffer; var LFMTree: TLFMTree): boolean;
|
||||
function CheckLFM(LFMBuf: TCodeBuffer; var LFMTree: TLFMTree;
|
||||
const OnGetDefineProperties: TOnGetDefineProperties): boolean;
|
||||
|
||||
// createform
|
||||
function FindCreateFormStatement(StartPos: integer;
|
||||
@ -873,17 +879,46 @@ begin
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
function TStandardCodeTool.CheckLFM(LFMBuf: TCodeBuffer; var LFMTree: TLFMTree
|
||||
): boolean;
|
||||
function TStandardCodeTool.CheckLFM(LFMBuf: TCodeBuffer; var LFMTree: TLFMTree;
|
||||
const OnGetDefineProperties: TOnGetDefineProperties): boolean;
|
||||
var
|
||||
RootContext: TFindContext;
|
||||
|
||||
function CheckLFMObjectValues(LFMObject: TLFMObjectNode;
|
||||
const ClassContext: TFindContext): boolean; forward;
|
||||
|
||||
function FindNonPublishedDefineProperty(LFMNode: TLFMTreeNode;
|
||||
DefaultErrorPosition: integer;
|
||||
const IdentName: string; const ClassContext: TFindContext): boolean;
|
||||
var
|
||||
PropertyNode: TLFMPropertyNode;
|
||||
ObjectNode: TLFMObjectNode;
|
||||
begin
|
||||
Result:=false;
|
||||
if (not (LFMNode is TLFMPropertyNode)) then exit;
|
||||
PropertyNode:=TLFMPropertyNode(LFMNode);
|
||||
if (PropertyNode.Parent=nil)
|
||||
or (not (PropertyNode.Parent is TLFMObjectNode)) then exit;
|
||||
ObjectNode:=TLFMObjectNode(PropertyNode.Parent);
|
||||
if ObjectNode.DefineProperties=nil then begin
|
||||
// fetch define properties
|
||||
if Assigned(OnGetDefineProperties) then begin
|
||||
OnGetDefineProperties(Self,ClassContext,LFMNode,IdentName,
|
||||
ObjectNode.DefineProperties);
|
||||
end else begin
|
||||
// create the default define properties for TComponent
|
||||
ObjectNode.DefineProperties:=TStringList.Create;
|
||||
ObjectNode.DefineProperties.Add('LEFT');
|
||||
ObjectNode.DefineProperties.Add('TOP');
|
||||
end;
|
||||
end;
|
||||
Result:=ObjectNode.DefineProperties.IndexOf(IdentName)>=0;
|
||||
end;
|
||||
|
||||
function FindLFMIdentifier(LFMNode: TLFMTreeNode;
|
||||
DefaultErrorPosition: integer;
|
||||
const IdentName: string; const ClassContext: TFindContext): TFindContext;
|
||||
const IdentName: string; const ClassContext: TFindContext;
|
||||
SearchAlsoInDefineProperties: boolean): TFindContext;
|
||||
var
|
||||
Params: TFindDeclarationParams;
|
||||
begin
|
||||
@ -918,6 +953,12 @@ var
|
||||
Params.Free;
|
||||
end;
|
||||
if Result.Node=nil then begin
|
||||
// no node found
|
||||
if SearchAlsoInDefineProperties then begin
|
||||
if FindNonPublishedDefineProperty(LFMNode,DefaultErrorPosition,
|
||||
IdentName,ClassContext)
|
||||
then exit;
|
||||
end;
|
||||
LFMTree.AddError(lfmeIdentifierNotFound,LFMNode,
|
||||
'identifier '+IdentName+' not found',
|
||||
DefaultErrorPosition);
|
||||
@ -995,7 +1036,7 @@ var
|
||||
exit;
|
||||
end;
|
||||
ChildContext:=FindLFMIdentifier(LFMObject,LFMObject.NamePosition,
|
||||
LFMObjectName,RootContext);
|
||||
LFMObjectName,RootContext,false);
|
||||
if ChildContext.Node=nil then exit;
|
||||
|
||||
// check if identifier is variable
|
||||
@ -1086,6 +1127,11 @@ var
|
||||
|
||||
procedure CheckLFMProperty(LFMProperty: TLFMPropertyNode;
|
||||
const ParentContext: TFindContext);
|
||||
// checks properties. For example lines like 'OnShow = FormShow'
|
||||
// or 'VertScrollBar.Range = 29'
|
||||
// LFMProperty is the property node
|
||||
// ParentContext is the context, where properties are searched.
|
||||
// This can be a class or a property.
|
||||
var
|
||||
i: Integer;
|
||||
CurName: string;
|
||||
@ -1113,7 +1159,7 @@ var
|
||||
CurName:=LFMProperty.NameParts.Names[i];
|
||||
CurPropertyContext:=FindLFMIdentifier(LFMProperty,
|
||||
LFMProperty.NameParts.NamePositions[i],
|
||||
CurName,SearchContext);
|
||||
CurName,SearchContext,true);
|
||||
if CurPropertyContext.Node=nil then
|
||||
break;
|
||||
SearchContext:=CurPropertyContext;
|
||||
|
@ -120,7 +120,7 @@ var
|
||||
end;
|
||||
|
||||
begin
|
||||
Result:=CodeToolBoss.CheckLFM(PascalBuffer,LFMBuffer,LFMTree);
|
||||
Result:=CodeToolBoss.CheckLFM(PascalBuffer,LFMBuffer,nil,LFMTree);
|
||||
try
|
||||
if Result then exit;
|
||||
WriteLFMErrors;
|
||||
|
@ -3736,11 +3736,14 @@ begin
|
||||
FormEditor1.CreateComponentFromStream(BinLFMStream,
|
||||
AncestorType,true));
|
||||
if CInterface=nil then begin
|
||||
// error streaming component -> examine lfm file
|
||||
NewComponent:=nil;
|
||||
AnUnitInfo.Component:=NewComponent;
|
||||
// open lfm file in editor
|
||||
Result:=DoOpenEditorFile(LFMBuf.Filename,AnUnitInfo.EditorIndex+1,
|
||||
Flags+[ofOnlyIfExists,ofQuiet,ofRegularFile]);
|
||||
if Result<>mrOk then exit;
|
||||
Result:=DoCheckLFMInEditor;
|
||||
if Result=mrOk then Result:=mrCancel;
|
||||
exit;
|
||||
end else begin
|
||||
@ -10312,6 +10315,9 @@ end.
|
||||
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.708 2004/02/04 11:09:40 mattias
|
||||
added DefineProperties check for check lfm
|
||||
|
||||
Revision 1.707 2004/02/03 20:01:29 mattias
|
||||
fixed gtk intf WaitMessages
|
||||
|
||||
|
@ -513,6 +513,7 @@ type
|
||||
TImage = class(TCustomImage)
|
||||
published
|
||||
property Align;
|
||||
property Anchors;
|
||||
property AutoSize;
|
||||
property Center;
|
||||
property Constraints;
|
||||
@ -852,6 +853,7 @@ type
|
||||
property ClientHeight;
|
||||
property ClientWidth;
|
||||
property Color;
|
||||
property Constraints;
|
||||
property DragMode;
|
||||
property Enabled;
|
||||
property Font;
|
||||
@ -919,6 +921,9 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.94 2004/02/04 11:09:40 mattias
|
||||
added DefineProperties check for check lfm
|
||||
|
||||
Revision 1.93 2004/02/03 19:00:10 mattias
|
||||
published TBevel.OnPaint
|
||||
|
||||
|
@ -416,6 +416,7 @@ type
|
||||
property Align;
|
||||
property Anchors;
|
||||
property BorderStyle;
|
||||
property Constraints;
|
||||
property ExtendedSelect;
|
||||
property Items;
|
||||
property ItemHeight;
|
||||
@ -1482,6 +1483,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.123 2004/02/04 11:09:40 mattias
|
||||
added DefineProperties check for check lfm
|
||||
|
||||
Revision 1.122 2004/02/04 00:21:40 mattias
|
||||
added SelectDirectory and TListBox.ItemVisible
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user