Skip to content

Commit b0ea5c2

Browse files
authored
Merge branch 'main' into fix/better-change-detection-for-extend
2 parents b330bb1 + ee7f5a1 commit b0ea5c2

File tree

6 files changed

+32
-2
lines changed

6 files changed

+32
-2
lines changed

src/org/rascalmpl/interpreter/env/GlobalEnvironment.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,4 +324,11 @@ public List<String> nonInitializedModules() {
324324
public void clearLookupChaches() {
325325
moduleEnvironment.values().forEach(ModuleEnvironment::clearLookupCaches);
326326
}
327+
328+
/**
329+
* This is for the tutor and eval; sometimes we do not want to keep seeing old messages
330+
*/
331+
public void clearModuleLoadMessage() {
332+
moduleEnvironment.values().forEach(ModuleEnvironment::clearLoadMessages);
333+
}
327334
}

src/org/rascalmpl/interpreter/env/ModuleEnvironment.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ public void clearLookupCaches() {
133133
cachedGeneralKeywordParameters = null;
134134
cachedPublicFunctions = null;
135135
}
136+
137+
/**
138+
* This is useful for the tutor and the eval repl where we
139+
* sometimes need to forget about previous errors without
140+
* actually fixing them. This is not for the real REPL, where
141+
* we _do_ want to be reminded of previous erroneous initializations.
142+
*/
143+
public void clearLoadMessages() {
144+
this.loadMessages.clear();
145+
}
136146

137147
public void extend(ModuleEnvironment other) {
138148
extendNameFlags(other);

src/org/rascalmpl/interpreter/result/ConstructorFunction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ public Result<IValue> computeDefaultKeywordParameter(String label, IConstructor
7979
Set<GenericKeywordParameters> kws = callerEnvironment.lookupGenericKeywordParameters(constructorType.getAbstractDataType());
8080
IWithKeywordParameters<? extends IConstructor> wkw = value.asWithKeywordParameters();
8181
Environment old = ctx.getCurrentEnvt();
82-
Environment resultEnv = new Environment(declarationEnvironment, URIUtil.rootLocation("initializer"), "keyword parameter initializer");
83-
82+
Environment resultEnv = new Environment(declarationEnvironment, callerEnvironment, callerEnvironment.getLocation(), URIUtil.rootLocation("initializer"), "keyword parameter initializer");
83+
8484
// first we compute the keyword parameters for the abstract data-type:
8585
for (GenericKeywordParameters gkw : kws) {
8686
// for hygiene's sake, each list of generic params needs to be evaluated in its declaring environment

src/org/rascalmpl/repl/rascal/RascalInterpreterREPL.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,4 +336,8 @@ protected void sourceLocationChanged(ISourceLocation srcPath, ISourceLocationCha
336336
dirtyModules.add(modName);
337337
}
338338
}
339+
340+
public void clearModuleLoadMessages() {
341+
eval.getHeap().clearModuleLoadMessage();
342+
}
339343
}

src/org/rascalmpl/tutor/lang/rascal/tutor/Compiler.rsc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,10 @@ list[Output] compileMarkdown([/^<prefix:.*>\[<title:[^\]]*>\]\(\(<link:[A-Za-z0-
716716
u = /^\/assets/ := u ? u : "<p2r><u>";
717717
return compileMarkdown(["<prefix>[<title>](<u>)<postfix>", *rest], line, offset, pcfg, exec, ind, dtls, sidebar_position=sidebar_position);
718718
}
719+
else if ({str u} := ind["<rootName(pcfg.currentRoot, pcfg.isPackageCourse)>:<removeSpaces(link)>"]) {
720+
u = /^\/assets/ := u ? u : "<p2r><u>";
721+
return compileMarkdown(["<prefix>[<title>](<u>)<postfix>", *rest], line, offset, pcfg, exec, ind, dtls, sidebar_position=sidebar_position);
722+
}
719723
720724
exactLinks = exactShortestLinks(ind, removeSpaces(link));
721725
@@ -772,6 +776,10 @@ default list[Output] compileMarkdown([/^<prefix:.*>\(\(<link:[A-Za-z0-9\-\ \t\.\
772776
u = /^\/assets/ := u ? u : "<p2r><u>";
773777
return compileMarkdown(["<prefix>[<addSpaces(link)>](<u>)<postfix>", *rest], line, offset, pcfg, exec, ind, dtls, sidebar_position=sidebar_position);
774778
}
779+
else if ({str u} := ind["<rootName(pcfg.currentRoot, pcfg.isPackageCourse)>:<removeSpaces(link)>"]) {
780+
u = /^\/assets/ := u ? u : "<p2r><u>";
781+
return compileMarkdown(["<prefix>[<title>](<u>)<postfix>", *rest], line, offset, pcfg, exec, ind, dtls, sidebar_position=sidebar_position);
782+
}
775783
776784
exactLinks = exactShortestLinks(ind, removeSpaces(link));
777785

src/org/rascalmpl/tutor/lang/rascal/tutor/repl/TutorCommandExecutor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ private static ISourceLocation inferProjectRoot(ISourceLocation member) {
142142
public void reset() {
143143
interpreter.cancelRunningCommandRequested();
144144
interpreter.cleanEnvironment();
145+
interpreter.clearModuleLoadMessages();
145146
outPrinter.flush();
146147
outWriter.getBuffer().setLength(0);
147148
errPrinter.flush();

0 commit comments

Comments
 (0)