jsweet icon indicating copy to clipboard operation
jsweet copied to clipboard

Cannot find import statement

Open AndreasMurk opened this issue 5 years ago • 1 comments

Hi guys!

When we create a TranspilationRequest we want to use the java.util.Scanner;

We use Java Files to process the response and transpile it to TypeScript. But we always need to manually add the import java.util.Scanner; at the beginning of the java file.

For example:

Level1.java:

import java.util.Scanner;

public class Level2 {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        String input = scan.nextLine();

        // Write your Code here


    }
}

When I remove the import statement the transpiler always says that he doesn't find the module Scanner.

Can I attach an import statement to a Printer or to the request itself?

I already tried to import the scanner directly in the subclass ScannerAdapter.

Thanks!

AndreasMurk avatar Sep 18 '18 15:09 AndreasMurk

Hello, Thanks for reporting. Actually, the Scanner class isn't supported by the transpiler because there is no obvious matching concept in JavaScript. Nevertheless, you can take a look at J4TS https://github.com/j4ts/j4ts/blob/master/src/main/java/java/util/Scanner.java which aims to provide JSweet/JS implementation for the whole standard Java API

lgrignon avatar Oct 07 '18 13:10 lgrignon