Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kicito
Copy link
Contributor

@kicito kicito commented Mar 4, 2025

This PR is the continuation of the applying ModuleSource PR. This PR unlocks the module system to be usable within jap file.

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
@kicito kicito force-pushed the feature/jap-module-system branch from 5c60c14 to 0c18d9c Compare March 5, 2025 10:39
@kicito kicito marked this pull request as ready for review March 5, 2025 11:02
@mwallnoefer
Copy link
Member

Does it also address issue #230 ?

@fmontesi fmontesi requested a review from Copilot March 5, 2025 18:48
Copy link

Copilot AI left a 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 );
Copy link

Copilot AI Mar 5, 2025

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.

Suggested change
return String.join( "/", this.pathParts() ).substring( 1 );
String joinedPath = String.join( "/", this.pathParts() );
if (joinedPath.isEmpty()) {
return "";
}
return joinedPath.substring( 1 );

Copilot uses AI. Check for mistakes.
} catch( ModuleNotFoundException e ) {
throw e;
} catch( URISyntaxException | IOException e ) {
throw new ModuleNotFoundException( importPath, Paths.get( source.getSchemeSpecificPart() ) );
Copy link

Copilot AI Mar 5, 2025

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.

Copilot uses AI. Check for mistakes.
@fmontesi fmontesi merged commit 92df9f3 into jolie:master Mar 7, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants