Skip to content

Commit

Permalink
Merge pull request #29 from rwols/fix-if-defined-parameter
Browse files Browse the repository at this point in the history
Highlight 'DEFINED' parameter of if/elseif
  • Loading branch information
zyxar committed Jul 30, 2017
2 parents d94124a + 8c44d15 commit ae888b4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
8 changes: 5 additions & 3 deletions CMake.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ contexts:
- match: \(
scope: punctuation.section.parens.begin.cmake
push: if-args
- match: \bDEFINED\b
scope: variable.parameter.if.DEFINED.cmake
- match: \bSTREQUAL\b
scope: variable.parameter.if.STREQUAL.cmake
- match: \bNOT\b
Expand Down Expand Up @@ -417,7 +419,7 @@ contexts:
- include: args-common

#--- CONTINUE ----------------------------------------------------------------

continue:
- match: (?i)\bcontinue\b
scope: keyword.control.continue.cmake
Expand Down Expand Up @@ -541,7 +543,7 @@ contexts:
string-raw:
- match: \[(=*)\[
scope: punctuation.definition.string.begin.cmake
push:
push:
- meta_include_prototype: false
- meta_scope: string.raw.cmake
- match: \]\1\]
Expand Down Expand Up @@ -588,7 +590,7 @@ contexts:
- match: \\.
scope: invalid.illegal.character.escape.cmake
- match: (?=\t| |\(|\)|\#|\"|\\|\n)
pop: true
pop: true
- match: (?=\s*$)
set:
- match: \s*$
Expand Down
37 changes: 27 additions & 10 deletions syntax_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ if (NOT (${something} AND ${something_else}))

endif()

if (DEFINED ENV{DUMMY})
# ^ variable.parameter
# ^ - variable.parameter - keyword
# ^ - punctuation
# ^ - punctuation
# pass
else()
message(FATAL_ERROR "DUMMY is not defined. \n ")
endif()
if (DEFINED $ENV{DUMMY})
# ^ variable.parameter
# ^ punctuation.definition
# pass
else()
message(FATAL_ERROR "DUMMY is not defined. \n ")
endif()

set(x "\! \@ \# \$ \% \& \* \( \) \a \b \c \d \e \f \g \h \i \j \k \l \m \n \o \p \q \r \s \t \u \v \w \x \y \z")
# ^^ invalid.illegal.character.escape
# ^^ constant.character.escape
Expand Down Expand Up @@ -60,7 +77,7 @@ set(blarg

message(STATUS "The some_var variable has the value \"${some_var}\"")
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments
# ^^^^^^ variable.parameter
# ^^^^^^ variable.parameter
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double
# ^^ constant.character.escape
# ^ punctuation.definition.variable
Expand Down Expand Up @@ -97,8 +114,8 @@ elseif("${somevar}" STREQUAL whatever AND NOT ${another_var} VERSION_LESS 1.2.3)

elseif (STREQUALasdf sTREQUAL COMMAND ANDNOT AND NOT VERSION_GREATER TARGET)
#^^^^^ keyword.control
# ^^^^^^^^^^^^ meta.string.unquoted
# ^^^^^^^^ meta.string.unquoted
# ^^^^^^^^^^^^ meta.string.unquoted
# ^^^^^^^^ meta.string.unquoted
# ^^^^^^^ variable.parameter
# ^^^^^^ - variable.parameter
# ^^^ keyword.operator
Expand Down Expand Up @@ -236,7 +253,7 @@ if(NOT (CMAKE_VERSION VERSION_LESS 3.0)) # CMake >= 3.0
# ^^^^^ variable.parameter
# ^^^^^^ meta.string.unquoted
# ^ punctuation.section.parens.end

endif()

#[=[
Expand All @@ -249,7 +266,7 @@ endif()

particular

]=] # and this is where a regular line comment starts
]=] # and this is where a regular line comment starts
# ^ comment.block
# ^ comment.line

Expand Down Expand Up @@ -277,12 +294,12 @@ endforeach()

add_custom_target(ClaraDeploy
COMMAND
${CMAKE_COMMAND}
-D VERSION=${PROJECT_VERSION}
${CMAKE_COMMAND}
-D VERSION=${PROJECT_VERSION}
# ^^^^^^^^ meta.string.unquoted
-D SUBLIME_PLATFORM_EXT=${SUBLIME_PLATFORM_EXT}
-D SUBLIME_PLATFORM_EXT=${SUBLIME_PLATFORM_EXT}
# ^^^^^^^^^^^^^^^^^^^^^ meta.string.unquoted
-D ZIPFILE="${Clara_tar_output}"
-D ZIPFILE="${Clara_tar_output}"
# ^^^^^^^^ meta.string.unquoted
-P "${CMAKE_CURRENT_SOURCE_DIR}/Deploy"
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double
Expand All @@ -300,7 +317,7 @@ incurreret. [[ x ]] nam quibusdam, et iis quidem non admodum indoctis, totum hoc
displicet philosophari. ]=])
#^^^^^^^^^^^^^^^^^^^^^^^^^^ string.raw
# ^^^ punctuation.definition.string.end
# ^ punctuation.section.parens.end
# ^ punctuation.section.parens.end

set_target_properties(gintonic PROPERTIES CXX_STANDARD 14)
# ^ meta.function-call support.function
Expand Down

0 comments on commit ae888b4

Please sign in to comment.