Skip to content

Commit

Permalink
Improve Javadoc style comment scope for various applicable languages (s…
Browse files Browse the repository at this point in the history
…ublimehq#1997)

* Improve Javadoc style comment scope for various applicable languages

Give "punctuation.definition" scope to leading asterisks in body of a
Javadoc style comment block.

Applied to ActionScript, C, C#, CSS, Go, Graphviz, PHP, SQL, Scala
  • Loading branch information
DavidW1024 authored and wbond committed Oct 16, 2019
1 parent 48d3ec0 commit 561df1c
Show file tree
Hide file tree
Showing 18 changed files with 75 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ActionScript/ActionScript.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ contexts:
captures:
0: punctuation.definition.comment.actionscript.2
pop: true
- match: ^\s*(\*)(?!/)
captures:
1: punctuation.definition.comment.actionscript.2
- match: (//).*$\n?
scope: comment.line.double-slash.actionscript.2
captures:
Expand Down
5 changes: 5 additions & 0 deletions ActionScript/syntax_test_as.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* SYNTAX TEST "Packages/ActionScript/ActionScript.sublime-syntax" */

/**
*
/* ^ comment.block.actionscript.2 punctuation.definition.comment.actionscript.2 */
3 changes: 3 additions & 0 deletions C#/C#.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ contexts:
- match: '\*/'
scope: punctuation.definition.comment.end.cs
pop: true
- match: ^\s*(\*)(?!/)
captures:
1: punctuation.definition.comment.cs
- include: comments_in

comments_in:
Expand Down
4 changes: 4 additions & 0 deletions C#/tests/syntax_test_Comments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ namespace HelloWorld
//* ^ punctuation.separator.argument.value
//* ^ punctuation.definition.tag.end
//* ^^^^^^^^^ text.documentation
/**
*
//* ^ meta.namespace.cs meta.block.cs comment.block.cs punctuation.definition.comment.cs
*/
class Hello
{
/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions C++/C.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ contexts:
- match: \*/
scope: punctuation.definition.comment.c
pop: true
- match: ^\s*(\*)(?!/)
captures:
1: punctuation.definition.comment.c
- match: \*/(?!\*)
scope: invalid.illegal.stray-comment-end.c
- match: ^// =(\s*.*?)\s*=\s*$\n?
Expand Down
4 changes: 4 additions & 0 deletions C++/syntax_test_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ struct X
/* <- storage.type */
};

/**
*
/* ^ comment.block.c punctuation.definition.comment.c */

/////////////////////////////////////////////
// Preprocessor branches starting blocks
/////////////////////////////////////////////
Expand Down
3 changes: 3 additions & 0 deletions CSS/CSS.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ contexts:
- match: \*/
scope: punctuation.definition.comment.css
pop: true
- match: ^\s*(\*)(?!/)
captures:
1: punctuation.definition.comment.css

at-charset:
- match: \s*((@)charset\b)\s*
Expand Down
4 changes: 4 additions & 0 deletions CSS/syntax_test_css.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.css */
/* ^^ punctuation.definition.comment.css */

/**
*
/* ^ comment.block.css punctuation.definition.comment.css */

.test-strings {
content: "double";
/* ^^^^^^^^ string.quoted.double.css */
Expand Down
3 changes: 3 additions & 0 deletions Go/Go.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ contexts:
- match: \*/
scope: punctuation.definition.comment.end.go
pop: true
- match: ^\s*(\*)(?!/)
captures:
1: punctuation.definition.comment.go

pop-line-comment:
- meta_scope: comment.line.go
Expand Down
5 changes: 5 additions & 0 deletions Go/syntax_test_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ You may have to disable Go-specific linters when working on this file.
// ^^^^^^^ comment.block.go
// ^ -comment

/**
*
// ^ comment.block.go punctuation.definition.comment.go
*/

//go
// ^ -comment -punctuation
// ^^ punctuation.definition.comment.go
Expand Down
3 changes: 3 additions & 0 deletions Graphviz/DOT.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,6 @@ contexts:
- match: \*/
scope: punctuation.definition.comment.dot
pop: true
- match: ^\s*(\*)(?!/)
captures:
1: punctuation.definition.comment.dot
8 changes: 8 additions & 0 deletions Graphviz/syntax_test_dot.dot
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
// ^^^^^^^^^^ comment.block.dot
// ^^ punctuation.definition.comment.dot

/**
// <- punctuation.definition.comment.dot
//^^ comment.block.dot
* Me as well!
// ^ punctuation.definition.comment.dot
*/
// <- punctuation.definition.comment.dot

# Me also!
// <- punctuation.definition.comment.dot
// ^^^^^^^ comment.line.number-sign.dot
Expand Down
12 changes: 8 additions & 4 deletions PHP/PHP Source.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -1196,11 +1196,15 @@ contexts:
- match: \*/
scope: punctuation.definition.comment.end.php
pop: true
- match: ^\s*\*\s*(@access)\s+((var|public|private|protected)|(.+))\s*$
- match: ^\s*(\*)\s*(@access)\s+((var|public|private|protected)|(.+))\s*$
captures:
1: keyword.other.phpdoc.php
3: storage.modifier.php
4: invalid.illegal.wrong-access-type.phpdoc.php
1: punctuation.definition.comment.php
2: keyword.other.phpdoc.php
4: storage.modifier.php
5: invalid.illegal.wrong-access-type.phpdoc.php
- match: ^\s*(\*)(?!/)
captures:
1: punctuation.definition.comment.php
- match: "((https?|s?ftp|ftps|file|smb|afp|nfs|(x-)?man|gopher|txmt)://|mailto:)[-:@a-zA-Z0-9_.~%+/?=&#]*[-@a-zA-Z0-9_~%+/=&#]"
scope: markup.underline.link.php
- match: (@xlink)\s+(.+)\s*$
Expand Down
5 changes: 5 additions & 0 deletions PHP/syntax_test_php.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ function foo(?stinrg ...$args) {}
*/
// ^ source - comment.block

/**
*
// ^ text.html.basic meta.embedded.block.php source.php comment.block.documentation.phpdoc.php punctuation.definition.comment.php
*/

/** @var Properties: class properties. */
// ^ keyword.other.phpdoc

Expand Down
3 changes: 3 additions & 0 deletions SQL/SQL.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ contexts:
- meta_scope: comment.block.c
- match: \*/
pop: true
- match: ^\s*(\*)(?!/)
captures:
1: punctuation.definition.comment.sql
regexps:
- match: /(?=\S.*/)
captures:
Expand Down
6 changes: 6 additions & 0 deletions SQL/syntax_test_sql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ This is a
multiline comment
-- ^ source.sql comment.block.c
*/

/**
*
-- ^ punctuation.definition.comment.sql
*/

select


Expand Down
3 changes: 3 additions & 0 deletions Scala/Scala.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ contexts:
- match: \*/
scope: punctuation.definition.comment.scala
pop: true
- match: ^\s*(\*)(?!/)
captures:
1: punctuation.definition.comment.scala
- match: (@\w+\s)
scope: keyword.other.documentation.scaladoc.scala
- match: '\{@link\s+[^\}]*\}'
Expand Down
2 changes: 2 additions & 0 deletions Scala/syntax_test_scala.scala
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ type Foo = Bar[A] forSome { type A }

/**
// <- comment.block.documentation.scala
*
// ^ punctuation.definition.comment.scala
*/

/**/0xff
Expand Down

0 comments on commit 561df1c

Please sign in to comment.