[Lazarus] IDE package interface question
Mattias Gaertner
nc-gaertnma at netcologne.de
Mon Jan 31 23:35:11 CET 2011
On Mon, 31 Jan 2011 22:38:54 +0100
Darius Blaszyk <dhkblaszyk at zeelandnet.nl> wrote:
>
> Martin / Mattias,
>
> Thanks for the help. I finally used RegisterChangeEvent and it works fine. Unfortunately I have a another problem now. After modifying the caret position the event is fired and from the caret position I need to resolve the method name. I have looked at how this is done ./examples/idequickfix, but unfortunately whatever I try ProcNode keeps returning nil. The snippet below is from the above mentioned example but slightly modified. To view the code in context see here: http://svn.freepascal.org/cgi-bin/viewvc.cgi/fpprofiler/trunk/lazprof/lazprofview.pas?view=markup&revision=2525&root=fpcprojects. Can someone help me here please?
>
> Thanks in advance,
>
> Darius
>
>
> AUnit := SourceEditorManagerIntf.ActiveSourceWindow.ActiveEditor.FileName;
> DebugLn('TLazProfileViewer.ShowCodeInfo - 1');
>
> if AUnit <> CachedUnit then
> begin
Maybe the above if is the cause. Remove it.
> if Assigned(CodeBuf) then
> FreeAndNil(CodeBuf);
Do not free what you have not created. This will crash the IDE.
> //load the unit file
> CodeBuf := CodeToolBoss.LoadFile(AUnit, False, False);
if CodeBuf=nil then exit;
> DebugLn('TLazProfileViewer.ShowCodeInfo - 2');
>
> // parse the code
> if not ParseCode(CodeBuf, CodeTool) then
> exit;
>
> DebugLn('TLazProfileViewer.ShowCodeInfo - 3');
> end;
>
> Pos := SourceEditorManagerIntf.ActiveSourceWindow.ActiveEditor.CursorTextXY;
>
> DebugLn('TLazProfileViewer.ShowCodeInfo - 4');
>
> //find the source position
> if not CaretToSourcePosition(CodeTool, CodeBuf, Pos.x, Pos.y, CleanPos) then
> exit;
>
> DebugLn('TLazProfileViewer.ShowCodeInfo - 5');
>
> // find procedure node
> ProcNode := CodeTool.FindDeepestNodeAtPos(CleanPos, False);
> if ProcNode <> nil then
> ProcNode := ProcNode.GetNodeOfType(ctnProcedure);
>
> DebugLn('TLazProfileViewer.ShowCodeInfo - 6');
>
> //nothing found so exit
> if ProcNode = nil then
> exit;
Mattias
More information about the Lazarus
mailing list