Skip to content

Conversation

@jbdoderlein
Copy link
Contributor

This PR fix an error on import command inside the debug console of DAP.

The command import module at REPL level, and reload the module if it is already imported.

@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

❌ Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 46%. Comparing base (9f5843f) to head (5508bd6).

Files with missing lines Patch % Lines
src/org/rascalmpl/debug/DebugHandler.java 0% 13 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##              main   #2596   +/-   ##
=======================================
- Coverage       46%     46%   -1%     
+ Complexity    6637    6635    -2     
=======================================
  Files          793     793           
  Lines        65695   65707   +12     
  Branches      9840    9842    +2     
=======================================
  Hits         30500   30500           
- Misses       32835   32849   +14     
+ Partials      2360    2358    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@jurgenvinju jurgenvinju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good feature! For a future refactoring we could use the command parser instead of the regex. That way we keep the Rascal syntax in one place (Rascal.rsc)

Copy link
Member

@DavyLandman DavyLandman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we continue using the regex (which as @jurgenvinju has some maintainability challenges) we should make sure it matches closer to what the rascal syntax allows for. Such as escapes of module names if they overlap with a keyword of the language.

@jbdoderlein
Copy link
Contributor Author

Fixed, the import now use RascalParser

Comment on lines +285 to +295
IActionExecutor<ITree> actionExecutor = new NoActionExecutor();
ITree tree = new RascalParser().parse(Parser.START_COMMAND, DEBUGGER_PROMPT_LOCATION.getURI(), command.toCharArray(), INodeFlattener.UNLIMITED_AMB_DEPTH, actionExecutor, new DefaultNodeFlattener<IConstructor, ITree, ISourceLocation>(), new UPTRNodeFactory(false));
Command stat = new ASTBuilder().buildCommand(tree);
if (!stat.isImport()) {
return null;
}
Environment oldEnvironment = evaluator.getCurrentEnvt();
evaluator.setCurrentEnvt(evaluator.__getRootScope()); // For import we set the current module to the root to reload modules properly
Result<IValue> result = evaluator.eval(evaluator.getMonitor(), command, DEBUGGER_PROMPT_LOCATION);
evaluator.setCurrentEnvt(oldEnvironment);
return result;
Copy link
Member

@DavyLandman DavyLandman Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make sure that ParseError exceptions are caught, so that if something is not a command, it doesn't bubble up as an exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function is called inside the evaluate function that catch and display nicely ParseErrror, this is already the case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking was: now the following if body (that does evaluator.eval(...)) will never run. Which will most likely not happen, as it also parses the string in the same way. lets add a comment or something? it smells a bit fishy that we just assume line 327 is the same parse as the one inside Evaluator::eval

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