File tree Expand file tree Collapse file tree 1 file changed +20
-7
lines changed
sdk-api-gen/src/main/java/dev/restate/sdk/gen Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -34,13 +34,26 @@ public TemplateSource sourceAt(String location) {
3434 return new TemplateSource () {
3535 @ Override
3636 public String content (Charset charset ) throws IOException {
37- return filer
38- .getResource (
39- StandardLocation .ANNOTATION_PROCESSOR_PATH ,
40- path .getParent ().toString ().replace ('/' , '.' ),
41- path .getFileName ().toString ())
42- .getCharContent (true )
43- .toString ();
37+ try {
38+ return filer
39+ .getResource (
40+ StandardLocation .ANNOTATION_PROCESSOR_PATH ,
41+ path .getParent ().toString ().replace ('/' , '.' ),
42+ path .getFileName ().toString ())
43+ .getCharContent (true )
44+ .toString ();
45+ } catch (java .lang .IllegalArgumentException | IOException filerException ) {
46+ // in vscode/cursor this happens https://github.com/restatedev/sdk-java/issues/516
47+ // so fallback to using the classloader
48+ try (var stream = getClass ().getResourceAsStream ("/" + location )) {
49+ if (stream == null ) {
50+ throw filerException ;
51+ }
52+ return new String (stream .readAllBytes (), charset );
53+ } catch (Exception classLoaderException ) {
54+ throw filerException ; // throw the original exception to retain the original behaviour
55+ }
56+ }
4457 }
4558
4659 @ Override
You can’t perform that action at this time.
0 commit comments