Skip to content

Add progress reporting and server status tracking - #3

Open
angelozerr wants to merge 1 commit into
tsmaeder:mainfrom
angelozerr:progress-support
Open

angelozerr wants to merge 1 commit into
tsmaeder:mainfrom
angelozerr:progress-support

Conversation

@angelozerr

Copy link
Copy Markdown

This PR:

  • Add ProgressSupport interface and ProgressMonitor for LSP $/progress
  • Add ServerStatus enum (starting/indexing/ready) with java/serverStatus notification
  • Add JavaLanguageClient interface extending LanguageClient with custom notifications
  • Integrate progress reporting into IndexService and Scanner
  • Use Launcher.Builder with JavaLanguageClient as remote interface

Here a sample LSP Trace

[Trace] Received request 'window/workDoneProgress/create - (1)'.
Params: {
    "token": "9fae0816-bb6d-4a91-be58-6ed0ba8d20c8"
}

[Trace] Received notification 'window/logMessage'.
Params: { "type": 3, "message": "Server status: indexing" }

[Trace] Received notification '$/progress'.
Params: {
    "token": "9fae0816-bb6d-4a91-be58-6ed0ba8d20c8",
    "value": {
        "kind": "begin",
        "title": "Indexing Java workspace",
        "cancellable": false,
        "message": "Loading mbt.json...",
        "percentage": 0
    }
}

[Trace] Received notification '$/progress'.
Params: {
    "token": "...",
    "value": { "kind": "report", "message": "Indexing class files (27 jars)...", "percentage": 10 }
}

[Trace] Received notification '$/progress'.
Params: {
    "token": "...",
    "value": { "kind": "report", "message": "Indexing class files 1/28", "percentage": 12 }
}

... (class files 2/28 → 28/28, percentage 15 ...

[Trace] Received notification '$/progress'.
Params: {
    "token": "...",
    "value": { "kind": "report", "message": "Indexing source files 1/2", "percentage": 50 }
}

[Trace] Received notification '$/progress'.
Params: {
    "token": "...",
    "value": { "kind": "report", "message": "Indexing source files 2/2", "percentage": 90 }
}

[Trace] Received notification '$/progress'.
Params: {
    "token": "...",
    "value": {
        "kind": "end",
        "message": "Indexed 31164 types from 30 sources in 2438 ms."
    }
}

[Trace] Received notification 'window/logMessage'.
Params: { "type": 3, "message": "Server status: ready" }

@angelozerr

angelozerr commented Sep 16, 2026 •

Copy link
Copy Markdown
Author

Please note I have add Java LS as mcp-ade extension https://github.com/angelozerr/mcp-ade/tree/main/extensions/java-ls and I need this PR to track the server ready, otherwise the first time that LSP references is consumed it returns empty references because Java LS has not finished to index the project.

- Add ProgressSupport interface and ProgressMonitor for LSP $/progress
- Add ServerStatus enum (starting/indexing/ready) with java/serverStatus
notification
- Add JavaLanguageClient interface extending LanguageClient with custom
notifications
- Integrate progress reporting into IndexService and Scanner
- Use Launcher.Builder with JavaLanguageClient as remote interface

Signed-off-by: azerr <azerr@redhat.com>
@tsmaeder

Copy link
Copy Markdown
Owner

@angelozerr I think you could achieve the same result by simply observing the log output of the language server.
In a test harness I use to run language servers, I do something like this for the Metals LS:

const indexLoadedDeferred = new Deferred<void>(900000);
    const subscription = client.onNotification<LogMessageParams>(
      LogMessageNotification.type,
      (params: LogMessageParams) => {
        // logRepoProgress(_repoName, "Metals log message: " + params.message);
        const message = params && typeof params.message === "string" ? params.message : "";
        if (/Indexing complete/.test(message)) {
          logRepoProgress(_repoName, "Metals index complete");
          indexLoadedDeferred.resolve(undefined);
        }
      },
    );

    return indexLoadedDeferred.promise().finally(() => {
      subscription.dispose();
    });

I think having this infrastructure would be interesting generally, because most language servers will not publish status information.

@angelozerr

Copy link
Copy Markdown
Author

@tsmaeder thanks for your answer.

First please note that jdtls and intellij server uses this custom notification.

It would be very nice if lsp spec could introduce this kind of notification.

I understand your point of view but IMHO I think it is a fragile solution because logs could be disabled.

If you want to be full compliant lsp, I think the proper solution is to manage that with lsp progress.

By using lsp progress you will give info to the user the status of rhe indexing. Even if java ls is super fast it could be interesting ro have that for large code base like quarkus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants