Mattias Gaertner wrote:
On Sat, 05 Nov 2005 12:32:22 +0000
Colin Western <[EMAIL PROTECTED]> wrote:
Mattias Gaertner wrote:
On Sat, 05 Nov 2005 11:33:47 +0000
Colin Western <[EMAIL PROTECTED]> wrote:
To improve this I need the lfm files for the
super class form, but I am not sure how to get hold of them.
1. The IDE must find the uses clause in the unit.
2. Find all these units.
3. read the lfm files to find the right one.
if ambigious: warn programmer
4. do that recursively
check for cycle
The main problem is here: the IDE must be able to load forms, even if
there are errors in source. That's why parsing the unit should be
minimized. I will try to help you with these points.
Then you got the LFM files. Next step is to feed them into TReader.
Can't you just use the same logic for ctrl-clicking on a type name to
get the source file for the form? Or am I missing something?
Yes, some parts will be used.
But if we would use exactly the same functions, then the form will not load
on the slightest syntax error and this can abort loading the whole project.
Very unpleasant. The IDE should be fault tolerant and be able to work with
source under development.
Delphi does it similar.
Is the attached anything like right for forcing the ancestor form to
load? It works on the one form I tried...
Colin
diff -uNr lazarus/ide/main.pp /dos/fpc/lazarus.w/ide/main.pp
--- lazarus/ide/main.pp 2005-11-05 16:57:48.000000000 +0000
+++ /dos/fpc/lazarus.w/ide/main.pp 2005-11-05 18:22:19.000000000 +0000
@@ -824,7 +824,7 @@
implementation
uses
- Math;
+ CustomCodeTool, CodeAtom, Math;
var
SkipAutoLoadingLastProject: boolean;
@@ -4379,6 +4379,30 @@
ACaption, AText: String;
NewUnitName: String;
InheritedForm: Boolean;
+ function EnsureAncestorLoaded: TModalResult;
+ var
+ NewCode: TCodeBuffer;
+ NewX, NewY, NewTopLine: integer;
+ CodeTool: TCustomCodeTool;
+ Caret: TCodeXYPosition;
+ begin
+ Result := mrCancel;
+ CodeTool:=CodeToolBoss.FindCodeToolForSource(AnUnitInfo.Source);
+ if not CodeTool.CleanPosToCaret(CodeTool.CurPos.StartPos,Caret) then
+ Exit; // Fail
+ if CodeToolBoss.FindDeclaration(AnUnitInfo.Source,
+ Caret.X,Caret.Y,
+ NewCode,NewX,NewY,NewTopLine) then
+ begin
+ if NewCode<>AnUnitInfo.Source then
+ // Ancestor form in another file -> ensure file is open
+ Result:=DoOpenEditorFile(NewCode.Filename,-1,[ofOnlyIfExists,ofRegularFile])
+ else
+ Result := mrOK; // TODO: Keep looking
+ end else begin
+ DoJumpToCodeToolBossError;
+ end;
+ end;
begin
// check installed packages
debugln('TMainIDE.DoLoadLFM A ',AnUnitInfo.Filename,' ',dbgs(AnUnitInfo.IsPartOfProject),' ');
@@ -4423,6 +4447,9 @@
then begin
DebugLn('TMainIDE.DoLoadLFM Filename="',AnUnitInfo.Filename,'" NewClassName=',NewClassName,'. Unable to find ancestor class: ',CodeToolBoss.ErrorMessage);
end;
+ if InheritedForm and (CompareText(NewAncestorName,'TDataModule')<>0) and (CompareText(NewAncestorName,'TForm')<>0) then
+ ComponentLoadingOK := EnsureAncestorLoaded = mrOK;
+
AncestorType:=nil;
if NewAncestorName<>'' then begin
if CompareText(NewAncestorName,'TDataModule')=0 then begin