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

Non-JDT errors are not reported in Java files #2154

Closed
fbricon opened this issue Jul 11, 2022 · 0 comments · Fixed by #2183
Closed

Non-JDT errors are not reported in Java files #2154

fbricon opened this issue Jul 11, 2022 · 0 comments · Fixed by #2183
Assignees
Labels

Comments

@fbricon
Copy link
Contributor

fbricon commented Jul 11, 2022

Some context
I'm trying to get JBang scripts work OOTB in VS Code. Since the classpath dependencies are coded right in the Java file, I use a similar mechanism to invisible projects to create a Java project under the jdt.ls workspace, that is then augmented with informations gathered from the JBang directives in the original file. This is based on jbang-eclipse. The jdt.ls integration is currently living on my fork. Finally, the VS Code Java integration can be found at https://github.com/fbricon/vscode-jbang, one can install a CI build of the vscode-jbang.vsix from the latest release page.

Now.

When I open a folder containing a JBang script, say hello.java:

///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS com.github.lalyos:jfiglet:0.0.9
//DEPS org.slf4j:slf4j-api:1.7.32
//JAVA 17
import com.github.lalyos.jfiglet.FigletFont;

class hello {

    public static void main(String... args) throws Exception {
        System.out.println(FigletFont.convertOneLine(
                "Hello " + ((args.length > 0) ? args[0] : "jbang")));
    }

}

When I change the version of a dependency to something invalid, eg. com.github.lalyos:jfiglet:6.6.6, jbang-eclipse adds a JBang error marker to the offending dependency, underlying the error. At least it works in Eclipse. But with jdt.ls, no diagnostic is reported to the client.

In https://github.com/eclipse/eclipse.jdt.ls/blob/a996b57495a150f31c8c2e61110ce8032086f2a1/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/WorkspaceDiagnosticsHandler.java#L169, if the file is a java-like file and not a working copy, all its JAVA_MODEL_PROBLEM_MARKER and TASK_MARKER problems are reported. My jbang errors are thus ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants