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

IValidatorExtension based Issue manifests with wrong context over LSP #244

Open
esmasth opened this issue May 1, 2024 · 2 comments
Open

Comments

@esmasth
Copy link
Contributor

esmasth commented May 1, 2024

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 esmasth changed the title IValidatorExtension based Issues manifest with wrong context over LSP IValidatorExtension based Issue manifests with wrong context over LSP May 1, 2024
@esmasth
Copy link
Contributor Author

esmasth commented Jun 24, 2024

@dhuebner any idea on this issue?

@dhuebner
Copy link
Member

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

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

No branches or pull requests

2 participants