Skip to content

Commit

Permalink
Turn off info in case of unused extend
Browse files Browse the repository at this point in the history
In the future we may want to control this via a compiler option or an annotation in the Rascal source code
  • Loading branch information
PaulKlint committed Oct 10, 2024
1 parent db5f820 commit 65e26d1
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ ModuleStatus rascalTModelForLocs(
if(checked() in ms.status[iname] && rsc_not_found() notin ms.status[iname]){
if(imod is \default){
msgs += warning("Unused import of `<iname>`", imod@\loc);
} else {
msgs += info("Extended module `<iname>` is unused in the current module", imod@\loc);
}
} //else { //TODO: maybe add option to turn off info messages?
//msgs += info("Extended module `<iname>` is unused in the current module", imod@\loc);
//}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,68 @@
module lang::rascalcore::compile::Examples::Tst4

import ParseTree;
import String;
import lang::rascalcore::check::Checker;
import lang::rascalcore::check::BasicRascalConfig;
import lang::rascalcore::check::RascalConfig;
import IO;
import Message;
import Map;
import util::FileSystem;
import util::Reflective;

public str squeeze(str src, type[&CharClass <: ![]] _) = visit(src) {
case /<c:.><c>+/ => c
when &CharClass _ := /*Tree::*/char(charAt(c, 0))
};
tuple[PathConfig, RascalCompilerConfig] testConfigs(loc projectPath) {
pcfg = pathConfig(
bin=projectPath + "bin",
libs=[|home:///.m2/repository/org/rascalmpl/rascal/0.40.10/rascal-0.40.10.jar|],
srcs=[projectPath + "src"],
resources=projectPath + "resources",
generatedSources=projectPath + "generated-sources"
);

RascalCompilerConfig ccfg = rascalCompilerConfig(pcfg)
[forceCompilationTopModule = true]
[verbose = true];

return <pcfg, ccfg>;
}

ModuleStatus checkModule(loc projectPath, str moduleName, str moduleBody, RascalCompilerConfig ccfg) {
modulePath = projectPath + "src" + "<moduleName>.rsc";
writeFile(modulePath, moduleBody);
return rascalTModelForLocs([modulePath], ccfg, dummy_compile1);
}

void noTmodel(loc projectPath = |memory:///NoTModelTest|) {
remove(projectPath);
<pcfg, ccfg> = testConfigs(projectPath);

moduleName = "M";
moduleStr = "
'module <moduleName>
'
'void main() {
' int foo = x + y;
'}
";

if(ms := checkModule(projectPath, moduleName, moduleStr, ccfg)) {
if (size(ms.tmodels) > 0) { // This branch is expected to be taken
println("Success!");
} else { // This branch is taken instead
println("Failure...");
println("TModels: <ms.tmodels>");
}
} else {
println("checkModule failed");
}
}

// import ParseTree;
// import String;

// public str squeeze(str src, type[&CharClass <: ![]] _) = visit(src) {
// case /<c:.><c>+/ => c
// when &CharClass _ := Tree::char(charAt(c, 0))
// };

// void f(int n){
// [x | x <- [0..n], [x] := [x], x > 0];
Expand Down

0 comments on commit 65e26d1

Please sign in to comment.