semantic-highlighting.test 5.36 KB
# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"textDocument":{"semanticHighlightingCapabilities":{"semanticHighlighting":true}}},"trace":"off"}}
---
#      CHECK:  "id": 0,
# CHECK:      "semanticHighlighting": {
# CHECK-NEXT:        "scopes": [
# CHECK-NEXT:          [
# CHECK-NEXT:            "variable.other.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "variable.other.local.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "variable.parameter.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "entity.name.function.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "entity.name.function.method.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "entity.name.function.method.static.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "variable.other.field.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "variable.other.field.static.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "entity.name.type.class.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "entity.name.type.enum.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "variable.other.enummember.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "entity.name.type.typedef.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "entity.name.type.dependent.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "entity.name.other.dependent.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "entity.name.namespace.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "entity.name.type.template.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "entity.name.type.concept.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "storage.type.primitive.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "entity.name.function.preprocessor.cpp"
# CHECK-NEXT:          ],
# CHECK-NEXT:          [
# CHECK-NEXT:            "meta.disabled"
# CHECK-NEXT:          ]
# CHECK-NEXT:        ]
# CHECK-NEXT:      },
---
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.cpp","languageId":"cpp","text":"int x = 2;"}}}
#      CHECK:  "method": "textDocument/semanticHighlighting",
# CHECK-NEXT:  "params": {
# CHECK-NEXT:    "lines": [
# CHECK-NEXT:      {
# CHECK-NEXT:        "isInactive": false,
# CHECK-NEXT:        "line": 0,
# CHECK-NEXT:        "tokens": "AAAABAABAAA="
# CHECK-NEXT:      }
# CHECK-NEXT:    ],
# CHECK-NEXT:    "textDocument": {
# CHECK-NEXT:      "uri": "file://{{.*}}/clangd-test/foo.cpp",
# CHECK-NEXT:      "version": 0
# CHECK-NEXT:    }
# CHECK-NEXT:  }
# CHECK-NEXT:}
---
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo2.cpp","languageId":"cpp","text":"int x = 2;\nint y = 2;"}}}
#      CHECK:  "method": "textDocument/semanticHighlighting",
# CHECK-NEXT:  "params": {
# CHECK-NEXT:    "lines": [
# CHECK-NEXT:      {
# CHECK-NEXT:        "isInactive": false,
# CHECK-NEXT:        "line": 0,
# CHECK-NEXT:        "tokens": "AAAABAABAAA="
# CHECK-NEXT:      }
# CHECK-NEXT:      {
# CHECK-NEXT:        "isInactive": false,
# CHECK-NEXT:        "line": 1,
# CHECK-NEXT:        "tokens": "AAAABAABAAA="
# CHECK-NEXT:      }
# CHECK-NEXT:    ],
# CHECK-NEXT:    "textDocument": {
# CHECK-NEXT:      "uri": "file://{{.*}}/clangd-test/foo2.cpp",
# CHECK-NEXT:      "version": 0
# CHECK-NEXT:    }
# CHECK-NEXT:  }
# CHECK-NEXT:}
---
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///foo.cpp"},"contentChanges": [{"range":{"start": {"line": 0,"character": 10},"end": {"line": 0,"character": 10}},"rangeLength": 0,"text": "\nint y = 2;"}]}}
#      CHECK:  "method": "textDocument/semanticHighlighting",
# CHECK-NEXT:  "params": {
# CHECK-NEXT:    "lines": [
# CHECK-NEXT:      {
# CHECK-NEXT:        "isInactive": false,
# CHECK-NEXT:        "line": 1,
# CHECK-NEXT:        "tokens": "AAAABAABAAA="
# CHECK-NEXT:      }
# CHECK-NEXT:   ],
# CHECK-NEXT:    "textDocument": {
# CHECK-NEXT:      "uri": "file://{{.*}}/clangd-test/foo.cpp",
# CHECK-NEXT:      "version": 1
# CHECK-NEXT:    }
# CHECK-NEXT:  }
# CHECK-NEXT:}
---
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///foo.cpp"},"contentChanges": [{"range":{"start": {"line": 0,"character": 10},"end": {"line": 1,"character": 10}},"rangeLength": 11,"text": ""}]}}
#      CHECK:  "method": "textDocument/semanticHighlighting",
# CHECK-NEXT:  "params": {
# CHECK-NEXT:    "lines": [
# CHECK-NEXT:      {
# CHECK-NEXT:        "isInactive": false,
# CHECK-NEXT:        "line": 1,
# CHECK-NEXT:        "tokens": ""
# CHECK-NEXT:      }
# CHECK-NEXT:   ],
# CHECK-NEXT:    "textDocument": {
# CHECK-NEXT:      "uri": "file://{{.*}}/clangd-test/foo.cpp",
# CHECK-NEXT:      "version": 2
# CHECK-NEXT:    }
# CHECK-NEXT:  }
# CHECK-NEXT:}
---
{"jsonrpc":"2.0","id":3,"method":"shutdown"}
---
{"jsonrpc":"2.0","method":"exit"}