yang-lsp icon indicating copy to clipboard operation
yang-lsp copied to clipboard

`IValidatorExtension` based `Issue` manifests with wrong context over LSP

Open esmasth opened this issue 1 year ago • 2 comments

Issues created within yang-lsp source have a precise context of start and end within LSP diagnostics, whereas Issues created within extensions only retain context of start but not the end which defaults(?) to [0,0] i.e., Line 1 Col 1, and eventually start and stop are swapped resulting in a misleading context of the issues.

Example extension for trial

package my.pack

import io.typefox.yang.validation.IValidatorExtension
import io.typefox.yang.validation.IssueFactory
import io.typefox.yang.yang.AbstractModule
import io.typefox.yang.yang.YangPackage
import org.eclipse.xtext.util.CancelIndicator
import org.eclipse.xtext.util.IAcceptor
import org.eclipse.xtext.validation.Issue

class MyExampleValidator implements IValidatorExtension {

    override validate(AbstractModule module, IAcceptor<Issue> issueAcceptor, CancelIndicator cancelIndicator) {
        if (module.getName().equals("foo")) {
            issueAcceptor.accept(IssueFactory.createIssue(module,
                                                          YangPackage.Literals.ABSTRACT_MODULE__NAME,
                                                          "'foo' is a bad name", "bad_name"))
        }
    }

}

Verbose trace excerpt from YANG Language server - foo.log

Manifestation of the issue in VS Code Yangster extension

image image

In the example above precisely foo is expected to be underlined

The editor user experience is degraded to a large extent, specially if an Issue pertaining to a context towards the end of a YANG file which ends up underlining from the start of the file till what is actually the start of the issue context. This further gets complicated when there are multiple issues raised via extensions since a list of issues are presented in the context that precedes the actual errors.

esmasth avatar May 01 '24 18:05 esmasth

@dhuebner any idea on this issue?

esmasth avatar Jun 24 '24 17:06 esmasth

@esmasth Hard to tell from only seeing the logs, need to investigate and debug.

dhuebner avatar Jun 25 '24 07:06 dhuebner