diff options
| author | Yong He <yonghe@outlook.com> | 2022-06-30 14:19:39 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-30 14:19:39 -0700 |
| commit | 2c09275388d4c88ea26bf709132b8be4a9e342bc (patch) | |
| tree | ac0049c3bc484aca9e36b489337771e90973bf0a /tools | |
| parent | 5eee6b03c391d0bb6ed0ded2d8d91c2e525fdb97 (diff) | |
Language server: extract documentation from ordinary comments (#2308)
* Language server: improved documentation formatting.
* Extend doc extractor to search in ordinary comments.
Reuse language server instance between tests.
* Fix test case.
* Fix comment.
* Fix crash.
* Fix enum case doc extraction.
* Doc extractor fixes.
* Fix.
* Fix.
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/slang-test/slang-test-main.cpp | 17 | ||||
| -rw-r--r-- | tools/slang-test/test-context.cpp | 7 | ||||
| -rw-r--r-- | tools/slang-test/test-context.h | 1 |
3 files changed, 20 insertions, 5 deletions
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp index 355f28a23..6391ad3e2 100644 --- a/tools/slang-test/slang-test-main.cpp +++ b/tools/slang-test/slang-test-main.cpp @@ -1465,16 +1465,18 @@ TestResult runExecutableTest(TestContext* context, TestInput& input) TestResult runLanguageServerTest(TestContext* context, TestInput& input) { - RefPtr<JSONRPCConnection> connection; - if (SLANG_FAILED(context->createLanguageServerJSONRPCConnection(connection))) + if (!context->m_languageServerConnection) { - return TestResult::Fail; + if (SLANG_FAILED(context->createLanguageServerJSONRPCConnection(context->m_languageServerConnection))) + { + return TestResult::Fail; + } } if (context->isCollectingRequirements()) { - connection->sendCall(LanguageServerProtocol::ExitParams::methodName, JSONValue::makeInt(0)); return TestResult::Pass; } + auto connection = context->m_languageServerConnection.Ptr(); LanguageServerProtocol::InitializeParams initParams; LanguageServerProtocol::WorkspaceFolder wsFolder; wsFolder.name = "test"; @@ -1684,7 +1686,12 @@ TestResult runLanguageServerTest(TestContext* context, TestInput& input) } } } - connection->sendCall(LanguageServerProtocol::ExitParams::methodName, JSONValue::makeInt(0)); + LanguageServerProtocol::DidCloseTextDocumentParams closeDocParams; + closeDocParams.textDocument.uri = URI::fromLocalFilePath(fullPath.getUnownedSlice()).uri; + connection->sendCall( + LanguageServerProtocol::DidCloseTextDocumentParams::methodName, + &closeDocParams, + JSONValue::makeInt(1)); auto outputStem = input.outputStem; String expectedOutputPath = outputStem + ".expected.txt"; diff --git a/tools/slang-test/test-context.cpp b/tools/slang-test/test-context.cpp index 6bf7406e6..df472d11d 100644 --- a/tools/slang-test/test-context.cpp +++ b/tools/slang-test/test-context.cpp @@ -6,6 +6,7 @@ #include "../../source/core/slang-shared-library.h" #include "../../source/core/slang-test-tool-util.h" +#include "../../source/compiler-core/slang-language-server-protocol.h" #include <stdio.h> #include <stdlib.h> @@ -71,6 +72,12 @@ Result TestContext::init(const char* exePath) TestContext::~TestContext() { + if (m_languageServerConnection) + { + m_languageServerConnection->sendCall( + LanguageServerProtocol::ExitParams::methodName, + JSONValue::makeInt(0)); + } if (m_session) { spDestroySession(m_session); diff --git a/tools/slang-test/test-context.h b/tools/slang-test/test-context.h index 284206efb..faf115ba8 100644 --- a/tools/slang-test/test-context.h +++ b/tools/slang-test/test-context.h @@ -165,6 +165,7 @@ class TestContext SlangResult createLanguageServerJSONRPCConnection(Slang::RefPtr<Slang::JSONRPCConnection>& out); std::mutex mutex; + Slang::RefPtr<Slang::JSONRPCConnection> m_languageServerConnection; protected: SlangResult _createJSONRPCConnection(Slang::RefPtr<Slang::JSONRPCConnection>& out); |
