usethesource / rascal-language-servers

An LSP server for Rascal which includes an easy-to-use LSP generator for languages implemented in Rascal, and an interactive terminal REPL.
BSD 2-Clause "Simplified" License
15 stars 8 forks source link

createAstFromFile prints org.rascalmpl.library.lang.java.m3.internal.ASTConverter.resolveType(ASTConverter.java:154) #95

Open iDylanK opened 2 years ago

iDylanK commented 2 years ago

I'm trying to use Visual Code but I'm running in a few issues.

The function createM3FromDirectory works.

createAstFromFile(loc, false) also works but prints something like:

Got NPE for node String catalog org.rascalmpl.library.lang.java.m3.internal.ASTConverter.resolveType(ASTConverter.java:154) However, it does work and returns the correct Declaration.

DavyLandman commented 2 years ago

Interesting. does it happen for every file or a specific file? And have you tried running the code inside eclipse or the command line?

iDylanK commented 2 years ago

We implemented a SIG model in rascal using eclipse. However, we can’t get eclipse to perform well. That’s why we want to start our new project using vscode.

First we want to get our built project working. We changed some minor things to get it up and running in vscode. All seems to be working fine, except for these messages occurring. It shows this message for all files (smallsql0.21) and thus spams the terminal.

How it’s implemented:

M3 model = createM3FromDirectory(|file://loc_smallsql0.21|); 
set[loc] files = files(model);
files = {f | loc f <- files, f.extension == "java"};
for (file <- files) {
    Declaration ast = createAstFromFile(file, false);
}
Schermafbeelding 2021-11-23 om 10 58 17
DavyLandman commented 2 years ago

could you try running it from the command line? https://update.rascal-mpl.org/console/rascal-shell-release.jar

@rodinaarssen pointed out that in the Eclipse version of the REPL, we are loosing the output printed on stderr, while in vscode we are showing that to the user. There seems to be a debug print for certain nodes: https://github.com/usethesource/rascal/blob/master/src/org/rascalmpl/library/lang/java/m3/internal/ASTConverter.java#L157

So it could be that this message is always there, it's just hidden inside eclipse.

iDylanK commented 2 years ago

Ah that explains it, thank you! I get the same result running it from the command line. Do you have any suggestions on how to prevent this?

DavyLandman commented 2 years ago

Not currently. I can imagine that it's annoying to keep seeing these prints.

I think we should migrate that print to use the logging framework, but that won't help you now.

jurgenvinju commented 2 years ago

We investigated this NPE some years ago; it happens deep inside the JDK compiler and so far we have not had bad results while ignoring it. However, we should take a newer version of the compiler and see if it still happens, and debug it again.

Possibly related: