mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-06 01:06:01 +02:00
IDE: implemented parsing LCLVersion from lfm, added ResourceBaseClass to TUnitInfo and TPkgFile
git-svn-id: trunk@15106 -
This commit is contained in:
parent
bb5587c1c8
commit
5d66571b44
@ -30,7 +30,8 @@ unit LFMTrees;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, AVL_Tree, FileProcs, CodeCache, CodeAtom, TypInfo;
|
Classes, SysUtils, AVL_Tree, FileProcs, BasicCodeTools, CodeCache, CodeAtom,
|
||||||
|
TypInfo;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ TLFMTreeNode }
|
{ TLFMTreeNode }
|
||||||
@ -132,6 +133,7 @@ type
|
|||||||
public
|
public
|
||||||
ValueType: TLFMValueType;
|
ValueType: TLFMValueType;
|
||||||
constructor CreateVirtual; override;
|
constructor CreateVirtual; override;
|
||||||
|
function ReadString: string;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -238,6 +240,8 @@ type
|
|||||||
TLFMTree = class
|
TLFMTree = class
|
||||||
protected
|
protected
|
||||||
Parser: TParser;
|
Parser: TParser;
|
||||||
|
TokenStart: LongInt;
|
||||||
|
function NextToken: Char;
|
||||||
procedure ProcessValue;
|
procedure ProcessValue;
|
||||||
procedure ProcessProperty;
|
procedure ProcessProperty;
|
||||||
procedure ProcessObject;
|
procedure ProcessObject;
|
||||||
@ -266,6 +270,11 @@ type
|
|||||||
function FindErrorAtNode(Node: TLFMTreeNode): TLFMError;
|
function FindErrorAtNode(Node: TLFMTreeNode): TLFMError;
|
||||||
function FindError(ErrorTypes: TLFMErrorTypes): TLFMError;
|
function FindError(ErrorTypes: TLFMErrorTypes): TLFMError;
|
||||||
function FirstErrorAsString: string;
|
function FirstErrorAsString: string;
|
||||||
|
|
||||||
|
function FindProperty(PropertyPath: string;
|
||||||
|
ContextNode: TLFMTreeNode): TLFMPropertyNode;
|
||||||
|
|
||||||
|
procedure WriteDebugReport;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TLFMTrees }
|
{ TLFMTrees }
|
||||||
@ -301,6 +310,18 @@ const
|
|||||||
'EndNotFound'
|
'EndNotFound'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
TLFMValueTypeNames: array[TLFMValueType] of string = (
|
||||||
|
'None',
|
||||||
|
'Integer',
|
||||||
|
'Float',
|
||||||
|
'String',
|
||||||
|
'Symbol',
|
||||||
|
'Set',
|
||||||
|
'List',
|
||||||
|
'Collection',
|
||||||
|
'Binary'
|
||||||
|
);
|
||||||
|
|
||||||
procedure FreeListOfPInstancePropInfo(List: TFPList);
|
procedure FreeListOfPInstancePropInfo(List: TFPList);
|
||||||
function CompareLFMTreesByLFMBuffer(Data1, Data2: Pointer): integer;
|
function CompareLFMTreesByLFMBuffer(Data1, Data2: Pointer): integer;
|
||||||
function CompareLFMBufWithTree(Buf, Tree: Pointer): integer;
|
function CompareLFMBufWithTree(Buf, Tree: Pointer): integer;
|
||||||
@ -334,6 +355,7 @@ begin
|
|||||||
Result:=ComparePointers(Buf,TLFMTree(Tree).LFMBuffer);
|
Result:=ComparePointers(Buf,TLFMTree(Tree).LFMBuffer);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TLFMTree }
|
{ TLFMTree }
|
||||||
|
|
||||||
constructor TLFMTree.Create;
|
constructor TLFMTree.Create;
|
||||||
@ -349,7 +371,8 @@ end;
|
|||||||
|
|
||||||
procedure TLFMTree.Clear;
|
procedure TLFMTree.Clear;
|
||||||
begin
|
begin
|
||||||
LFMBuffer:=nil;
|
// do not set LFMBuffer to nil
|
||||||
|
TokenStart:=0;
|
||||||
CurNode:=nil;
|
CurNode:=nil;
|
||||||
ClearErrors;
|
ClearErrors;
|
||||||
while Root<>nil do Root.Free;
|
while Root<>nil do Root.Free;
|
||||||
@ -368,6 +391,8 @@ begin
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
Clear;
|
Clear;
|
||||||
if LFMBuf<>LFMBuffer then begin
|
if LFMBuf<>LFMBuffer then begin
|
||||||
|
DebugLn(['TLFMTree.Parse New=',LFMBuf.Filename]);
|
||||||
|
DebugLn(['TLFMTree.Parse Old=',LFMBuffer.Filename]);
|
||||||
if Trees<>nil then
|
if Trees<>nil then
|
||||||
raise Exception.Create('TLFMTree.Parse: changing LFMBuffer in Tree is not allowed');
|
raise Exception.Create('TLFMTree.Parse: changing LFMBuffer in Tree is not allowed');
|
||||||
LFMBuffer:=LFMBuf;
|
LFMBuffer:=LFMBuf;
|
||||||
@ -466,10 +491,81 @@ begin
|
|||||||
if FirstError<>nil then Result:=FirstError.ErrorMessage;
|
if FirstError<>nil then Result:=FirstError.ErrorMessage;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TLFMTree.FindProperty(PropertyPath: string; ContextNode: TLFMTreeNode
|
||||||
|
): TLFMPropertyNode;
|
||||||
|
var
|
||||||
|
Node: TLFMTreeNode;
|
||||||
|
ObjNode: TLFMObjectNode;
|
||||||
|
p: LongInt;
|
||||||
|
FirstPart: String;
|
||||||
|
RestParts: String;
|
||||||
|
begin
|
||||||
|
if ContextNode=nil then
|
||||||
|
Node:=Root
|
||||||
|
else
|
||||||
|
Node:=ContextNode.FirstChild;
|
||||||
|
p:=System.Pos(PropertyPath,'.');
|
||||||
|
FirstPart:=copy(PropertyPath,1,p-1);
|
||||||
|
RestParts:=copy(PropertyPath,p+1,length(PropertyPath));
|
||||||
|
while Node<>nil do begin
|
||||||
|
if Node is TLFMPropertyNode then begin
|
||||||
|
Result:=TLFMPropertyNode(Node);
|
||||||
|
if SysUtils.CompareText(Result.CompleteName,PropertyPath)=0 then
|
||||||
|
exit;
|
||||||
|
end else if (Node is TLFMObjectNode)
|
||||||
|
and (RestParts<>'') then begin
|
||||||
|
ObjNode:=TLFMObjectNode(Node);
|
||||||
|
if CompareIdentifierPtrs(Pointer(ObjNode.Name),Pointer(FirstPart))=0 then
|
||||||
|
begin
|
||||||
|
Result:=FindProperty(RestParts,ObjNode);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Node:=Node.NextSibling;
|
||||||
|
end;
|
||||||
|
Result:=nil;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLFMTree.WriteDebugReport;
|
||||||
|
var
|
||||||
|
Src: string;
|
||||||
|
|
||||||
|
procedure WriteNode(const Prefix: string; Node: TLFMTreeNode);
|
||||||
|
var
|
||||||
|
Child: TLFMTreeNode;
|
||||||
|
EndPos: LongInt;
|
||||||
|
begin
|
||||||
|
if Node=nil then exit;
|
||||||
|
Child:=Node.FirstChild;
|
||||||
|
EndPos:=Node.EndPos;
|
||||||
|
if (Child<>nil) and (EndPos>Child.StartPos) then
|
||||||
|
EndPos:=Child.StartPos;
|
||||||
|
DebugLn([Prefix,dbgstr(copy(Src,Node.StartPos,EndPos-Node.StartPos))]);
|
||||||
|
while Child<>nil do begin
|
||||||
|
WriteNode(Prefix+' ',Child);
|
||||||
|
Child:=Child.NextSibling;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if LFMBuffer=nil then begin
|
||||||
|
DebugLn(['TLFMTree.WriteDebugReport LFMBuffer=nil']);
|
||||||
|
end;
|
||||||
|
DebugLn(['TLFMTree.WriteDebugReport ',LFMBuffer.Filename]);
|
||||||
|
Src:=LFMBuffer.Source;
|
||||||
|
WriteNode('',Root);
|
||||||
|
end;
|
||||||
|
|
||||||
{$if not declared(toWString)}
|
{$if not declared(toWString)}
|
||||||
const toWString = char(5);
|
const toWString = char(5);
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
function TLFMTree.NextToken: Char;
|
||||||
|
begin
|
||||||
|
TokenStart:=Parser.SourcePos+1;
|
||||||
|
Result:=Parser.NextToken;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TLFMTree.ProcessValue;
|
procedure TLFMTree.ProcessValue;
|
||||||
var
|
var
|
||||||
s: String;
|
s: String;
|
||||||
@ -482,7 +578,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
CreateChildNode(TLFMValueNode);
|
CreateChildNode(TLFMValueNode);
|
||||||
TLFMValueNode(CurNode).ValueType:=lfmvInteger;
|
TLFMValueNode(CurNode).ValueType:=lfmvInteger;
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
CloseChildNode;
|
CloseChildNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -490,7 +586,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
CreateChildNode(TLFMValueNode);
|
CreateChildNode(TLFMValueNode);
|
||||||
TLFMValueNode(CurNode).ValueType:=lfmvFloat;
|
TLFMValueNode(CurNode).ValueType:=lfmvFloat;
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
CloseChildNode;
|
CloseChildNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -498,8 +594,8 @@ begin
|
|||||||
begin
|
begin
|
||||||
CreateChildNode(TLFMValueNode);
|
CreateChildNode(TLFMValueNode);
|
||||||
TLFMValueNode(CurNode).ValueType:=lfmvString;
|
TLFMValueNode(CurNode).ValueType:=lfmvString;
|
||||||
while Parser.NextToken = '+' do begin
|
while NextToken = '+' do begin
|
||||||
Parser.NextToken; // Get next string fragment
|
NextToken; // Get next string fragment
|
||||||
if not (Parser.Token in [toString,toWString]) then
|
if not (Parser.Token in [toString,toWString]) then
|
||||||
Parser.CheckToken(toString);
|
Parser.CheckToken(toString);
|
||||||
end;
|
end;
|
||||||
@ -512,13 +608,13 @@ begin
|
|||||||
SymbolNode:=TLFMValueNodeSymbol(CurNode);
|
SymbolNode:=TLFMValueNodeSymbol(CurNode);
|
||||||
if SymbolNode=nil then ;
|
if SymbolNode=nil then ;
|
||||||
s := Parser.TokenString;
|
s := Parser.TokenString;
|
||||||
if CompareText(s, 'End') = 0 then
|
if SysUtils.CompareText(s, 'End') = 0 then
|
||||||
SymbolNode.SymbolType:=lfmsNone
|
SymbolNode.SymbolType:=lfmsNone
|
||||||
else if CompareText(s, 'True') = 0 then
|
else if SysUtils.CompareText(s, 'True') = 0 then
|
||||||
SymbolNode.SymbolType:=lfmsTrue
|
SymbolNode.SymbolType:=lfmsTrue
|
||||||
else if CompareText(s, 'False') = 0 then
|
else if SysUtils.CompareText(s, 'False') = 0 then
|
||||||
SymbolNode.SymbolType:=lfmsFalse
|
SymbolNode.SymbolType:=lfmsFalse
|
||||||
else if CompareText(s, 'nil') = 0 then
|
else if SysUtils.CompareText(s, 'nil') = 0 then
|
||||||
SymbolNode.SymbolType:=lfmsNil
|
SymbolNode.SymbolType:=lfmsNil
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -526,7 +622,7 @@ begin
|
|||||||
Parser.TokenComponentIdent;
|
Parser.TokenComponentIdent;
|
||||||
end;
|
end;
|
||||||
if SymbolNode.SymbolType<>lfmsNone then
|
if SymbolNode.SymbolType<>lfmsNone then
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
CloseChildNode;
|
CloseChildNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -534,20 +630,20 @@ begin
|
|||||||
'[':
|
'[':
|
||||||
begin
|
begin
|
||||||
CreateChildNode(TLFMValueNodeSet);
|
CreateChildNode(TLFMValueNodeSet);
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
if Parser.Token <> ']' then
|
if Parser.Token <> ']' then
|
||||||
while True do
|
while True do
|
||||||
begin
|
begin
|
||||||
CreateChildNode(TLFMEnumNode);
|
CreateChildNode(TLFMEnumNode);
|
||||||
Parser.CheckToken(toSymbol);
|
Parser.CheckToken(toSymbol);
|
||||||
CloseChildNode;
|
CloseChildNode;
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
if Parser.Token = ']' then
|
if Parser.Token = ']' then
|
||||||
break;
|
break;
|
||||||
Parser.CheckToken(',');
|
Parser.CheckToken(',');
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
end;
|
end;
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
CloseChildNode;
|
CloseChildNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -555,10 +651,10 @@ begin
|
|||||||
'(':
|
'(':
|
||||||
begin
|
begin
|
||||||
CreateChildNode(TLFMValueNodeList);
|
CreateChildNode(TLFMValueNodeList);
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
while Parser.Token <> ')' do
|
while Parser.Token <> ')' do
|
||||||
ProcessValue;
|
ProcessValue;
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
CloseChildNode;
|
CloseChildNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -566,18 +662,18 @@ begin
|
|||||||
'<':
|
'<':
|
||||||
begin
|
begin
|
||||||
CreateChildNode(TLFMValueNodeCollection);
|
CreateChildNode(TLFMValueNodeCollection);
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
while Parser.Token <> '>' do
|
while Parser.Token <> '>' do
|
||||||
begin
|
begin
|
||||||
Parser.CheckTokenSymbol('item');
|
Parser.CheckTokenSymbol('item');
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
CreateChildNode(TLFMValueNodeList);
|
CreateChildNode(TLFMValueNodeList);
|
||||||
while not Parser.TokenSymbolIs('end') do
|
while not Parser.TokenSymbolIs('end') do
|
||||||
ProcessProperty;
|
ProcessProperty;
|
||||||
Parser.NextToken; // Skip 'end'
|
NextToken; // Skip 'end'
|
||||||
CloseChildNode;
|
CloseChildNode;
|
||||||
end;
|
end;
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
CloseChildNode;
|
CloseChildNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -591,7 +687,7 @@ begin
|
|||||||
finally
|
finally
|
||||||
MemStream.Free;
|
MemStream.Free;
|
||||||
end;
|
end;
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
CloseChildNode;
|
CloseChildNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -611,14 +707,14 @@ begin
|
|||||||
Parser.CheckToken(toSymbol);
|
Parser.CheckToken(toSymbol);
|
||||||
PropertyNode.Add(Parser.TokenString,Parser.SourcePos+1);
|
PropertyNode.Add(Parser.TokenString,Parser.SourcePos+1);
|
||||||
while True do begin
|
while True do begin
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
if Parser.Token <> '.' then break;
|
if Parser.Token <> '.' then break;
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
Parser.CheckToken(toSymbol);
|
Parser.CheckToken(toSymbol);
|
||||||
PropertyNode.Add(Parser.TokenString,Parser.SourcePos+1);
|
PropertyNode.Add(Parser.TokenString,Parser.SourcePos+1);
|
||||||
end;
|
end;
|
||||||
Parser.CheckToken('=');
|
Parser.CheckToken('=');
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
ProcessValue;
|
ProcessValue;
|
||||||
CloseChildNode;
|
CloseChildNode;
|
||||||
end;
|
end;
|
||||||
@ -636,7 +732,7 @@ begin
|
|||||||
Parser.CheckTokenSymbol('INHERITED');
|
Parser.CheckTokenSymbol('INHERITED');
|
||||||
ObjectNode.IsInherited := True;
|
ObjectNode.IsInherited := True;
|
||||||
end;
|
end;
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
Parser.CheckToken(toSymbol);
|
Parser.CheckToken(toSymbol);
|
||||||
if not Parser.TokenSymbolIs('END') then begin
|
if not Parser.TokenSymbolIs('END') then begin
|
||||||
ObjectStartLine:=Parser.SourceLine;
|
ObjectStartLine:=Parser.SourceLine;
|
||||||
@ -644,21 +740,21 @@ begin
|
|||||||
ObjectNode.TypeName := Parser.TokenString;
|
ObjectNode.TypeName := Parser.TokenString;
|
||||||
ObjectNode.TypeNamePosition:=Parser.SourcePos+1;
|
ObjectNode.TypeNamePosition:=Parser.SourcePos+1;
|
||||||
ObjectNode.ChildPos := -1;
|
ObjectNode.ChildPos := -1;
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
if Parser.Token = ':' then begin
|
if Parser.Token = ':' then begin
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
Parser.CheckToken(toSymbol);
|
Parser.CheckToken(toSymbol);
|
||||||
ObjectNode.Name := ObjectNode.TypeName;
|
ObjectNode.Name := ObjectNode.TypeName;
|
||||||
ObjectNode.NamePosition:=ObjectNode.TypeNamePosition;
|
ObjectNode.NamePosition:=ObjectNode.TypeNamePosition;
|
||||||
ObjectNode.TypeName := Parser.TokenString;
|
ObjectNode.TypeName := Parser.TokenString;
|
||||||
ObjectNode.TypeNamePosition:=Parser.SourcePos+1;
|
ObjectNode.TypeNamePosition:=Parser.SourcePos+1;
|
||||||
Parser.NextToken;
|
NextToken;
|
||||||
if parser.Token = '[' then begin
|
if parser.Token = '[' then begin
|
||||||
parser.NextToken;
|
NextToken;
|
||||||
ObjectNode.ChildPos := parser.TokenInt;
|
ObjectNode.ChildPos := parser.TokenInt;
|
||||||
parser.NextToken;
|
NextToken;
|
||||||
parser.CheckToken(']');
|
parser.CheckToken(']');
|
||||||
parser.NextToken;
|
NextToken;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -678,7 +774,7 @@ begin
|
|||||||
ProcessObject;
|
ProcessObject;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Parser.NextToken; // Skip 'END' token
|
NextToken; // Skip 'END' token
|
||||||
|
|
||||||
CloseChildNode;
|
CloseChildNode;
|
||||||
end;
|
end;
|
||||||
@ -689,8 +785,8 @@ var
|
|||||||
begin
|
begin
|
||||||
NewNode:=NodeClass.CreateVirtual;
|
NewNode:=NodeClass.CreateVirtual;
|
||||||
NewNode.Tree:=Self;
|
NewNode.Tree:=Self;
|
||||||
NewNode.StartPos:=Parser.SourcePos+1;
|
NewNode.StartPos:=TokenStart;
|
||||||
NewNode.EndPos:=NewNode.StartPos;
|
NewNode.EndPos:=0;
|
||||||
if CurNode<>nil then begin
|
if CurNode<>nil then begin
|
||||||
CurNode.AddChild(NewNode);
|
CurNode.AddChild(NewNode);
|
||||||
end else begin
|
end else begin
|
||||||
@ -701,7 +797,8 @@ end;
|
|||||||
|
|
||||||
procedure TLFMTree.CloseChildNode;
|
procedure TLFMTree.CloseChildNode;
|
||||||
begin
|
begin
|
||||||
CurNode.EndPos:=Parser.SourcePos+1;
|
if CurNode.EndPos<1 then
|
||||||
|
CurNode.EndPos:=TokenStart;
|
||||||
CurNode:=CurNode.Parent;
|
CurNode:=CurNode.Parent;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -884,6 +981,34 @@ begin
|
|||||||
ValueType:=lfmvNone;
|
ValueType:=lfmvNone;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TLFMValueNode.ReadString: string;
|
||||||
|
var
|
||||||
|
p: LongInt;
|
||||||
|
Src: String;
|
||||||
|
i: integer;
|
||||||
|
AtomStart: LongInt;
|
||||||
|
begin
|
||||||
|
Result:='';
|
||||||
|
if ValueType<>lfmvString then exit;
|
||||||
|
p:=StartPos;
|
||||||
|
AtomStart:=p;
|
||||||
|
Src:=Tree.LFMBuffer.Source;
|
||||||
|
repeat
|
||||||
|
ReadRawNextPascalAtom(Src,p,AtomStart);
|
||||||
|
if AtomStart>length(Src) then exit;
|
||||||
|
if Src[AtomStart]='''' then begin
|
||||||
|
Result:=Result+copy(Src,AtomStart+1,p-AtomStart-2)
|
||||||
|
end else if Src[AtomStart]='+' then begin
|
||||||
|
// skip
|
||||||
|
end else if Src[AtomStart]='#' then begin
|
||||||
|
i:=StrToIntDef(copy(Src,AtomStart+1,p-AtomStart-1),-1);
|
||||||
|
if (i<0) or (i>255) then exit;
|
||||||
|
Result:=Result+chr(i);
|
||||||
|
end else
|
||||||
|
exit;
|
||||||
|
until false;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TLFMValueNodeSymbol }
|
{ TLFMValueNodeSymbol }
|
||||||
|
|
||||||
constructor TLFMValueNodeSymbol.CreateVirtual;
|
constructor TLFMValueNodeSymbol.CreateVirtual;
|
||||||
|
@ -4140,7 +4140,7 @@ begin
|
|||||||
if ProcNode.Desc=ctnProcedureHead then
|
if ProcNode.Desc=ctnProcedureHead then
|
||||||
ProcNode:=ProcNode.Parent;
|
ProcNode:=ProcNode.Parent;
|
||||||
if ProcNode.Desc<>ctnProcedure then
|
if ProcNode.Desc<>ctnProcedure then
|
||||||
RaiseException('INTERNAL ERROR: TPascalParserTool.BuildSubTreeForProcHead');
|
RaiseException('INTERNAL ERROR: TPascalParserTool.BuildSubTreeForProcHead with FunctionResult');
|
||||||
BuildSubTreeForProcHead(ProcNode);
|
BuildSubTreeForProcHead(ProcNode);
|
||||||
FunctionResult:=ProcNode.FirstChild.FirstChild;
|
FunctionResult:=ProcNode.FirstChild.FirstChild;
|
||||||
if (FunctionResult<>nil) and (FunctionResult.Desc=ctnParameterList) then
|
if (FunctionResult<>nil) and (FunctionResult.Desc=ctnParameterList) then
|
||||||
|
@ -727,7 +727,7 @@ begin
|
|||||||
if HasDFMFile and (LFMCode=nil) then
|
if HasDFMFile and (LFMCode=nil) then
|
||||||
DebugLn('WARNING: ConvertDelphiToLazarusUnit unable to load LFMCode');
|
DebugLn('WARNING: ConvertDelphiToLazarusUnit unable to load LFMCode');
|
||||||
if (LFMCode<>nil)
|
if (LFMCode<>nil)
|
||||||
and (CheckLFMBuffer(UnitCode,LFMCode,@IDEMessagesWindow.AddMsg,true,true)<>mrOk)
|
and (RepairLFMBuffer(UnitCode,LFMCode,@IDEMessagesWindow.AddMsg,true,true)<>mrOk)
|
||||||
then begin
|
then begin
|
||||||
LazarusIDE.DoJumpToCompilerMessage(-1,true);
|
LazarusIDE.DoJumpToCompilerMessage(-1,true);
|
||||||
exit(mrAbort);
|
exit(mrAbort);
|
||||||
|
@ -218,7 +218,7 @@ var
|
|||||||
|
|
||||||
function CheckProperties: boolean;
|
function CheckProperties: boolean;
|
||||||
begin
|
begin
|
||||||
Result:=CheckLFMBuffer(UnitCode,LFMBuffer,nil,false,false)=mrOk;
|
Result:=RepairLFMBuffer(UnitCode,LFMBuffer,nil,false,false)=mrOk;
|
||||||
if not Result and (CodeToolBoss.ErrorMessage<>'') then
|
if not Result and (CodeToolBoss.ErrorMessage<>'') then
|
||||||
MainIDEInterface.DoJumpToCodeToolBossError;
|
MainIDEInterface.DoJumpToCodeToolBossError;
|
||||||
end;
|
end;
|
||||||
|
@ -39,7 +39,7 @@ uses
|
|||||||
SynHighlighterLFM, SynEdit, BasicCodeTools, CodeCache, CodeToolManager,
|
SynHighlighterLFM, SynEdit, BasicCodeTools, CodeCache, CodeToolManager,
|
||||||
LFMTrees,
|
LFMTrees,
|
||||||
// IDE
|
// IDE
|
||||||
PropEdits, ComponentReg, PackageIntf, IDEWindowIntf,
|
PropEdits, IDEDialogs, ComponentReg, PackageIntf, IDEWindowIntf,
|
||||||
LazarusIDEStrConsts, OutputFilter, IDEProcs, IDEOptionDefs, EditorOptions;
|
LazarusIDEStrConsts, OutputFilter, IDEProcs, IDEOptionDefs, EditorOptions;
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -77,16 +77,22 @@ type
|
|||||||
property LFMTree: TLFMTree read FLFMTree write SetLFMTree;
|
property LFMTree: TLFMTree read FLFMTree write SetLFMTree;
|
||||||
property LFMSource: TCodeBuffer read FLFMSource write SetLFMSource;
|
property LFMSource: TCodeBuffer read FLFMSource write SetLFMSource;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CheckLFMBuffer(PascalBuffer, LFMBuffer: TCodeBuffer;
|
// check and repair lfm files
|
||||||
|
function QuickCheckLFMBuffer(PascalBuffer, LFMBuffer: TCodeBuffer;
|
||||||
|
out LCLVersion: string;
|
||||||
|
out MissingClasses: TStrings// e.g. MyFrame2:TMyFrame
|
||||||
|
): TModalResult;
|
||||||
|
function RepairLFMBuffer(PascalBuffer, LFMBuffer: TCodeBuffer;
|
||||||
const OnOutput: TOnAddFilteredLine;
|
const OnOutput: TOnAddFilteredLine;
|
||||||
RootMustBeClassInIntf, ObjectsMustExists: boolean): TModalResult;
|
RootMustBeClassInIntf, ObjectsMustExists: boolean): TModalResult;
|
||||||
function CheckLFMText(PascalBuffer: TCodeBuffer; var LFMText: string;
|
function RepairLFMText(PascalBuffer: TCodeBuffer; var LFMText: string;
|
||||||
const OnOutput: TOnAddFilteredLine;
|
const OnOutput: TOnAddFilteredLine;
|
||||||
RootMustBeClassInIntf, ObjectsMustExists: boolean): TModalResult;
|
RootMustBeClassInIntf, ObjectsMustExists: boolean): TModalResult;
|
||||||
function ShowRepairLFMWizard(LFMBuffer: TCodeBuffer;
|
function ShowRepairLFMWizard(LFMBuffer: TCodeBuffer;
|
||||||
LFMTree: TLFMTree): TModalResult;
|
LFMTree: TLFMTree): TModalResult;
|
||||||
|
|
||||||
|
// dangling events
|
||||||
function RemoveDanglingEvents(RootComponent: TComponent;
|
function RemoveDanglingEvents(RootComponent: TComponent;
|
||||||
PascalBuffer: TCodeBuffer; OkOnCodeErrors: boolean;
|
PascalBuffer: TCodeBuffer; OkOnCodeErrors: boolean;
|
||||||
out ComponentModified: boolean): TModalResult;
|
out ComponentModified: boolean): TModalResult;
|
||||||
@ -101,7 +107,42 @@ type
|
|||||||
NewText: string;
|
NewText: string;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CheckLFMBuffer(PascalBuffer, LFMBuffer: TCodeBuffer;
|
function QuickCheckLFMBuffer(PascalBuffer, LFMBuffer: TCodeBuffer; out
|
||||||
|
LCLVersion: string; out MissingClasses: TStrings): TModalResult;
|
||||||
|
var
|
||||||
|
LFMTree: TLFMTree;
|
||||||
|
LCLVersionNode: TLFMPropertyNode;
|
||||||
|
LCLVersionValueNode: TLFMValueNode;
|
||||||
|
begin
|
||||||
|
DebugLn(['QuickCheckLFMBuffer LFMBuffer=',LFMBuffer.Filename]);
|
||||||
|
LCLVersion:='';
|
||||||
|
MissingClasses:=nil;
|
||||||
|
|
||||||
|
LFMTree:=DefaultLFMTrees.GetLFMTree(LFMBuffer,true);
|
||||||
|
if not LFMTree.ParseIfNeeded then begin
|
||||||
|
DebugLn(['QuickCheckLFMBuffer LFM error: ',LFMTree.FirstErrorAsString]);
|
||||||
|
exit(mrCancel);
|
||||||
|
end;
|
||||||
|
|
||||||
|
//LFMTree.WriteDebugReport;
|
||||||
|
|
||||||
|
// first search the version
|
||||||
|
LCLVersionNode:=LFMTree.FindProperty('LCLVersion',LFMTree.Root);
|
||||||
|
//DebugLn(['QuickCheckLFMBuffer LCLVersionNode=',LCLVersionNode<>nil]);
|
||||||
|
if (LCLVersionNode<>nil) and (LCLVersionNode.FirstChild is TLFMValueNode) then
|
||||||
|
begin
|
||||||
|
LCLVersionValueNode:=TLFMValueNode(LCLVersionNode.FirstChild);
|
||||||
|
//DebugLn(['QuickCheckLFMBuffer ',TLFMValueTypeNames[LCLVersionValueNode.ValueType]]);
|
||||||
|
if LCLVersionValueNode.ValueType=lfmvString then begin
|
||||||
|
LCLVersion:=LCLVersionValueNode.ReadString;
|
||||||
|
//DebugLn(['QuickCheckLFMBuffer LCLVersion=',LCLVersion]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Result:=mrOk;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function RepairLFMBuffer(PascalBuffer, LFMBuffer: TCodeBuffer;
|
||||||
const OnOutput: TOnAddFilteredLine;
|
const OnOutput: TOnAddFilteredLine;
|
||||||
RootMustBeClassInIntf, ObjectsMustExists: boolean): TModalResult;
|
RootMustBeClassInIntf, ObjectsMustExists: boolean): TModalResult;
|
||||||
var
|
var
|
||||||
@ -257,7 +298,6 @@ begin
|
|||||||
DebugLn(['CheckLFMBuffer failed parsing unit: ',PascalBuffer.Filename]);
|
DebugLn(['CheckLFMBuffer failed parsing unit: ',PascalBuffer.Filename]);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if CodeToolBoss.CheckLFM(PascalBuffer,LFMBuffer,LFMTree,
|
if CodeToolBoss.CheckLFM(PascalBuffer,LFMBuffer,LFMTree,
|
||||||
RootMustBeClassInIntf,ObjectsMustExists)
|
RootMustBeClassInIntf,ObjectsMustExists)
|
||||||
then begin
|
then begin
|
||||||
@ -274,7 +314,7 @@ begin
|
|||||||
Result:=ShowRepairLFMWizard(LFMBuffer,LFMTree);
|
Result:=ShowRepairLFMWizard(LFMBuffer,LFMTree);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CheckLFMText(PascalBuffer: TCodeBuffer; var LFMText: string;
|
function RepairLFMText(PascalBuffer: TCodeBuffer; var LFMText: string;
|
||||||
const OnOutput: TOnAddFilteredLine;
|
const OnOutput: TOnAddFilteredLine;
|
||||||
RootMustBeClassInIntf, ObjectsMustExists: boolean): TModalResult;
|
RootMustBeClassInIntf, ObjectsMustExists: boolean): TModalResult;
|
||||||
var
|
var
|
||||||
@ -284,8 +324,8 @@ begin
|
|||||||
LFMBuf:=CodeToolBoss.CreateTempFile('temp.lfm');
|
LFMBuf:=CodeToolBoss.CreateTempFile('temp.lfm');
|
||||||
try
|
try
|
||||||
LFMBuf.Source:=LFMText;
|
LFMBuf.Source:=LFMText;
|
||||||
Result:=CheckLFMBuffer(PascalBuffer,LFMBuf,OnOutput,RootMustBeClassInIntf,
|
Result:=RepairLFMBuffer(PascalBuffer,LFMBuf,OnOutput,RootMustBeClassInIntf,
|
||||||
ObjectsMustExists);
|
ObjectsMustExists);
|
||||||
LFMText:=LFMBuf.Source;
|
LFMText:=LFMBuf.Source;
|
||||||
finally
|
finally
|
||||||
CodeToolBoss.ReleaseTempFile(LFMBuf);
|
CodeToolBoss.ReleaseTempFile(LFMBuf);
|
||||||
|
@ -5401,6 +5401,8 @@ var
|
|||||||
NewUnitName: String;
|
NewUnitName: String;
|
||||||
AncestorUnitInfo: TUnitInfo;
|
AncestorUnitInfo: TUnitInfo;
|
||||||
ReferencesLocked: Boolean;
|
ReferencesLocked: Boolean;
|
||||||
|
LCLVersion: string;
|
||||||
|
MissingClasses: TStrings;
|
||||||
begin
|
begin
|
||||||
debugln('TMainIDE.DoLoadLFM A ',AnUnitInfo.Filename,' IsPartOfProject=',dbgs(AnUnitInfo.IsPartOfProject),' ');
|
debugln('TMainIDE.DoLoadLFM A ',AnUnitInfo.Filename,' IsPartOfProject=',dbgs(AnUnitInfo.IsPartOfProject),' ');
|
||||||
|
|
||||||
@ -5444,6 +5446,8 @@ begin
|
|||||||
|
|
||||||
if AnUnitInfo.Component=nil then begin
|
if AnUnitInfo.Component=nil then begin
|
||||||
// load/create new instance
|
// load/create new instance
|
||||||
|
|
||||||
|
QuickCheckLFMBuffer(AnUnitInfo.Source,LFMBuf,LCLVersion,MissingClasses);
|
||||||
|
|
||||||
// find the classname of the LFM, and check for inherited form
|
// find the classname of the LFM, and check for inherited form
|
||||||
ReadLFMHeader(LFMBuf.Source,NewClassName,LFMType);
|
ReadLFMHeader(LFMBuf.Source,NewClassName,LFMType);
|
||||||
@ -9924,8 +9928,8 @@ begin
|
|||||||
DoArrangeSourceEditorAndMessageView(false);
|
DoArrangeSourceEditorAndMessageView(false);
|
||||||
|
|
||||||
// parse the LFM file and the pascal unit
|
// parse the LFM file and the pascal unit
|
||||||
if CheckLFMBuffer(PascalBuf,LFMUnitInfo.Source,@MessagesView.AddMsg,
|
if RepairLFMBuffer(PascalBuf,LFMUnitInfo.Source,@MessagesView.AddMsg,
|
||||||
true,true)<>mrOk
|
true,true)<>mrOk
|
||||||
then begin
|
then begin
|
||||||
DoJumpToCompilerMessage(-1,true);
|
DoJumpToCompilerMessage(-1,true);
|
||||||
end;
|
end;
|
||||||
|
@ -155,7 +155,7 @@ type
|
|||||||
uifMarked
|
uifMarked
|
||||||
);
|
);
|
||||||
TUnitInfoFlags = set of TUnitInfoFlag;
|
TUnitInfoFlags = set of TUnitInfoFlag;
|
||||||
|
|
||||||
{ TUnitInfo }
|
{ TUnitInfo }
|
||||||
|
|
||||||
TUnitInfo = class(TLazProjectFile)
|
TUnitInfo = class(TLazProjectFile)
|
||||||
@ -165,6 +165,7 @@ type
|
|||||||
fBookmarks: TFileBookmarks;
|
fBookmarks: TFileBookmarks;
|
||||||
FBuildFileIfActive: boolean;
|
FBuildFileIfActive: boolean;
|
||||||
fComponent: TComponent;
|
fComponent: TComponent;
|
||||||
|
FResourceBaseClass: TPFComponentBaseClass;
|
||||||
fComponentName: string; { classname is always T<ComponentName>
|
fComponentName: string; { classname is always T<ComponentName>
|
||||||
this attribute contains the component name,
|
this attribute contains the component name,
|
||||||
even if the unit is not loaded,
|
even if the unit is not loaded,
|
||||||
@ -176,6 +177,7 @@ type
|
|||||||
FComponentLastLRSStreamSize: TStreamSeekType;
|
FComponentLastLRSStreamSize: TStreamSeekType;
|
||||||
fCursorPos: TPoint;
|
fCursorPos: TPoint;
|
||||||
fCustomHighlighter: boolean; // do not change highlighter on file extension change
|
fCustomHighlighter: boolean; // do not change highlighter on file extension change
|
||||||
|
FDirectives: TStrings;
|
||||||
fEditorIndex: integer;
|
fEditorIndex: integer;
|
||||||
fFileName: string;
|
fFileName: string;
|
||||||
fFileReadOnly: Boolean;
|
fFileReadOnly: Boolean;
|
||||||
@ -222,6 +224,7 @@ type
|
|||||||
function GetPrevUnitWithEditorIndex: TUnitInfo;
|
function GetPrevUnitWithEditorIndex: TUnitInfo;
|
||||||
procedure SetAutoReferenceSourceDir(const AValue: boolean);
|
procedure SetAutoReferenceSourceDir(const AValue: boolean);
|
||||||
procedure SetBuildFileIfActive(const AValue: boolean);
|
procedure SetBuildFileIfActive(const AValue: boolean);
|
||||||
|
procedure SetDirectives(const AValue: TStrings);
|
||||||
procedure SetEditorIndex(const AValue: integer);
|
procedure SetEditorIndex(const AValue: integer);
|
||||||
procedure SetFileReadOnly(const AValue: Boolean);
|
procedure SetFileReadOnly(const AValue: Boolean);
|
||||||
procedure SetComponent(const AValue: TComponent);
|
procedure SetComponent(const AValue: TComponent);
|
||||||
@ -264,12 +267,12 @@ type
|
|||||||
procedure IgnoreCurrentFileDateOnDisk;
|
procedure IgnoreCurrentFileDateOnDisk;
|
||||||
procedure IncreaseAutoRevertLock;
|
procedure IncreaseAutoRevertLock;
|
||||||
procedure DecreaseAutoRevertLock;
|
procedure DecreaseAutoRevertLock;
|
||||||
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
|
||||||
Merge: boolean);
|
|
||||||
function ParseUnitNameFromSource(TryCache: boolean): string;
|
function ParseUnitNameFromSource(TryCache: boolean): string;
|
||||||
procedure ReadUnitNameFromSource(TryCache: boolean);
|
procedure ReadUnitNameFromSource(TryCache: boolean);
|
||||||
function CreateUnitName: string;
|
function CreateUnitName: string;
|
||||||
procedure ImproveUnitNameCache(const NewUnitName: string);
|
procedure ImproveUnitNameCache(const NewUnitName: string);
|
||||||
|
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
||||||
|
Merge: boolean);
|
||||||
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
||||||
SaveData, SaveSession: boolean);
|
SaveData, SaveSession: boolean);
|
||||||
procedure UpdateUsageCount(Min, IfBelowThis, IncIfBelow: extended);
|
procedure UpdateUsageCount(Min, IfBelowThis, IncIfBelow: extended);
|
||||||
@ -315,6 +318,8 @@ type
|
|||||||
property ComponentName: string read fComponentName write fComponentName;
|
property ComponentName: string read fComponentName write fComponentName;
|
||||||
property ComponentResourceName: string read fComponentResourceName
|
property ComponentResourceName: string read fComponentResourceName
|
||||||
write fComponentResourceName;
|
write fComponentResourceName;
|
||||||
|
property ResourceBaseClass: TPFComponentBaseClass read FResourceBaseClass
|
||||||
|
write FResourceBaseClass;
|
||||||
property ComponentLastBinStreamSize: TStreamSeekType
|
property ComponentLastBinStreamSize: TStreamSeekType
|
||||||
read FComponentLastBinStreamSize write FComponentLastBinStreamSize;
|
read FComponentLastBinStreamSize write FComponentLastBinStreamSize;
|
||||||
property ComponentLastLRSStreamSize: TStreamSeekType
|
property ComponentLastLRSStreamSize: TStreamSeekType
|
||||||
@ -324,7 +329,7 @@ type
|
|||||||
property CursorPos: TPoint read fCursorPos write fCursorPos; // physical (screen) position
|
property CursorPos: TPoint read fCursorPos write fCursorPos; // physical (screen) position
|
||||||
property CustomHighlighter: boolean
|
property CustomHighlighter: boolean
|
||||||
read fCustomHighlighter write fCustomHighlighter;
|
read fCustomHighlighter write fCustomHighlighter;
|
||||||
property Directives: TStrings;
|
property Directives: TStrings read FDirectives write SetDirectives;
|
||||||
property EditorIndex: integer read fEditorIndex write SetEditorIndex;
|
property EditorIndex: integer read fEditorIndex write SetEditorIndex;
|
||||||
property FileReadOnly: Boolean read fFileReadOnly write SetFileReadOnly;
|
property FileReadOnly: Boolean read fFileReadOnly write SetFileReadOnly;
|
||||||
property FirstRequiredComponent: TUnitComponentDependency
|
property FirstRequiredComponent: TUnitComponentDependency
|
||||||
@ -869,14 +874,14 @@ type
|
|||||||
property EnableI18N: boolean read FEnableI18N write SetEnableI18N;
|
property EnableI18N: boolean read FEnableI18N write SetEnableI18N;
|
||||||
property POOutputDirectory: string read FPOOutputDirectory
|
property POOutputDirectory: string read FPOOutputDirectory
|
||||||
write SetPOOutputDirectory;
|
write SetPOOutputDirectory;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
ResourceFileExt = '.lrs';
|
ResourceFileExt = '.lrs';
|
||||||
|
|
||||||
var
|
var
|
||||||
Project1: TProject = nil;
|
Project1: TProject = nil;// the main project
|
||||||
|
|
||||||
procedure AddCompileReasonsDiff(Tool: TCompilerDiffTool;
|
procedure AddCompileReasonsDiff(Tool: TCompilerDiffTool;
|
||||||
const PropertyName: string; const Old, New: TCompileReasons);
|
const PropertyName: string; const Old, New: TCompileReasons);
|
||||||
@ -1148,6 +1153,9 @@ begin
|
|||||||
XMLConfig.SetDeleteValue(Path+'ComponentName/Value',fComponentName,'');
|
XMLConfig.SetDeleteValue(Path+'ComponentName/Value',fComponentName,'');
|
||||||
XMLConfig.SetDeleteValue(Path+'HasResources/Value',fHasResources,false);
|
XMLConfig.SetDeleteValue(Path+'HasResources/Value',fHasResources,false);
|
||||||
XMLConfig.SetDeleteValue(Path+'IsPartOfProject/Value',IsPartOfProject,false);
|
XMLConfig.SetDeleteValue(Path+'IsPartOfProject/Value',IsPartOfProject,false);
|
||||||
|
XMLConfig.SetDeleteValue(Path+'ResourceBaseClass/Value',
|
||||||
|
PFComponentBaseClassNames[FResourceBaseClass],
|
||||||
|
PFComponentBaseClassNames[pfcbcNone]);
|
||||||
AFilename:=FResourceFilename;
|
AFilename:=FResourceFilename;
|
||||||
if Assigned(fOnLoadSaveFilename) then
|
if Assigned(fOnLoadSaveFilename) then
|
||||||
fOnLoadSaveFilename(AFilename,false);
|
fOnLoadSaveFilename(AFilename,false);
|
||||||
@ -1198,6 +1206,8 @@ begin
|
|||||||
if fComponentName='' then
|
if fComponentName='' then
|
||||||
fComponentName:=XMLConfig.GetValue(Path+'FormName/Value','');
|
fComponentName:=XMLConfig.GetValue(Path+'FormName/Value','');
|
||||||
HasResources:=XMLConfig.GetValue(Path+'HasResources/Value',false);
|
HasResources:=XMLConfig.GetValue(Path+'HasResources/Value',false);
|
||||||
|
FResourceBaseClass:=StrToComponentBaseClass(
|
||||||
|
XMLConfig.GetValue(Path+'ResourceBaseClass/Value',''));
|
||||||
IsPartOfProject:=XMLConfig.GetValue(Path+'IsPartOfProject/Value',false);
|
IsPartOfProject:=XMLConfig.GetValue(Path+'IsPartOfProject/Value',false);
|
||||||
AFilename:=XMLConfig.GetValue(Path+'ResourceFilename/Value','');
|
AFilename:=XMLConfig.GetValue(Path+'ResourceFilename/Value','');
|
||||||
if (AFilename<>'') and Assigned(fOnLoadSaveFilename) then
|
if (AFilename<>'') and Assigned(fOnLoadSaveFilename) then
|
||||||
@ -1695,6 +1705,12 @@ begin
|
|||||||
SessionModified:=true;
|
SessionModified:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TUnitInfo.SetDirectives(const AValue: TStrings);
|
||||||
|
begin
|
||||||
|
if FDirectives=AValue then exit;
|
||||||
|
FDirectives:=AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TUnitInfo.SetEditorIndex(const AValue: integer);
|
procedure TUnitInfo.SetEditorIndex(const AValue: integer);
|
||||||
begin
|
begin
|
||||||
if fEditorIndex=AValue then exit;
|
if fEditorIndex=AValue then exit;
|
||||||
@ -1717,7 +1733,10 @@ begin
|
|||||||
if fComponent=AValue then exit;
|
if fComponent=AValue then exit;
|
||||||
fComponent:=AValue;
|
fComponent:=AValue;
|
||||||
UpdateList(uilWithComponent,fComponent<>nil);
|
UpdateList(uilWithComponent,fComponent<>nil);
|
||||||
if fComponent=nil then ClearComponentDependencies;
|
if fComponent=nil then
|
||||||
|
ClearComponentDependencies
|
||||||
|
else
|
||||||
|
FResourceBaseClass:=GetComponentBaseClass(fComponent.ClassType);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUnitInfo.SetIsPartOfProject(const AValue: boolean);
|
procedure TUnitInfo.SetIsPartOfProject(const AValue: boolean);
|
||||||
|
@ -147,6 +147,25 @@ type
|
|||||||
const
|
const
|
||||||
PkgFileUnitTypes = [pftUnit,pftVirtualUnit];
|
PkgFileUnitTypes = [pftUnit,pftVirtualUnit];
|
||||||
|
|
||||||
|
type
|
||||||
|
TPFComponentBaseClass = (
|
||||||
|
pfcbcNone, // unknown
|
||||||
|
pfcbcForm, // is TForm
|
||||||
|
pfcbcFrame, // is TFrame
|
||||||
|
pfcbcDataModule // is TDataModule
|
||||||
|
);
|
||||||
|
|
||||||
|
const
|
||||||
|
PFComponentBaseClassNames: array[TPFComponentBaseClass] of string = (
|
||||||
|
'None',
|
||||||
|
'Form',
|
||||||
|
'Frame',
|
||||||
|
'DataModule'
|
||||||
|
);
|
||||||
|
|
||||||
|
function StrToComponentBaseClass(const s: string): TPFComponentBaseClass;
|
||||||
|
function GetComponentBaseClass(aClass: TClass): TPFComponentBaseClass;
|
||||||
|
|
||||||
type
|
type
|
||||||
TPkgFileFlag = (
|
TPkgFileFlag = (
|
||||||
pffHasRegisterProc, // file is unit and has a 'register' procedure
|
pffHasRegisterProc, // file is unit and has a 'register' procedure
|
||||||
@ -170,6 +189,7 @@ type
|
|||||||
fFullFilename: string;
|
fFullFilename: string;
|
||||||
fFullFilenameStamp: integer;
|
fFullFilenameStamp: integer;
|
||||||
FPackage: TLazPackage;
|
FPackage: TLazPackage;
|
||||||
|
FResourceBaseClass: TPFComponentBaseClass;
|
||||||
FSourceDirectoryReferenced: boolean;
|
FSourceDirectoryReferenced: boolean;
|
||||||
FSourceDirNeedReference: boolean;
|
FSourceDirNeedReference: boolean;
|
||||||
FUnitName: string;
|
FUnitName: string;
|
||||||
@ -204,23 +224,25 @@ type
|
|||||||
procedure UpdateSourceDirectoryReference;
|
procedure UpdateSourceDirectoryReference;
|
||||||
function GetFullFilename: string;
|
function GetFullFilename: string;
|
||||||
public
|
public
|
||||||
property Removed: boolean read FRemoved write SetRemoved;
|
property AddToUsesPkgSection: boolean
|
||||||
|
read GetAddToUsesPkgSection write SetAddToUsesPkgSection;
|
||||||
|
property AutoReferenceSourceDir: boolean read FAutoReferenceSourceDir
|
||||||
|
write SetAutoReferenceSourceDir;
|
||||||
|
property ResourceBaseClass: TPFComponentBaseClass read FResourceBaseClass
|
||||||
|
write FResourceBaseClass;
|
||||||
|
property ComponentPriority: TComponentPriority read FComponentPriority
|
||||||
|
write FComponentPriority;
|
||||||
|
property Components[Index: integer]: TPkgComponent read GetComponents;// registered components
|
||||||
property Directory: string read FDirectory;
|
property Directory: string read FDirectory;
|
||||||
property Filename: string read FFilename write SetFilename;
|
property Filename: string read FFilename write SetFilename;
|
||||||
property FileType: TPkgFileType read FFileType write SetFileType;
|
property FileType: TPkgFileType read FFileType write SetFileType;
|
||||||
property Flags: TPkgFileFlags read FFlags write SetFlags;
|
property Flags: TPkgFileFlags read FFlags write SetFlags;
|
||||||
property HasRegisterProc: boolean
|
property HasRegisterProc: boolean
|
||||||
read GetHasRegisterProc write SetHasRegisterProc;
|
read GetHasRegisterProc write SetHasRegisterProc;
|
||||||
property AddToUsesPkgSection: boolean
|
|
||||||
read GetAddToUsesPkgSection write SetAddToUsesPkgSection;
|
|
||||||
property LazPackage: TLazPackage read FPackage;
|
property LazPackage: TLazPackage read FPackage;
|
||||||
property UnitName: string read FUnitName write FUnitName;
|
property Removed: boolean read FRemoved write SetRemoved;
|
||||||
property ComponentPriority: TComponentPriority read FComponentPriority
|
|
||||||
write FComponentPriority;
|
|
||||||
property Components[Index: integer]: TPkgComponent read GetComponents;
|
|
||||||
property SourceDirectoryReferenced: boolean read FSourceDirectoryReferenced;
|
property SourceDirectoryReferenced: boolean read FSourceDirectoryReferenced;
|
||||||
property AutoReferenceSourceDir: boolean read FAutoReferenceSourceDir
|
property UnitName: string read FUnitName write FUnitName;
|
||||||
write SetAutoReferenceSourceDir;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1109,6 +1131,25 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function StrToComponentBaseClass(const s: string): TPFComponentBaseClass;
|
||||||
|
begin
|
||||||
|
for Result:=low(TPFComponentBaseClass) to high(TPFComponentBaseClass) do
|
||||||
|
if SysUtils.CompareText(PFComponentBaseClassNames[Result],s)=0 then exit;
|
||||||
|
Result:=pfcbcNone;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetComponentBaseClass(aClass: TClass): TPFComponentBaseClass;
|
||||||
|
begin
|
||||||
|
Result:=pfcbcNone;
|
||||||
|
if aClass=nil then exit;
|
||||||
|
if aClass.InheritsFrom(TForm) then
|
||||||
|
Result:=pfcbcForm
|
||||||
|
else if aClass.InheritsFrom(TFrame) then
|
||||||
|
Result:=pfcbcFrame
|
||||||
|
else if aClass.InheritsFrom(TDataModule) then
|
||||||
|
Result:=pfcbcDataModule;
|
||||||
|
end;
|
||||||
|
|
||||||
function CompareLazPackageID(Data1, Data2: Pointer): integer;
|
function CompareLazPackageID(Data1, Data2: Pointer): integer;
|
||||||
var
|
var
|
||||||
Pkg1: TLazPackageID;
|
Pkg1: TLazPackageID;
|
||||||
@ -1541,6 +1582,8 @@ begin
|
|||||||
if CompareText(fUnitName,CaseInsensitiveUnitName)<>0 then
|
if CompareText(fUnitName,CaseInsensitiveUnitName)<>0 then
|
||||||
fUnitName:=CaseInsensitiveUnitName;
|
fUnitName:=CaseInsensitiveUnitName;
|
||||||
end;
|
end;
|
||||||
|
FResourceBaseClass:=StrToComponentBaseClass(
|
||||||
|
XMLConfig.GetValue(Path+'ResourceBaseClass/Value',''));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPkgFile.SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
|
procedure TPkgFile.SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
|
||||||
@ -1557,6 +1600,9 @@ begin
|
|||||||
XMLConfig.SetDeleteValue(Path+'Type/Value',PkgFileTypeIdents[FileType],
|
XMLConfig.SetDeleteValue(Path+'Type/Value',PkgFileTypeIdents[FileType],
|
||||||
PkgFileTypeIdents[pftUnit]);
|
PkgFileTypeIdents[pftUnit]);
|
||||||
XMLConfig.SetDeleteValue(Path+'UnitName/Value',FUnitName,'');
|
XMLConfig.SetDeleteValue(Path+'UnitName/Value',FUnitName,'');
|
||||||
|
XMLConfig.SetDeleteValue(Path+'ResourceBaseClass/Value',
|
||||||
|
PFComponentBaseClassNames[FResourceBaseClass],
|
||||||
|
PFComponentBaseClassNames[pfcbcNone]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPkgFile.ConsistencyCheck;
|
procedure TPkgFile.ConsistencyCheck;
|
||||||
|
Loading…
Reference in New Issue
Block a user