vscode-fortran icon indicating copy to clipboard operation
vscode-fortran copied to clipboard

No Subroutine or Function symbols

Open daverous opened this issue 9 years ago • 4 comments

Subroutine or function symbols that would make it easy to access parts of a file with

ctrl+p @<functionName>

would be very useful. I would happily help in trying to add this - I just do not know where to start!

daverous avatar Sep 07 '16 15:09 daverous

Hi, I would be pleased to get some help 👍

You can create a fork, and start working in this fork, preferably in a branch specific for this feature.

Then, for the development of the feature itself, you can check this page https://code.visualstudio.com/docs/extensions/example-word-count that shows a simple extension. Otherwise you can ask me and I'll probably be able to help.

Cheers, Xavier

Gimly avatar Sep 07 '16 20:09 Gimly

Version 0.2.0 now has support for function code symbol. Could you please test and tell me if you're happy with that or if you'd like something changed.

Gimly avatar Oct 02 '17 20:10 Gimly

Hi, necropost but still an issue. First, thanks for putting together this package in the first place!

The "function" implementation is incorrect, because the fortran.tmlanguage code keys on the word "interface": think of "interface" as you would a function definition, rather than the declaration.

And it does not cover similar Fortran features "program", "subroutine", and "module".

I've bent my pick trying to get this to work: editing the .tmlanguage file I have been unable to get rid of those interface function definitions - they continue to appear in the breadcrumb list, and I've also been unable to get the keywords I've added (subroutine/program, etc.) to show up!

I'm attaching my work so far, it is incomplete because I can't seem to get any of it working. But I'd be happy to finish it if you can point me to the reason(s) why it's not affected anything :-) Note I had to change to text extension to upload it. fortran.tmLanguage.txt

EDIT: I'm also adding a sample .f90 file that has almost all the stuff we need to work with: linkedlist.f90.txt

cniggeler avatar Jun 06 '20 15:06 cniggeler

I've also added may different "symbols used as brackets" to modern.configuration.json. It's really just an enumeration of the various keywords that start/end blocks of code. The allows VS Code to do a couple interesting things:

  1. Use "Go to Bracket" to jump to the beginning or end of a function, subroutine, program, module, type, if, where select, do, interface, and "block data" block of code.

  2. Expand or shrink selection now includes those different block types during the expand or shrink.

Here is what the new "brackets" key looks like now:

	// symbols used as brackets
	"brackets": [
		["(", ")"],
		["program", "end program"],
		["function", "end function"],
		["subroutine", "end subroutine"],
	        ["module", "end module"],
		["interface", "end interface"],
		["if", "end if"],
		["where", "end where"],
		["block data", "end block data"],
		["type", "end type"],
		["select", "end select"],
		["do", "end do"]
	]

cniggeler avatar Jun 06 '20 17:06 cniggeler