Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some typos and issues reported by dscanner #367

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions serverbase/source/served/serverbase.d
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct LanguageServerConfig
///
/// Params:
/// ExtensionModule = a module defining the following members:
/// - `moduleMembers`: an AliasSeq list of all imported modules that should
/// - `memberModules`: an AliasSeq list of all imported modules that should
/// be introspected to be called automatically on matching RPC commands.
/// - `InitializeResult initialize(InitializeParams)`: initialization method.
///
Expand All @@ -62,9 +62,11 @@ struct LanguageServerConfig
/// - `parallelMain`: an optional method which is run alongside everything
/// else in parallel using fibers. Should yield as much as possible when
/// there is nothing to do.
mixin template LanguageServerRouter(alias ExtensionModule, LanguageServerConfig serverConfig = LanguageServerConfig.init)
mixin template LanguageServerRouter(alias ExtensionModule, LanguageServerConfig serverConfig
= LanguageServerConfig.init)
{
static assert(is(typeof(ExtensionModule.initialize)), "Missing initialize function in ExtensionModule " ~ ExtensionModule.stringof);
static assert(is(typeof(ExtensionModule.initialize)), "Missing initialize function in ExtensionModule " ~
ExtensionModule.stringof);

import core.sync.mutex;
import core.thread;
Expand Down Expand Up @@ -103,7 +105,7 @@ mixin template LanguageServerRouter(alias ExtensionModule, LanguageServerConfig
else static if (__traits(hasMember, ExtensionModule, "memberModules"))
{ /* ok */ }
else
static assert(false, "Missing members field in ExtensionModule " ~ ExtensionModule.stringof);
static assert(false, "Missing members or memberModules field in ExtensionModule " ~ ExtensionModule.stringof);
mixin EventProcessor!(ExtensionModule, serverConfig.eventConfig) eventProcessor;

/// Calls a method associated with the given request type in the
Expand Down Expand Up @@ -183,7 +185,8 @@ mixin template LanguageServerRouter(alias ExtensionModule, LanguageServerConfig
scope (exit)
working--;
auto thisId = working;
trace("Partial ", thisId, " / ", numHandlers, "... ", partialResultToken.length ? "(supported)" : "(no support)");
trace("Partial ", thisId, " / ", numHandlers, "... ", partialResultToken.length ?
"(supported)" : "(no support)");
auto result = fn(args.expand);
trace("Partial ", thisId, " = ", result);
auto json = result.serializeJson;
Expand All @@ -202,7 +205,8 @@ mixin template LanguageServerRouter(alias ExtensionModule, LanguageServerConfig
scope (exit)
working--;
auto thisId = working;
trace("Partial iterator as ", thisId, " / ", numHandlers, "... ", partialResultToken.length ? "(supported)" : "(no support)");
trace("Partial iterator as ", thisId, " / ", numHandlers, "... ",
partialResultToken.length ? "(supported)" : "(no support)");
auto result = fn(args.expand);
foreach (chunk; result)
{
Expand Down Expand Up @@ -325,7 +329,7 @@ mixin template LanguageServerRouter(alias ExtensionModule, LanguageServerConfig
return res;
}

// calls @postProcotolMethod methods for the given request
// calls @postProtocolMethod methods for the given request
private void processRequestObservers(T)(RequestMessageRaw msg, T result)
{
eventProcessor.emitProtocol!(postProtocolMethod, (name, callSymbol, uda) {
Expand Down Expand Up @@ -441,7 +445,8 @@ mixin template LanguageServerRouter(alias ExtensionModule, LanguageServerConfig
__gshared FiberManager fibers;
__gshared Mutex fibersMutex;

void pushFiber(T)(string name, T callback, int pages = serverConfig.defaultPages, string file = __FILE__, int line = __LINE__)
void pushFiber(T)(string name, T callback, int pages = serverConfig.defaultPages,
string file = __FILE__, int line = __LINE__)
{
synchronized (fibersMutex)
fibers.put(name, new Fiber(callback, serverConfig.fiberPageSize * pages), file, line);
Expand Down Expand Up @@ -597,7 +602,7 @@ unittest
bool sanityFalse;
}

__gshared static int calledCustomNotify;
__gshared int calledCustomNotify;

static struct UTServer
{
Expand Down