summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-01-22 13:13:49 -0800
committerGitHub <noreply@github.com>2024-01-22 13:13:49 -0800
commitc4e42ab49019bcd9f05217abe8e5d4c083622473 (patch)
tree0b088d1efae3ee5759f03ba9492f6a1ced2a600c
parentfdc17a974970559d8ff76d52c3ce40aaa056d441 (diff)
Fix language server for VS. (#3473)
Co-authored-by: Yong He <yhe@nvidia.com>
-rw-r--r--source/compiler-core/slang-json-rpc-connection.cpp18
-rw-r--r--source/compiler-core/slang-json-rpc-connection.h2
-rw-r--r--source/slang/slang-language-server.cpp4
3 files changed, 22 insertions, 2 deletions
diff --git a/source/compiler-core/slang-json-rpc-connection.cpp b/source/compiler-core/slang-json-rpc-connection.cpp
index c4413d306..af9dd9e48 100644
--- a/source/compiler-core/slang-json-rpc-connection.cpp
+++ b/source/compiler-core/slang-json-rpc-connection.cpp
@@ -136,6 +136,24 @@ SlangResult JSONRPCConnection::sendError(JSONRPC::ErrorCode errorCode, const Uno
return sendRPC(&errorResponse);
}
+SlangResult JSONRPCConnection::checkArrayObjectWrap( const JSONValue& srcArgs, const RttiInfo* dstArgsRttiInfo, void* dstArgs, const JSONValue& id )
+{
+ if ( dstArgsRttiInfo->m_kind == RttiInfo::Kind::Struct &&
+ srcArgs.getKind() == JSONValue::Kind::Array )
+ {
+ auto array = m_container.getArray( srcArgs );
+ if ( array.getCount() == 1 )
+ {
+ return toNativeOrSendError( array[0], dstArgsRttiInfo, dstArgs, id );
+ }
+ return SLANG_OK;
+ }
+ else
+ {
+ return toNativeOrSendError( srcArgs, dstArgsRttiInfo, dstArgs, id );
+ }
+}
+
SlangResult JSONRPCConnection::toNativeArgsOrSendError(const JSONValue& srcArgs, const RttiInfo* dstArgsRttiInfo, void* dstArgs, const JSONValue& id)
{
if (dstArgsRttiInfo->m_kind == RttiInfo::Kind::Struct &&
diff --git a/source/compiler-core/slang-json-rpc-connection.h b/source/compiler-core/slang-json-rpc-connection.h
index 7246fb780..f5525d033 100644
--- a/source/compiler-core/slang-json-rpc-connection.h
+++ b/source/compiler-core/slang-json-rpc-connection.h
@@ -48,6 +48,8 @@ public:
/// Disconnect. May block while server shuts down
void disconnect();
+ SlangResult checkArrayObjectWrap( const JSONValue& srcArgs, const RttiInfo* dstArgsRttiInfo, void* dstArgs, const JSONValue& id );
+
/// Convert value to dst. Will write response on fails
SlangResult toNativeOrSendError(const JSONValue& value, const RttiInfo* info, void* dst, const JSONValue& id);
diff --git a/source/slang/slang-language-server.cpp b/source/slang/slang-language-server.cpp
index 12151441c..2c24ba6e5 100644
--- a/source/slang/slang-language-server.cpp
+++ b/source/slang/slang-language-server.cpp
@@ -1974,7 +1974,7 @@ SlangResult LanguageServer::queueJSONCall(JSONRPCCall call)
else if (call.method == SemanticTokensParams::methodName)
{
SemanticTokensParams args;
- SLANG_RETURN_ON_FAIL(m_connection->toNativeArgsOrSendError(call.params, &args, call.id));
+ SLANG_RETURN_ON_FAIL(m_connection->checkArrayObjectWrap( call.params, GetRttiInfo<SemanticTokensParams>::get(), &args, call.id ));
cmd.semanticTokenArgs = args;
}
else if (call.method == SignatureHelpParams::methodName)
@@ -1995,7 +1995,7 @@ SlangResult LanguageServer::queueJSONCall(JSONRPCCall call)
else if (call.method == DocumentSymbolParams::methodName)
{
DocumentSymbolParams args;
- SLANG_RETURN_ON_FAIL(m_connection->toNativeArgsOrSendError(call.params, &args, call.id));
+ SLANG_RETURN_ON_FAIL(m_connection->checkArrayObjectWrap( call.params, GetRttiInfo<DocumentSymbolParams>::get(), &args, call.id ));
cmd.documentSymbolArgs = args;
}
else if (call.method == DocumentFormattingParams::methodName)