open_with_cpp_nonexistent.carbon 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // TODO: At present, this has a
  6. // "dropping diagnostic in /test.carbon.generated.cpp_imports.h". That should be
  7. // fixed to assign back to this file, but that may come from other fixes to C++
  8. // diagnostic output.
  9. //
  10. // AUTOUPDATE
  11. // TIP: To test this file alone, run:
  12. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/language_server/testdata/text_document/open_with_cpp_nonexistent.carbon
  13. // TIP: To dump output, run:
  14. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/language_server/testdata/text_document/open_with_cpp_nonexistent.carbon
  15. // --- STDIN
  16. [[@LSP-CALL:initialize]]
  17. [[@LSP-NOTIFY:textDocument/didOpen:
  18. "textDocument": {"uri": "file:/test.carbon", "languageId": "carbon",
  19. "text": "import Cpp library \"nonexistent.h\";"}
  20. ]]
  21. [[@LSP-NOTIFY:textDocument/didClose:
  22. "textDocument": {"uri": "file:/test.carbon"}
  23. ]]
  24. [[@LSP-CALL:shutdown]]
  25. [[@LSP-NOTIFY:exit]]
  26. // --- AUTOUPDATE-SPLIT
  27. // CHECK:STDERR: /test.carbon: warning: dropping diagnostic in /test.carbon.generated.cpp_imports.h:
  28. // CHECK:STDERR: /test.carbon.generated.cpp_imports.h:1: error: C++:
  29. // CHECK:STDERR: /test.carbon.generated.cpp_imports.h:1:10: fatal error: 'nonexistent.h' file not found
  30. // CHECK:STDERR: 1 | #include "nonexistent.h"
  31. // CHECK:STDERR: | ^~~~~~~~~~~~~~~
  32. // CHECK:STDERR:
  33. // CHECK:STDERR: /test.carbon:1:1: note: in `Cpp` import
  34. // CHECK:STDERR: import Cpp library "nonexistent.h";
  35. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  36. // CHECK:STDERR: [LanguageServerDiagnosticInWrongFile]
  37. // CHECK:STDERR:
  38. // CHECK:STDOUT: Content-Length: 146{{\r}}
  39. // CHECK:STDOUT: {{\r}}
  40. // CHECK:STDOUT: {
  41. // CHECK:STDOUT: "id": 1,
  42. // CHECK:STDOUT: "jsonrpc": "2.0",
  43. // CHECK:STDOUT: "result": {
  44. // CHECK:STDOUT: "capabilities": {
  45. // CHECK:STDOUT: "documentSymbolProvider": true,
  46. // CHECK:STDOUT: "textDocumentSync": 2
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: }Content-Length: 144{{\r}}
  50. // CHECK:STDOUT: {{\r}}
  51. // CHECK:STDOUT: {
  52. // CHECK:STDOUT: "jsonrpc": "2.0",
  53. // CHECK:STDOUT: "method": "textDocument/publishDiagnostics",
  54. // CHECK:STDOUT: "params": {
  55. // CHECK:STDOUT: "diagnostics": [],
  56. // CHECK:STDOUT: "uri": "file:///test.carbon"
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: }Content-Length: 144{{\r}}
  59. // CHECK:STDOUT: {{\r}}
  60. // CHECK:STDOUT: {
  61. // CHECK:STDOUT: "jsonrpc": "2.0",
  62. // CHECK:STDOUT: "method": "textDocument/publishDiagnostics",
  63. // CHECK:STDOUT: "params": {
  64. // CHECK:STDOUT: "diagnostics": [],
  65. // CHECK:STDOUT: "uri": "file:///test.carbon"
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT: }Content-Length: 51{{\r}}
  68. // CHECK:STDOUT: {{\r}}
  69. // CHECK:STDOUT: {
  70. // CHECK:STDOUT: "id": 2,
  71. // CHECK:STDOUT: "jsonrpc": "2.0",
  72. // CHECK:STDOUT: "result": null
  73. // CHECK:STDOUT: }