vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

[Bug] Odd `SOURCE_FILES` variable highlighting?

Open Andrej730 opened this issue 3 months ago • 7 comments

Brief Issue Summary

SOURCE_FILES seems to have a special highlighting - e.g. see the snippet below.

Is it a bug? Highlighting looks like there was some kind of syntax issue but there isn't.

Image
find_package(Boost REQUIRED)

set(XXX ${TEST})

file(GLOB CPP_FILES *.cpp)
file(GLOB H_FILES *.h)
set(SOURCE_FILES ${CPP_FILES} ${H_FILES})
set(TEST_FILES ${CPP_FILES} ${H_FILES})
add_executable(IfcGeomServer ${SOURCE_FILES})
target_link_libraries(IfcGeomServer IfcGeom ${kernel_libraries} ${OPENCASCADE_LIBRARIES})

install(TARGETS IfcGeomServer)

CMake Tools Diagnostics

{
  "os": "win32",
  "vscodeVersion": "1.107.0-insider",
  "cmtVersion": "1.21.36",
  "configurations": [
    {
      "folder": "l:\\Projects\\Github\\test",
      "cmakeVersion": "unknown",
      "configured": false,
      "generator": "unknown",
      "usesPresets": false,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": false,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Debug Log

.

Additional Information

No response

Andrej730 avatar Nov 18 '25 13:11 Andrej730

Update: trying to find anything, I've found that back in the days there was SOURCE_FILES command which was deprecated in 1.4 and removed somewhere later. Couldn't find that old release notes, but apparently this command was a thing maybe 20 years ago. So it's probably safe to remove it from syntax highlighting.

https://web.archive.org/web/20151017200346/https://cmake.org/pipermail/cmake/2002-April/059578.html

Andrej730 avatar Nov 18 '25 13:11 Andrej730

@Andrej730 Thank you for reporting this issue. We have determined that this issue is not a bug. We will close this issue, if you have any questions, please feel free to contact us. Thanks.

yanghhhhhhh avatar Nov 19 '25 01:11 yanghhhhhhh

@yanghhhhhhh hi! Why it's not a bug?

Andrej730 avatar Nov 19 '25 06:11 Andrej730

@Andrej730 Thanks for your reply. We tried to check this issue in a simple project, please refer to this video. After running 'Developer: Inspect Editor Tokens and Scopes', it showed 'invalid.deprecated.source.cmake'. So we think ‘SOURCE_FILES’ highlighted in red is not a bug. Do you think this is a bug? What is your expected result? We look forward to your reply. Thank you.

Image

yanghhhhhhh avatar Nov 19 '25 07:11 yanghhhhhhh

@yanghhhhhhh

Thank you for looking into this!

Ah, I see, so my guess was correct - it's an artifact from the long time deprecated and removed SOURCE_FILES command.

I couldn't find any information on SOURCE_FILES command - only the fact that it was deprecated in 1.4, mentioned in the email list from 2002. So it was removed some time later, presumably also in 200x.

So I think at this point the highlighting SOURCE_FILES as deprecated is a bug. It was removed long time ago, highlighting is just historical and doesn't communicate anything useful to the user, only creating confusion - it emphasizes this variable name, but there's no need to do anything about it.

The expected result is to treat SOURCE_FILES now as no other name (e.g. the same way as TEST_FILES has no highlighting).

Andrej730 avatar Nov 19 '25 10:11 Andrej730

Looking at the full list of deprecated keywords below, it seems other keywords are possible also long time deprecated and removed (see email below dating 2001)

https://github.com/microsoft/vscode-cmake-tools/blob/51b7ced409a4e0e26c036d4284d5077cbad66318/syntaxes/CMake.tmLanguage#L211-L219

Ref - https://web.archive.org/web/20040315045607/https://cmake.org/pipermail/cmake/2001-June/002341.html

Looking through git history, those keywords seem to be first time introduced in https://github.com/microsoft/vscode-cmake-tools/pull/3679. Not sure what was the source of the original syntaxes/CMake.tmLanguage file - maybe issue is somewhere upstream and we need to just pull the more recent version of cmake syntax config or fix it here and upstream the changes. Ping @gcampbell-msft as author of #3679.

Andrej730 avatar Nov 19 '25 11:11 Andrej730

@Andrej730 Thank you for the detailed information. Reproduced this issue in VS Code 1.106.1 + CMake Tools 1.21.36.

Repro steps:

  1. Create a new project, open CMakeLists.txt and paste the code.
find_package(Boost REQUIRED)

set(XXX ${TEST})

file(GLOB CPP_FILES *.cpp)
file(GLOB H_FILES *.h)
set(SOURCE_FILES ${CPP_FILES} ${H_FILES})
set(TEST_FILES ${CPP_FILES} ${H_FILES})
add_executable(IfcGeomServer ${SOURCE_FILES})
target_link_libraries(IfcGeomServer IfcGeom ${kernel_libraries} ${OPENCASCADE_LIBRARIES})

install(TARGETS IfcGeomServer)
  1. Observe the syntax highlighting for SOURCE_FILES. Image

FYI: @gcampbell-msft

yanghhhhhhh avatar Nov 20 '25 02:11 yanghhhhhhh