Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Support IOTAModuleRegions for custom file extension.



Permlink Replies: 2 - Last Post: Aug 18, 2016 10:06 AM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
Alzbeta Slapkova

Posts: 20
Registered: 7/1/15
Support IOTAModuleRegions for custom file extension.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 2, 2016 10:22 PM
Hey guys.

I have written my custom IDE expert which adds new file extensions with syntax highlighting, Code Completion etc.

Now I want to support Code Folding.

 
var
  MS: IOTAModuleServices;
  SourceEditor: IOTASourceEditor;
  ElideAction: IOTAElideActions;
  ModuleRegions: IOTAModuleRegions;
  ModuleServices: IOTAModuleServices;
 
// parEditView is IOTAEditView
 
begin
    MS := BorlandIDEServices As IOTAModuleServices;
    SourceEditor := GetSourceEditor(MS.CurrentModule);
    ModuleServices := BorlandIDEServices as IOTAModuleServices;
 
    if Supports(parEditView, IOTAElideActions, ElideAction) then
    begin
        (parEditView as IOTAElideActions).EnableElisions; <<< This code is reached but does nothing
        //(parEditView as IOTAElideActions).EnableElisions;
        //parEditView.Paint;
    end;
 
   if Supports(MS.CurrentModule, IOTAModuleRegions, ModuleRegions) then
   begin
    ModuleRegions.GetRegions(MS.CurrentModule.CurrentEditor.FileName); <<< Never reached
   end;
 
   if Supports(parEditView, IOTAModuleRegions, ModuleRegions) then
   begin
    ModuleRegions.GetRegions(MS.CurrentModule.CurrentEditor.FileName); <<< Never reached
   end;
 


How can I force IDE to use Code Folding on my custom extension?

If you need more info about my expert it is here: http://rad-installer.com/downloads.html
Alzbeta Slapkova

Posts: 20
Registered: 7/1/15
Re: Support IOTAModuleRegions for custom file extension.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 18, 2016 3:26 AM   in response to: Alzbeta Slapkova in response to: Alzbeta Slapkova
Update:

If try to call QueryInterface with IOTAModuleRegions on .pas file it works fine:
var
  se: IOTASourceEditor;
 
  regs: TOTARegions;
  rg: IOTAModuleRegions;
 
begin
 
   se := ActiveSourceEditor;
   if(se.Module.QueryInterface(IOTAModuleRegions, rg) = S_OK) then
        regs := rg.GetRegions(); <<< Works for .pas but never reached for custom extension
 
...


ActiveSourceEditor is just function:
Function ActiveSourceEditor : IOTASourceEditor;
 
Var
  CM : IOTAModule;
 
Begin
  Result := Nil;
  If BorlandIDEServices = Nil Then
    Exit;
  CM := (BorlandIDEServices as IOTAModuleServices).CurrentModule;
  Result := SourceEditor(CM);
End;

But calling QueryInterface on module with my own extension (*.iss*) does not work.

So how do I tell the IDE to recognize my Module (my extension)?

I am creating my own Module (code from here: http://www.davidghoyle.co.uk/WordPress/?p=357) with IOTACreator and IOTAModuleCreator.

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Support IOTAModuleRegions for custom file extension.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 18, 2016 10:06 AM   in response to: Alzbeta Slapkova in response to: Alzbeta Slapkova
Alzbeta wrote:

If try to call QueryInterface with IOTAModuleRegions on .pas file
it works fine:
<snip>
But calling QueryInterface on module with my own extension (*.iss*)
does not work.

It should be obvious - your custom file extension is not using a module class
that implements IOTAModuleRegions, which is why QueryInterface() fails.

So how do I tell the IDE to recognize my Module (my extension)?

You will likely have to implement your own custom module class that implements
both IOTAModule and IOTAModuleRegions. But how you define and register custom
module classes, I don't know.

A similar question was recently asked on StackOverflow, maybe you can monitor
it for answers:

How to implement folding (regions) in RAD Studio IDE with Open Tools API?
http://stackoverflow.com/questions/38721585/

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02