CTAGs and functions

Get help with the installation and running of the Zeus IDE. Please do not post bug reports or feature requests here. When in doubt post your question here.
Post Reply
dpbozarth
Posts: 5
Joined: Fri Oct 19, 2007 12:48 am

CTAGs and functions

Post by dpbozarth »

I'm evaluating Zeus so a brand new newbie. Search the forum and found a couple of articles of similar vein but didn't solve my problem so here goes...

How to get functions list populated for Fortran or a custom language (in this case Matlab)?

For Fortran, the regex expression of showed up automatically w/ the language extension so figure that was good. But, when add a .f90 file, the syntax coloration works so it's clear the file extension was recognized, but get nothing but "no functions found..." message. So what next?

Added a regex expression for the ".m" files for Matlab files as well as a few keywords and same story...

A question on design -- why is it necessary to add a file to a workspace for any of this to work? Seems like a pita design if simply want to look at or read a file (the sort of thing I seem to do quite a lot).

I also don't understand the deal about database and so on--seems internally all would be required is to have the regex expression and whatever command is tied to the engine to start off the search and return the results. I'm sure it would all make sense eventually, but as a newbie seems excessively complicated having just come from still using Brief (that unfortunately was killed dead by XP so I had been continuing to do code editing on the old NT platform)...

Anyway, I'm presuming there's something obvious I'm overlooking...
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

How to get functions list populated for Fortran or a custom language (in this case Matlab)?
The first thing to understand is Zeus has two types of function list.

The first type uses the function regular expression found in the document type.

This regular expression is then used to list and navigate between functions using the View Function List, Next Function, Previous Function menu items.

The second type of function list is the one displayed in the Classes and Functions panels of the Navigator dialog. This function list is nothing more that the function information produced by the ctags.exe tagging utility and is tied to the current workspace.

As to whether functions get displayed in these list is fully dependent on how well ctags does or does not support the language in question.
For Fortran, the regex expression of showed up automatically w/ the language extension so figure that was good. But, when add a .f90 file, the syntax coloration works so it's clear the file extension was recognized, but get nothing but "no functions found..." message. So what next?
The Fortran regexp defined in the Fortran document type is this: (function )|(program )|(subroutine )

What this regexp says is any line containing "function " or "program " or "subroutine " is considered a function.

So if you open a fortan .f90 file and the use the View Function List menu you should see a list of all lines that fit this description.

If this does not work, post a small piece of example code of what you consider to be a valid function.
Added a regex expression for the ".m" files for Matlab files as well as a few keywords and same story...
Since there is no Matlab document type , I would suggest first adding a new Matlab document type.

See my reply to this question for more details on how to do this: http://www.zeusedit.com/forum/viewtopic.php?t=1268

This topic may also help: http://www.zeusedit.com/forum/viewtopic.php?t=176
A question on design -- why is it necessary to add a file to a workspace for any of this to work?
You don't need to, but for the function to show up in the Classes and Functions panels of the Navigator dialog you do.

As I said before these list are nothing more that the function information produced by the ctags.exe and Zeus automatically runs the ctags.exe for all files in the workspace. But these list are not related to the function regexp Zeus feature.
I also don't understand the deal about database and so on--seems internally all would be required is to have the regex expression and whatever command is tied to the engine to start off the search and return the results.
This is exactly what the View Function List, Next Function, Previous Function menu items do ;)
I'm sure it would all make sense eventually
The secret to the Zeus configuration is the document type and you do need to spend a little time understanding how these work.

Other Zeus configuration options like workspaces and projects fit out side the document type and the use of these features is purely optional.
but as a newbie seems excessively complicated having just come from still using Brief
It might look complicated at first, but I can assure you there is some method to all the madness ;)

Cheers Jussi
dpbozarth
Posts: 5
Joined: Fri Oct 19, 2007 12:48 am

Post by dpbozarth »

OK. That there are two completely separate function lists surely wasn't clear from the help. The regexp works for both file types (I had previously added the Matlab file type--that part I was able to decipher).

I'd never used ctags and have no real interest in having to decipher what it might be or not be doing, but if it only understands C-like languages, seems like a poor choice for a general purpose editor. Although the previous discussion I found points to a link that says it claims that it understands Fortran (and Matlab is quite simple in that only has functions and their definition consists of the word function as the first word on a line so a simple Fortran finder ought to be able to figure them out as well).

But, if the above is true re: Fortran, still doesn't answer the question of how to get it to work inside Zeus or how to figure out anything at all about why it doesn't work. Seems like there ought to be some way to decipher what it does or doesn't see when requesting to use the internal ctags support.

But, why not use the output of View Function List command to populate the Navigator dialog? Replacing the file view of the file one is working on w/ the list of functions/subroutines is somewhat rude. :)

I'll keep plowing, maybe something will dawn...at least I found out one source of confusion.[/quote]
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

I'd never used ctags and have no real interest in having to decipher what it might be or not be doing, but if it only understands C-like languages, seems like a poor choice for a general purpose editor.

It's better than nothing ;)
Although the previous discussion I found points to a link that says it claims that it understands Fortran.

The Exuberant Ctags Languages Supported web page says it does support Fortran:

http://ctags.sourceforge.net/languages.html
But, if the above is true re: Fortran, still doesn't answer the question of how to get it to work inside Zeus

Get what to work, I'm not sure what is/is not working :?:

If you want the functions to appear in the navigator functions panel you will need to create a workspace and add you files to the workspace.

Zeus will then tag these files and put all the tag information into the class browser window.

