Skip to content

Commit

Permalink
Fix conditionals followed by comments, closes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Gama11 committed Jan 31, 2017
1 parent 61b55f1 commit 440324a
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,3 +1,4 @@
/node_modules
/generated
/bin
/bin
*.log
14 changes: 8 additions & 6 deletions baselines/ConditionalCompilation.hx.baseline.txt
Expand Up @@ -36,31 +36,31 @@ class Foo {
-----------------------------------

>#if flash8
^^^^^^^^^^^
^^^^^^^^^^
source.hx punctuation.definition.tag
>// Haxe code specific for flash player 8
^^
source.hx comment.line.double-slash.hx punctuation.definition.comment.hx
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
source.hx comment.line.double-slash.hx
>#elseif flash
^^^^^^^^^^^^^^
^^^^^^^^^^^^^
source.hx punctuation.definition.tag
>// Haxe code specific for flash platform (any version)
^^
source.hx comment.line.double-slash.hx punctuation.definition.comment.hx
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
source.hx comment.line.double-slash.hx
>#elseif js
^^^^^^^^^^^
^^^^^^^^^^
source.hx punctuation.definition.tag
>// Haxe code specific for javascript plaform
^^
source.hx comment.line.double-slash.hx punctuation.definition.comment.hx
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
source.hx comment.line.double-slash.hx
>#elseif neko
^^^^^^^^^^^^^
^^^^^^^^^^^^
source.hx punctuation.definition.tag
>// Haxe code specific for neko plaform
^^
Expand Down Expand Up @@ -237,7 +237,7 @@ class Foo {
> #if foo
^^^^^^^^
source.hx meta.class.hx meta.block.hx meta.method.hx meta.method.block.hx
^^^^^^^^
^^^^^^^
source.hx meta.class.hx meta.block.hx meta.method.hx meta.method.block.hx punctuation.definition.tag
> #if !!(flash || js)
^^^^^^^^^^^^
Expand Down Expand Up @@ -370,8 +370,10 @@ class Foo {
source.hx meta.class.hx meta.block.hx meta.method.hx meta.method.block.hx constant.language.hx
^
source.hx meta.class.hx meta.block.hx meta.method.hx meta.method.block.hx
^^^^^^^^^^^^^^
^^^^^^^^^^^^^
source.hx meta.class.hx meta.block.hx meta.method.hx meta.method.block.hx punctuation.definition.tag
^
source.hx meta.class.hx meta.block.hx meta.method.hx meta.method.block.hx
^^^^^^
source.hx meta.class.hx meta.block.hx meta.method.hx meta.method.block.hx keyword.control.flow-control.hx
^
Expand Down
62 changes: 62 additions & 0 deletions baselines/Issue1.hx.baseline.txt
@@ -0,0 +1,62 @@
original file
-----------------------------------
#if foo/*test*/#end
#if foo//test
#end

#if (foo)/*test*/#end
#if (foo)//
#end
-----------------------------------

>#if foo/*test*/#end
^^^^^^^
source.hx punctuation.definition.tag
^^
source.hx comment.block.hx punctuation.definition.comment.hx
^^^^
source.hx comment.block.hx
^^
source.hx comment.block.hx punctuation.definition.comment.hx
^^^^
source.hx punctuation.definition.tag
>#if foo//test
^^^^^^^
source.hx punctuation.definition.tag
^^
source.hx comment.line.double-slash.hx punctuation.definition.comment.hx
^^^^^
source.hx comment.line.double-slash.hx
>#end
^^^^
source.hx punctuation.definition.tag
>
^
source.hx
>#if (foo)/*test*/#end
^^^^^
source.hx punctuation.definition.tag punctuation.definition.tag
^^^
source.hx punctuation.definition.tag
^
source.hx punctuation.definition.tag
^^
source.hx comment.block.hx punctuation.definition.comment.hx
^^^^
source.hx comment.block.hx
^^
source.hx comment.block.hx punctuation.definition.comment.hx
^^^^
source.hx punctuation.definition.tag
>#if (foo)//
^^^^^
source.hx punctuation.definition.tag punctuation.definition.tag
^^^
source.hx punctuation.definition.tag
^
source.hx punctuation.definition.tag
^^
source.hx comment.line.double-slash.hx punctuation.definition.comment.hx
>#end
^^^^
source.hx punctuation.definition.tag
7 changes: 7 additions & 0 deletions cases/Issue1.hx
@@ -0,0 +1,7 @@
#if foo/*test*/#end
#if foo//test
#end

#if (foo)/*test*/#end
#if (foo)//
#end
6 changes: 3 additions & 3 deletions haxe.YAML-tmLanguage
Expand Up @@ -192,7 +192,7 @@ repository:
endCaptures:
'1': {name: punctuation.definition.block.begin.hx}
patterns:
- include: '#type'
- include: '#type'
enum-block:
begin: (?<=\{)
end: (\})
Expand Down Expand Up @@ -740,7 +740,7 @@ repository:
end: (?=\))
patterns:
- include: '#type'
- include: '#block-contents'
- include: '#block-contents'
- match: \b(try|catch|throw)\b
name: keyword.control.catch-exception.hx
- begin: \b(case|default)\b
Expand Down Expand Up @@ -819,7 +819,7 @@ repository:
# the correct scope is meta.preprocessor, but at least in the default theme,
# the gray of punctuation.definition.tag looks _much_ better
patterns:
- match: ((#(if|elseif))[\s!]+([a-zA-Z0-9_]+)\s)
- match: ((#(if|elseif))[\s!]+([a-zA-Z0-9_]+)(?=\s|/*|//))
captures:
'0': {name: punctuation.definition.tag}
- begin: ((#(if|elseif))[\s!]*\()
Expand Down
2 changes: 1 addition & 1 deletion haxe.tmLanguage

Large diffs are not rendered by default.

0 comments on commit 440324a

Please sign in to comment.