spgennard / vscode_cobol

Visual Studio Code Extension for COBOL, JCL and MF Directive Files
MIT License
36 stars 16 forks source link

FR: add code navigation / outline #3

Closed GitMensch closed 5 years ago

GitMensch commented 6 years ago

Not sure if there are other plugins for this that should be used, but asking cannot harm. What do you think about implementing something like OCIDE Navigation pane showing the code outline and providing the option to navigate via click?

spgennard commented 6 years ago

Yes, it is something I've been thinking about too.

I will have a look and see what I can do.

GitMensch commented 6 years ago

VSCode has an Outline View but says "There are no editors open that can provide outline information." I guess once this is in the options goto-definition/peek-definition will also work...

Just a note as this isn't referenced in the extension page already: the "better comments" extension works nicely together with this one.

IntelOrca commented 6 years ago

@GitMensch This information is provided by the provideDocumentDefinition API which I am currently working on. There is soon going to be a new API for providing symbol hierarchies as well.

spgennard commented 5 years ago

I've added the start of outline support, it currently shows various divisions, sections, copybooks, program-id, method-id, enum-id, valuetype-id.

note: it will be enhanced as time goes along, so comments/issues are always welcome.

GitMensch commented 5 years ago

Yes, I see (after extension upgrade) the outline. Well done.

Question: Should I open a new FR to add paragraphs to the outline?

Additional question: I'd like to include some preparser stuff as section and other as copybook - can we add things to the outline by configuration already?

Note: The copybooks are currently all-lower-case, which may be bad as those often are case-sensitive on disk. Also the current symbol (a wrench) seems a little bit strange. In general it likely is a good idea to use symbols identical to the C/C++ outline (sections as functions, paragraphs as jump-markers [currently not in the outline], copybooks as includes [also not in the outline yet]).

GitMensch commented 5 years ago

@spgennard ping... and thank you for your work again

spgennard commented 5 years ago

Yes, I see (after extension upgrade) the outline. Well done.

Question: Should I open a new FR to add paragraphs to the outline? It's on my TODO list, so it's up to you.

Additional question: I'd like to include some preparser stuff as section and other as copybook - can we add things to the outline by configuration already?

I've not come across an open-source parser/grammar that is dialect friendly, for example one that does the following grammar.. plus preprocessor support too:

So given this, I decided not to use any parser but to create something in between a tokenizer/lexer

Note: The copybooks are currently all-lower-case, which may be bad as those often are case-sensitive on disk. Also the current symbol (a wrench) seems a little bit strange. In general, it likely is a good idea to use symbols identical to the C/C++ outline (sections as functions, paragraphs as jump-markers [currently not in the outline], copybooks as includes [also not in the outline yet]).

The current symbol is the "file" symbol and for a copybook it seems reasonable to me because it is a file.

I will look at lowercasing bit.

GitMensch commented 5 years ago

I've not come across an open-source parser/grammar that is dialect friendly, for example one that does the following grammar.. plus preprocessor support too

Actually GnuCOBOL tries to provide this, but it is internal only. The only thing I know so far that does not work is the ACUCOBOL source-include/exclude by markers in column 73+ and the one that isn't claimed to be supported and only works partial the ACUCOBOL terminal mode. If you see more: please create a feature request on the GnuCOBOL project.

So given this, I decided not to use any parser but to create something in between a tokenizer/lexer

Reasonable approach. I guess it does handle conditional compilation via $IF and >>IF but not the ACUCOBOL conditionals (that can only be adjusted on command line), does it?

I've seen that you worked on paragraphs (is this finished already?).

Is there any option to integrate an own preparser without recompilation? It would be enough to be able to specify symbols that define a new section, symbols that should be recognized as statements and symbols that should be recognized as copybooks, obviously starting neither with COPY nor with INCLUDE, but in this case with *MACRO copybook in column 7, in fixed form....