[Lazarus] IDE package interface question

Darius Blaszyk dhkblaszyk at zeelandnet.nl
Mon Jan 31 22:38:54 CET 2011


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
    if Assigned(CodeBuf) then
      FreeAndNil(CodeBuf);

    //load the unit file
    CodeBuf := CodeToolBoss.LoadFile(AUnit, False, False);

    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;
         



More information about the Lazarus mailing list