-
Notifications
You must be signed in to change notification settings - Fork 55
Jap Module System #599
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
Jap Module System #599
Conversation
attempt to fix windows fix inputstreamsource UriUtils covers more cases for constucting path debug windows fix windows Module system to support jap Apply ModuleSource to interpreter attempt to fix windows jap-new-syntax.ol - fix syntax to get recognised by Jolie's test framework jap-new-syntax.ol - move twice-new-syntax.jap under '/lib' and fix imports to get correctly recognised fixed jap file Jap supports import statement Update ModuleFinderImpl.java revert changes
5c60c14 to
0c18d9c
Compare
|
Does it also address issue #230 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR enables the module system to be used within jap files by extending module lookup functionality and enhancing URI handling. Key changes include:
- Addition of comprehensive tests to verify module importing with various import paths.
- Refactoring of ModuleFinderImpl to separate handling for file and jap schemes, and improved module lookups.
- Updates to JapSource and ImportPath to better support and normalize jap-related URIs and relative imports, with a minor log formatting fix in Interpreter.
Reviewed Changes
| File | Description |
|---|---|
| libjolie/src/test/java/jolie/lang/parse/module/ModuleFinderImplTest.java | Added tests covering various import path scenarios for the module system. |
| libjolie/src/main/java/jolie/lang/parse/module/ModuleFinderImpl.java | Refactored find implementation to split file and jap scheme handling and updated lookup logic. |
| libjolie/src/main/java/jolie/lang/parse/module/JapSource.java | Enhanced URI handling for jap sources and improved module target resolution. |
| libjolie/src/main/java/jolie/lang/parse/module/ImportPath.java | Added a toRelativePathString method to support relative module import paths. |
| jolie/src/main/java/jolie/Interpreter.java | Adjusted log formatting for unhandled faults. |
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
libjolie/src/main/java/jolie/lang/parse/module/JapSource.java:68
- Ensure that appending '.ol' to the module target properly handles cases where the entry name might already include the extension, to avoid inadvertently duplicating it.
String moduleTarget = japURIStrings[ 1 ].endsWith( ".ol" ) ? japURIStrings[ 1 ] : japURIStrings[ 1 ] + ".ol";
| if( !this.isRelativeImport() ) { | ||
| throw new IllegalStateException( "This import path is targeting packages module" ); | ||
| } | ||
| return String.join( "/", this.pathParts() ).substring( 1 ); |
Copilot
AI
Mar 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling substring(1) without verifying that the joined string is non-empty may throw a StringIndexOutOfBoundsException when pathParts contains only an empty string. Consider adding a check for an empty string or returning an empty result in that case.
| return String.join( "/", this.pathParts() ).substring( 1 ); | |
| String joinedPath = String.join( "/", this.pathParts() ); | |
| if (joinedPath.isEmpty()) { | |
| return ""; | |
| } | |
| return joinedPath.substring( 1 ); |
| } catch( ModuleNotFoundException e ) { | ||
| throw e; | ||
| } catch( URISyntaxException | IOException e ) { | ||
| throw new ModuleNotFoundException( importPath, Paths.get( source.getSchemeSpecificPart() ) ); |
Copilot
AI
Mar 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider including the caught exception as a cause when throwing ModuleNotFoundException to improve debugging information.
This PR is the continuation of the applying ModuleSource PR. This PR unlocks the module system to be usable within jap file.