@@ -1360,19 +1360,19 @@ var JavaScriptHighlightRules = function() {
13601360 token : "comment" ,
13611361 regex : / \/ \/ .* $ /
13621362 } ,
1363- new DocCommentHighlightRules ( ) . getStartRule ( "doc-start" ) ,
1363+ DocCommentHighlightRules . getStartRule ( "doc-start" ) ,
13641364 {
13651365 token : "comment" , // multi line comment
13661366 merge : true ,
13671367 regex : / \/ \* / ,
13681368 next : "comment"
13691369 } , {
13701370 token : "string" ,
1371- regex : "'" ,
1371+ regex : "'(?=.) " ,
13721372 next : "qstring"
13731373 } , {
13741374 token : "string" ,
1375- regex : '"' ,
1375+ regex : '"(?=.) ' ,
13761376 next : "qqstring"
13771377 } , {
13781378 token : "constant.numeric" , // hex
@@ -1392,11 +1392,10 @@ var JavaScriptHighlightRules = function() {
13921392 "text" ,
13931393 "storage.type" ,
13941394 "text" ,
1395- "paren.lparen" ,
1396- "variable.parameter" ,
1397- "paren.rparen"
1395+ "paren.lparen"
13981396 ] ,
1399- regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe + ")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
1397+ regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe + ")(\\s*)(=)(\\s*)(function)(\\s*)(\\()" ,
1398+ next : "function_arguments"
14001399 } , { // match stuff like: Sound.prototype.play = myfunc
14011400 token : [
14021401 "storage.type" ,
@@ -1408,7 +1407,8 @@ var JavaScriptHighlightRules = function() {
14081407 "keyword.operator" ,
14091408 "text"
14101409 ] ,
1411- regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe + ")(\\s*)(=)(\\s*)"
1410+ regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe + ")(\\s*)(=)(\\s*)" ,
1411+ next : "function_arguments"
14121412 } , { // match stuff like: Sound.play = function() { }
14131413 token : [
14141414 "storage.type" ,
@@ -1419,11 +1419,10 @@ var JavaScriptHighlightRules = function() {
14191419 "text" ,
14201420 "storage.type" ,
14211421 "text" ,
1422- "paren.lparen" ,
1423- "variable.parameter" ,
1424- "paren.rparen"
1422+ "paren.lparen"
14251423 ] ,
1426- regex : "(" + identifierRe + ")(\\.)(" + identifierRe + ")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
1424+ regex : "(" + identifierRe + ")(\\.)(" + identifierRe + ")(\\s*)(=)(\\s*)(function)(\\s*)(\\()" ,
1425+ next : "function_arguments"
14271426 } , { // match stuff like: play = function() { }
14281427 token : [
14291428 "entity.name.function" ,
@@ -1432,22 +1431,20 @@ var JavaScriptHighlightRules = function() {
14321431 "text" ,
14331432 "storage.type" ,
14341433 "text" ,
1435- "paren.lparen" ,
1436- "variable.parameter" ,
1437- "paren.rparen"
1434+ "paren.lparen"
14381435 ] ,
1439- regex : "(" + identifierRe + ")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
1436+ regex : "(" + identifierRe + ")(\\s*)(=)(\\s*)(function)(\\s*)(\\()" ,
1437+ next : "function_arguments"
14401438 } , { // match regular function like: function myFunc(arg) { }
14411439 token : [
14421440 "storage.type" ,
14431441 "text" ,
14441442 "entity.name.function" ,
14451443 "text" ,
1446- "paren.lparen" ,
1447- "variable.parameter" ,
1448- "paren.rparen"
1444+ "paren.lparen"
14491445 ] ,
1450- regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
1446+ regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()" ,
1447+ next : "function_arguments"
14511448 } , { // match stuff like: foobar: function() { }
14521449 token : [
14531450 "entity.name.function" ,
@@ -1456,22 +1453,20 @@ var JavaScriptHighlightRules = function() {
14561453 "text" ,
14571454 "storage.type" ,
14581455 "text" ,
1459- "paren.lparen" ,
1460- "variable.parameter" ,
1461- "paren.rparen"
1456+ "paren.lparen"
14621457 ] ,
1463- regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
1458+ regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()" ,
1459+ next : "function_arguments"
14641460 } , { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
14651461 token : [
14661462 "text" ,
14671463 "text" ,
14681464 "storage.type" ,
14691465 "text" ,
1470- "paren.lparen" ,
1471- "variable.parameter" ,
1472- "paren.rparen"
1466+ "paren.lparen"
14731467 ] ,
1474- regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
1468+ regex : "(:)(\\s*)(function)(\\s*)(\\()" ,
1469+ next : "function_arguments"
14751470 } , {
14761471 token : "constant.language.boolean" ,
14771472 regex : / (?: t r u e | f a l s e ) \b /
@@ -1541,6 +1536,7 @@ var JavaScriptHighlightRules = function() {
15411536 // regular expressions are only allowed after certain tokens. This
15421537 // makes sure we don't mix up regexps with the divison operator
15431538 "regex_allowed" : [
1539+ DocCommentHighlightRules . getStartRule ( "doc-start" ) ,
15441540 {
15451541 token : "comment" , // multi line comment
15461542 merge : true ,
@@ -1568,18 +1564,16 @@ var JavaScriptHighlightRules = function() {
15681564 "regex" : [
15691565 {
15701566 token : "regexp.keyword.operator" ,
1571- regex : "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" ,
1572- next : "regex"
1567+ regex : "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
15731568 } , {
1574- // flag
1569+ // flag
15751570 token : "string.regexp" ,
15761571 regex : "/\\w*" ,
15771572 next : "start" ,
15781573 merge : true
15791574 } , {
15801575 token : "string.regexp" ,
15811576 regex : "[^\\\\/\\[]+" ,
1582- next : "regex" ,
15831577 merge : true
15841578 } , {
15851579 token : "string.regexp.charachterclass" ,
@@ -1595,8 +1589,7 @@ var JavaScriptHighlightRules = function() {
15951589 "regex_character_class" : [
15961590 {
15971591 token : "regexp.keyword.operator" ,
1598- regex : "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" ,
1599- next : "regex_character_class"
1592+ regex : "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
16001593 } , {
16011594 token : "string.regexp.charachterclass" ,
16021595 regex : "]" ,
@@ -1605,7 +1598,24 @@ var JavaScriptHighlightRules = function() {
16051598 } , {
16061599 token : "string.regexp.charachterclass" ,
16071600 regex : "[^\\\\\\]]+" ,
1608- next : "regex_character_class" ,
1601+ merge : true
1602+ } , {
1603+ token : "empty" ,
1604+ regex : "" ,
1605+ next : "start"
1606+ }
1607+ ] ,
1608+ "function_arguments" : [
1609+ {
1610+ token : "variable.parameter" ,
1611+ regex : identifierRe ,
1612+ } , {
1613+ token : "punctuation.operator" ,
1614+ regex : "[, ]+" ,
1615+ merge : true
1616+ } , {
1617+ token : "punctuation.operator" ,
1618+ regex : "$" ,
16091619 merge : true
16101620 } , {
16111621 token : "empty" ,
@@ -1643,11 +1653,18 @@ var JavaScriptHighlightRules = function() {
16431653 regex : escapedRe
16441654 } , {
16451655 token : "string" ,
1646- regex : '[^"\\\\]+'
1656+ regex : '[^"\\\\]+' ,
1657+ merge : true
1658+ } , {
1659+ token : "string" ,
1660+ regex : "\\\\$" ,
1661+ next : "qqstring" ,
1662+ merge : true
16471663 } , {
16481664 token : "string" ,
1649- regex : '"' ,
1650- next : "start"
1665+ regex : '"|$' ,
1666+ next : "start" ,
1667+ merge : true
16511668 }
16521669 ] ,
16531670 "qstring" : [
@@ -1656,17 +1673,24 @@ var JavaScriptHighlightRules = function() {
16561673 regex : escapedRe
16571674 } , {
16581675 token : "string" ,
1659- regex : "[^'\\\\]+"
1676+ regex : "[^'\\\\]+" ,
1677+ merge : true
16601678 } , {
16611679 token : "string" ,
1662- regex : "'" ,
1663- next : "start"
1680+ regex : "\\\\$" ,
1681+ next : "qstring" ,
1682+ merge : true
1683+ } , {
1684+ token : "string" ,
1685+ regex : "'|$" ,
1686+ next : "start" ,
1687+ merge : true
16641688 }
16651689 ]
16661690 } ;
16671691
16681692 this . embedRules ( DocCommentHighlightRules , "doc-" ,
1669- [ new DocCommentHighlightRules ( ) . getEndRule ( "start" ) ] ) ;
1693+ [ DocCommentHighlightRules . getEndRule ( "start" ) ] ) ;
16701694} ;
16711695
16721696oop . inherits ( JavaScriptHighlightRules , TextHighlightRules ) ;
@@ -1744,27 +1768,24 @@ var DocCommentHighlightRules = function() {
17441768
17451769oop . inherits ( DocCommentHighlightRules , TextHighlightRules ) ;
17461770
1747- ( function ( ) {
1748-
1749- this . getStartRule = function ( start ) {
1750- return {
1751- token : "comment.doc" , // doc comment
1752- merge : true ,
1753- regex : "\\/\\*(?=\\*)" ,
1754- next : start
1755- } ;
1771+ DocCommentHighlightRules . getStartRule = function ( start ) {
1772+ return {
1773+ token : "comment.doc" , // doc comment
1774+ merge : true ,
1775+ regex : "\\/\\*(?=\\*)" ,
1776+ next : start
17561777 } ;
1757-
1758- this . getEndRule = function ( start ) {
1759- return {
1760- token : "comment.doc" , // closing comment
1761- merge : true ,
1762- regex : "\\*\\/" ,
1763- next : start
1764- } ;
1778+ } ;
1779+
1780+ DocCommentHighlightRules . getEndRule = function ( start ) {
1781+ return {
1782+ token : "comment.doc" , // closing comment
1783+ merge : true ,
1784+ regex : "\\*\\/" ,
1785+ next : start
17651786 } ;
1787+ } ;
17661788
1767- } ) . call ( DocCommentHighlightRules . prototype ) ;
17681789
17691790exports . DocCommentHighlightRules = DocCommentHighlightRules ;
17701791
0 commit comments