cquery icon indicating copy to clipboard operation
cquery copied to clipboard

Weird `textDocument/documentSymbol` output

Open isundaylee opened this issue 6 years ago • 0 comments

Version: latest master (9494c3e6)

When I run cquery on the following simple .cpp file:

enum class Color { WHITE, GREY, BLACK };

textDocument/documentSymbol gives the following (prettified) JSON output:

{
  "jsonrpc": "2.0",
  "id": 60,
  "result": [{
    "name": "Color",
    "kind": 10,
    "location": {
      "uri": "file:///.../test.cpp",
      "range": {
        "start": {"line": 0, "character": 0},
        "end": {"line": 0, "character": 39}
      }
    },
    "containerName": "Color"
  }, {
    "name": "WHITE",
    "kind": 22,
    "location": {
      "uri": "file:///.../test.cpp",
      "range": {
        "start": {"line": 0, "character": 19},
        "end": {"line": 0, "character": 24}
      }
    },
    "containerName": "Color::WHITE"
  }, {
    "name": "GREY",
    "kind": 22,
    "location": {
      "uri": "file:///.../test.cpp",
      "range": {
        "start": {"line": 0, "character": 26},
        "end": {"line": 0, "character": 30}
      }
    },
    "containerName": "Color::GREY"
  }, {
    "name": "BLACK",
    "kind": 22,
    "location": {
      "uri": "file:///.../test.cpp",
      "range": {
        "start": {"line": 0, "character": 32},
        "end": {"line": 0, "character": 37}
      }
    },
    "containerName": "Color::BLACK"
  }]
}

which then results in the following outline being rendered in Atom:

screen shot 2018-10-30 at 11 37 49 pm

Question: Shouldn't Color::WHITE, Color::GREY, and Color::BLACK be nested under Color? In particular, shouldn't those three entries have Color as their containerName? Aside from that, all the top-level names (e.g. Color here) seems to have their own names as the containerName, which in this case causes Color to be unnecessarily nested under an extra Color entry. I feel like maybe top-level names should have an empty containerName instead? Ideally I think the outline that makes sense in this case should look like:

Color
-- WHITE
-- GREY
-- BLACK

Thanks! :)

isundaylee avatar Oct 31 '18 03:10 isundaylee