Then based on the currently active window, Zeus will search the tags databse and display the function information for that file in the function panel of the navigator.

If no functions are list in the function panel then it can mean one of two things:

1) the file is not in the workspace as the message will indicate

2) there is no function information for that file in the tag database, which is what the message will also indicate.

If there is no information in the database it just means ctags.exe did not produce any function information or ctags and Zeus can not agree on waht is a function.
But, why not use the output of View Function List command to populate the Navigator dialog?

Because that function list is populated using the function information stored in the ctags database for the currently open workspace.
Replacing the file view of the file one is working on w/ the list of functions/subroutines is somewhat rude.
I'm not sure what you mean by that :?:

Cheers Jussi
dpbozarth
Posts: 5
Joined: Fri Oct 19, 2007 12:48 am

Post by dpbozarth »

It's better than nothing...

Only if you can figure out how to make it function... :)

OK, we're talking past each other here, but I figured out one problem but can't figure out the "how" of it so I'll ask how to solve it and then maybe the ctags problem will resolve itself...

I now realize the Fortran file isn't in the workspace and I can't seem to add any additional files after an initial group that created a temporary workspace (they were all ".m" files while I was working on the new language support templates). But, since Matlab can call functions written in C and/or Fortran, I then opened a Fortran file but can't see any way to get it to be recognized as belonging to the workspace. So, maybe if I can get past that hurdle, then maybe the ctags issue will resolve itself (hopefully).

I was just asking/suggesting that if there are two ways to generate the function list, that's fine but perhaps the other could also create the database or be used in the Navigator to be more convenient.

My "rude" :) comment was related to the surprise I got when I thought I was just building a database of functions just using the internal regex instead of ctags and the file I had been looking at was superseded by the function list window...it was simply a surprise as it didn't do what I was expecting (altho it is what it says)...

OBTW, when I used the Workspace Builder, the status message at the bottom read "Use the Create button..." but there was no button labeled Create. I don't recall what I eventually found that apparently worked, but the message wasn't helpful since it didn't correlate w/ the buttons available at the time...

Overall, seems good and I'm sure this is just a case of how to fit a not quite round peg into the hole combined w/ first time looking at it...

Thanks for the patience...

--duane
dpbozarth
Posts: 5
Joined: Fri Oct 19, 2007 12:48 am

Post by dpbozarth »

OK, I have _no_ clue as to the "why", but here's the "how" --

I removed the Fortran file I had tried to Add to the Project, closed the workspace, and then looked at the built Workspace z-file. Noticed that alll source paths were relative to the first directory, so made a copy of the Fortran file there, reopened the project and then tried the Add operation again. At that point, it recognized it as being in the Workspace. After that, as you surmised, ctags did find the functions/subroutines in the file. So, I then Delete'd the file from the Project and added back in the original in its original location. This time, the file was also recognized as being in the Workspace. What the difference was between this time and earlier, I have no clue.

One peculiarity I notice, however, is that when this file is Add'ed, in the Workspace tree view, this file is not included in the Source folder, but at the same level as the folder under the tree expansion control for the Source folder. Is this normal or indicative of a problem? In the display, this is identical to the previous time when the file wasn't recognized as being in the Workspace. Oh, and this positioning is the same regardless of which location the Fortran file actually resides.

Anyway, I'm at least farther along... :)

--dpb
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

As you have found out the Workspace file is nothing more than an XML text file containing a list of project and the project file is a list of folders and files.

All the paths in the project and workspace are stored relative to the workspace file. This is so that if the workspace and project files are moved to a different base directory location it will continue to work in Zeus ;)

But the Folders in the project are purely abstract. They don't have to map to any physical disk location.

As to where the files get placed in the project, this is also purely abstract. I could put a file one level down just under the project, inside a folder just under the project or in a folder under a folder that is just under thproject. The choice is yours ;)

You can control the placement by making sure you select the correct location from the workspace panel of the navigator dialog and then using the correct optionf rom the right mouse button menu popup.

Finally, if a file can not be found Zeus will indicate this with a red cross next to the file name. For example if you add a file to the workspace then rename that file, you will see this cross.

Cheers Jussi
dpbozarth
Posts: 5
Joined: Fri Oct 19, 2007 12:48 am

Post by dpbozarth »

you can control the placement by making sure you select the correct location from the workspace panel of the navigator dialog and then using the correct option from the right mouse button menu popup.

OK, I figured out how that works now.

My confusion had to do with the previous problem of adding a file to the workspace and it's still not clear to me the difference between the end result (if any) of the sequence steps of File--Open and File--Add to Active Project vis a vis the RMB Add Current File to Folder. As noted previously, in my initial experiment that started this whole conversation, I used the File Menu --Add to Active Project route and problems started because for some reason the new file wasn't interpreted as part of the Workspace and ctags was inoperable. At that point, whatever route I then took seemed to make no difference in making the file "visible" to whatever it is internally controlling that state. Only after I removed the problem file, closed the Workspace and reopened it did things began to work as you describe. Seems to be a "sneak path" somehow was what I was trying to report.

In my earlier posting I noted another anomaly -- I'll post it again simply for the information for future investigation...

When I used the Workspace Builder, the message at the bottom read "Use the Create button..." but there was no button labeled Create. I don't recall what I eventually found that apparently worked, but the message wasn't helpful since it didn't correlate w/ the buttons available at the time...

Again, thanks for the patience w/ a newbie struggling w/ what appears to have been a one-time aberration, probably caused by an unusual sequence of events owing to being totally unfamiliar w/ the product so doing many abnormal things in abnormal orders...

-duane
Post Reply