diff --git a/src/org/rascalmpl/library/IO.rsc b/src/org/rascalmpl/library/IO.rsc index a3535ef9bbf..4681445d487 100644 --- a/src/org/rascalmpl/library/IO.rsc +++ b/src/org/rascalmpl/library/IO.rsc @@ -151,23 +151,6 @@ Otherwise, the same method of deciding the character set is used as in ((readFil public java void appendToFile(loc file, value V..., str charset=DEFAULT_CHARSET, bool inferCharset=!(charset?)) throws PathNotFound, IO; -@synopsis{Append a value to a file.} -@description{ -Append a textual representation of some values to an existing or a newly created file: - -* If a value is a simple string, the quotes are removed and the contents are de-escaped. -* If a value has a non-terminal type, the parse tree is unparsed to produce a value. -* All other values are printed as-is. -* Each value is terminated by a newline character. - -Files are encoded using the charset provided. -} -@deprecated{ -Use `appendToFile(file, V, charset=DEFAULT_CHARSET)` instead. -} -public void appendToFileEnc(loc file, str charset, value V...) throws PathNotFound, IO - = appendToFile(file, V, charset=charset, inferCharset=false); - @synopsis{Returns all available character sets.} @javaClass{org.rascalmpl.library.Prelude} public java set[str] charsets(); @@ -551,7 +534,7 @@ Also see ((readFileLines)). } @encoding{ A text file can be encoded in many different character sets, most common are UTF8, ISO-8859-1, and ASCII. -If you know the encoding of the file, please use the ((readFileEnc)) and ((readFileLinesEnc)) overloads. +If you know the encoding of the file, please use the `charset` argument. If you do not know, we try to detect this. This detection is explained below: * If the implementation of the used scheme in the location @@ -575,17 +558,6 @@ the first 32 bytes of the file are not valid UTF-8. public java str readFile(loc file, str charset=DEFAULT_CHARSET, bool inferCharset=!(charset?)) throws PathNotFound, IO; -@synopsis{Read the contents of a location and return it as string value.} -@description{ -Return the contents (decoded using the Character set supplied) of a file location as a single string. -Also see ((readFileLinesEnc)). -} -@deprecated{ -Use `readFile(file, inferCharset=false, charset=DEFAULT_CHARSET)` instead. -} -public str readFileEnc(loc file, str charset) throws PathNotFound, IO - = readFile(file, inferCharset=false, charset=charset); - @synopsis{Read the content of a file and return it as a base-64 encoded string.} @description { } @@ -593,11 +565,6 @@ public str readFileEnc(loc file, str charset) throws PathNotFound, IO public java str readBase64(loc file, bool includePadding=true) throws PathNotFound, IO; -@deprecated{ -Use readBase64 instead. -} -public str uuencode(loc file) = readBase64(file); - @synopsis{Decode a base-64 encoded string and write the resulting bytes to a file.} @description { } @@ -605,11 +572,6 @@ public str uuencode(loc file) = readBase64(file); public java void writeBase64(loc file, str content) throws PathNotFound, IO; -@deprecated{ -Use writeBase64 instead. -} -public void uudecode(loc file, str content) = writeBase64(file, content); - @synopsis{Read the content of a file and return it as a base-32 encoded string.} @description { } @@ -661,19 +623,6 @@ public void writeFileLines(loc file, list[str] lines, str charset=DEFAULT_CHARSE charset=charset); } -@synopsis{Read the contents of a file location and return it as a list of strings.} -@description{ -Return the contents (decoded using the Character set supplied) of a file location as a list of lines. -Also see ((readFileLines)). -} -@deprecated{ -Use `readFileLines(file, charset=DEFAULT_CHARSET)` instead. -} -public list[str] readFileLinesEnc(loc file, str charset) -throws PathNotFound, IO - = readFileLines(file, charset=charset); - - @javaClass{org.rascalmpl.library.Prelude} @synopsis{Remove files or directories} public java void remove(loc file, bool recursive=true) throws IO; @@ -700,7 +649,7 @@ Write a textual representation of some values to a file: * All other values are printed as-is. * Each value is terminated by a newline character. -Files are encoded in UTF-8, in case this is not desired, use ((writeFileEnc)). +Files are encoded in UTF-8, in case this is not desired, use the `charset` argument. } @javaClass{org.rascalmpl.library.Prelude} public java void writeFile(loc file, value V..., str charset=DEFAULT_CHARSET) @@ -711,25 +660,6 @@ throws PathNotFound, IO; public java void writeFileBytes(loc file, list[int] bytes) throws PathNotFound, IO; - -@synopsis{Write values to a file.} -@description{ -Write a textual representation of some values to a file: - -* If a value is a simple string, the quotes are removed and the contents are de-escaped. -* If a value has a non-terminal type, the parse tree is unparsed to produce a value. -* All other values are printed as-is. -* Each value is terminated by a newline character. - -Files are encoded using the charset provided. -} -@deprecated{ -Use `writeFile(file, charset=...)` instead. -} -public void writeFileEnc(loc file, str charset, value V...) throws PathNotFound, IO - = writeFile(file, V, charset=charset); - - @synopsis{Read the contents of a location and return its MD5 hash.} @description{ MD5 hash the contents of a file location. @@ -745,31 +675,9 @@ public java str md5Hash(value v); @javaClass{org.rascalmpl.library.Prelude} public java str createLink(str title, str target); - -@javaClass{org.rascalmpl.library.Prelude} -@deprecated{ -Use `readBase64` instead. -} -public java str toBase64(loc file, bool includePadding=true) -throws PathNotFound, IO; - @javaClass{org.rascalmpl.library.Prelude} java void copy(loc source, loc target, bool recursive=false, bool overwrite=true) throws IO; -@deprecated{ -Use the `copy` function instead -} -void copyFile(loc source, loc target) { - copy(source, target, recursive=false, overwrite=true); -} - -@deprecated{ -Use the `copy` function instead -} -void copyDirectory(loc source, loc target) { - copy(source, target, recursive=true, overwrite=true); -} - @javaClass{org.rascalmpl.library.Prelude} @synopsis{Is an alias for ((rename))} java void move(loc source, loc target, bool overwrite=true) throws IO; diff --git a/src/org/rascalmpl/library/Node.rsc b/src/org/rascalmpl/library/Node.rsc index d05dd36d233..13a4635ae93 100644 --- a/src/org/rascalmpl/library/Node.rsc +++ b/src/org/rascalmpl/library/Node.rsc @@ -49,11 +49,6 @@ getKeywordParameters("f"(10, "abc", height=0)); @javaClass{org.rascalmpl.library.Prelude} public java map[str,value] getKeywordParameters(node T); -@deprecated{ -Use getKeywordParameters(T) -} -public map[str, value] getAnnotations(node T) = getKeywordParameters(T); - @synopsis{Set the keyword parameters of a node.} @examples{ @@ -65,24 +60,17 @@ setKeywordParameters("f"(10, "abc"), ("height":0)); @javaClass{org.rascalmpl.library.Prelude} public java &T <: node setKeywordParameters(&T <: node x, map[str,value] keywordParameters); -// @synopsis{Adds new keyword parameters to a node, keeping the existing ones unless there is an entry in the new map.} -// @examples{ -// ```rascal-shell -// import Node; -// mergeKeywordParameters("f"(10, "abc", width=10), ("height":0)); -// ``` -// } -// @javaClass{org.rascalmpl.library.Prelude} -// TODO: uncomment after bootstrap -// public java &T <: node mergeKeywordParameters(&T <: node x, map[str,value] keywordParameters); +@synopsis{Adds new keyword parameters to a node, keeping the existing ones unless there is an entry in the new map.} +@examples{ +```rascal-shell +import Node; +mergeKeywordParameters("f"(10, "abc", width=10), ("height":0)); +``` +} +@javaClass{org.rascalmpl.library.Prelude} +public java &T <: node mergeKeywordParameters(&T <: node x, map[str,value] keywordParameters); -@deprecated{ -Use setKeywordParameters(x, keywordParameters) -} -public &T <: node setAnnotations(&T <: node x, map[str,value] keywordParameters) - = setKeywordParameters(x, keywordParameters); - @synopsis{Determine the name of a node.} @examples{ @@ -110,11 +98,6 @@ public java node makeNode(str N, value V..., map[str, value] keywordParameters = @javaClass{org.rascalmpl.library.Prelude} public java &T <: node unset(&T <: node x, str keywordParameter); -@deprecated{ -Use unset(x, kw) -} -public &T <: node delAnnotation(&T <: node x, str keywordParameter) = unset(x, keywordParameter); - @synopsis{Reset a set of keyword parameters back to their default on a node.} public &T <: node unset(&T <: node x, set[str] keywordParameters){ @@ -130,21 +113,11 @@ public &T <: node unset(&T <: node x, set[str] keywordParameters){ @javaClass{org.rascalmpl.library.Prelude} public java &T <: node unset(&T <: node x); -@deprecated{ -Use `unset(x)` -} -public &T <: node delAnnotations(&T <: node x) = unset(x); - @synopsis{Recursively reset all keyword parameters of the node and its children back to their default.} @javaClass{org.rascalmpl.library.Prelude} public java &T unsetRec(&T x); -@deprecated{ -Use `unsetRec(x)` -} -public &T delAnnotationsRec(&T x) = unsetRec(x); - @synopsis{Recursively reset a specific keyword parameter of the node and its children back to its default.} public &T unsetRec(&T x, str keywordParameter) = visit(x) { diff --git a/src/org/rascalmpl/library/Set.rsc b/src/org/rascalmpl/library/Set.rsc index 2e40e3f1a36..374f54b0760 100644 --- a/src/org/rascalmpl/library/Set.rsc +++ b/src/org/rascalmpl/library/Set.rsc @@ -218,23 +218,6 @@ power1({1,2,3,4}); } public set[set[&T]] power1(set[&T] st) = power(st) - {{}}; -@synopsis{Apply a function to successive elements of a set and combine the results.} -@description{ -Apply the function `fn` to successive elements of set `s` starting with `unit`. -} -@examples{ -```rascal-shell -import Set; -int add(int x, int y) { return x + y; } -reducer({10, 20, 30, 40}, add, 0); -``` -} -@deprecated{Use a reducer expression instead, such as `(init | fn(it,e) | e <- st)`.} -public &T reducer(set[&T] st, &T (&T,&T) fn, &T unit) = - (unit | fn(it,elm) | elm <- st); - -public &T reducer(set[&T] _:{}) { throw EmptySet(); } - @synopsis{Determine the number of elements in a set.} @examples{ diff --git a/src/org/rascalmpl/library/String.rsc b/src/org/rascalmpl/library/String.rsc index c3122cf3e2e..b75854bc1ec 100644 --- a/src/org/rascalmpl/library/String.rsc +++ b/src/org/rascalmpl/library/String.rsc @@ -527,24 +527,6 @@ beans "); public java str trim(str s); -@synopsis{Squeeze repeated occurrences of characters.} -@description{ -Squeeze repeated occurrences in `src` of characters in `charSet` removed. -See http://commons.apache.org/lang/api-2.6/index.html?org/apache/commons/lang/text/package-summary.html[Apache] -for the allowed syntax in `charSet`. -} -@examples{ -```rascal-shell -import String; -squeeze("hello", "el"); -// the other squeeze function uses character class types instead: -squeeze("hello", "el") == squeeze("hello", #[el]); -``` -} -@javaClass{org.rascalmpl.library.Prelude} -@deprecated{Use the other squeeze function that accepts Rascal character class syntax.} -public java str squeeze(str src, str charSet); - @synopsis{Squeeze repeated occurrences of characters.} @description{ Squeeze repeated occurrences in `src` of characters, if they are a member of `&CharClass`, removed. @@ -638,30 +620,6 @@ public java str wrap(str src, int wrapLength); private java str format(str s, str dir, int n, str pad); -@synopsis{Determine if a string matches the given (Java-syntax) regular expression.} -@javaClass{org.rascalmpl.library.Prelude} -@deprecated{ -Use `/re/ := s` instead -} -public java bool rexpMatch(str s, str re); - - -@synopsis{Convert a string value to a (source code) location.} -@description{ -* Converts string `s` to a location. -* If the scheme is not provided, it is assumed to be `cwd`. -} -@examples{ -```rascal-shell -import String; -toLocation("http://grammarware.net"); -toLocation("document.xml"); -``` -} -@deprecated{Use ((lang::paths::Windows::parseWindowsPath)) for example; toLocation does not handle all intricacies of path notation.} -public loc toLocation(str s) = (/\:\/\// := s) ? |://| : |cwd:///|; - - @synopsis{Substitute substrings in a string based on a substitution map from location to string.} @examples{ ```rascal-shell diff --git a/src/org/rascalmpl/library/analysis/diff/edits/ExecuteTextEdits.rsc b/src/org/rascalmpl/library/analysis/diff/edits/ExecuteTextEdits.rsc index c06600a5be5..ab98bd03f97 100644 --- a/src/org/rascalmpl/library/analysis/diff/edits/ExecuteTextEdits.rsc +++ b/src/org/rascalmpl/library/analysis/diff/edits/ExecuteTextEdits.rsc @@ -19,12 +19,6 @@ import IO; import List; import String; -@synopsis{Execute file changes, including in-file edits if present.} -@deprecated{Replaced by ((executeFileSystemChanges)) due to a rename of the concept.} -void executeDocumentEdits(list[FileSystemChange] edits) { - executeFileSystemChanges(edits); -} - @synopsis{Execute file changes, including in-file edits if present.} void executeFileSystemChanges(list[FileSystemChange] edits) { for (e <- edits) { diff --git a/src/org/rascalmpl/library/analysis/diff/edits/TextEdits.rsc b/src/org/rascalmpl/library/analysis/diff/edits/TextEdits.rsc index 93670400f44..8b6fe42b92c 100644 --- a/src/org/rascalmpl/library/analysis/diff/edits/TextEdits.rsc +++ b/src/org/rascalmpl/library/analysis/diff/edits/TextEdits.rsc @@ -29,10 +29,6 @@ module analysis::diff::edits::TextEdits extend analysis::diff::edits::FileSystemChanges; -@synopsis{For compatibility we rename FileSystemChange to DocumentEdit} -@deprecated{It's better to use ((FileSystemChange)) for future compatibility.} -alias DocumentEdit = FileSystemChange; - @synopsis{For some FileSystemChanges we know exactly what happened.} data FileSystemChange = changed(loc file, list[TextEdit] edits) diff --git a/src/org/rascalmpl/library/analysis/m3/Core.rsc b/src/org/rascalmpl/library/analysis/m3/Core.rsc index f2d09ef9e2e..e80c3392720 100644 --- a/src/org/rascalmpl/library/analysis/m3/Core.rsc +++ b/src/org/rascalmpl/library/analysis/m3/Core.rsc @@ -236,24 +236,6 @@ M3 modifyM3(loc id, list[M3] models, value (&T,&T) fun) { bool isEmpty(M3 model) = model.id.scheme == "unknown"; -@deprecated{Does not make much sense since containment usually contains only logical locations.} -set[loc] files(M3 model) { - todo = top(model.containment); - done = {}; - - while (todo != {}) { - = takeOneFrom(todo); - if (isDirectory(elem)) { - todo += model.containment[elem]; - } - else { - done += elem; - } - } - - return done; -} - @synopsis{Transform the containment relation to a recursive tree model} @description{ This makes the containment relation into an abstract ((FileSystem)) for further analysis, diff --git a/src/org/rascalmpl/library/lang/csv/IO.rsc b/src/org/rascalmpl/library/lang/csv/IO.rsc index 1e1b3753f71..ba83c88749e 100644 --- a/src/org/rascalmpl/library/lang/csv/IO.rsc +++ b/src/org/rascalmpl/library/lang/csv/IO.rsc @@ -100,13 +100,6 @@ R1 = readCSV(|project://rascal/src/org/rascalmpl/library/lang/csv/examples/ex1.c @javaClass{org.rascalmpl.library.lang.csv.IO} public java value readCSV(loc location, bool header = true, str separator = ",", str encoding = "UTF8"); -@deprecated{ -Use readCSV with keyword parameters -} -public value readCSV(loc location, map[str,str] options) { - return readCSV(location, header = ((options["header"]?"true") == "true"), separator = options["separator"]?","); -} - @javaClass{org.rascalmpl.library.lang.csv.IO} public java &T readCSV(type[&T] result, loc location, bool header = true, str separator = ",", str encoding = "UTF8"); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/basic/IO.rsc b/src/org/rascalmpl/library/lang/rascal/tests/basic/IO.rsc index b198284ac22..5fbd1b2052a 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/basic/IO.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/basic/IO.rsc @@ -33,13 +33,13 @@ map[Encoding, str] encodingNames = (utf8() : "UTF-8", utf16le() : "UTF-16LE", test bool correctEncoding(Encoding enc, str content) { content = removeZeroIAmbBOM(enc, content); - writeFileEnc(aFile, encodingNames[enc], content); - return readFileEnc(aFile, encodingNames[enc]) == content; + writeFile(aFile, content, charset=encodingNames[enc]); + return readFile(aFile, charset=encodingNames[enc]) == content; } test bool correctEncodingImplicit(Encoding enc, str content) { content = removeZeroIAmbBOM(enc, content); - writeFileEnc(aFile, encodingNames[enc], content); + writeFile(aFile, content, charset=encodingNames[enc]); return readFile(aFile) == content; } @@ -53,8 +53,8 @@ public str removeZeroIAmbBOM(Encoding enc, str s) { test bool appendWorksCorrectly(Encoding enc, str a, str b) { a = removeZeroIAmbBOM(enc, a); b = removeZeroIAmbBOM(enc, b); - writeFileEnc(aFile, encodingNames[enc], a); - appendToFileEnc(aFile, encodingNames[enc], b); + writeFile(aFile, a, charset=encodingNames[enc]); + appendToFile(aFile, b, charset=encodingNames[enc]); r = readFile(aFile); if (r != a + b) { println("a: "); @@ -68,23 +68,23 @@ test bool appendWorksCorrectly(Encoding enc, str a, str b) { test bool appendWorksCorrectlyImplicit(Encoding enc, str a, str b) { a = removeZeroIAmbBOM(enc, a); b = removeZeroIAmbBOM(enc, b); - writeFileEnc(aFile, encodingNames[enc], a); + writeFile(aFile, a, charset=encodingNames[enc]); appendToFile(aFile, b); return readFile(aFile) == a + b; } test bool readOffsetStart(str a, str b) { if (a != "", b != "", size(a) + size(b) == size(a + b)) { - writeFileEnc(aFile, "UTF8", a + b); - return readFileEnc(aFile[offset=0][length=size(a)], "utf8") == a; + writeFile(aFile, a + b); + return readFile(aFile[offset=0][length=size(a)]) == a; } return true; } test bool readOffsetEnd(str a, str b) { if (size(a) + size(b) == size(a + b)) { - writeFileEnc(aFile, "UTF8", a + b); - return readFileEnc(aFile[offset=size(a)][length=size(b)], "utf8") == b; + writeFile(aFile, a + b); + return readFile(aFile[offset=size(a)][length=size(b)]) == b; } return true; } @@ -92,14 +92,14 @@ test bool readOffsetEnd(str a, str b) { test bool readOffsetMiddle(str a, str b, str c) { if (size(a) == 0 || size(b) == 0) return true; if (size(a) + size(b) + size(c) == size(a + b + c)) { - writeFileEnc(aFile, "UTF8", a + b + c); - return readFileEnc(aFile[offset=size(a)][length=size(b)], "utf8") == b; + writeFile(aFile, a + b + c); + return readFile(aFile[offset=size(a)][length=size(b)]) == b; } return true; } test bool md5Hash(){ - writeFileEnc(|memory://test-tmp/basic-io-md5.txt|, encodingNames[utf8()], "abc\n123\n!@#$%\n"); + writeFile(|memory://test-tmp/basic-io-md5.txt|, "abc\n123\n!@#$%\n"); return md5HashFile(|memory://test-tmp/basic-io-md5.txt|) == "931210fcfae2c4979e5d51a264648b82"; } @@ -134,8 +134,8 @@ test bool compressionWorks(str a, Compression comp) { test bool compressionWorksWithEncoding(str a, Compression comp, Encoding enc) { targetFile = aFile[extension = aFile.extension + "." + comprExtension[comp]]; targetFile = targetFile[scheme = "compressed+" + targetFile.scheme]; - writeFileEnc(targetFile, encodingNames[enc], a); - return readFileEnc(targetFile, encodingNames[enc]) == a; + writeFile(targetFile, a, charset=encodingNames[enc]); + return readFile(targetFile, charset=encodingNames[enc]) == a; } @expected{PathNotFound} @@ -158,10 +158,10 @@ test bool writeFileOffsetEnd(Encoding enc, str a, str b) { if (a == "" || b == "") { return true; } - writeFileEnc(aFile, encodingNames[enc], a); + writeFile(aFile, a, charset=encodingNames[enc]); l2 = aFile[offset=size(a)][length=0]; - writeFileEnc(l2, encodingNames[enc], b); - return readFileEnc(aFile, encodingNames[enc]) == a + b; + writeFile(l2, b, charset=encodingNames[enc]); + return readFile(aFile, charset=encodingNames[enc]) == a + b; } test bool writeFileOffsetEndInvalidLength(Encoding enc, str a, str b) { a = removeZeroIAmbBOM(enc, a); @@ -169,10 +169,10 @@ test bool writeFileOffsetEndInvalidLength(Encoding enc, str a, str b) { if (a == "" || b == "") { return true; } - writeFileEnc(aFile, encodingNames[enc], a); + writeFile(aFile, a, charset=encodingNames[enc]); l2 = aFile[offset=size(a)][length=10]; - writeFileEnc(l2, encodingNames[enc], b); - return readFileEnc(aFile, encodingNames[enc]) == a + b; + writeFile(l2, b, charset=encodingNames[enc]); + return readFile(aFile, charset=encodingNames[enc]) == a + b; } test bool writeFileOffsetEnd2(Encoding enc, str a, str b) { @@ -181,10 +181,10 @@ test bool writeFileOffsetEnd2(Encoding enc, str a, str b) { if (a == "" || b == "") { return true; } - writeFileEnc(aFile, encodingNames[enc], a + b); + writeFile(aFile, a + b, charset=encodingNames[enc]); l2 = aFile[offset=size(a)][length=size(b)]; - writeFileEnc(l2, encodingNames[enc], b); - return readFileEnc(aFile, encodingNames[enc]) == a + b; + writeFile(l2, b, charset=encodingNames[enc]); + return readFile(aFile, charset=encodingNames[enc]) == a + b; } test bool writeFileOffsetMiddle(Encoding enc, str a, str b) { @@ -193,10 +193,10 @@ test bool writeFileOffsetMiddle(Encoding enc, str a, str b) { if (a == "" || b == "") { return true; } - writeFileEnc(aFile, encodingNames[enc], a+a); + writeFile(aFile, a+a, charset=encodingNames[enc]); l2 = aFile[offset=size(a)][length=size(a)]; - writeFileEnc(l2, encodingNames[enc], b); - return readFileEnc(aFile, encodingNames[enc]) == a + b; + writeFile(l2, b, charset=encodingNames[enc]); + return readFile(aFile, charset=encodingNames[enc]) == a + b; } test bool writeFileOffsetMiddle2(Encoding enc, str a, str b) { @@ -205,10 +205,10 @@ test bool writeFileOffsetMiddle2(Encoding enc, str a, str b) { if (a == "" || b == "") { return true; } - writeFileEnc(aFile, encodingNames[enc], a+a); + writeFile(aFile, a+a, charset=encodingNames[enc]); l2 = aFile[offset=size(a)][length=0]; - writeFileEnc(l2, encodingNames[enc], b); - return readFileEnc(aFile, encodingNames[enc]) == a + b + a; + writeFile(l2, b, charset=encodingNames[enc]); + return readFile(aFile, charset=encodingNames[enc]) == a + b + a; } @@ -218,10 +218,10 @@ test bool writeFileOffsetStart(Encoding enc, str a, str b) { if (a == "" || b == "") { return true; } - writeFileEnc(aFile, encodingNames[enc], a+a); + writeFile(aFile, a+a, charset=encodingNames[enc]); l2 = aFile[offset=0][length=size(a)]; - writeFileEnc(l2, encodingNames[enc], b); - return readFileEnc(aFile, encodingNames[enc]) == b + a; + writeFile(l2, b, charset=encodingNames[enc]); + return readFile(aFile, charset=encodingNames[enc]) == b + a; } diff --git a/src/org/rascalmpl/library/util/Eval.rsc b/src/org/rascalmpl/library/util/Eval.rsc index dc7dbae8b02..9643bd46421 100644 --- a/src/org/rascalmpl/library/util/Eval.rsc +++ b/src/org/rascalmpl/library/util/Eval.rsc @@ -97,94 +97,6 @@ to evaluate Rascal commands or the static type checker. } java RascalRuntime createRascalRuntime(PathConfig pcfg=pathConfig()); -@synopsis{Evaluate a single command and return its return value.} -@description{ -This creates a ((RascalRuntime)), uses it to evaluate one command, and then discards the runtime again. -} -@deprecated{Use ((createRascalRuntime)) for better efficiency/configurability.} -Result[&T] eval(type[&T] typ, str command, int duration=-1, PathConfig pcfg=pathConfig()) - throws Timeout, StaticError, ParseError, ModuleLoadMessages - = eval(typ, [command], pcfg=pcfg, duration=duration); - -@synopsis{Evaluate a list of command and return the value of the last command.} -@description{ -This creates a ((RascalRuntime)), uses it to evaluate some commands, and then discards the runtime again. -} -@deprecated{Use ((createRascalRuntime)) for better efficiency/configurability.} -Result[&T] eval(type[&T] typ, list[str] commands, int duration=-1, PathConfig pcfg=pathConfig()) - throws Timeout, StaticError, ParseError { - e = createRascalRuntime(pcfg=pcfg); - if (duration?) { - e.setTimeout(duration); - } - - for (command <- commands[..-1]) { - e.eval(#value, command); - } - - return e.eval(typ, commands[-1]); -} - -@synopsis{Evaluate a list of command and return the value of the last command.} -@description{ -This creates a ((RascalRuntime)), uses it to evaluate some commands, and then discards the runtime again. -} -@deprecated{Use ((createRascalRuntime)) instead for better efficiency and configurability.} -Result[value] eval(list[str] commands, int duration=-1, PathConfig pcfg=pathConfig()) - throws Timeout, StaticError, ParseError - = eval(#value, commands, duration=duration, pcfg=pcfg); - -@deprecated{Use ((createRascalRuntime)) for better efficiency/configurability.} -@synopsis{Evaluate a command and return the value, unless the `duration` amount of milliseconds has passed first.} -Result[&T] eval(type[&T] typ, str command, int duration) throws Timeout, StaticError, ParseError - = eval(typ, command, duration=duration); - -@deprecated{Use ((createRascalRuntime)) for better efficiency/configurability.} -@synopsis{Evaluate a list of commands and return the value of the last command, unless the `duration` amount of milliseconds has passed first.} -Result[&T] eval(type[&T] typ, list[str] commands, int duration) throws Timeout, StaticError, ParseError - = eval(typ, commands, duration=duration); - -@deprecated{Use ((createRascalRuntime)) for better efficiency/configurability.} - -Result[value] eval(list[str] commands, int duration) - = eval(#value, commands, duration=duration); - -@synopsis{Give input string to the Rascal evaluator and return its type as string.} -@deprecated{Use ((createRascalRuntime)) for better efficiency/configurability.} -str evalType(str command, PathConfig pcfg=pathConfig(), int duration = -1) throws Timeout, StaticError, ParseError { - e = createRascalRuntime(pcfg=pcfg); - if (duration?) { - e.setTimeout(duration); - } - - return ""; -} - -@synopsis{Give input strings to the Rascal evaluator and return the type of the last command as a string.} -@deprecated{Use ((createRascalRuntime)) for better efficiency/configurability.} -str evalType(list[str] commands, PathConfig pcfg=pathConfig(), int duration = -1) throws Timeout, StaticError, ParseError { - e = createRascalRuntime(pcfg=pcfg); - if (duration?) { - e.setTimeout(duration); - } - - for (command <- commands[..-1]) { - e.eval(#value, command); - } - - return ""; -} - -@deprecated{Use ((createRascalRuntime)) for better efficiency/configurability.} -@synopsis{Return the static type of the given command unless `duration` milliseconds pass before that.} -str evalType(str command, int duration, PathConfig pcfg=pathConfig()) throws Timeout, StaticError, ParseError - = evalType(command, pcfg=pcfg, duration=duration); - -@synopsis{Give list of commands to the Rascal evaluator and return the type of the last one within duration ms.} -@deprecated{Use ((createRascalRuntime)) for better efficiency/configurability.} -str evalType(list[str] commands, int duration, PathConfig pcfg=pathConfig()) throws Timeout, StaticError, ParseError - = evalType(commands, pcfg=pcfg, duration=duration); - @synopsis{Tests and demonstrates how to work with an encapsulated stateful Rascal runtime.} test bool stateFulEvalCanReset() { e = createRascalRuntime(); diff --git a/src/org/rascalmpl/library/util/Reflective.rsc b/src/org/rascalmpl/library/util/Reflective.rsc index 3129a339f7d..c8489999061 100644 --- a/src/org/rascalmpl/library/util/Reflective.rsc +++ b/src/org/rascalmpl/library/util/Reflective.rsc @@ -45,33 +45,6 @@ data RascalConfigMode | interpreterExternal() ; -@deprecated{not in use anymore} -data RascalManifest - = rascalManifest( - str \Project-Name = "Project", - str \Main-Module = "Plugin", - str \Main-Function = "main", - list[str] Source = ["src"], - str Bin = "bin", - list[str] \Required-Libraries = [], - list[str] \Required-Dependencies = [] - ); - -@deprecated{not in use anymore} -data JavaBundleManifest - = javaManifest( - str \Manifest-Version = "", - str \Bundle-SymbolicName = "", - str \Bundle-RequiredExecutionEnvironment = "JavaSE-1.8", - list[str] \Require-Bundle = [], - str \Bundle-Version = "0.0.0.qualifier", - list[str] \Export-Package = [], - str \Bundle-Vendor = "", - str \Bundle-Name = "", - list[str] \Bundle-ClassPath = [], - list[str] \Import-Package = [] - ); - @synopsis{Makes the location of a jar file explicit, based on the project name} @description{ The classpath of the current JVM is searched and jar files are searched that contain @@ -103,274 +76,6 @@ java loc resolveModuleOnCurrentInterpreterSearchPath(str moduleName); loc resolvedCurrentRascalJar() = resolveProjectOnClasspath("rascal"); loc metafile(loc l) = l + "META-INF/RASCAL.MF"; - -@synopsis{Converts a PathConfig and replaces all references to roots of projects or bundles - by the folders which are nested under these roots as configured in their respective - META-INF/RASCAL.MF files.} -@deprecated{Not in use anymore.} -PathConfig applyManifests(PathConfig cfg) { - mf = (l:readManifest(#RascalManifest, metafile(l)) | l <- cfg.srcs + cfg.libs + [cfg.bin], exists(metafile(l))); - - list[loc] expandSrcs(loc p) = [ p + s | s <- mf[p].Source] when mf[p]?; - default list[loc] expandSrcs(loc p, str _) = [p]; - - list[loc] expandlibs(loc p) = [ p + s | s <- mf[p].\Required-Libraries] when mf[p]?; - default list[loc] expandlibs(loc p, str _) = [p]; - - loc expandBin(loc p) = p + mf[p].Bin when mf[p]?; - default loc expandBin(loc p) = p; - - cfg.srcs = [*expandSrcs(p) | p <- cfg.srcs]; - cfg.libs = [*expandlibs(p) | p <- cfg.libs]; - cfg.bin = expandBin(cfg.bin); - - return cfg; -} - -@deprecated{Function will be moved to Rascal compiler} -str makeFileName(str qualifiedModuleName, str extension = "rsc") { - str qnameSlashes = replaceAll(qualifiedModuleName, "::", "/"); - int n = findLast(qnameSlashes, "/"); - str prefix = extension == "rsc" ? "" : "$"; - str package = extension == "rsc" ? "" : "rascal/"; - qnameSlashes = n < 0 ? "" + qnameSlashes : qnameSlashes[0..n] + "/" + qnameSlashes[n+1..]; - return "">"; -} - -@deprecated{Function will be moved to Rascal compiler} -loc getSearchPathLoc(str filePath, PathConfig pcfg){ - for(loc dir <- pcfg.srcs + pcfg.libs){ - fileLoc = dir + filePath; - if(exists(fileLoc)){ - //println("getModuleLocation =\> "); - return fileLoc; - } - } - throw "Module with path not found"; -} - -@deprecated{Function will be moved to Rascal compiler} -@synopsis{Get the location of a named module, search for `src` in srcs and `tpl` in libs} -loc getModuleLocation(str qualifiedModuleName, PathConfig pcfg){ - fileName = makeFileName(qualifiedModuleName, extension="rsc"); - for(loc dir <- pcfg.srcs){ - fileLoc = dir + fileName; - if(exists(fileLoc)){ - return fileLoc; - } - } - fileName = makeFileName(qualifiedModuleName, extension="tpl"); - for(loc dir <- pcfg.libs){ - fileLoc = dir + fileName; - - if(exists(fileLoc)){ - return fileLoc; - } - } - throw "Module `` not found;\n"; -} - -@deprecated{Function will be moved to Rascal compiler} -tuple[str,str] splitFileExtension(str path){ - int n = findLast(path, "."); - if(n < 0) return ; - return ; -} - -@deprecated{Function will be moved to Rascal compiler} -@synopsis{Determine length of common suffix of list of strings} -int commonSuffix(list[str] dir, list[str] m) - = commonPrefix(reverse(dir), reverse(m)); - -@deprecated{Function will be moved to Rascal compiler} -@synopsis{Determine length of common prefix of list of strings} -int commonPrefix(list[str] rdir, list[str] rm){ - for(int i <- index(rm)){ - if(i >= size(rdir)){ - return i; - } else if(rdir[i] != rm[i]){ - return i; - } else { - continue; - } - } - return size(rm); -} - -@deprecated{Function will be moved to Rascal compiler} -@synopsis{Find the module name corresponding to a given module location via its (src or tpl) location} -str getModuleName(loc moduleLoc, PathConfig pcfg){ - modulePath = moduleLoc.path; - - rscFile = endsWith(modulePath, "rsc"); - tplFile = endsWith(modulePath, "tpl"); - - if(!( rscFile || tplFile )){ - throw "Not a Rascal .rsc or .tpl file: "; - } - - // Find matching .rsc file in source directories - if(rscFile){ - for(loc dir <- pcfg.srcs){ - if(moduleLoc.authority == dir.authority && startsWith(modulePath, dir.path)){ - moduleName = replaceFirst(modulePath, dir.path, ""); - if(exists(dir + moduleName)){ - = splitFileExtension(moduleName); - if(moduleName[0] == "/"){ - moduleName = moduleName[1..]; - } - moduleName = replaceAll(moduleName, "/", "::"); - return moduleName; - } - } - } - } - - // Find longest matching .tpl file in library directories - - = splitFileExtension(modulePath); - while(modulePathNoExt[0] == "/"){ - modulePathNoExt = modulePathNoExt[1..]; - } - - modulePathAsList = split("/", modulePathNoExt); - if(tplFile){ - lastName = modulePathAsList[-1]; - if(lastName[0] == "$"){ - modulePathAsList = [*modulePathAsList[..-1],lastName[1..]]; - } - } - if(modulePathAsList[0] == "rascal"){ - modulePathAsList = modulePathAsList[1..]; - } - modulePathReversed = reverse(modulePathAsList); - - int longestSuffix = 0; - for(loc dir <- pcfg.libs){ - dir = dir + "rascal"; - dpath = dir.path; - - while(dpath[0] == "/"){ - dpath = dpath[1..]; - } - - for(loc file <- find(dir, "tpl")){ - candidate = replaceFirst(file.path, dpath, ""); - = splitFileExtension(candidate); - while(candidate[0] == "/"){ - candidate = candidate[1..]; - } - - candidateAsList = split("/", candidate); - lastName = candidateAsList[-1]; - if(lastName[0] == "$"){ - candidateAsList = [*candidateAsList[..-1],lastName[1..]]; - } - // println("cand: , modpath: "); - n = commonPrefix(reverse(candidateAsList), modulePathReversed); - - if(n > longestSuffix){ - longestSuffix = n; - } - } - } - - if(longestSuffix > 0){ - lastName = modulePathAsList[-1]; - if(lastName[0] == "$"){ - modulePathAsList = [*modulePathAsList[..-1],lastName[1..]]; - } - return intercalate("::", modulePathAsList[size(modulePathAsList) - longestSuffix .. ]); - } - throw "No module name found for ;\nsrcs=;\nlibs="; -} - -@deprecated{Function will be moved to Rascal compiler} -@synopsis{Derive a location from a given module name for reading} -@description{ -Given a module name, a file name extension, and a PathConfig, -a path name is constructed from the module name + extension. - -If a file F with this path exists in one of the directories in the PathConfig, -then the pair is returned. Otherwise is returned. - -For a source extension (typically "rsc" or "mu" but this can be configured) srcs is searched, otherwise binPath + libs. -} -@examples{ -```rascal-shell -import util::Reflective; -getDerivedReadLoc("List", "rsc", pathConfig()); -getDerivedReadLoc("experiments::Compiler::Compile", "rvm", pathConfig()); -getDerivedReadLoc("experiments::Compiler::muRascal2RVM::Library", "mu", pathConfig()); -``` -} -@benefits{ -This function is useful for type checking and compilation tasks, when derived information related to source modules has to be read -from locations in different, configurable, directories. -} - -tuple[bool, loc] getDerivedReadLoc(str qualifiedModuleName, str extension, PathConfig pcfg, set[str] srcExtensions = {"rsc", "mu"}, str rootDir = ""){ - fileName = makeFileName(qualifiedModuleName, extension=extension); - //println("getDerivedReadLoc: "); - - if(extension in srcExtensions){ - for(loc dir <- pcfg.srcs){ // In a source directory? - fileLoc = dir + rootDir + fileName; - if(exists(fileLoc)){ - //println("getDerivedReadLoc: , =\> ; - } - } - } else { - for(loc dir <- pcfg.bin + pcfg.libs){ // In a bin or lib directory? - - fileLoc = dir + rootDir + fileName; - if(exists(fileLoc)){ - //println("getDerivedReadLoc: , =\> "); - return ; - } - } - } - //println("getDerivedReadLoc: , =\> |error:///|"); - return ; -} - -@deprecated{Function will be moved to Rascal compiler} -@synopsis{Derive a location from a given module name for writing} -@description{ -Given a module name, a file name extension, and a PathConfig, -a path name is constructed from the module name + extension. - -For source modules, a writable location cannot be derived. -For other modules, a location for this path in bin will be returned. -} -@examples{ -```rascal-shell -import util::Reflective; -getDerivedWriteLoc("List", "rvm", pathConfig()); -getDerivedWriteLoc("experiments::Compiler::Compile", "rvm", pathConfig()); -``` - -```rascal-shell,error -getDerivedWriteLoc("experiments::Compiler::muRascal2RVM::Library", "rsc", pathConfig()); -``` -} -@benefits{ -This function is useful for type checking and compilation tasks, when derived information related to source modules has to be written -to locations in separate, configurable, directories. -} -loc getDerivedWriteLoc(str qualifiedModuleName, str extension, PathConfig pcfg, set[str] srcExtensions = {"rsc", "mu"}, str rootDir = ""){ - if(extension in srcExtensions){ - throw "Cannot derive writable location for module with extension "; - } - fileNameSrc = makeFileName(qualifiedModuleName); - fileNameBin = makeFileName(qualifiedModuleName, extension=extension); - - bin = pcfg.bin; - fileLocBin = bin + rootDir + fileNameBin; - //println("getDerivedWriteLoc: , =\> "); - return fileLocBin; -} @javaClass{org.rascalmpl.library.util.Reflective} public java PathConfig getProjectPathConfig(loc projectRoot, RascalConfigMode mode = compiler());