diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc index 590e72af..5b2ad3b1 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc @@ -70,180 +70,6 @@ void rascalPreCollectInitialization(map[str, Tree] _namedTrees, Collector c){ c.push(key_allow_use_before_def, <|none:///|(0,0,<0,0>,<0,0>), |none:///|(0,0,<0,0>,<0,0>)>); } -//TODO: renact this when we will generate parsers -//void rascalPostSolver(map[str,Tree] namedTrees, Solver s){ -// if(!s.reportedErrors()){ -// for(mname <- namedTrees){ -// pt = namedTrees[mname]; -// g = addGrammar(getLoc(pt), s); -// if(!isEmpty(g.rules)){ -// pname = "DefaultParser"; -// if(Module m := pt) { -// moduleName = ""; -// pname = parserName(moduleName); -// } -// // = newGenerate(parserPackage, pname, g); -// //s.addMessages(msgs); -// //TODO: generates too long file names -// //msgs = saveParser(pname, parserClass, |project://rascal-core/src/org/rascalmpl/core/library/lang/rascalcore/grammar/tests/generated_parsers|, s.getConfig().verbose); -// //s.addMessages(msgs); -// } -// addADTsAndCommonKeywordFields(s); -// } -// } -//} - -// ---- Various PathConfigs --------------------------------------------- - -private int npc = 0; -@synopsis{PathConfig for testing generated modules in |memory://test-modules/| in memory file system, not depending on any outside libraries.} -@description{ -* gets source files exclusively from |memory://test-modules/| and |std:///| (for library code) -* generates bin files in the in-memory file system -} -public PathConfig getDefaultTestingPathConfig() { - npc += 1; - snpc = ""; - return pathConfig( - srcs = [ |memory:///test-modules/|, |std:///| ], - bin = |memory:///test-modules/rascal-core-tests-bin-|, - generatedSources = |memory:///test-modules/generated-test-sources-|, - resources = |memory:///test-modules/generated-test-resources-|, - libs = [ ] - ); -} - -@synopsis{PathConfig for testing generated modules in |memory://test-modules/| in memory file system, dependent on a previously released standard library} -@description{ -* gets source files exclusively from |memory://test-modules/| -* generates bin files in the in-memory file system -* depends only on the pre-compiled standard library from the rascal project -} -public PathConfig getReleasedStandardLibraryTestingPathConfig() { - npc += 1; - snpc = ""; - return pathConfig( - srcs = [ |memory:///test-modules/| ], - bin = |memory:///test-modules/rascal-core-tests-bin-|, - generatedSources = |memory:///test-modules/generated-test-sources-|, - resources = |memory:///test-modules/generated-test-resources-|, - libs = [ |lib://rascal| ] - ); -} - -@synopsis{PathConfig for type-checking test modules in the rascal-core project} -@description{ -* sources have to be in `|project://rascal-core/src/org/rascalmpl/core/library|` -* binaries will be stored the target folder of the rascal-core project -* has the standard library and typepal on the library path, in case you accidentally want to test a module in rascal-core which depends on typepal. -} -public PathConfig getRascalCorePathConfig() { - return pathConfig( - srcs = [ - |std:///|, - |project://rascal-core/src/org/rascalmpl/core/library|, - |project://typepal/src| - ], - bin = |project://rascal-core/target/test-classes|, - generatedSources = |project://rascal-core/target/generated-test-sources|, - resources = |project://rascal-core/target/generated-test-resources|, - libs = [] - ); -} - -public RascalCompilerConfig getRascalCoreCompilerConfig(){ - return rascalCompilerConfig(getRascalCorePathConfig())[verbose = true][forceCompilationTopModule = true][logWrittenFiles=true]; -} - -@synopsis{Developers version: PathConfig for type-checking modules in other (named) Rascal projects} -@description{ -* sources have to be in `|project://rascal-core/src/org/rascalmpl/core/library|` -* binaries will be stored the target folder of the rascal-core project -* has the standard library and typepal on the library path, in case you accidentally want to test a module in rascal-core which depends on typepal. -* Included projects: rascal-tutor, flybytes, rascal-lsp -} -public PathConfig getRascalCorePathConfigDev() { - return pathConfig( - srcs = [ - |project://rascal/src/org/rascalmpl/library|, - //|std:///|, - |project://rascal-core/src/org/rascalmpl/core/library|, - |project://typepal/src| - // |project://rascal-tutor/src|, - // |project://flybytes/src|, - // |project://salix/src|, - // |project://rascal-lsp/src/main/rascal/| - ], - bin = |project://generated-sources/target/classes|, - generatedSources = |project://generated-sources/target/generated-sources/src/main/java/|, - generatedTestSources = |project://generated-sources/target/generated-sources/src/main/java/|, - resources = |project://generated-sources/target/generated-resources/src/main/java/|, //|project://rascal-core/target/generated-test-resources|, - libs = [] - ); -} - -public RascalCompilerConfig getRascalCoreCompilerConfigDev(){ - return rascalCompilerConfig(getRascalCorePathConfigDev())[verbose = true][forceCompilationTopModule = true][logWrittenFiles=true]; -} - -public RascalCompilerConfig getRascalCoreCompilerConfig(PathConfig pcfg){ - return rascalCompilerConfig(pcfg); -} - -@synopsis{a path config for testing type-checking of the standard library in the rascal project} -public PathConfig getRascalProjectPathConfig() { - npc += 1; - snpc = ""; - return pathConfig( - srcs = [|project://rascal/src/org/rascalmpl/library|], - bin = |memory:///test-modules/rascal-lib-bin-|, - libs = [] - ); -} - -public PathConfig getTypePalProjectPathConfig() { - git = |file:///Users/paulklint/git/|; - return pathConfig( - srcs = [ git + "typepal/src" ], - bin = git + "generated-sources/typepal/target/classes", - generatedSources = git + "generated-sources/typepal/target/generated-sources/src/main/java/", - generatedTestSources = git + "generated-sources/typepal/target/generated-sources/src/main/java/", - resources = git + "generated-sources/typepal/target/generated-resources/src/main/java/", - libs = [ |jar+file:///Users/paulklint/.m2/repository/org/rascalmpl/rascal/0.40.8-SNAPSHOT/rascal-0.40.8-SNAPSHOT.jar!/| ] - ); -} - -public RascalCompilerConfig getTypePalCompilerConfig(PathConfig pcfg){ - return rascalCompilerConfig(pcfg)[verbose = true][forceCompilationTopModule = false][logWrittenFiles=true]; -} - -public RascalCompilerConfig getTypePalCompilerConfig(){ - return rascalCompilerConfig(getTypePalProjectPathConfig())[verbose = true][forceCompilationTopModule = false][logWrittenFiles=true]; -} - -public PathConfig getFlyBytesProjectPathConfig() { - git = |file:///Users/paulklint/git/|; - return pathConfig( - srcs = [ git + "flybytes/src" ], - bin = git + "generated-sources/flybytes/target/classes", - generatedSources = git + "generated-sources/flybytes/target/generated-sources/src/main/java/", - generatedTestSources = git + "generated-sources/flybytes/target/generated-sources/src/main/java/", - resources = git + "generated-sources/flybytes/target/generated-resources/src/main/java/", - libs = [ |jar+file:///Users/paulklint/.m2/repository/org/rascalmpl/rascal/0.40.8-SNAPSHOT/rascal-0.40.8-SNAPSHOT.jar!/| - ] - ); -} - -public RascalCompilerConfig getFlyBytesCompilerConfig(PathConfig pcfg){ - return rascalCompilerConfig(pcfg)[verbose = true][forceCompilationTopModule = false][logWrittenFiles=true]; -} - -public RascalCompilerConfig getFlyBytesCompilerConfig(){ - return rascalCompilerConfig(getFlyBytesProjectPathConfig()); -} - - - list[Message] validatePathConfigForChecker(PathConfig pcfg, loc mloc) { msgs = []; @@ -302,6 +128,9 @@ ModuleStatus rascalTModelForLocs( for (mloc <- mlocs) { m = getModuleName(mloc, pcfg); + if(isModuleLocationInLibs(mloc, pcfg)){ + ms.status[m] ? {} += rsc_not_found(); + } topModuleNames += {m}; ms.moduleLocs[m] = mloc; msgs += ms.messages[m] ? []; @@ -506,6 +335,10 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt for(str nm <- moduleNames){ ms.status[nm] = {}; ms.messages[nm] = []; + mloc = getModuleLocation(nm, pcfg); + if(mloc.extension != "rsc" || isModuleLocationInLibs(mloc, pcfg)){ + continue; + } = getModuleParseTree(nm, ms); if(success){ tagsMap = getTags(pt.header.tags); @@ -521,38 +354,43 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt // ms.messages[nm] += error("Cannot get parse tree for module ``", ms.moduleLocs[nm]); //} } + if(!isEmpty(namedTrees)){ + if(compilerConfig.verbose) { println("Checking ... "); } - if(compilerConfig.verbose) { println("Checking ... "); } - - start_check = cpuTime(); - c = newCollector(modelName, namedTrees, compilerConfig); - c.push(key_pathconfig, pcfg); + start_check = cpuTime(); + c = newCollector(modelName, namedTrees, compilerConfig); + c.push(key_pathconfig, pcfg); - rascalPreCollectInitialization(namedTrees, c); + rascalPreCollectInitialization(namedTrees, c); - added = {}; - for(str nm <- domain(namedTrees)){ - = loadImportsAndExtends(nm, ms, c, added); - added += a; - } + added = {}; + for(str nm <- domain(namedTrees)){ + = loadImportsAndExtends(nm, ms, c, added); + added += a; + } - for(str nm <- namedTrees){ - collect(namedTrees[nm], c); - } - tm = c.run(); + for(str nm <- namedTrees){ + collect(namedTrees[nm], c); + } + tm = c.run(); - tm.paths = ms.paths; + tm.paths = ms.paths; - if(!isEmpty(namedTrees)){ - s = newSolver(namedTrees, tm); - tm = s.run(); - } - //iprintln(tm.messages); + if(!isEmpty(namedTrees)){ + s = newSolver(namedTrees, tm); + tm = s.run(); + } + //iprintln(tm.messages); - check_time = (cpuTime() - start_check)/1000000; + check_time = (cpuTime() - start_check)/1000000; - if(compilerConfig.verbose) { println("Checked .... in ms"); } - return ; + if(compilerConfig.verbose) { println("Checked .... in ms"); } + return ; + } else { + ms.status[modelName]? {} += tpl_saved(); + = getTModelForModule(modelName, ms); + return ; + } } // ---- rascalTModelForName a checker version that works on module names diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/TestConfigs.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/TestConfigs.rsc new file mode 100644 index 00000000..478cdead --- /dev/null +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/TestConfigs.rsc @@ -0,0 +1,201 @@ +module lang::rascalcore::check::TestConfigs + +import util::Reflective; +import lang::rascalcore::check::BasicRascalConfig; +import lang::rascalcore::check::RascalConfig; + +// Duplicate in lang::rascalcore::compile::util::Names, factor out +data PathConfig( + loc generatedSources=|unknown:///|, + loc generatedTestSources=|unknown:///|, + loc resources = |unknown:///|, + loc testResources =|unknown:///| +); + +// ---- Various PathConfigs --------------------------------------------- + +loc REPO = |file:///Users/paulklint/git/|; +loc RASCAL_JAR = |jar+file:///Users/paulklint/.m2/repository/org/rascalmpl/rascal/0.40.8-SNAPSHOT/rascal-0.40.8-SNAPSHOT.jar!/|; +loc TYPEPAL_JAR = |jar+file:///Users/paulklint/.m2/repository/org/rascalmpl/typepal/0.13.5-SNAPSHOT/typepal-0.13.5-SNAPSHOT.jar!/|; + +// ---- PathConfigs for testing purposes -------------------------------------- + +private int npc = 0; +@synopsis{PathConfig for testing generated modules in |memory://test-modules/| in memory file system, not depending on any outside libraries.} +@description{ +* gets source files exclusively from |memory://test-modules/| and |std:///| (for library code) +* generates bin files in the in-memory file system +} +public PathConfig getDefaultTestingPathConfig() { + npc += 1; + snpc = ""; + return pathConfig( + srcs = [ |memory:///test-modules/|, |std:///| ], + bin = |memory:///test-modules/rascal-core-tests-bin-|, + generatedSources = |memory:///test-modules/generated-test-sources-|, + resources = |memory:///test-modules/generated-test-resources-|, + libs = [ ] + ); +} + +@synopsis{PathConfig for testing generated modules in |memory://test-modules/| in memory file system, dependent on a previously released standard library} +@description{ +* gets source files exclusively from |memory://test-modules/| +* generates bin files in the in-memory file system +* depends only on the pre-compiled standard library from the rascal project +} +public PathConfig getReleasedStandardLibraryTestingPathConfig() { + npc += 1; + snpc = ""; + return pathConfig( + srcs = [ |memory:///test-modules/| ], + bin = |memory:///test-modules/rascal-core-tests-bin-|, + generatedSources = |memory:///test-modules/generated-test-sources-|, + resources = |memory:///test-modules/generated-test-resources-|, + libs = [ |lib://rascal| ] + ); +} + +// ---- testing rascal standard library --------------------------------------- + +@synopsis{a path config for testing type-checking of the standard library in the rascal project} +public PathConfig getRascalProjectTestingPathConfig() { + npc += 1; + snpc = ""; + return pathConfig( + srcs = [|project://rascal/src/org/rascalmpl/library|], + bin = |memory:///test-modules/rascal-lib-bin-|, + libs = [] + ); +} + +// ---- rascal ---------------------------------------------------------------- + +public PathConfig getRascalPathConfig() { + return pathConfig( + srcs = [ REPO + "rascal/src/org/rascalmpl/library" ], + bin = REPO + "generated-sources/target/rascal/test-classes", + bin = REPO + "generated-sources/target/rascal/classes", + generatedSources = REPO + "generated-sources/target/rascal/generated-sources/src/main/java/", + generatedTestSources = REPO + "generated-sources/target/rascal/generated-sources/src/main/java/", + resources = REPO + "generated-sources/target/rascal/generated-resources/src/main/java/", + libs = [ ] + ); +} + +public RascalCompilerConfig getRascalCompilerConfig(){ + return rascalCompilerConfig(getRascalPathConfig())[verbose = true][forceCompilationTopModule = true][logWrittenFiles=true]; +} + +// ---- rascal-core ----------------------------------------------------------- + +@synopsis{PathConfig for type-checking test modules in the rascal-core project} +@description{ +* sources have to be in `|project://rascal-core/src/org/rascalmpl/core/library|` +* binaries will be stored the target folder of the rascal-core project +* has the standard library and typepal on the library path, in case you accidentally want to test a module in rascal-core which depends on typepal. +} +public PathConfig getRascalCorePathConfig() { + return pathConfig( + srcs = [ REPO + "rascal-core/src/" ], + bin = |project://rascal-core/target/test-classes|, + bin = REPO + "generated-sources/target/rascal-core/classes", + generatedSources = REPO + "generated-sources/target/rascal-core/generated-sources/src/main/java/", + generatedTestSources = REPO + "generated-sources/target/rascal-core/generated-sources/src/main/java/", + resources = REPO + "generated-sources/target/rascal-core/generated-resources/src/main/java/", + libs = [ RASCAL_JAR, TYPEPAL_JAR ] + ); +} + +public RascalCompilerConfig getRascalCoreCompilerConfig(){ + return rascalCompilerConfig(getRascalCorePathConfig())[verbose = true][forceCompilationTopModule = true][logWrittenFiles=true]; +} + +@synopsis{Developers version: PathConfig for type-checking modules in other (named) Rascal projects} +@description{ +* sources have to be in `|project://rascal-core/src/org/rascalmpl/core/library|` +* binaries will be stored the target folder of the rascal-core project +* has the standard library and typepal on the library path, in case you accidentally want to test a module in rascal-core which depends on typepal. +* Included projects: rascal-tutor, flybytes, rascal-lsp +} +public PathConfig getRascalCorePathConfigDev() { + return pathConfig( + srcs = [ REPO + "rascal-core/src" ], + bin = REPO + "generated-sources/target/rascal-core/classes", + generatedSources = REPO + "generated-sources/target/rascal-core/generated-sources/src/main/java/", + generatedTestSources = REPO + "generated-sources/target/rascal-core/generated-sources/src/main/java/", + resources = REPO + "generated-sources/target/rascal-core/generated-resources/src/main/java/", + libs = [ RASCAL_JAR, TYPEPAL_JAR ] + ); +} + +public RascalCompilerConfig getRascalCoreCompilerConfigDev(){ + return rascalCompilerConfig(getRascalCorePathConfigDev())[verbose = true][forceCompilationTopModule = true][logWrittenFiles=true]; +} + +public RascalCompilerConfig getRascalCoreCompilerConfigDev(PathConfig pcfg){ + return rascalCompilerConfig(pcfg); +} + + + +// ---- typepal --------------------------------------------------------------- + +public PathConfig getTypePalProjectPathConfig() { + return pathConfig( + srcs = [ REPO + "typepal/src" ], + bin = REPO + "generated-sources/target/typepal/classes", + generatedSources = REPO + "generated-sources/target/typepal/generated-sources/src/main/java/", + generatedTestSources = REPO + "generated-sources/target/typepal/generated-sources/src/main/java/", + resources = REPO + "generated-sources/target/typepal/generated-resources/src/main/java/", + libs = [ RASCAL_JAR ] + ); +} + +public RascalCompilerConfig getTypePalCompilerConfig(PathConfig pcfg){ + return rascalCompilerConfig(pcfg)[verbose = true][forceCompilationTopModule = false][logWrittenFiles=true]; +} + +public RascalCompilerConfig getTypePalCompilerConfig(){ + return rascalCompilerConfig(getTypePalProjectPathConfig())[verbose = true][forceCompilationTopModule = false][logWrittenFiles=true]; +} + +// ---- salix ----------------------------------------------------------------- + +public PathConfig getFlyBytesProjectPathConfig() { + return pathConfig( + srcs = [ REPO + "flybytes/src" ], + bin = REPO + "generated-sources/target/flybytes/classes", + generatedSources = REPO + "generated-sources/target/flybytes/generated-sources/src/main/java/", + generatedTestSources = REPO + "generated-sources/target/flybytes/generated-sources/src/main/java/", + resources = REPO + "generated-sources/target/flybytes/generated-resources/src/main/java/", + libs = [ RASCAL_JAR ] + ); +} + +public RascalCompilerConfig getFlyBytesCompilerConfig(PathConfig pcfg){ + return rascalCompilerConfig(pcfg)[verbose = true][forceCompilationTopModule = false][logWrittenFiles=true]; +} + +public RascalCompilerConfig getFlyBytesCompilerConfig(){ + return rascalCompilerConfig(getFlyBytesProjectPathConfig()); +} + +public PathConfig getSalixProjectPathConfig() { + return pathConfig( + srcs = [ REPO + "salix/src" ], + bin = REPO + "generated-sources/target/salix/classes", + generatedSources = REPO + "generated-sources/target/salix/generated-sources/src/main/java/", + generatedTestSources = REPO + "generated-sources/target/salix/generated-sources/src/main/java/", + resources = REPO + "generated-sources/target/salix/generated-resources/src/main/java/", + libs = [ RASCAL_JAR ] + ); +} + +public RascalCompilerConfig getSalixCompilerConfig(PathConfig pcfg){ + return rascalCompilerConfig(pcfg)[verbose = true][forceCompilationTopModule = false][logWrittenFiles=true]; +} + +public RascalCompilerConfig getSalixCompilerConfig(){ + return rascalCompilerConfig(getSalixProjectPathConfig()); +}