Skip to content

Commit

Permalink
lint CCDB on file open
Browse files Browse the repository at this point in the history
  • Loading branch information
rtbo committed Jun 5, 2023
1 parent 2cf589f commit 26db0cc
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion source/served/extension.d
Original file line number Diff line number Diff line change
Expand Up @@ -948,17 +948,29 @@ void didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParams params)
@protocolNotification("textDocument/didOpen")
void onDidOpenDocument(DidOpenTextDocumentParams params)
{
string lintSetting = config(params.textDocument.uri).d.lintOnFileOpen;
auto config = workspace(params.textDocument.uri).config;
auto document = documents[params.textDocument.uri];

string lintSetting = config.d.lintOnFileOpen;
bool shouldLint;
if (lintSetting == "always")
shouldLint = true;
else if (lintSetting == "project")
shouldLint = workspaceIndex(params.textDocument.uri) != size_t.max;

if (shouldLint)
{
onDidChangeDocument(DidChangeTextDocumentParams(
VersionedTextDocumentIdentifier(
params.textDocument.uri, params.textDocument.version_)));

if (config.d.enableCcdbLinting && document.languageId == "d")
{
import served.linters.ccdb;

lint(document);
}
}
}

@protocolNotification("textDocument/didClose")
Expand Down

0 comments on commit 26db0cc

Please sign in to comment.