Skip to content

Commit 920ea64

Browse files
committed
Comments are correctly highlighted for type,...
Fixes Erroneous syntax highlighting with type,abstract :: var #262 A unittest has been added and the CHANGELOG has been updated.
1 parent 5a6039d commit 920ea64

File tree

4 files changed

+382
-1
lines changed

4 files changed

+382
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3131
([#205](https://github.com/krvajal/vscode-fortran-support/issues/205))
3232
- Fixes labelled `stop` conditions
3333
([#172](https://github.com/krvajal/vscode-fortran-support/issues/172))
34+
- Fixes incorrect comment capture for type, abstract|extends types
35+
([#262](https://github.com/krvajal/vscode-fortran-support/issues/262))
3436

3537
### Added
3638

syntaxes/fortran_free-form.tmLanguage.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2385,6 +2385,9 @@
23852385
{
23862386
"include": "#dummy-variable-list"
23872387
},
2388+
{
2389+
"include": "#comments"
2390+
},
23882391
{
23892392
"comment": "Derived type specification block.",
23902393
"name": "meta.block.specification.derived-type.fortran",
@@ -4460,7 +4463,7 @@
44604463
"name": "punctuation.parentheses.left.fortran"
44614464
},
44624465
"3": {
4463-
"name": "entity.name.module.fortran"
4466+
"name": "entity.name.class.submodule.fortran"
44644467
}
44654468
},
44664469
"end": "(\\))",

test/resources/abstraction.f90

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
! This is an example demonstrating abstraction and the benefit of using
2+
! submodules. However for convenience of testing all files have been merged to 1
3+
4+
! base.f90
5+
module BaseClass
6+
7+
implicit none
8+
9+
type, abstract :: Base ! <-- the base class with subroutine "sub"
10+
contains
11+
procedure(sub_interface), nopass, deferred :: sub
12+
end type
13+
14+
interface
15+
subroutine sub_interface(i) ! <-- the interface is defined here
16+
implicit none
17+
integer, intent(in) :: i
18+
end subroutine sub_interface
19+
end interface
20+
21+
end module BaseClass
22+
23+
! child.f90
24+
module ChildClass
25+
26+
use BaseClass
27+
implicit none
28+
29+
type, extends(Base) :: Child ! <-- we extend the Base Class
30+
contains
31+
procedure, nopass :: sub
32+
end type
33+
34+
interface
35+
module subroutine sub(i) ! <-- the interface for the submodule (unfortunately we have to declare the entire thing again)
36+
implicit none
37+
integer, intent(in) :: i
38+
end subroutine sub
39+
end interface
40+
41+
end module ChildClass
42+
43+
! sub.f90
44+
submodule (ChildClass) ChildSub
45+
46+
contains
47+
48+
module procedure sub ! <-- we finally get to define the subroutine
49+
print*, "The answer is :", i
50+
end procedure
51+
52+
end submodule
53+
54+
! main.f90
55+
program test
56+
57+
use ChildClass
58+
59+
implicit none
60+
61+
type(Child) :: c
62+
integer :: i
63+
64+
do i=1, 10
65+
call c%sub(i)
66+
end do
67+
68+
end program test

0 commit comments

Comments
 (0)