Pārlūkot izejas kodu

增加注释中的`TODO`、`FIXME`高亮

mxd 4 gadi atpakaļ
vecāks
revīzija
008d73a76a

+ 3 - 2
magic-editor/src/console/src/scripts/editor/dark-theme.js

@@ -18,8 +18,9 @@ export default {
             {token: 'string.invalid', foreground: '008000', background: 'FFCCCC'},
             {token: 'string.escape.invalid', foreground: '008000', background: 'FFCCCC'},
             {token: 'string.escape', foreground: '000080', fontStyle: 'bold'},
-            {token: 'comment', foreground: '808080'},
-            {token: 'comment.doc', foreground: '629755'},
+            {token: 'comment', foreground: '808080', fontStyle: 'italic'},
+            {token: 'comment.doc', foreground: '629755', fontStyle: 'italic'},
+            {token: 'comment.todo', foreground: 'A8C023', fontStyle: 'italic'},
             {token: 'string.escape', foreground: 'CC7832'}
         ],
         colors: {

+ 3 - 2
magic-editor/src/console/src/scripts/editor/default-theme.js

@@ -17,8 +17,9 @@ export default {
             {token: 'string.invalid', foreground: '008000', background: 'FFCCCC'},
             {token: 'string.escape.invalid', foreground: '008000', background: 'FFCCCC'},
             {token: 'string.escape', foreground: '000080', fontStyle: 'bold'},
-            {token: 'comment', foreground: '808080'},
-            {token: 'comment.doc', foreground: '808080'},
+            {token: 'comment', foreground: '808080', fontStyle: 'italic'},
+            {token: 'comment.doc', foreground: '808080', fontStyle: 'italic'},
+            {token: 'comment.todo', foreground: '008DDE', fontStyle: 'italic'},
             {token: 'string.escape', foreground: '000080'}
         ],
         colors: {

+ 11 - 14
magic-editor/src/console/src/scripts/editor/high-light.js

@@ -27,9 +27,8 @@ export const HighLightOptions = {
             [/::[a-zA-Z]+/, 'keywords'],
             [/[{}()[\]]/, '@brackets'],
             [/(@digits)[lLbBsSdDfFmM]?/, 'number'],
-            [/\/\*\*(?!\/)/, 'comment.doc', '@mulcomment'],
             [/\/\*/, 'comment', '@comment'],
-            [/\/\/.*$/, 'comment'],
+            [/\/\//, 'comment', '@commentTodo'],
             [
                 /\/(?=([^\\\/]|\\.)+\/([gimsuy]*)(\s*)(\.|;|,|\)|\]|\}|$))/,
                 {token: 'regexp', bracket: '@open', next: '@regexp'}
@@ -42,11 +41,16 @@ export const HighLightOptions = {
             [/'/, 'string', '@string_single'],
         ],
         comment: [
-            [/[^/*]+/, 'comment'],
-            // [/\/\*/, 'comment', '@push' ],    // nested comment not allowed :-(
-            // [/\/\*/,    'comment.invalid' ],    // this breaks block comments in the shape of /* //*/
-            [/\*\//, 'comment', '@pop'],
-            [/[/*]/, 'comment']
+            [/((TODO)|(todo)|(fixme)|(FIXME))[ \t]+[^\n(?!\*\/)]+/, 'comment.todo','@comment'],
+            [/[ \t]+/, 'comment','@comment'],
+            [/\*\//, 'comment', '@popall'],
+            [/[^ \t]+(?!((TODO)|(todo)|(fixme)|(FIXME)))/, 'comment','@comment']
+        ],
+        commentTodo: [
+            [/((TODO)|(todo)|(fixme)|(FIXME))[ \t]+[^\n]+/, 'comment.todo','@popall'],
+            [/^/,'', '@popall'],
+            [/[^ \t]+(?!((TODO)|(todo)|(fixme)|(FIXME)))/, 'comment', '@commentTodo']
+
         ],
         regexp: [
             [
@@ -90,13 +94,6 @@ export const HighLightOptions = {
                 }
             ]
         ],
-        mulcomment: [
-            [/[^/*]+/, 'comment.doc'],
-            // [/\/\*/, 'comment.doc', '@push' ],    // nested comment not allowed :-(
-            [/\/\*/, 'comment.doc.invalid'],
-            [/\*\//, 'comment.doc', '@pop'],
-            [/[/*]/, 'comment.doc']
-        ],
         string_multi_embedded: [
             [/[^"]+/, ''],
             ['"""', {token: 'string', next: '@pop', nextEmbedded: '@pop'}]