Unwrapping IMPORT aliasses

Unwrapping IMPORT aliasses

Postby Robert » Fri Oct 21, 2016 8:19 am

The Menu Commands "Source", "Interface", & "Documentation" unwrap item aliases, which is a very useful feature.

The Menu Command "Info->Global Variables" does not, which is both inconsistent and unhelpful.

I guess it should be easy to implement this feature by copying the procedure "CheckModName" from DevReferences, or DevBrowser, to DevDebug. (Maybe it would be better not to have three copies of the same procedure?)
User avatar
Robert
 
Posts: 108
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: Unwrapping IMPORT aliasses

Postby Robert » Fri Oct 21, 2016 2:37 pm

Below are the additions I tried in Module DevDebug. It seems to work fine, but the different values of the CONSTant "module" was a bit of a trap!
"CheckModName" is new (actually copied from elsewhere). "GetMod" has one new line.
Code: Select all
   PROCEDURE CheckModName (VAR mod: TextMappers.String; t: TextModels.Model);
      CONST module = 101;      (*  Overrides global definition !! *)
      VAR s: TextMappers.Scanner;
   BEGIN
      s.ConnectTo(t); s.SetPos(0); Scan(s);
      IF s.type = module THEN
         Scan(s);
         WHILE (s.type # TextMappers.eot) & (s.type # import) DO Scan(s) END;
         WHILE (s.type # TextMappers.eot) & (s.type # semicolon)
               & ((s.type # TextMappers.string) OR (s.string # mod)) DO Scan(s) END;
         IF s.type = TextMappers.string THEN
            Scan(s);
            IF s.type = becomes THEN
               Scan(s);
               IF s.type = TextMappers.string THEN
                  mod := s.string$
               END
            END
         END
      END
   END CheckModName;

   PROCEDURE GetMod (VAR mod: Kernel.Module);
      VAR c: TextControllers.Controller; s: TextMappers.Scanner; beg, end: INTEGER; res: INTEGER; n: Kernel.Utf8Name;
   BEGIN
      mod := NIL;
      c := TextControllers.Focus();
      IF (c # NIL) & c.HasSelection() THEN
         c.GetSelection(beg, end);
         s.ConnectTo(c.text); s.SetPos(beg); s.Scan;
         IF s.type = TextMappers.string THEN
CheckModName(s.string, c.text);
            Strings.StringToUtf8(s.string, n, res); mod := Kernel.ThisMod(n$);
            IF mod = NIL THEN
               Dialog.ShowParamMsg("#Dev:ModuleNotFound", s.string, "", "");
            END            
         ELSE Dialog.ShowMsg("#Dev:NoModuleNameSelected")
         END
      ELSE Dialog.ShowMsg("#Dev:NoSelectionFound")
      END
   END GetMod;
User avatar
Robert
 
Posts: 108
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: Unwrapping IMPORT aliasses

Postby Josef Templ » Fri Oct 21, 2016 3:44 pm

I think this is an improvement.
If the code can be reused it would even be a simplification.

Is there any lower level module where the common code could be put for reuse?

- Josef
Josef Templ
 
Posts: 195
Joined: Tue Sep 17, 2013 6:50 am

Re: Unwrapping IMPORT aliasses

Postby Robert » Fri Oct 21, 2016 5:12 pm

Josef Templ wrote:Is there any lower level module where the common code could be put for reuse?

The obvious question ... I haven't had any time to investigate!

Actually I would like it to be exported (and documented!), as it would be useful in some of my private tools.
User avatar
Robert
 
Posts: 108
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: Unwrapping IMPORT aliasses

Postby Robert » Sun Oct 23, 2016 11:07 am

The only obvious place to put the common code (without a new Module) is in TextMappers.

One would also want to move the duplicated copies of the procedure "Scan". The copies of Scan in DevReferences & DevBrowser are identical; the copy in DevDebug is different (bigger). One could easily make a dual purpose version (with an input BOOLEAN to configure it).

I'm not sure what the best thing to suggest is.


On second thoughts, maybe it is best to export these two procedres from DevReferences, and have DevBrowser & DevDebug import DevReferences?
User avatar
Robert
 
Posts: 108
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: Unwrapping IMPORT aliasses

Postby Josef Templ » Tue Oct 25, 2016 3:06 pm

Shouldn't this also be applied to DevDependencies?
Even if it is a pretty useless tool, for the sake of completeness
it should be considered, I think.

DevReferences looks like a good place to export from.

- Josef
Josef Templ
 
Posts: 195
Joined: Tue Sep 17, 2013 6:50 am

Re: Unwrapping IMPORT aliasses

Postby Ivan Denisov » Thu Mar 30, 2017 2:56 am

User avatar
Ivan Denisov
 
Posts: 227
Joined: Tue Sep 17, 2013 12:21 am
Location: Krasnoyarsk, Russia


Return to Feature

Who is online

Users browsing this forum: No registered users and 1 guest

cron