diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2fa4caddbff..8525489a09b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -8,6 +8,7 @@ on: pull_request: branches: - main + - 'feat/*' env: MAVEN_OPTS: "-Xmx4G -Dhttps.protocols=TLSv1.2 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" diff --git a/pom.xml b/pom.xml index a376d5782fc..f7597d25c7c 100644 --- a/pom.xml +++ b/pom.xml @@ -3,12 +3,12 @@ org.rascalmpl rascal - 0.40.7-SNAPSHOT + 0.40.18-SNAPSHOT jar scm:git:ssh://git@github.com/usethesource/rascal.git - v0.40.0-BOOT1 + v0.40.16 @@ -32,9 +32,19 @@ org.rascalmpl.shell.RascalShell 2 11 - 0.28.0-RC1 + 0.28.9-BOOT1 + + + BSD-2-Clause + https://opensource.org/license/BSD-2-Clause + repo + + Note, some older files are still licensed under Eclipse v1 + + + src @@ -55,6 +65,9 @@ rascal-DEPENDENCIES.txt + + ${project.build.directory}/generated-resources + test @@ -135,7 +148,7 @@ ${project.basedir}/src/org/rascalmpl/library/lang/rascal/syntax/tests false - false + true ${project.basedir}/src/org/rascalmpl/library/Prelude.rsc @@ -268,6 +281,19 @@ -Drascal.compile.skip -Drascal.tutor.skip -DskipTests + + org.codehaus.mojo + license-maven-plugin + 2.4.0 + + + download-licenses + + download-licenses + + + + org.apache.maven.plugins maven-shade-plugin @@ -292,6 +318,11 @@ org/rascalmpl/uri/resolvers.config io/usethesource/vallang/type/types.config + + + + false + diff --git a/src/org/rascalmpl/interpreter/result/ConstructorFunction.java b/src/org/rascalmpl/interpreter/result/ConstructorFunction.java index 54fb43423f4..b7d602b6635 100644 --- a/src/org/rascalmpl/interpreter/result/ConstructorFunction.java +++ b/src/org/rascalmpl/interpreter/result/ConstructorFunction.java @@ -112,14 +112,17 @@ public Result computeDefaultKeywordParameter(String label, IConstructor kwResult = def.interpret(eval); } + // apply the static type we expect from the declaration: + kwResult = ResultFactory.makeResult(kwType, kwResult.getValue(), ctx); + if (name.equals(label)) { // we have the one we need, bail out quickly return kwResult; } else { - env.declareVariable(kwResult.getStaticType(), name); + env.declareVariable(kwType, name); env.storeVariable(name, kwResult); - resultEnv.declareVariable(kwResult.getStaticType(), name); + resultEnv.declareVariable(kwType, name); resultEnv.storeVariable(name, kwResult); } } diff --git a/src/org/rascalmpl/interpreter/result/RelationResult.java b/src/org/rascalmpl/interpreter/result/RelationResult.java index 196fec40206..76f7a205ef2 100644 --- a/src/org/rascalmpl/interpreter/result/RelationResult.java +++ b/src/org/rascalmpl/interpreter/result/RelationResult.java @@ -431,13 +431,16 @@ public Result fieldSelect(Field[] selectedFields) { fieldIndices[i] = ((IInteger) f.getFieldIndex() .interpret(this.ctx.getEvaluator()).getValue()).intValue(); } else { - String fieldName = org.rascalmpl.interpreter.utils.Names - .name(f.getFieldName()); + String fieldName = org.rascalmpl.interpreter.utils.Names.name(f.getFieldName()); + + if (!baseType.hasFieldNames()) { + throw new UndeclaredField(fieldName, baseType,ctx.getCurrentAST()); + } + try { fieldIndices[i] = baseType.getFieldIndex(fieldName); } catch (UndeclaredFieldException e) { - throw new UndeclaredField(fieldName, baseType, - ctx.getCurrentAST()); + throw new UndeclaredField(fieldName, baseType, ctx.getCurrentAST()); } } diff --git a/src/org/rascalmpl/interpreter/utils/IResourceLocationProvider.java b/src/org/rascalmpl/interpreter/utils/IResourceLocationProvider.java index 4721bbb4391..36b5521f36c 100644 --- a/src/org/rascalmpl/interpreter/utils/IResourceLocationProvider.java +++ b/src/org/rascalmpl/interpreter/utils/IResourceLocationProvider.java @@ -4,6 +4,14 @@ import io.usethesource.vallang.ISourceLocation; +/** + * This is a injected configuration parameter of a Rascal run-time + * environment like IRascalMonitor and IDEServices. The goal is + * to find all the file names that have the given `fileName` in + * the current run-time environment. For compiled Rascal this would + * be ClassLoader.findResources, while for the interpreter it is + * typically a search through all the roots of the source folders. + */ public interface IResourceLocationProvider { Set findResources(String fileName); } diff --git a/src/org/rascalmpl/interpreter/utils/JavaBridge.java b/src/org/rascalmpl/interpreter/utils/JavaBridge.java index 201703578f1..71362ef5f39 100644 --- a/src/org/rascalmpl/interpreter/utils/JavaBridge.java +++ b/src/org/rascalmpl/interpreter/utils/JavaBridge.java @@ -45,6 +45,7 @@ import org.rascalmpl.exceptions.JavaCompilation; import org.rascalmpl.exceptions.JavaMethodLink; import org.rascalmpl.exceptions.RuntimeExceptionFactory; +import org.rascalmpl.ideservices.BasicIDEServices; import org.rascalmpl.ideservices.IDEServices; import org.rascalmpl.interpreter.Configuration; import org.rascalmpl.interpreter.IEvaluator; @@ -445,7 +446,7 @@ else if (formals[i].isAssignableFrom(IDEServices.class)) { args[i] = (IDEServices) monitor; } else { - throw new IllegalArgumentException("no IDE services are available in this environment"); + args[i] = new BasicIDEServices(err, monitor); } } else if (formals[i].isAssignableFrom(IResourceLocationProvider.class)) { diff --git a/src/org/rascalmpl/library/Content.rsc b/src/org/rascalmpl/library/Content.rsc index 28be88bbe94..54600a5021f 100644 --- a/src/org/rascalmpl/library/Content.rsc +++ b/src/org/rascalmpl/library/Content.rsc @@ -4,7 +4,7 @@ module Content @synopsis{Content wraps the HTTP Request/Response API to support interactive visualization types -on the terminal ((RascalShell)).} +on the terminal.} @description{ Values wrapped in a `Content` wrapper will be displayed by interactive Rascal applications such as the IDE, the REPL terminal and the documentation pages. diff --git a/src/org/rascalmpl/library/IO.rsc b/src/org/rascalmpl/library/IO.rsc index 47eb70e19f9..06f119c06ed 100644 --- a/src/org/rascalmpl/library/IO.rsc +++ b/src/org/rascalmpl/library/IO.rsc @@ -571,7 +571,7 @@ public java str readBase64(loc file, bool includePadding=true) throws PathNotFound, IO; @deprecated{ -Use readBase64 instead. Uuencode was a misnomer. +Use readBase64 instead. } public str uuencode(loc file) = readBase64(file); @@ -583,7 +583,7 @@ public java void writeBase64(loc file, str content) throws PathNotFound, IO; @deprecated{ -Use writeBase64 instead. Uudecode was a misnomer. +Use writeBase64 instead. } public void uudecode(loc file, str content) = writeBase64(file, content); @@ -712,7 +712,7 @@ public java str createLink(str title, str target); @javaClass{org.rascalmpl.library.Prelude} @deprecated{ - use `readBase64` instead. +Use `readBase64` instead. } public java str toBase64(loc file, bool includePadding=true) throws PathNotFound, IO; @@ -721,14 +721,14 @@ throws PathNotFound, IO; java void copy(loc source, loc target, bool recursive=false, bool overwrite=true) throws IO; @deprecated{ -use the `copy` function instead +Use the `copy` function instead } void copyFile(loc source, loc target) { copy(source, target, recursive=false, overwrite=true); } @deprecated{ -use the `copy` function instead +Use the `copy` function instead } void copyDirectory(loc source, loc target) { copy(source, target, recursive=true, overwrite=true); diff --git a/src/org/rascalmpl/library/List.rsc b/src/org/rascalmpl/library/List.rsc index e8c86ba18df..2f05b116005 100644 --- a/src/org/rascalmpl/library/List.rsc +++ b/src/org/rascalmpl/library/List.rsc @@ -96,9 +96,7 @@ dup([3, 1, 5, 3, 1, 7, 1, 2]); list[&T] dup(list[&T] lst) = ([] | (ix in it) ? it : it + [ix] | &T ix <- lst); -@deprecated{ -use the indexing instead -} +@deprecated{Use a list index instead} @javaClass{org.rascalmpl.library.Prelude} java &T elementAt(list[&T] lst, int index); @@ -420,7 +418,7 @@ list[&T] mix(list[&T] l, list[&T] r){ sizeL = size(l); sizeR = size(r); minSize = sizeL < sizeR ? sizeL : sizeR; - return [elementAt(l,i),elementAt(r,i)| i <- [0 .. minSize]] + drop(sizeR,l) + drop(sizeL,r); + return [l[i],r[i] | i <- [0 .. minSize]] + drop(sizeR,l) + drop(sizeL,r); } @synopsis{Compute all permutations of a list.} @@ -481,7 +479,8 @@ push("eagle", ["zebra", "elephant", "snake", "owl"]); list[&T] push(&T elem, list[&T] lst) = [elem] + lst; -@synopsis{Apply a function to successive elements of list and combine the results (__deprecated__).} +@synopsis{Apply a function to successive elements of list and combine the results.} +@deprecated{This function is deprecated. Use a reducer expression instead, like `(init | f(it, e) | e <- lst)`.} @description{ Apply the function `fn` to successive elements of list `lst` starting with `unit`. } @@ -492,22 +491,7 @@ int add(int x, int y) { return x + y; } reducer([10, 20, 30, 40], add, 0); ``` } -@benefits{ - -} -@pitfalls{ -:::warning -This function is *deprecated*, use a reducer expression instead. E.g. `(init | f(it, e) | e <- lst)`. -::: -} -&T reducer(list[&T] lst, &T (&T, &T) fn, &T unit) -{ - &T result = unit; - for(&T elm <- lst){ - result = fn(result, elm); - } - return result; -} +&T reducer(list[&T] lst, &T (&T, &T) fn, &T unit) = (unit | fn(it, elm) | elm <- lst); list[&T] remove(list[&T] lst, int indexToDelete) = [ lst[i] | i <- index(lst), i != indexToDelete ]; @@ -845,9 +829,7 @@ l = [10,20,30,40]; s = {*l}; ``` } -@deprecated{ -Please use {*myList} instead. -} + @javaClass{org.rascalmpl.library.Prelude} java set[&T] toSet(list[&T] lst); diff --git a/src/org/rascalmpl/library/Prelude.java b/src/org/rascalmpl/library/Prelude.java index a28ca8f0d79..d873d1e01f3 100644 --- a/src/org/rascalmpl/library/Prelude.java +++ b/src/org/rascalmpl/library/Prelude.java @@ -1748,7 +1748,7 @@ public IValue head(IList lst) } public IValue last(IList lst) - // @doc{head -- get the last element of a list} + // @doc{last -- get the last element of a list} { if(lst.length() > 0){ return lst.get(lst.length() - 1); @@ -4110,9 +4110,9 @@ public IBool isOverlapping(ISourceLocation first, ISourceLocation second) { if (first.hasOffsetLength()) { if (second.hasOffsetLength()) { int firstStart = first.getOffset(); - int firstEnd = firstStart + first.getLength(); + int firstEnd = firstStart + first.getLength() - 1; // Inclusive int secondStart = second.getOffset(); - int secondEnd = secondStart + second.getLength(); + int secondEnd = secondStart + second.getLength() - 1; // Inclusive return values.bool( (firstStart <= secondStart && secondStart <= firstEnd) diff --git a/src/org/rascalmpl/library/Set.rsc b/src/org/rascalmpl/library/Set.rsc index 10e0f819cdd..729b96ea4c0 100644 --- a/src/org/rascalmpl/library/Set.rsc +++ b/src/org/rascalmpl/library/Set.rsc @@ -218,7 +218,7 @@ 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 (__deprecated__).} +@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`. } @@ -229,11 +229,7 @@ int add(int x, int y) { return x + y; } reducer({10, 20, 30, 40}, add, 0); ``` } -@pitfalls{ -:::warning -This function is *deprecated*, use a reducer expression instead, such as `(init | fn(it,e) | e <- st)`. -::: -} +@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); diff --git a/src/org/rascalmpl/library/String.rsc b/src/org/rascalmpl/library/String.rsc index 30593c3fb04..5a61188792e 100644 --- a/src/org/rascalmpl/library/String.rsc +++ b/src/org/rascalmpl/library/String.rsc @@ -610,7 +610,7 @@ 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 +Use `/re/ := s` instead } public java bool rexpMatch(str s, str re); @@ -627,7 +627,7 @@ toLocation("http://grammarware.net"); toLocation("document.xml"); ``` } -@deprecated{Use ((Location::locFromWindowsPath)) for example. The current function does not handle all the different intricasies of path notation.} +@deprecated{Use ((Location::locFromWindowsPath)) for example; toLocation does not handle all intricasies of path notation.} public loc toLocation(str s) = (/\:\/\// := s) ? |://| : |cwd:///|; diff --git a/src/org/rascalmpl/library/analysis/diff/edits/TextEdits.rsc b/src/org/rascalmpl/library/analysis/diff/edits/TextEdits.rsc index 55cf05f948b..11c0c71e1d7 100644 --- a/src/org/rascalmpl/library/analysis/diff/edits/TextEdits.rsc +++ b/src/org/rascalmpl/library/analysis/diff/edits/TextEdits.rsc @@ -1,5 +1,33 @@ +@license{ +Copyright (c) 2022, NWO-I Centrum Wiskunde & Informatica (CWI) +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +} +@synopsis{Intermediate representation for file creation, removal and changing, including textual (string) rewriting.} +@description{ +((DocumentEdit))s can be produced by source-to-source transformation tools, and then executed +via ((executeDocumentEdits)) in the REPL or ((applyDocumentsEdits)) by the IDE. +} +@benefits{ +* Document edits can be attached to ((data:CodeAction))s and error ((util::IDEServices-Message))s, to achieve interactive +source code rewriting utilities. +* Document edits can be tested via ((executeDocumentEdits)) +* Document edits can be "high fidelity", avoiding unnecessary damage to a source text. +} +@pitfalls{ +* Code edits depend on a specific state of the source file that may be transient while editing. Use the ((CodeAction)) interface +to avoid racing for the state of the source file. +} module analysis::diff::edits::TextEdits +@synopsis{File changing operations} data DocumentEdit = removed(loc file) | created(loc file) @@ -7,9 +35,32 @@ data DocumentEdit | changed(loc file, list[TextEdit] edits) ; +@synopsis{Shorthand for file changes.} +DocumentEdit changed(list[TextEdit] edits:[replace(loc l, str _), *_]) + = changed(l.top, edits); + +@synopsis{String rewriting operations} +@description{ +The core operation is to replace a substring with another. +The replace operator uses a `loc` value to point to a range inside a string, +and a `str` as its replacement. +} data TextEdit - = replace(loc range, str replacement) - ; + = replace(loc range, str replacement); + +@synopsis{Deletion is replacement with an empty string.} +TextEdit delete(loc range) + = replace(range, ""); -TextEdit delete(loc range) = replace(range, ""); +@synopsis{Inserting before a given range.} +TextEdit insertBefore(loc range, str insertion, str separator=" ") + = (range.begin?) + ? replace(range.top(range.offset, 0, range.begin, range.begin), "") + : replace(range.top(range.offset, 0), ""); +@synopsis{Inserting after a given range.} +TextEdit insertAfter(loc range, str insertion, str separator=" ") + = (range.end?) + ? replace(range.top(range.offset + range.length, 0, range.end, range.end), "") + : replace(range.top(range.offset + range.length, 0), ""); + diff --git a/src/org/rascalmpl/library/analysis/m3/AST.rsc b/src/org/rascalmpl/library/analysis/m3/AST.rsc index f18332f3858..2003d19c893 100644 --- a/src/org/rascalmpl/library/analysis/m3/AST.rsc +++ b/src/org/rascalmpl/library/analysis/m3/AST.rsc @@ -86,7 +86,7 @@ data Expression( TypeSymbol typ = \unresolved() ); -@synopsis{Uniform name for everything that is an _type_ in programming languages syntax: int, void, List, ...} +@synopsis{Uniform name for everything that is an _type_ in programming languages syntax: `int`, `void`, `List`} @description{ Instances of the Type type represent the _syntax_ of types in programming languages. diff --git a/src/org/rascalmpl/library/analysis/m3/Core.rsc b/src/org/rascalmpl/library/analysis/m3/Core.rsc index 3bdda576649..2864cd79252 100644 --- a/src/org/rascalmpl/library/analysis/m3/Core.rsc +++ b/src/org/rascalmpl/library/analysis/m3/Core.rsc @@ -236,7 +236,7 @@ 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..} +@deprecated{Does not make much sense since containment usually contains only logical locations.} set[loc] files(M3 model) { todo = top(model.containment); done = {}; diff --git a/src/org/rascalmpl/library/analysis/text/search/LuceneAdapter.java b/src/org/rascalmpl/library/analysis/text/search/LuceneAdapter.java index 30064558d6f..11b03a95f85 100644 --- a/src/org/rascalmpl/library/analysis/text/search/LuceneAdapter.java +++ b/src/org/rascalmpl/library/analysis/text/search/LuceneAdapter.java @@ -154,146 +154,191 @@ public void createIndex(ISourceLocation indexFolder, ISet documents, IConstructo } } - public ISet listTerms(ISourceLocation indexFolder, IString fieldName, IInteger max) throws IOException { - DirectoryReader reader = makeReader(indexFolder); - ISetWriter result = vf.setWriter(); - Fields fields = MultiFields.getFields(reader); - - for (String label : fields) { - if (label.equals(fieldName.getValue())) { - Terms terms = fields.terms(label); - - if (terms == null) { - continue; - } - TermsEnum list = terms.iterator(); - BytesRef bytes; - int countDown = max.intValue(); - - while ((bytes = list.next()) != null && countDown-- > 0) { - IString val = vf.string(bytes.utf8ToString()); - IInteger freq = vf.integer(reader.totalTermFreq(new Term(label, bytes))); - result.insert(vf.tuple(val, freq)); + public ISet listTerms(ISourceLocation indexFolder, IString fieldName, IInteger max) { + try { + DirectoryReader reader = makeReader(indexFolder); + ISetWriter result = vf.setWriter(); + Fields fields = MultiFields.getFields(reader); + + for (String label : fields) { + if (label.equals(fieldName.getValue())) { + Terms terms = fields.terms(label); + + if (terms == null) { + continue; + } + TermsEnum list = terms.iterator(); + BytesRef bytes; + int countDown = max.intValue(); + + while ((bytes = list.next()) != null && countDown-- > 0) { + IString val = vf.string(bytes.utf8ToString()); + IInteger freq = vf.integer(reader.totalTermFreq(new Term(label, bytes))); + result.insert(vf.tuple(val, freq)); + } } } + + return result.done(); + } catch (IOException e) { + throw RuntimeExceptionFactory.io(vf.string(e.getMessage()), null, null); } - - return result.done(); } - public ISet listFields(ISourceLocation indexFolder) throws IOException { - DirectoryReader reader = makeReader(indexFolder); - ISetWriter result = vf.setWriter(); - - // str field, int docCount, int percentage - for (LeafReaderContext subReader : reader.leaves()) { - LeafReader sub = subReader.reader(); - for (FieldInfo field : sub.getFieldInfos()) { - IString name = vf.string(field.name); - IInteger docCount = vf.integer(sub.getDocCount(field.name)); - IInteger termCount = vf.integer(sub.getSumTotalTermFreq(field.name)); - result.insert(vf.tuple(name, docCount, termCount)); + public ISet listFields(ISourceLocation indexFolder) { + try { + DirectoryReader reader = makeReader(indexFolder); + ISetWriter result = vf.setWriter(); + + // str field, int docCount, int percentage + for (LeafReaderContext subReader : reader.leaves()) { + LeafReader sub = subReader.reader(); + for (FieldInfo field : sub.getFieldInfos()) { + IString name = vf.string(field.name); + IInteger docCount = vf.integer(sub.getDocCount(field.name)); + IInteger termCount = vf.integer(sub.getSumTotalTermFreq(field.name)); + result.insert(vf.tuple(name, docCount, termCount)); + } } + + return result.done(); + } catch (IOException e){ + throw RuntimeExceptionFactory.io(vf.string(e.getMessage()), null, null); } - - return result.done(); } private Directory makeDirectory(ISourceLocation indexFolder, SingleInstanceLockFactory lockFactory) throws IOException { return new SourceLocationDirectory(vf, lockFactory, indexFolder); } - public IList searchDocument(ISourceLocation doc, IString query, IConstructor analyzer, IInteger max, IString charset, IBool inferCharset) throws IOException, ParseException, InvalidTokenOffsetsException { - String entireDocument = Prelude.readFile(vf, false, doc, charset.getValue(), inferCharset.getValue()).getValue(); - - try (Reader reader = URIResolverRegistry.getInstance().getCharacterReader(doc, charset.getValue())) { - TokenStream tokenStream = makeAnalyzer(analyzer).tokenStream(SRC_FIELD_NAME, reader); - QueryParser parser = makeQueryParser(analyzer); - Query queryExpression = parser.parse(query.getValue()); - QueryScorer scorer = new QueryScorer(queryExpression); - final IListWriter result = vf.listWriter(); - - Formatter formatter = new Formatter() { - @Override - public String highlightTerm(String originalText, TokenGroup tokenGroup) { - if (tokenGroup.getScore(tokenGroup.getNumTokens() - 1) > 0) { - int startOffset = tokenGroup.getStartOffset(); - int endOffset = tokenGroup.getEndOffset(); - result.append(vf.sourceLocation(doc, startOffset, endOffset - startOffset)); + public IList searchDocument(ISourceLocation doc, IString query, IConstructor analyzer, IInteger max, IString charset, IBool inferCharset) { + try { + String entireDocument = Prelude.readFile(vf, false, doc, charset.getValue(), inferCharset.getValue()).getValue(); + + try (Reader reader = URIResolverRegistry.getInstance().getCharacterReader(doc, charset.getValue())) { + TokenStream tokenStream = makeAnalyzer(analyzer).tokenStream(SRC_FIELD_NAME, reader); + QueryParser parser = makeQueryParser(analyzer); + Query queryExpression = parser.parse(query.getValue()); + QueryScorer scorer = new QueryScorer(queryExpression); + final IListWriter result = vf.listWriter(); + + Formatter formatter = new Formatter() { + @Override + public String highlightTerm(String originalText, TokenGroup tokenGroup) { + if (tokenGroup.getScore(tokenGroup.getNumTokens() - 1) > 0) { + int startOffset = tokenGroup.getStartOffset(); + int endOffset = tokenGroup.getEndOffset(); + result.append(vf.sourceLocation(doc, startOffset, endOffset - startOffset)); + } + return tokenGroup.toString(); } - return tokenGroup.toString(); - } - }; - - new Highlighter(formatter, scorer).getBestFragments(tokenStream, entireDocument, max.intValue()); + }; + + new Highlighter(formatter, scorer).getBestFragments(tokenStream, entireDocument, max.intValue()); + + return result.done(); + } - return result.done(); + } catch (IOException e){ + throw RuntimeExceptionFactory.io(vf.string(e.getMessage()), null, null); + } + catch (ParseException e) { + int beginLine = e.currentToken.next.beginLine; + int beginColumn = e.currentToken.next.beginColumn; + // TODO: fix the coordinates below + throw RuntimeExceptionFactory.parseError(vf.sourceLocation(doc, beginLine, beginColumn)); + + } + catch (ArithmeticException e) { + throw RuntimeExceptionFactory.arithmeticException(e.getMessage(), null, null); + } + catch (InvalidTokenOffsetsException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return vf.list(); } } - public IList analyzeDocument(IString doc, IConstructor analyzer) throws IOException { + public IList analyzeDocument(IString doc, IConstructor analyzer) { return analyzeDocument(URIUtil.rootLocation("string"), new StringReader(doc.getValue()), analyzer); } - public IList analyzeDocument(ISourceLocation doc, IConstructor analyzer) throws IOException { + public IList analyzeDocument(ISourceLocation doc, IConstructor analyzer) { try (Reader reader = URIResolverRegistry.getInstance().getCharacterReader(doc)) { return analyzeDocument(doc, reader, analyzer); } + catch (IOException e) { + throw RuntimeExceptionFactory.io(vf.string(e.getMessage()), null, null); + } } - private IList analyzeDocument(ISourceLocation src, Reader doc, IConstructor analyzer) throws IOException { - Analyzer theAnalyzer = makeAnalyzer(analyzer); - - TokenStream tokenStream = theAnalyzer.tokenStream(SRC_FIELD_NAME, doc); - OffsetAttribute offsetAttribute = tokenStream.addAttribute(OffsetAttribute.class); - CharTermAttribute termAtt = tokenStream.addAttribute(CharTermAttribute.class); - TypeAttribute typeAtt = tokenStream.addAttribute(TypeAttribute.class); - IListWriter result = vf.listWriter(); - - tokenStream.reset(); - while (tokenStream.incrementToken()) { - int startOffset = offsetAttribute.startOffset(); - result.append(vf.constructor(termCons, vf.string(termAtt.toString()), vf.sourceLocation(src, startOffset, termAtt.length()), vf.string(typeAtt.type()))); + private IList analyzeDocument(ISourceLocation src, Reader doc, IConstructor analyzer) { + try { + Analyzer theAnalyzer = makeAnalyzer(analyzer); + + TokenStream tokenStream = theAnalyzer.tokenStream(SRC_FIELD_NAME, doc); + OffsetAttribute offsetAttribute = tokenStream.addAttribute(OffsetAttribute.class); + CharTermAttribute termAtt = tokenStream.addAttribute(CharTermAttribute.class); + TypeAttribute typeAtt = tokenStream.addAttribute(TypeAttribute.class); + IListWriter result = vf.listWriter(); + + tokenStream.reset(); + while (tokenStream.incrementToken()) { + int startOffset = offsetAttribute.startOffset(); + result.append(vf.constructor(termCons, vf.string(termAtt.toString()), vf.sourceLocation(src, startOffset, termAtt.length()), vf.string(typeAtt.type()))); + } + + return result.done(); + } catch (IOException e) { + throw RuntimeExceptionFactory.io(vf.string(e.getMessage()), null, null); } - - return result.done(); } - public ISet searchIndex(ISourceLocation indexFolder, IString query, IConstructor analyzer, IInteger max) throws IOException, ParseException { - // TODO the searcher should be cached on the indexFolder key - IndexSearcher searcher = makeSearcher(indexFolder); - QueryParser parser = makeQueryParser(analyzer); - Query queryExpression = parser.parse(query.getValue()); - TopDocs docs = searcher.search(queryExpression, max.intValue()); - - ISetWriter result = vf.setWriter(); - - for (ScoreDoc doc : docs.scoreDocs) { - org.apache.lucene.document.Document found = searcher.doc(doc.doc); - String loc = found.get(ID_FIELD_NAME); - ISourceLocation sloc = parseLocation(loc); - - if (loc != null) { - IConstructor node = vf.constructor(docCons, sloc); - Map params = new HashMap<>(); - - params.put("score", vf.real(doc.score)); - - found.forEach((f) -> { - String value = f.stringValue(); - String name = f.name(); - - if (value != null && !name.equals(ID_FIELD_NAME)) { - params.put(name, vf.string(value)); - } - }); - - - result.insert(node.asWithKeywordParameters().setParameters(params)); + public ISet searchIndex(ISourceLocation indexFolder, IString query, IConstructor analyzer, IInteger max) { + try { + // TODO the searcher should be cached on the indexFolder key + IndexSearcher searcher = makeSearcher(indexFolder); + QueryParser parser = makeQueryParser(analyzer); + Query queryExpression = parser.parse(query.getValue()); + TopDocs docs = searcher.search(queryExpression, max.intValue()); + + ISetWriter result = vf.setWriter(); + + for (ScoreDoc doc : docs.scoreDocs) { + org.apache.lucene.document.Document found = searcher.doc(doc.doc); + String loc = found.get(ID_FIELD_NAME); + ISourceLocation sloc = parseLocation(loc); + + if (loc != null) { + IConstructor node = vf.constructor(docCons, sloc); + Map params = new HashMap<>(); + + params.put("score", vf.real(doc.score)); + + found.forEach((f) -> { + String value = f.stringValue(); + String name = f.name(); + + if (value != null && !name.equals(ID_FIELD_NAME)) { + params.put(name, vf.string(value)); + } + }); + + + result.insert(node.asWithKeywordParameters().setParameters(params)); + } } + + return result.done(); + } catch (IOException e) { + throw RuntimeExceptionFactory.io(vf.string(e.getMessage()), null, null); + } + catch (ParseException e) { + int beginLine = e.currentToken.next.beginLine; + int beginColumn = e.currentToken.next.beginColumn; + // TODO: fix the coordinates below + throw RuntimeExceptionFactory.parseError(vf.sourceLocation(indexFolder, beginLine, beginColumn)); } - - return result.done(); } private ISourceLocation parseLocation(String loc) throws IOException { diff --git a/src/org/rascalmpl/library/lang/box/util/Box2Text.rsc b/src/org/rascalmpl/library/lang/box/util/Box2Text.rsc index 275c48e5bfb..b2f113d8c7f 100644 --- a/src/org/rascalmpl/library/lang/box/util/Box2Text.rsc +++ b/src/org/rascalmpl/library/lang/box/util/Box2Text.rsc @@ -11,8 +11,8 @@ @description{ The input to Box2Text is a hierarchy of "Boxes" represented by the Box algebraic data-type. These boxes put hard and soft relative positioning constraints on the embedded text fragments, and -there is the global soft constraints of the width of the screen (or the paper). Box2Text can also -add markup for syntax highlighting in either ANSI plaintext encoding, HTML font tags or LaTex macros. +there is the global soft constraints of the width of the screen (or the paper). + This implementation is a port from ASF+SDF to Rascal. The ASF+SDF implementation was published as "From Box to Tex:An algebraic approach to the construction of documentation tools" by Mark van den Brand @@ -62,6 +62,9 @@ format(H([L("if"), H([L("("), L("true"), L(")")], hs=0), HOV([L("W") | i <- [ format(H([L("if"), H([L("("), L("true"), L(")")], hs=0), HV([L("W") | i <- [0..30]])])) ``` } +@pitfalls{ +* Box2text does not have highlighting features anymore; you can use ((util::Highlight)) for this instead. +} module lang::box::util::Box2Text import util::Math; diff --git a/src/org/rascalmpl/library/lang/csv/IO.rsc b/src/org/rascalmpl/library/lang/csv/IO.rsc index 7431d9c645f..9780d127ec5 100644 --- a/src/org/rascalmpl/library/lang/csv/IO.rsc +++ b/src/org/rascalmpl/library/lang/csv/IO.rsc @@ -101,7 +101,7 @@ R1 = readCSV(|lib://rascal/org/rascalmpl/library/lang/csv/examples/ex1.csv|, sep public java value readCSV(loc location, bool header = true, str separator = ",", str encoding = "UTF8"); @deprecated{ -use the readCSV with keyword parameters +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"]?","); diff --git a/src/org/rascalmpl/library/lang/java/m3/TypeSymbol.rsc b/src/org/rascalmpl/library/lang/java/m3/TypeSymbol.rsc index 3b7d35b38ee..81773c5a201 100644 --- a/src/org/rascalmpl/library/lang/java/m3/TypeSymbol.rsc +++ b/src/org/rascalmpl/library/lang/java/m3/TypeSymbol.rsc @@ -33,7 +33,6 @@ data TypeSymbol | \null() | \array(TypeSymbol component, int dimension) | \typeVariable(loc decl) - | \unresolved() | \module(loc decl) ; diff --git a/src/org/rascalmpl/library/lang/json/IO.rsc b/src/org/rascalmpl/library/lang/json/IO.rsc index 463c8f299c4..f751745311d 100644 --- a/src/org/rascalmpl/library/lang/json/IO.rsc +++ b/src/org/rascalmpl/library/lang/json/IO.rsc @@ -16,19 +16,19 @@ module lang::json::IO @javaClass{org.rascalmpl.library.lang.json.IO} @deprecated{ -use writeJSON +Use writeJSON } public java str toJSON(value v); @javaClass{org.rascalmpl.library.lang.json.IO} @deprecated{ -use asJSON +Use asJSON } public java str toJSON(value v, bool compact); @javaClass{org.rascalmpl.library.lang.json.IO} @deprecated{ -use readJSON +Use readJSON } public java &T fromJSON(type[&T] typ, str src); diff --git a/src/org/rascalmpl/library/lang/paths/Unix.rsc b/src/org/rascalmpl/library/lang/paths/Unix.rsc index 4e89ac113e6..abd9eeeba16 100644 --- a/src/org/rascalmpl/library/lang/paths/Unix.rsc +++ b/src/org/rascalmpl/library/lang/paths/Unix.rsc @@ -26,7 +26,7 @@ lexical UnixPath = absolute: Slashes UnixFilePath? | relative: UnixFilePath | home : "~" (Slashes UnixFilePath)? - | user : "~" UserName name (Slashes UnixFilePath)? + | user : "~" UserName uname (Slashes UnixFilePath)? ; lexical UserName = ![/~]+; @@ -36,7 +36,7 @@ lexical PathChar = ![/]; lexical PathSegment = current: "." | parent : ".." - | name : (PathChar \ "~" PathChar*) \ ".." \ "." \ "~" + | pname : (PathChar \ "~" PathChar*) \ ".." \ "." \ "~" ; lexical Slashes = Slash+ !>> [/]; @@ -78,12 +78,12 @@ private loc mapPathToLoc((UnixPath) `~`) = |home:///|; @synopsis{User relative: relative to any specific user's home directory} -private loc mapPathToLoc((UnixPath) `~`) - = appendPath(|home:///..//|, path); +private loc mapPathToLoc((UnixPath) `~`) + = appendPath(|home:///..//|, path); @synopsis{User relative: relative to any specific user's home directory} -private loc mapPathToLoc((UnixPath) `~`) - = |home:///..//|; +private loc mapPathToLoc((UnixPath) `~`) + = |home:///..//|; private loc appendPath(loc root, UnixFilePath path) = (root | it + "" | segment <- path.segments); diff --git a/src/org/rascalmpl/library/lang/rascal/grammar/analyze/Dependency.rsc b/src/org/rascalmpl/library/lang/rascal/grammar/analyze/Dependency.rsc index c0dc170ca71..fe717137e6e 100644 --- a/src/org/rascalmpl/library/lang/rascal/grammar/analyze/Dependency.rsc +++ b/src/org/rascalmpl/library/lang/rascal/grammar/analyze/Dependency.rsc @@ -16,7 +16,7 @@ import analysis::graphs::Graph; for regular expressions.} @experimental public Graph[Symbol] symbolDependencies(Grammar g) = - { | /prod(Symbol s,[*_,Symbol elem,*_],_) := g, /Symbol to := elem, (label(_,Symbol from) := s || Symbol from := s), to is sort || to is lex || to is \parameterized-sort, from is sort || from is lex || from is \parameterized-sort}; + { | /prod(Symbol s,[*_,Symbol elem,*_],_) := g, /Symbol to := elem, Symbol from := ((label(_,Symbol f) := s) ? f : s), to is sort || to is lex || to is \parameterized-sort, from is sort || from is lex || from is \parameterized-sort}; public Graph[Symbol] symbolDependencies(GrammarDefinition d) = { *symbolDependencies(d.modules[m].grammar) | m <- d.modules }; diff --git a/src/org/rascalmpl/library/lang/rascal/grammar/definition/Layout.rsc b/src/org/rascalmpl/library/lang/rascal/grammar/definition/Layout.rsc index c9e2c3b6cf6..264db1e4ac8 100644 --- a/src/org/rascalmpl/library/lang/rascal/grammar/definition/Layout.rsc +++ b/src/org/rascalmpl/library/lang/rascal/grammar/definition/Layout.rsc @@ -86,8 +86,13 @@ list[Symbol] intermix(list[Symbol] syms, Symbol l, set[Symbol] others) { return syms; } -private bool sepInOthers(Symbol sep, set[Symbol] others) // TODO: factored out due to compiler issue - = sep in others || (seq([a,_,b]) := sep && (a in others || b in others)); +private bool sepInOthers(Symbol sep, set[Symbol] others) + // TODO: factored out due to compiler issue + // TODO: rewritten to satisfy stricter variable rules for or operator + { if(sep in others) return true; + if(seq([a,_,b]) := sep) return (a in others || b in others); + return false; + } private Symbol regulars(Symbol s, Symbol l, set[Symbol] others) { return visit(s) { diff --git a/src/org/rascalmpl/library/lang/rascal/grammar/definition/Productions.rsc b/src/org/rascalmpl/library/lang/rascal/grammar/definition/Productions.rsc index 38d345354d4..3bfaccaab05 100644 --- a/src/org/rascalmpl/library/lang/rascal/grammar/definition/Productions.rsc +++ b/src/org/rascalmpl/library/lang/rascal/grammar/definition/Productions.rsc @@ -59,19 +59,17 @@ public tuple[set[Production] prods, Maybe[Symbol] \start] rule2prod(SyntaxDefini private Production prod2prod(Symbol nt, Prod p) { switch(p) { - case labeled(ProdModifier* ms, Name n, Sym* args) : - if ([Sym x] := args.args, x is empty) { - return associativity(nt, \mods2assoc(ms), prod(label(unescape(""),nt), [], mods2attrs(ms))); + case labeled(ProdModifier* ms, Name n, Sym* args) : { + if ([Sym x] := args.args, x is empty) { + return associativity(nt, \mods2assoc(ms), prod(label(unescape(""),nt), [], mods2attrs(ms))); + } + return associativity(nt, \mods2assoc(ms), prod(label(unescape(""),nt), args2symbols(args), mods2attrs(ms))); } - else { - return associativity(nt, \mods2assoc(ms), prod(label(unescape(""),nt), args2symbols(args), mods2attrs(ms))); - } - case unlabeled(ProdModifier* ms, Sym* args) : - if ([Sym x] := args.args, x is empty) { - return associativity(nt, mods2assoc(ms), prod(nt, [], mods2attrs(ms))); - } - else { - return associativity(nt, mods2assoc(ms), prod(nt,args2symbols(args),mods2attrs(ms))); + case unlabeled(ProdModifier* ms, Sym* args) : { + if ([Sym x] := args.args, x is empty) { + return associativity(nt, mods2assoc(ms), prod(nt, [], mods2attrs(ms))); + } + return associativity(nt, mods2assoc(ms), prod(nt,args2symbols(args),mods2attrs(ms))); } case \all(Prod l, Prod r) : return choice(nt,{prod2prod(nt, l), prod2prod(nt, r)}); diff --git a/src/org/rascalmpl/library/lang/rascal/matching/Fingerprint.rsc b/src/org/rascalmpl/library/lang/rascal/matching/Fingerprint.rsc index fa06484a54a..2bea1824da0 100644 --- a/src/org/rascalmpl/library/lang/rascal/matching/Fingerprint.rsc +++ b/src/org/rascalmpl/library/lang/rascal/matching/Fingerprint.rsc @@ -43,6 +43,9 @@ extend ParseTree; import Node; import List; +@synopsis{Remove outer label from symbol, if any} +private Symbol delabel(Symbol s) = label(_, Symbol t) := s ? t : s; + @synopsis{Computes a unique fingerprint for each kind of tree based on the identity of the top-level tree node.} @description{ Concrete fingerprint implements the pattern matching contract: @@ -56,8 +59,7 @@ To complete the function for the other kinds of trees, even though less importan implement a sensible encoding that follows the contract and tries to differentiate as much as possible between different values. } int concreteFingerprint(appl(Production p, list[Tree] _)) = concreteFingerprint(p); -int concreteFingerprint(amb({appl(prod(Symbol s, _, _), list[Tree] _), _})) = internalHashCode("amb") + 43 * internalHashCode(t) - when label(_, Symbol t) := s || Symbol t := s; +int concreteFingerprint(amb({appl(prod(Symbol s, _, _), list[Tree] _), _})) = internalHashCode("amb") + 43 * internalHashCode(delabel(s)); int concreteFingerprint(amb({})) = internalHashCode("amb"); int concreteFingerprint(char(int ch)) = internalHashCode("char") + internalHashCode(ch); int concreteFingerprint(cycle(Symbol s, int _)) = internalHashCode("cycle") + 13 * internalHashCode(s); diff --git a/src/org/rascalmpl/library/lang/rascal/syntax/tests/ImplodeTests.rsc b/src/org/rascalmpl/library/lang/rascal/syntax/tests/ImplodeTests.rsc index 476897ea5e6..61f3813df40 100644 --- a/src/org/rascalmpl/library/lang/rascal/syntax/tests/ImplodeTests.rsc +++ b/src/org/rascalmpl/library/lang/rascal/syntax/tests/ImplodeTests.rsc @@ -12,11 +12,11 @@ import lang::rascal::\syntax::tests::ImplodeTestGrammar; import ParseTree; import Exception; -public data Num(loc src=|unknown:///|, map[int,list[str]] comments = ()) = \int(str n); +public data Num(loc src=|unknown:///|, map[int,list[str]] comments = ()); public data Exp(loc src=|unknown:///|, map[int,list[str]] comments = ()) = id(str name) | eq(Exp e1, Exp e2) | number(Num n); public Exp number(Num::\int("0")) = Exp::number(Num::\int("01")); -public data Number(loc src=|unknown:///|, map[int,list[str]] comments = ()) = \int(str n); +public data Number(loc src=|unknown:///|, map[int,list[str]] comments = ()); public data Expr(loc src=|unknown:///|, map[int,list[str]] comments = ()) = id(str name) | eq(Expr e1, Expr e2) | number(Number n); public Expr number(Number::\int("0")) = Expr::number(Number::\int("02")); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/basic/CompilerIssues/LIstMatchInOR.rsc b/src/org/rascalmpl/library/lang/rascal/tests/basic/CompilerIssues/LIstMatchInOR.rsc index 2d008367184..c2c9027e004 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/basic/CompilerIssues/LIstMatchInOR.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/basic/CompilerIssues/LIstMatchInOR.rsc @@ -1,15 +1,40 @@ module lang::rascal::tests::basic::CompilerIssues::LIstMatchInOR +import IO; + data Symbol = strt() | par(list[Symbol] parameters) // <6>> ; + - @ignoreCompiler{Generates incorrect code} -test bool listMatchInOR() { - bool unquotable(Symbol x) - = par([*Symbol _]) := x - || strt() := x - ; - return unquotable(\strt()); -} \ No newline at end of file +//@ignoreCompiler{Generates incorrect code} +//test bool listMatchInOR() { +// bool unquotable(Symbol x) +// = par([*Symbol _]) := x +// || strt() := x +// ; +// return unquotable(\strt()); +//} + + +data Symbol + = sym(str name) + | label(str name, Symbol sym) + ; + +// Simplified version from lang::rascal::grammar::analyze::Dependency +set[Symbol] symbolDependenciesOld(set[Symbol] sses) = + { from | s <- sses, (label(_,Symbol from) := s || Symbol from := s)}; + +// Test for original version (with probably unintended result) +@ignoreCompiler{Generates incorrect code} +test bool symbolDependenciesOld1() += symbolDependenciesOld({sym("a"), label("x", sym("b"))}) == {sym("a"), sym("b"), label("x", sym("b"))}; + +// Rewritten version with intended output, compiler behaves well on it +set[Symbol] symbolDependenciesNew(set[Symbol] sses) = + { from | s <- sses, Symbol from := ((label(_,Symbol f) := s) ? f : s) }; + +test bool symbolDependenciesNew1() += symbolDependenciesNew({sym("a"), label("x", sym("b"))}) == {sym("a"), sym("b")}; diff --git a/src/org/rascalmpl/library/lang/rascal/tests/basic/CompilerIssues/ListMatchInIfCondition.rsc b/src/org/rascalmpl/library/lang/rascal/tests/basic/CompilerIssues/ListMatchInIfCondition.rsc new file mode 100644 index 00000000000..a667e2122e6 --- /dev/null +++ b/src/org/rascalmpl/library/lang/rascal/tests/basic/CompilerIssues/ListMatchInIfCondition.rsc @@ -0,0 +1,15 @@ +module lang::rascal::tests::basic::CompilerIssues::ListMatchInIfCondition + +int f(list[int] ds){ + if([int xxx]:= ds, xxx > 0){ + return 1; + } else { + return 2; + } +} + +@ignoreCompiler{Generates incorrect code} +test bool ListMatchInIfCondition1() = f([1]) == 1; + +@ignoreCompiler{Generates incorrect code} +test bool ListMatchInIfCondition2() = f([-1]) == 2; \ No newline at end of file diff --git a/src/org/rascalmpl/library/lang/rascal/tests/basic/CompilerIssues/VariableInOr.rsc b/src/org/rascalmpl/library/lang/rascal/tests/basic/CompilerIssues/VariableInOr.rsc new file mode 100644 index 00000000000..22ed4a3da7b --- /dev/null +++ b/src/org/rascalmpl/library/lang/rascal/tests/basic/CompilerIssues/VariableInOr.rsc @@ -0,0 +1,10 @@ +module lang::rascal::tests::basic::CompilerIssues::VariableInOr + +data D = d1(int n) | label(D d); + +@ignoreCompiler{Generates erroneous Java code} +int f(D d) = e.n + when label(D e) := d || e := d; + +@ignoreCompiler{Generates erroneous Java code} +test bool testF() = f(label(d1(10))) == 10; \ No newline at end of file diff --git a/src/org/rascalmpl/library/lang/rascal/tests/basic/Functions.rsc b/src/org/rascalmpl/library/lang/rascal/tests/basic/Functions.rsc index eff38a9960f..fec17b3fa7d 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/basic/Functions.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/basic/Functions.rsc @@ -543,3 +543,48 @@ int useExtraFormalInListPattern(f([*int ints])){ } test bool useExtraFormalInListPattern1() = useExtraFormalInListPattern(f([42])) == 42; + +int _f(int n) = n; + +test bool functionNameStartsWithUnderscore() = _f(13) == 13; + +test bool innerAndOuterFunctionUseSameParameterName1(){ + int outer(int t) { + int inner(t:3) = t; + default int inner(int t) = 10*t; + return inner(t); + } + + return outer(3) == 3 && outer(5) == 50; +} + +test bool innerAndOuterFunctionUseSameParameterName2(){ + int outer(int t) { + int inner(int t:3) = t; + default int inner(int t) = 10*t; + return inner(t); + } + + return outer(3) == 3 && outer(5) == 50; +} + +@ignoreCompiler{"Return type `int` expected, found `str`"} +test bool innerAndOuterFunctionUseSameParameterName3(){ + int outer(str t) { + int inner(t:3) = t; + default int inner(int t) = 10*t; + return inner(3); + } + + return outer("a") == 30; +} + +test bool innerAndOuterFunctionUseSameParameterName4(){ + int outer(str t) { + int inner(int t:3) = t; + default int inner(int t) = 10*t; + return inner(3); + } + + return outer("a") == 3; +} 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 5397a82f756..4c97c758153 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/basic/IO.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/basic/IO.rsc @@ -4,6 +4,7 @@ import String; import IO; import util::UUID; +import Exception; private loc aFile = |memory://test-tmp/basic-io-<"">.txt|; diff --git a/src/org/rascalmpl/library/lang/rascal/tests/basic/Locations.rsc b/src/org/rascalmpl/library/lang/rascal/tests/basic/Locations.rsc index ef8cb6b5c3b..7937e963d36 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/basic/Locations.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/basic/Locations.rsc @@ -12,11 +12,11 @@ import util::FileSystem; int singleChar(str s) = charAt(s,0); -list[int] makeValidSchemeChars() = [singleChar("a")..singleChar("z")] + [singleChar("A")..singleChar("Z")] +list[int] makeValidSchemeChars() = [singleChar("a")..singleChar("z")] + [singleChar("A")..singleChar("Z")] + [singleChar("0")..singleChar("9")] + [singleChar("+"), singleChar("-"), singleChar(".")] ; - -list[int] validSchemeChars = [singleChar("a")..singleChar("z")] + [singleChar("A")..singleChar("Z")] + +list[int] validSchemeChars = [singleChar("a")..singleChar("z")] + [singleChar("A")..singleChar("Z")] + [singleChar("0")..singleChar("9")] + [singleChar("+"), singleChar("-"), singleChar(".")] ; @@ -66,10 +66,10 @@ test bool validURIFragment(loc l, str s) = l[fragment = s].uri != ""; str fixPathAddition(str s) = replaceAll(s, "/", ""); -test bool pathAdditions1(list[str] ss) - = (|tmp:///ba| | it + t | s <- ss, t := fixPathAddition(s), t != "" ).path +test bool pathAdditions1(list[str] ss) + = (|tmp:///ba| | it + t | s <- ss, t := fixPathAddition(s), t != "" ).path == ("/ba" | it + "/" + t | s <- ss, t := fixPathAddition(s), t != "" ); - + test bool pathAdditions2(loc l, str s) = s == "" || (l + fixPathAddition(s)).path == ((endsWith(l.path, "/") ? l.path : l.path + "/") + fixPathAddition(s)) ; test bool testParent(loc l, str s) = s == "" || ((l + replaceAll(s, "/","_")).parent + "/") == (l[path=l.path] + "/"); @@ -113,21 +113,21 @@ test bool enclosingTest8() = !(|tmp:///x.src|(4,11,<0,0>,<0,0>) <= |tmp:///x.src test bool enclosingTest9() = !(|tmp:///x.src|(4,11,<0,0>,<0,0>) <= |tmp:///x.src|(4,10,<0,0>,<0,0>)); test bool offSetLengthEnclosing(int aOffset, int aLength, int bOffset, int bLength) - = (abs(aOffset) < toInt(pow(2,31)) + = (abs(aOffset) < toInt(pow(2,31)) && abs(aOffset) + abs(aLength) < toInt(pow(2,31)) - && abs(bOffset) < toInt(pow(2,31)) + && abs(bOffset) < toInt(pow(2,31)) && abs(bOffset) + abs(bLength) < toInt(pow(2,31)) - && abs(aOffset) >= abs(bOffset) - && abs(aOffset) <= abs(bOffset) + abs(bLength) + && abs(aOffset) >= abs(bOffset) + && abs(aOffset) <= abs(bOffset) + abs(bLength) && abs(aOffset) + abs(aLength) <= abs(bOffset) + abs(bLength)) ==> |tmp:///x.rsc|(abs(aOffset), abs(aLength),<0,0>,<0,0>) <= |tmp:///x.rsc|(abs(bOffset), abs(bLength),<0,0>,<0,0>); - + // Simulate a list of 1000 lines each of length < 1000; -public list[int] lineSizes = [ arbInt(1000) | int _ <- [1 .. 1000] ]; +public list[int] lineSizes = [ arbInt(1000) | int _ <- [1 .. 1000] ]; -public int maxIndex = (0 | it + lineSizes[i] | int i <- index(lineSizes)); +public int maxIndex = (0 | it + lineSizes[i] | int i <- index(lineSizes)); // Turn an index in the above list into a line/column pair tuple[int line, int column] getLineAndColumn(int idx){ @@ -225,7 +225,7 @@ test bool equal1(int f, int t){ test bool equal2(int f, int t){ f = restrict(f); t = restrict(t); l1 = getLoc(f, t, base="base1.src"); l2 = getLoc(f, t, base="base2.src"); - return !(l1 == l2); + return !(l1 == l2); } // Create a list of n different locations @@ -270,20 +270,20 @@ tuple[loc, loc] makeLocsWithGap(int gap){ sign = gap > 0 ? 1 : -1; absgap = min(abs(gap), maxIndex/2); m1 = 1 + arbInt(maxIndex - absgap - 2); // 1 <= m1 <= maxIndex - 2 - m2 = m1 + sign * absgap; - + m2 = m1 + sign * absgap; + llen = arbInt(m1); l = getLoc(m1 - llen, m1); - + rlen = m2 == maxIndex ? 0 : arbInt(maxIndex - m2); r = getLoc(m2, m2 + rlen); - + if (l.offset == r.offset && r.length == 0) { return ; } else if (l.offset >= r.offset) { return ; - } + } else { return ; } @@ -371,7 +371,7 @@ test bool isStrictlyContainedIn2(int f, int len) { test bool isStrictlyContainedIn3(int f, int len) { f1 = restrict(f); t1 = restrict(f1 + len); - l1 = getLoc(f1, t1); + l1 = getLoc(f1, t1); return report(l1, l1, !isStrictlyContainedIn(l1, l1)); } @@ -446,6 +446,16 @@ test bool isOverlapping2(int _){ return !isOverlapping(l1, l2); } +test bool isOverlapping3() = isOverlapping(|unknown:///|(0, 2), |unknown:///|(0, 2)); +test bool isOverlapping4() = isOverlapping(|unknown:///|(0, 2), |unknown:///|(1, 2)); +test bool isOverlapping5() = !isOverlapping(|unknown:///|(0, 2), |unknown:///|(2, 2)); +test bool isOverlapping6() = isOverlapping(|unknown:///|(1, 2), |unknown:///|(0, 2)); +test bool isOverlapping7() = isOverlapping(|unknown:///|(1, 2), |unknown:///|(1, 2)); +test bool isOverlapping8() = isOverlapping(|unknown:///|(1, 2), |unknown:///|(2, 2)); +test bool isOverlapping9() = !isOverlapping(|unknown:///|(2, 2), |unknown:///|(0, 2)); +test bool isOverlapping10() = isOverlapping(|unknown:///|(2, 2), |unknown:///|(1, 2)); +test bool isOverlapping11() = isOverlapping(|unknown:///|(2, 2), |unknown:///|(2, 2)); + // cover test bool isCover1(int _){ @@ -486,7 +496,7 @@ test bool trailingSlashFile2() { ; } -test bool testRelativize() +test bool testRelativize() = relativize(|file:///a/b|, |file:///a/b/c.txt|) == |relative:///c.txt|; @@ -494,11 +504,11 @@ test bool testFailedRelativize() = relativize(|file:///b/b|, |file:///a/b/c.txt|) == |file:///a/b/c.txt|; -test bool trailingSlashRelativize1() +test bool trailingSlashRelativize1() = relativize(|file:///library/|, |file:///library|) == relativize(|file:///library/|, |file:///library/|); -test bool trailingSlashRelativize2() +test bool trailingSlashRelativize2() = relativize(|file:///library|, |file:///library/|) == relativize(|file:///library|, |file:///library|); @@ -514,7 +524,7 @@ test bool extensionSetWithSlash() test bool extensionSetWithSlashAndMoreDots() = |file:///a.txt/b.noot/|[extension="aap"] == |file:///a.txt/b.aap/|; -test bool extensionGetWithMoreDot1() +test bool extensionGetWithMoreDot1() = |file:///a.txt/b|.extension == ""; test bool extensionGetWithMoreDots2() @@ -610,4 +620,17 @@ test bool mvnSchemeTest() { return true; -} \ No newline at end of file +} + +@synopsis{Nested clones in different scopes are acceptable} +int fun_with_clone(int n){ + if(n > 0){ + int h(int n) = 2*n; + return h(n); + } else { + int h(int n) = 2*n; + return h(n); + } +} + +test bool noCodeClone() = fun_with_clone(3) == 6; \ No newline at end of file diff --git a/src/org/rascalmpl/library/lang/rascal/tests/basic/Relations.rsc b/src/org/rascalmpl/library/lang/rascal/tests/basic/Relations.rsc index bfbae1e6403..459ef2588c4 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/basic/Relations.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/basic/Relations.rsc @@ -108,3 +108,16 @@ test bool tst_rangeX(rel[int, int] X) { XR = rangeX(X, s); return isEmpty(XR) || all(<_, b> <- XR, b notin s); } + +@expected{UndeclaredField} +@ignoreCompiler{The checker would detect this} +test bool fieldSelectionNoFields() { + x = {}; + x; // throws UndeclaredField + return false; +} + +test bool fieldSelectionEmpty() { + rel[int a, int b] x = {}; + return x == {}; +} \ No newline at end of file diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/AtColumnRequirement.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/AtColumnRequirement.rsc new file mode 100644 index 00000000000..11011a95a92 --- /dev/null +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/AtColumnRequirement.rsc @@ -0,0 +1,22 @@ +module lang::rascal::tests::concrete::AtColumnRequirement + +import ParseTree; +import Exception; + +lexical C = C C C | "a"@2 | "b"; + +bool testParse(str input, bool shouldParse) { + try { + parse(#C, input); + } catch ParseError(_): { + return !shouldParse; + } + + return shouldParse; +} + +test bool testA() = testParse("a", false); + +test bool testBab() = testParse("bab", false); + +test bool testBba() = testParse("bba", true); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/Syntax1.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/Syntax1.rsc index 25e3cda0242..636eb06ebef 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/Syntax1.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/Syntax1.rsc @@ -87,485 +87,4 @@ test bool cntES1() = cntES(((ES) `e`).args) == 1; test bool cntES2() = cntES(((ES) `e,e`).args) == 2; test bool cntES3() = cntES(((ES) `e ,e`).args) == 2; test bool cntES4() = cntES(((ES) `e, e`).args) == 2; -test bool cntES5() = cntES(((ES) `e , e`).args) == 2; - -/* - - @Test - public void parseDSInModule(){ - prepareModule("M", "module M " + - "import GrammarABCDE;" + - "import ParseTree;" + - "public DS ds = (DS)`d d d`;" + - "public DS parseDS(str input) { return parse(#DS, input); }"); - prepareMore("import ParseTree;"); - prepareMore("import M;"); - assertTrue(runTestInSameEvaluator("parseDS(\"d d d\") == ds;")); - } - - @Test @Ignore("not supported") - public void singleA(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("`a` := `a`;")); - } - - @Test @Ignore("not supported") - public void singleATyped(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("(A)`a` := `a`;")); - } - - @Test @Ignore("not supported") - public void singleAUnquoted1(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("a := `a`;")); - } - - @Test(expected=UndeclaredVariable.class) @Ignore("not supported") - public void singleAUnquoted2(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("a := a;")); - } - - @Test @Ignore("not supported") - public void AB(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("`a b` := `a b`;")); - } - - @Test @Ignore("not supported") - public void ABspaces1(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("`a b` := `a b`;")); - } - - @Test(expected=UnsupportedPattern.class) @Ignore("not supported") - public void varAQuoted(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - runTestInSameEvaluator("`` := `a`;"); - } - - @Test @Ignore("not supported") - public void varAassign(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - runTestInSameEvaluator("{someA := `a` && someA == `a`;}"); - } - - @Test @Ignore("not supported") - public void varAQuotedTyped(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("`` := `a`;")); - } - - @Test @Ignore("not supported") - public void varAQuotedDeclaredBefore(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{A someA; (A)`` := `a`;}")); - } - - @Test @Ignore("not supported") - public void VarATypedInsertAmbiguous(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{ `` := `a` && someA == `a`; }")); - } - - @Test @Ignore("not supported") - public void VarATypedInsert(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{ `` := `a` && someA == `a`; }")); - } - - @Test @Ignore("not supported") - public void ABvars1(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("`a ` := `a b`;")); - } - - @Test @Ignore("not supported") - public void ABvars1Typed(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("`a ` := `a b`;")); - } - - @Test @Ignore("not supported") - public void ABvars2(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("` ` := `a b`;")); - } - - @Test @Ignore("not supported") - public void ABvars2Typed(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("` ` := `a b`;")); - } - - @Test @Ignore("not supported") - public void ABvars2TypedEq(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{` ` := `a b` && someA ==`a` && someB == `b`;}")); - } - - @Test @Ignore("not supported") - public void ABvars2TypedInsertWithoutTypes(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{ `` := `a b` && `` == `a b`;}")); - } - - @Test @Ignore("not supported") - public void ABvars2TypedInsertWithTypes(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{ `` := `a b` && (C)`` == `a b`;}")); - } - - @Test @Ignore("not supported") - public void ABequal1(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("`a b` == `a b`;")); - } - - @Test @Ignore("not supported") - public void ABequal5(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("`a b` == `a b`;")); - } - - @Test @Ignore("not supported") - public void D1(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("`d` := `d`;")); - } - - @Test @Ignore("not supported") - public void D2(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("`d d` := `d d`;")); - } - - @Test @Ignore("not supported") - public void D3(){ - prepare("import GrammarABCDE;"); - assertTrue(runTestInSameEvaluator("(DS)`d d` := `d d`;")); - } - - @Test @Ignore("not supported") - public void D4(){ - prepare("import GrammarABCDE;"); - assertTrue(runTestInSameEvaluator("`d d` := (DS)`d d`;")); - } - - @Test(expected=UnsupportedPattern.class) @Ignore("not supported") - public void Dvars(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("`` := `d d`;")); - } - - @Test @Ignore("not supported") - public void DvarsTyped(){ - prepare("import GrammarABCDE;"); - assertTrue(runTestInSameEvaluator("{ D+ Xs := (D+) `d d` && Xs == (D+) `d d`; }")); - } - - @Test(expected=StaticError.class) @Ignore("not supported") - public void DvarsTypedInsert2Untyped(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{ `` := `d`; }")); - } - - @Test @Ignore("not supported") - public void DvarsTypedInsert32(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{ `` := (D+) `d d`; }")); - } - - @Test @Ignore("not supported") - public void DvarsTypedInsert4UnTyped(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("(`d ` := `d d`) && `d ` == `d d`;")); - } - - @Test @Ignore("not supported") - public void DvarsTypedInsert5Untyped(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{ `d ` := `d d d` && `d ` == `d d d`; }")); - } - - @Test @Ignore("not supported") - public void E1(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("`e` := `e`;")); - } - - @Test @Ignore("not supported") - public void E2(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("`e, e` := `e, e`;")); - } - - @Test @Ignore("not supported") - public void E2spaces1(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("`e, e` := `e , e`;")); - } - - @Test @Ignore("not supported") - public void E2spaces2(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("`e, e` := `e , e`;")); - } - - @Test @Ignore("not supported") - public void Evars1(){ - prepare("import GrammarABCDE;"); - assertTrue(runTestInSameEvaluator("{ Xs := `e, e` && Xs == `e, e`;}")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void Evar1Typed(){ - prepare("import GrammarABCDE;"); - assertTrue(runTestInSameEvaluator("{ {E \",\"}+ Xs := ({E \",\"}+) `e, e` && Xs == ({E \",\"}+) `e, e`;}")); - } - - @Test @Ignore("not supported") // (expected=AmbiguousConcretePattern.class) - public void Evars2(){ - prepare("import GrammarABCDE;"); - assertTrue(runTestInSameEvaluator("{ `e, ` := `e, e` && Xs == `e`;}")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void NoStarSubjectToPlusVar(){ - prepare("import GrammarABCDE;"); - assertFalse(runTestInSameEvaluator("{E \",\"}+ Xs := ({E \",\"}*) ``;")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void plusListShouldNotMatchEmptyList() { - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertFalse(runTestInSameEvaluator("({E \",\"}+) `e, <{E \",\"}+ Es>` := ({E \",\"}+) `e`;")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void starListPatternShouldMatchPlusListSubject() { - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{E \",\"}* Zs := ({E \",\"}+) `e, e`;")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void plusListPatternShouldMatchPStarListSubjectIfNotEmpty() { - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{E \",\"}+ Zs := ({E \",\"}*) `e, e`;")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void plusListPatternShouldNotMatchPStarListSubjectIfEmpty() { - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertFalse(runTestInSameEvaluator("{E \",\"}+ Zs := ({E \",\"}*) ``;")); - } - - @Test @Ignore("not supported") - public void emptyListVariablePatternShouldBeSplicedInbetweenSeparators() { - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("`e, <{E \",\"}* Xs>, e` := `e, e`;")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void emptyListVariablePatternShouldBeSplicedInbetweenSeparatorsAndBindToEmptyList() { - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("`e, <{E \",\"}* Xs>, e` := `e, e` && Xs == ({E \",\"}*) ``;")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void emptySepListShouldSpliceCorrectly(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{E \",\"}* Xs := ({E \",\"}*) `` && `e, <{E \",\"}* Xs>, e` == `e, e`;")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void Evars2Typed(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{ `e, <{E \",\"}+ Xs>` := `e, e` && Xs == ({E \",\"}+) `e`;}")); - } - - @Test // (expected=AmbiguousConcretePattern.class) - @Ignore("not supported") - // @Ignore("needs to be reinstated when we have a type checker") - public void Evars3(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{ `e, ` := `e, e` && Xs == `e` && `e, ` == `e, e`; }")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void Evars3Typed(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{ `e, <{E \",\"}+ Xs>` := `e, e` && Xs == ({E \",\"}+) `e` && ({E \",\"}+) `e, <{E \",\"}+ Xs>` == `e, e`; }")); - } - - @Test // (expected=AmbiguousConcretePattern.class) - @Ignore("needs to be reinstated when we have a type checker") - public void Evars4(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{ `e, ` := `e` && Xs == ` ` && ` e, ` == `e`; }")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void EvarsTyped(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{E \",\"}+ Xs := `e, e`;")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void EvarsTypedInsert1(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{ `<{E \",\"}+ Xs>` := `e, e` && `e, <{E \",\"}+ Xs>` == `e, e, e`; }")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void EvarsTypedInsert1Typed(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{ `<{E \",\"}+ Xs>` := `e, e` && `e, <{E \",\"}+ Xs>` == `e, e, e`; }")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void EvarsTypedInsert2(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{ `<{E \",\"}+ Xs>` := `e, e` && `e, <{E \",\"}+ Xs>` == `e, e, e`; }")); - } - - @Test @Ignore("not supported") - public void EvarsTypedInsert3(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{ `e, <{E \",\"}+ Xs>` := `e, e, e` && `e, <{E \",\"}+ Xs>` == `e, e, e`; }")); - } - - @Test @Ignore("can not know that `d` should be a D+ list without a type checker") - public void enumeratorDs1Untyped(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{L = [X | X <- `d` ]; L == [`d`];}")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void enumeratorDs1Typed(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{L = [X | D X <- `d` ]; L == [ `d` ];}")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void enumeratorDsUnyped(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{L = [X | X <- `d d d` ]; L == [`d`, `d`, `d`];}")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void enumeratorDsTyped(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{L = [X | D X <- `d d d` ]; L == [`d`, `d`, `d`];}")); - } - - @Test @Ignore("Can not know that `e` should be an E* or E+ list without a type-checker") - public void enumeratorEs1Untyped(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{L = [X | X <- `e` ]; L == [ `e` ];}")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void enumeratorEs1Typed(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{L = [X | E X <- `e` ]; L == [ `e` ];}")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void enumeratorEsUntyped(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{L = [X | X <- `e, e, e` ]; L == [`e`, `e`, `e`];}")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void enumeratorEsTyped(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("{L = [X | E X <- `e, e, e` ]; L == [`e`, `e`, `e`];}")); - } - - @Test - @Ignore("Functionality subject to future/current change") - public void EvarsTypedInsert3Empty(){ - prepare("import GrammarABCDE;"); - prepareMore("import ParseTree;"); - assertTrue(runTestInSameEvaluator("` e, <{E \",\"}* Xs> ` := ({E \",\"}+) `e`;")); - } - - */ +test bool cntES5() = cntES(((ES) `e , e`).args) == 2; \ No newline at end of file diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/Syntax3.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/Syntax3.rsc index 7a51d029e6c..0d267360dce 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/Syntax3.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/Syntax3.rsc @@ -8,8 +8,8 @@ syntax Aas | aas: [a][a][a]* ; -Aas ambFilter(amb(set[Aas] alternatives)) { - set[Aas] result = {a | Aas a <- alternatives, !(a is nil)}; +&T <: Tree ambFilter(amb(set[&T <: Tree] alternatives)) { + set[&T <: Tree] result = {a | &T <: Tree a <- alternatives, !(a is nil)}; if ({oneTree} := result) { return oneTree; diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/Syntax8.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/Syntax8.rsc index b971dc252c5..1e020593f06 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/Syntax8.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/Syntax8.rsc @@ -37,14 +37,14 @@ test bool sizeABStar0() = size(([ABStar]"").abs) == 0; @ignoreInterpreter{Not implemented} test bool sizeABStar1() = size(([ABStar]"a").abs) == 1; @ignoreInterpreter{Not implemented} -test bool sizeABStar2() = size(([ABStar]"a").abs) == 2; +test bool sizeABStar2() = size(([ABStar]"a a").abs) == 2; @ignoreInterpreter{Not implemented} test bool sizeABPlus1() = size(([ABPlus]"a").abs) == 1; @ignoreInterpreter{Not implemented} -test bool sizeABPlus2() = size(([ABPlus]"a, b").abs) == 2; +test bool sizeABPlus2() = size(([ABPlus]"a b").abs) == 2; @ignoreInterpreter{Not implemented} -test bool sizeABPlus3() = size(([ABPlus]"a, b, a").abs) == 3; +test bool sizeABPlus3() = size(([ABPlus]"a b a").abs) == 3; int size({&E &S}* l) = (0 | it + 1 | _ <- l); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/extends3/Modules2DefinitionTest.rsc b/src/org/rascalmpl/library/lang/rascal/tests/extends3/Modules2DefinitionTest.rsc index cfe1d542460..2987d2941cf 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/extends3/Modules2DefinitionTest.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/extends3/Modules2DefinitionTest.rsc @@ -1,5 +1,6 @@ module lang::rascal::tests::extends3::Modules2DefinitionTest +import lang::rascal::\syntax::Rascal; import lang::rascal::grammar::definition::Parameters; import lang::rascal::grammar::definition::Modules; import lang::rascal::grammar::definition::Names; @@ -14,7 +15,7 @@ test bool layoutPropagationOverImportAndExtendTest() { trees = {parseModuleWithSpaces(m).top | m <- testModules, bprintln(m)}; - for (m <- trees) { + for (Module m <- trees) { str main = ""; def = modules2definition(main, trees); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/functionality/KeywordParameter.rsc b/src/org/rascalmpl/library/lang/rascal/tests/functionality/KeywordParameter.rsc index c0008ca8c5f..8e59c4ff85d 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/functionality/KeywordParameter.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/functionality/KeywordParameter.rsc @@ -244,4 +244,106 @@ data GGG = ggg(rel[int a, int b] r = {<1,2>}); test bool fieldsNamesOfKeywordParametersIssue1851() { ax = ggg(); return ax.r.a == {1}; -} \ No newline at end of file +} + +// Keyword parameters used in closures + +test bool keywordParameterInClosure1(){ + int f(int n, int(int) fun) = n + fun(n); + + int g(int d = 3){ + return f(7, int(int x) { return x + d; }); + } + return g(d = 5) == 19; +} + +test bool keywordParameterInClosure2(){ + int f(int n, int(int) fun) = n + fun(n); + + int g(int n, int d = 2 * n){ + return f(n, int(int x) { return x + d; }); + } + return g(7) == 28; +} + +test bool keywordParameterInClosure3(){ + int f(int n, int(int) fun) = n+ fun(n); + + int g(int n, int d = 2 * n){ + return f(n, int(int x) { return x + d; }); + } + return g(7, d=5) == 19; +} + +// Using keyword parameters in inner functions + + +int outer1(int t, int tabSize=4){ + int rec(int t) = t + tabSize when t > 10; + default int rec(int t) = t; + return rec(t); +} + +test bool outer1_1() = outer1(1) == 1; +test bool outer1_11() = outer1(11) == 15; +test bool outer1_11_kw() = outer1(11, tabSize=40) == 51; + +int outer2(int t, int tabSize=4){ + int rec(int t, int innerKwp = 5) = t + tabSize + innerKwp when t > 10; + default int rec(int t) = t; + return rec(t); +} + +test bool outer2_1() = outer2(1) == 1; +test bool outer2_11() = outer2(11) == 20; +test bool outer2_11_kw() = outer2(11, tabSize=40) == 56; + +int outer3(int t, int tabSize=4){ + int rec(int t){ + int rec_inner(int t) = t + tabSize when t > 10; + default int rec_inner(int t) = t; + return rec_inner(t); + } + return rec(t); +} + +test bool outer3_1() = outer3(1) == 1; +test bool outer3_11() = outer3(11) == 15; +test bool outer3_11_kw() = outer3(11, tabSize=40) == 51; + + +int outer4(int t, int tabSize=4){ + int rec(int t){ + int rec_inner(int t, int innerKwp = 5) = t + tabSize + innerKwp when t > 10; + default int rec_inner(int t) = t; + return rec_inner(t); + } + return rec(t); +} + +test bool outer4_1() = outer4(1) == 1; +test bool outer4_11() = outer4(11) == 20; +test bool outer4_11_kw() = outer4(11, tabSize=40) == 56; + + +int outer5(int t, int tabSize=4){ + int rec(int t){ + int rec_inner(int t, int innerKwp = 5) = t + tabSize + innerKwp when t > 10; + default int rec_inner(int t) = t; + return rec_inner(t, innerKwp = 50); + } + return rec(t); +} + +test bool outer5_1() = outer5(1) == 1; +test bool outer5_11() = outer5(11) == 65; +test bool outer5_11_kw() = outer5(11, tabSize=40) == 101; + + +data WorkspaceInfo(rel[int a, int b] defines = {}) = workspaceInfo(); + +@synopsis{a test for issue #2049} +test bool staticTypesOfCommonKeywordDefaults() { + ws = workspaceInfo(); + return ws.defines == {}; +} diff --git a/src/org/rascalmpl/library/lang/rascal/tests/functionality/PatternList1.rsc b/src/org/rascalmpl/library/lang/rascal/tests/functionality/PatternList1.rsc index 03040c4f4b3..b814d802733 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/functionality/PatternList1.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/functionality/PatternList1.rsc @@ -687,6 +687,7 @@ test bool matchListSpliceVars4() = [1, * int _, 4, 5] := [1, 2, 3, 4, 5]; test bool matchListSpliceVars5() = [1, *L, 4, *L, 5] := [1, 2, 3, 4, 2, 3, 5] && L == [2, 3]; test bool matchListSpliceVars6() = [1, * int L, 4, *L, 5] := [1, 2, 3, 4, 2, 3, 5] && L == [2, 3]; +@ignoreCompiler{To be investigated} test bool matchListSpliceVarsInOr() = [1,2,3] == (([*int x] := [1,2,3] || [*int x] := [10,20,30]) ? x : []); @@ -700,6 +701,7 @@ test bool matchListTuples5() = [*c, ] := [<1, 2>, <3, 3>]; test bool matchListTuples6() = [*c, ] := [<1, 2>, <3, 3>]; test bool matchListTuples7() = [, , *c] := [<1, 2>, <2, 2>, <3, 4>]; +@ignoreCompiler{To be investigated} test bool matchListTuples8() { if([<1, int n, 3>] := [<1, 2, 3>] && n == -2){ return false; @@ -951,6 +953,7 @@ test bool matchTypedListVarBecomes2() = [1, list[int] L: [int _], 2] := [1,[2],2 test bool matchTypedListVarBecomes3() = [1, list[int] L1: [*int L2, int N], 5] := [1,[2,3,4],5] && L1 == [2,3,4] && L2 == [2,3] && N == 4; test bool matchTypedListVarBecomes4() = [1, list[int] L1: [*int L2, int N], L1] := [1,[2,3,4],[2,3,4]] && L1 == [2,3,4] && L2 == [2,3] && N == 4; +@ignoreCompiler{To be investiagted} test bool matchTypedListVarInOr() = 1 == (([int x: 1] := [1] || [int x: 10] := [10]) ? x : -1); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/functionality/PatternSet1.rsc b/src/org/rascalmpl/library/lang/rascal/tests/functionality/PatternSet1.rsc index a9137121085..0e28ad13d6b 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/functionality/PatternSet1.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/functionality/PatternSet1.rsc @@ -638,9 +638,11 @@ test bool matchSetSpliceVars2() = {1, * int S, 4, 5}:= {1, 2, 3, 4, 5} && S == { test bool matchSetSpliceVars3() = {1, *_, 4, 5} := {1, 2, 3, 4, 5}; test bool matchSetSpliceVars4() = {1, * int _, 4, 5} := {1, 2, 3, 4, 5}; +@ignoreCompiler{To be investigated} test bool matchSetSpliceVarInOr() = {1,2,3} == (({*int x} := {1,2,3} || {*int x} := {10,20,30}) ? x : {}); +@ignoreCompiler{To be investigated} test bool matchTypedSetVarInOr() = 1 == (({int x: 1} := {1} || {int x: 10} := {10}) ? x : -1); @@ -672,6 +674,7 @@ test bool matchSetLists5() = {[a, a], *c} := {[1, 2], [3, 3]}; test bool matchSetLists6() = {[int a, a], *c} := {[1, 2], [3, 3]}; test bool matchSetLists7() = {[int a, int b], [b, b], *c} := {[1, 2], [2, 2], [3, 4]}; +@ignoreCompiler{To be investigated} test bool matchSetLists8() { if({[1, int n, 3]} := {[1, 2, 3]} && n == -2){ return false; diff --git a/src/org/rascalmpl/library/lang/rascal/tests/functionality/Scoping.rsc b/src/org/rascalmpl/library/lang/rascal/tests/functionality/Scoping.rsc index 21c463d300f..bc05f0ba7f4 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/functionality/Scoping.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/functionality/Scoping.rsc @@ -35,7 +35,7 @@ module lang::rascal::tests::functionality::Scoping int n = 5; L = [n | int n <- [1 .. 10]]; return n==5; } - test bool localRedeclarationError10(){ + test bool localReunexpectedDeclaration10(){ int n; L = [n | int n <- [1 .. 10]]; return L == [1 .. 10]; } */ diff --git a/src/org/rascalmpl/library/lang/rascal/tests/functionality/Visit1.rsc b/src/org/rascalmpl/library/lang/rascal/tests/functionality/Visit1.rsc index cef05682a43..891b3606f4e 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/functionality/Visit1.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/functionality/Visit1.rsc @@ -751,6 +751,84 @@ test bool StringVisit74() = deescape("\\\<") == "\<"; test bool StringVisit75() = deescape("\\\>") == "\>"; test bool StringVisit76() = deescape("\\n") == "n"; +// test some unicode features of string visiting +test bool StringUnicodeVisitEmoji1() { + return visit ("Hello 🌈World") { + case /🌈/ => "" + } == "Hello World"; +} + +test bool StringUnicodeVisitEmoji1TD() { + return top-down visit ("Hello 🌈World") { + case /🌈/ => "" + } == "Hello World"; +} + +test bool StringUnicodeVisitEmoji1TDB() { + return top-down-break visit ("Hello 🌈World") { + case /🌈/ => "" + } == "Hello World"; +} + +test bool StringUnicodeVisitEmoji1BU() { + return bottom-up visit ("Hello 🌈World") { + case /🌈/ => "" + } == "Hello World"; +} + +test bool StringUnicodeVisitEmoji1BUB() { + return bottom-up-break visit ("Hello 🌈World") { + case /🌈/ => "" + } == "Hello World"; +} + +test bool StringUnicodeVisitEmoji1INNER() { + return innermost visit ("Hello 🌈World") { + case /🌈/ => "" + } == "Hello World"; +} + +test bool StringUnicodeVisitEmoji1OUTER() { + return outermost visit ("Hello 🌈World") { + case /🌈/ => "" + } == "Hello World"; +} + +test bool StringUnicodeVisitEmoji2() { + return visit ("Hello World") { + case / / => "🌈" + } == "Hello🌈World"; +} +test bool StringUnicodeVisitEmoji3() { + return visit ("Hello👍🏽World") { + case /👍🏽/ => "🌈" + } == "Hello🌈World"; +} + +test bool StringUnicodeVisitEmoji4() { + return visit ("Hello🫂🌈World") { + case /🫂/ => "🌈" + } == "Hello🌈🌈World"; +} +test bool StringUnicodeVisitEmoji5() { + return visit ("Hello🫂🫂🫂World") { + case /[🫂]+/ => "🌈" + } == "Hello🌈World"; +} + +test bool StringUnicodeVisitEmoji6() { + return visit ("Hello🫂🫂🫂World") { + case /🫂[🫂]*/ => "🌈" + } == "Hello🌈World"; +} + + +test bool StringUnicodeVisitEmoji7() { + return visit ("Hello🌈World") { + case /World/ => "🌍" + } == "Hello🌈🌍"; +} + // Keywords and visit data RECT = rect(int w, int h, str color = "white"); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/library/util/MaybeTests.rsc b/src/org/rascalmpl/library/lang/rascal/tests/library/util/MaybeTests.rsc new file mode 100644 index 00000000000..0551b1434f4 --- /dev/null +++ b/src/org/rascalmpl/library/lang/rascal/tests/library/util/MaybeTests.rsc @@ -0,0 +1,62 @@ +module lang::rascal::tests::library::util::MaybeTests + +import util::Maybe; + +test bool nothingStrEqual(){ + Maybe[str] x = nothing(); + Maybe[str] y = nothing(); + return x == nothing() && y == nothing() && x == y; +} + +test bool just2nothing(){ + x = just(3); + x = nothing(); + return x == nothing(); +} + +test bool inc1(){ + Maybe[int] x = just(3); + x.val += 1; + return x.val == 4; +} + +test bool inc2(){ + x = just(3); + x.val += 1; + return x.val == 4; +} + +test bool inc3(){ + x = just((1 : "a")); + x.val[1] ? "aaa" += "xxx"; + return x.val == (1:"axxx"); +} + +test bool inc4(){ + x = just((1 : "a")); + x.val[2] ? "aaa" += "xxx"; + return x.val == (1:"a",2:"aaaxxx"); +} + +data X = contain( + Maybe[bool] p, + Maybe[int] kw1 = just(2), + Maybe[str] kw2 = nothing() + ); + +test bool contain1(){ + c = contain(nothing()); + return c.p == nothing() && c.kw1.val == 2 && c.kw2 == nothing(); +} + +test bool contain2(){ + c = contain(nothing(), kw1 = nothing(), kw2 = just("hi")); + return c.p == nothing() && c.kw1 == nothing() && c.kw2 == just("hi"); +} + +test bool contain3(){ + c = contain(nothing()); + c.kw1 = nothing(); + c.kw2 = just("hi"); + return c.p == nothing() && c.kw1 == nothing() && c.kw2 == just("hi"); +} \ No newline at end of file diff --git a/src/org/rascalmpl/library/lang/rascal/vis/ImportGraph.rsc b/src/org/rascalmpl/library/lang/rascal/vis/ImportGraph.rsc index 0efc06a82a3..a5271a6f0e8 100644 --- a/src/org/rascalmpl/library/lang/rascal/vis/ImportGraph.rsc +++ b/src/org/rascalmpl/library/lang/rascal/vis/ImportGraph.rsc @@ -46,8 +46,8 @@ void importGraph(PathConfig pcfg, bool hideExternals=true) { // let's start with a simple graph and elaborate on details in later versions g = { | <- m.imports, hideExternals ==> to notin m.external} + { | <- m.extends, hideExternals ==> to notin m.external} - + { <"_", "_", to> | to <- top(m.imports + m.extends) } // pull up the top modules - + { | from <- bottom(m.imports + m.extends), hideExternals ==> from notin m.external} // pull the bottom modules down. + // + { <"_", "_", to> | to <- top(m.imports + m.extends) } // pull up the top modules + // + { | from <- bottom(m.imports + m.extends), hideExternals ==> from notin m.external} // pull the bottom modules down. ; loc modLinker(str name) { diff --git a/src/org/rascalmpl/library/util/Eval.rsc b/src/org/rascalmpl/library/util/Eval.rsc index 4ca37489286..b9fa0367bfa 100644 --- a/src/org/rascalmpl/library/util/Eval.rsc +++ b/src/org/rascalmpl/library/util/Eval.rsc @@ -31,7 +31,6 @@ data Result[&T] } data RuntimeException = StaticError(str message, loc location) - | Timeout() ; @synopsis{A reusable instance of the Rascal runtime system configured by a specific PathConfig.} @@ -95,7 +94,7 @@ java RascalRuntime createRascalRuntime(PathConfig pcfg=pathConfig()); @description{ This creates a ((RascalRuntime)), uses it to evaluate one command, and then discards the runtime again. } -@deprecated{Use ((createRascalRuntime)) instead for better efficiency and configurability.} +@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 = eval(typ, [command], pcfg=pcfg, duration=duration); @@ -104,7 +103,7 @@ Result[&T] eval(type[&T] typ, str command, int duration=-1, PathConfig pcfg=path @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.} +@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); @@ -128,23 +127,23 @@ Result[value] eval(list[str] commands, int duration=-1, PathConfig pcfg=pathConf throws Timeout, StaticError, ParseError = eval(#value, commands, duration=duration, pcfg=pcfg); -@deprecated{Use ((createRascalRuntime)) instead for better efficiency and configurability.} +@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)) instead for better efficiency and configurability.} +@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)) instead for better efficiency and configurability.} +@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)) instead for better efficiency and configurability.} +@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?) { @@ -155,7 +154,7 @@ str evalType(str command, PathConfig pcfg=pathConfig(), int duration = -1) throw } @synopsis{Give input strings to the Rascal evaluator and return the type of the last command as a string.} -@deprecated{Use ((createRascalRuntime)) instead for better efficiency and configurability.} +@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?) { @@ -169,13 +168,13 @@ str evalType(list[str] commands, PathConfig pcfg=pathConfig(), int duration = -1 return ""; } -@deprecated{Use ((createRascalRuntime)) instead for better efficiency and configurability.} +@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)) instead for better efficiency and configurability.} +@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); diff --git a/src/org/rascalmpl/library/util/IDEServices.rsc b/src/org/rascalmpl/library/util/IDEServices.rsc index 32950e82142..dcc5222cea4 100644 --- a/src/org/rascalmpl/library/util/IDEServices.rsc +++ b/src/org/rascalmpl/library/util/IDEServices.rsc @@ -1,20 +1,18 @@ module util::IDEServices extend analysis::diff::edits::TextEdits; +import analysis::diff::edits::ExecuteTextEdits; extend Content; extend Message; - @synopsis{Open a browser for a given location.} @javaClass{org.rascalmpl.library.util.IDEServicesLibrary} java void browse(loc uri, str title = "", int viewColumn=1); - @synopsis{Open an editor for file at a given location.} @javaClass{org.rascalmpl.library.util.IDEServicesLibrary} java void edit(loc uri); - @synopsis{Let the IDE apply a list of document edits.} @description{ Asks the IDE to apply document edits as defined in the standard library module @@ -27,21 +25,79 @@ Typically a call to this IDE service method is included in the implementation of refactoring and quick-fix features of the language service protocol. } @javaClass{org.rascalmpl.library.util.IDEServicesLibrary} -public java void applyDocumentsEdits(list[DocumentEdit] edits); - +java void applyDocumentsEdits(list[DocumentEdit] edits); @synopsis{Asks the IDE to show a "browser window" with the given interactive Content.} @javaClass{org.rascalmpl.library.util.IDEServicesLibrary} -public java void showInteractiveContent(Content content, str title=content.title, int viewColumn=content.viewColumn); +java void showInteractiveContent(Content content, str title=content.title, int viewColumn=content.viewColumn); @javaClass{org.rascalmpl.library.util.IDEServicesLibrary} -public java void showMessage(Message message); +java void showMessage(Message message); @javaClass{org.rascalmpl.library.util.IDEServicesLibrary} -public java void logMessage(Message message); +java void logMessage(Message message); @javaClass{org.rascalmpl.library.util.IDEServicesLibrary} -public java void registerDiagnostics(list[Message] messages); +java void registerDiagnostics(list[Message] messages); @javaClass{org.rascalmpl.library.util.IDEServicesLibrary} -public java void unregisterDiagnostics(list[loc] resources); +java void unregisterDiagnostics(list[loc] resources); + +@synopsis{Fixes are an extension to error messages that allow for interactive code fixes in the IDE.} +@description{ +This definition adds lists of ((CodeAction))s as optional fields to any message. In collaboration +with a language server, these messages then lead to interactive quick fixes in IDEs. +} +data Message(list[CodeAction] fixes = []); + +@synopsis{Code actions bundle synchronous text edits and command execution with a title for the menu option.} +@description{ +For any action instance, the IDE will: +* show a menu option with the given title. +* if the title is selected, then the (optional) edits will be executed first +* and then the (optional) command is executed via the `execution` service of the language service protocol. +} +data CodeAction + = action(list[DocumentEdit] edits = [], Command command = noop(), str title = command.title); + +@synopsis{Commands are an open data-type for describing interactive functions that may be attached to CodeActions.} +@description{ +Commands are simply immutable constructors with parameters. To use a command you can attach it to a ((module:Message)) +via a ((CodeAction)), and then have it executed by the respective language server. +} +data Command(str title="") + = noop(); + +@synopsis{Utility function for testing code actions.} +@benefits{ +* test code actions outside of the IDE context, for example while running unit tests. +* this function is synchronous and blocks until the IO is finished. After running it you +can test for changed file contents without waiting, in most cases (see pitfalls). +} +@description{ +* `action` is the action to execute +* `evaluator` is used to evaluate action.command if it is present. +* the return value is the return value of the evaluated command, or `true` if no command is present. +} +@pitfalls{ +* ((CodeAction))s may use the other features of ((util::IDEServices)), and thus start editors or browsers as side-effects. +* ((CodeAction))s code actions with ((DocumentEdit))s will write to disk and change the original files. +* ((util::IDEServices::Command))s can only be executed by a parametrized command `evaluator``; if you do not provide it then +this test function will throw ((CallFailed)) exceptions for every unsupported (((util::IDEServices::Command)). +* (((util::IDEServices::Command))s can start asynchronous effects by calling non-blocking functions that schedule other effects. +An example is the starting and running of web ((Library:module:Content)) via ((showInteractiveContent)). Testing properties of the +rendered content will require the use of asynchronous testing frameworks, like Selenium. +* Never call ((testCodeAction)) to execute actions in an interactive context. That must be done by the IDE client +to synchronize the contents of editors and parse trees, etc. This function is only for unit testing code actions. +} +value testCodeAction(CodeAction action, value (Command _) evaluator = value (noop()) { return true; }) { + if (action.edits?) { + executeDocumentEdits(action.edits); + } + + if (action.command?) { + return evaluator(action.command); + } + + return true; +} diff --git a/src/org/rascalmpl/library/util/Reflective.rsc b/src/org/rascalmpl/library/util/Reflective.rsc index 07bfeb7c626..8ae7a24ee12 100644 --- a/src/org/rascalmpl/library/util/Reflective.rsc +++ b/src/org/rascalmpl/library/util/Reflective.rsc @@ -103,8 +103,14 @@ PathConfig applyManifests(PathConfig cfg) { return cfg; } -str makeFileName(str qualifiedModuleName, str extension = "rsc") = - replaceAll(qualifiedModuleName, "::", "/") + (isEmpty(extension) ? "" : ("." + extension)); +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 "">"; +} loc getSearchPathLoc(str filePath, PathConfig pcfg){ for(loc dir <- pcfg.srcs + pcfg.libs){ @@ -129,6 +135,7 @@ loc getModuleLocation(str qualifiedModuleName, PathConfig pcfg){ fileName = makeFileName(qualifiedModuleName, extension="tpl"); for(loc dir <- pcfg.libs){ fileLoc = dir + fileName; + if(exists(fileLoc)){ return fileLoc; } @@ -164,15 +171,11 @@ int commonPrefix(list[str] rdir, list[str] rm){ str getModuleName(loc moduleLoc, PathConfig pcfg){ modulePath = moduleLoc.path; - if(!endsWith(modulePath, "rsc")){ - throw "Not a Rascal source file: "; + if(!(endsWith(modulePath, "rsc") || endsWith(modulePath, "tpl"))){ + throw "Not a Rascal .src or .tpl file: "; } - = splitFileExtension(modulePath); - if(modulePathNoExt[0] == "/"){ - modulePathNoExt = modulePathNoExt[1..]; - } - modulePathAsList = split("/", modulePathNoExt); - modulePathAsListReversed = reverse(modulePathAsList); + + // Find matching .rsc file in source directories for(loc dir <- pcfg.srcs){ if(moduleLoc.authority == dir.authority && startsWith(modulePath, dir.path)) { @@ -185,25 +188,46 @@ str getModuleName(loc moduleLoc, PathConfig pcfg){ return moduleName; } } - + + // Find longest matching .tpl file in library directories + + = splitFileExtension(modulePath); + while(modulePathNoExt[0] == "/"){ + modulePathNoExt = modulePathNoExt[1..]; + } + modulePathAsList = split("/", modulePathNoExt); + 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, dir.path, ""); - candidate = replaceLast(candidate, "$", ""); - if(candidate[0] == "/"){ + candidate = replaceFirst(file.path, dpath, ""); + = splitFileExtension(candidate); + while(candidate[0] == "/"){ candidate = candidate[1..]; } - = splitFileExtension(candidate); + candidateAsList = split("/", candidate); - n = commonPrefix(reverse(candidateAsList), modulePathAsListReversed); - //println(", =\> "); + 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){ return intercalate("::", modulePathAsList[size(modulePathAsList) - longestSuffix .. ]); } diff --git a/src/org/rascalmpl/library/util/ShellExec.java b/src/org/rascalmpl/library/util/ShellExec.java index 92dd0e5d25a..f19014c116a 100644 --- a/src/org/rascalmpl/library/util/ShellExec.java +++ b/src/org/rascalmpl/library/util/ShellExec.java @@ -19,6 +19,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.rascalmpl.exceptions.RuntimeExceptionFactory; import org.rascalmpl.uri.URIResolverRegistry; @@ -34,7 +35,8 @@ import io.usethesource.vallang.IValueFactory; public class ShellExec { - private static Map runningProcesses = new HashMap<>(); + private static Map runningProcesses = new ConcurrentHashMap<>(); + private static Map processExitCodes = new ConcurrentHashMap<>(); private static Map processInputStreams = new HashMap<>(); private static Map processErrorStreams = new HashMap<>(); private static Map processOutputStreams = new HashMap<>(); @@ -107,16 +109,18 @@ public IInteger exitCode(IInteger pid) { Process p = runningProcesses.get(pid); if (p == null) { - throw RuntimeExceptionFactory.illegalArgument(pid, "unknown process"); + IInteger storedExitCode = processExitCodes.get(pid); + if (storedExitCode == null) { + throw RuntimeExceptionFactory.illegalArgument(pid, "unknown process"); + } + return storedExitCode; } - while (true) { - try { - return vf.integer(p.waitFor()); - } - catch (InterruptedException e) { - continue; - } + try { + return vf.integer(p.waitFor()); + } + catch (InterruptedException e) { + throw RuntimeExceptionFactory.javaException(e, null, null); } } @@ -228,12 +232,13 @@ public synchronized void killProcess(IInteger processId, IBool force) { runningProcess.destroy(); } } - - new Thread("zombie process clean up") { + + Thread waitForCleared = new Thread("zombie process clean up") { public void run() { while (true) { try { runningProcess.waitFor(); + processExitCodes.put(processId, vf.integer(runningProcess.exitValue())); runningProcesses.remove(processId); return; } @@ -244,8 +249,9 @@ public void run() { } } }; - }.start(); - + }; + waitForCleared.setDaemon(true); + waitForCleared.start(); return; } diff --git a/src/org/rascalmpl/library/util/ShellExec.rsc b/src/org/rascalmpl/library/util/ShellExec.rsc index b31a031f760..01b168c3fbe 100644 --- a/src/org/rascalmpl/library/util/ShellExec.rsc +++ b/src/org/rascalmpl/library/util/ShellExec.rsc @@ -77,7 +77,7 @@ tuple[str output, int exitCode] execWithCode(loc processCommand, loc workingDir= @synopsis{Kill a running process, or a zombie process (a process which is not alive yet not killed)} @javaClass{org.rascalmpl.library.util.ShellExec} -public java int killProcess(PID processId, bool force=false); +public java void killProcess(PID processId, bool force=false); @synopsis{Check whether a process is still alive} @javaClass{org.rascalmpl.library.util.ShellExec} diff --git a/src/org/rascalmpl/library/util/tasks/Manager.rsc b/src/org/rascalmpl/library/util/tasks/Manager.rsc index 4abe8d743f8..d12235eb6e7 100644 --- a/src/org/rascalmpl/library/util/tasks/Manager.rsc +++ b/src/org/rascalmpl/library/util/tasks/Manager.rsc @@ -94,7 +94,7 @@ public java void removeFact(Transaction tr, type[&T] key, value name); For producing exceptions with stack traces } @javaClass{org.rascalmpl.library.util.tasks.Manager} -public java Fact setFact(Transaction tr, type[&T] key, value name, &T val); +public java void setFact(Transaction tr, type[&T] key, value name, &T val); @javaClass{org.rascalmpl.library.util.tasks.Manager} public java tuple[rel[str,str,str,int],rel[str,str,str]] getDependencyGraph(Transaction tr); diff --git a/src/org/rascalmpl/library/vis/Graphs.rsc b/src/org/rascalmpl/library/vis/Graphs.rsc index b24a4d3ce8b..40d27f19345 100644 --- a/src/org/rascalmpl/library/vis/Graphs.rsc +++ b/src/org/rascalmpl/library/vis/Graphs.rsc @@ -90,7 +90,7 @@ default str defaultNodeLabeler(&T v) = ""; alias EdgeLabeler[&T]= str (&T _source, &T _target); str defaultEdgeLabeler(&T _source, &T _target) = ""; - +@synopsis{Produces an overall cytoscape.js wrapper which is sent as JSON to the client side.} Cytoscape cytoscape(list[CytoData] \data, \CytoLayout \layout=\defaultCoseLayout(), CytoStyle nodeStyle=defaultNodeStyle(), CytoStyle edgeStyle=defaultEdgeStyle()) = cytoscape( elements=\data, @@ -101,6 +101,7 @@ Cytoscape cytoscape(list[CytoData] \data, \CytoLayout \layout=\defaultCoseLayout \layout=\layout ); +@synopsis{Translates different types of Rascal data conveniently to the Cytoscape.js data format.} list[CytoData] graphData(rel[loc x, loc y] v, NodeLinker[loc] nodeLinker=defaultNodeLinker, NodeLabeler[loc] nodeLabeler=defaultNodeLabeler, EdgeLabeler[loc] edgeLabeler=defaultEdgeLabeler) = [cytodata(\node("", label=nodeLabeler(e), editor="")) | e <- {*v, *v}] + [cytodata(\edge("", "", label=edgeLabeler(from, to))) | <- v] @@ -169,6 +170,7 @@ data CytoNodeShape | \polygon() ; +@synopsis{Overall cytoscape.js object for sending to the client side.} data Cytoscape = cytoscape( list[CytoData] elements = [], @@ -242,6 +244,11 @@ data CytoStyleOf CytoStyleOf cytoNodeStyleOf(CytoStyle style) = cytoNodeStyleOf(selector=\node(), style=style); CytoStyleOf cytoEdgeStyleOf(CytoStyle style) = cytoEdgeStyleOf(selector=\edge(), style=style); +@synopsis{Instantiates a default node style} +@description{ +Because the JSON writer can not instantiate default values for keyword fields, +we have to do it manually here. +} CytoStyle defaultNodeStyle() = cytoNodeStyle( width = "label", @@ -256,6 +263,11 @@ CytoStyle defaultNodeStyle() \text-valign = CytoVerticalAlign::\center() ); +@synopsis{Instantiates a default edge style} +@description{ +Because the JSON writer can not instantiate default values for keyword fields +we have to do it manually here. +} CytoStyle defaultEdgeStyle() = cytoEdgeStyle( width = 3, @@ -433,7 +445,16 @@ Response (Request) graphServer(Cytoscape ch) { return reply; } -@synopsis{default HTML wrapper for a chart} +@synopsis{default HTML wrapper for a cytoscape.js graph} +@description{ +This client features: +* cytoscape.js loading with cytoscape-dagre and dagre present. +* fetching of graph data via `http://localhost/cytoscape` URL +* clickable links in every node that has an 'editor' data field that holds a `loc`, via the `http://localhost/editor?src=loc` URL +* full screen graph view + +This client mirrors the server defined by ((graphServer)). +} private HTMLElement plotHTML() = html([ head([ diff --git a/src/org/rascalmpl/parser/gtd/stack/filter/precede/AtColumnRequirement.java b/src/org/rascalmpl/parser/gtd/stack/filter/precede/AtColumnRequirement.java index c262661e394..ded77492a67 100644 --- a/src/org/rascalmpl/parser/gtd/stack/filter/precede/AtColumnRequirement.java +++ b/src/org/rascalmpl/parser/gtd/stack/filter/precede/AtColumnRequirement.java @@ -27,7 +27,7 @@ public AtColumnRequirement(int column){ } public boolean isFiltered(int[] input, int start, PositionStore positionStore){ - return positionStore.isAtColumn(start, column); + return !positionStore.isAtColumn(start, column); } public boolean isEqual(IEnterFilter otherEnterFilter){ diff --git a/src/org/rascalmpl/repl/TerminalProgressBarMonitor.java b/src/org/rascalmpl/repl/TerminalProgressBarMonitor.java index e155bc26c48..dfd6c48c60c 100644 --- a/src/org/rascalmpl/repl/TerminalProgressBarMonitor.java +++ b/src/org/rascalmpl/repl/TerminalProgressBarMonitor.java @@ -419,7 +419,16 @@ static int getCursorPosition(PrintWriter writer, InputStream in) throws IOExcept byte[] col = new byte[32]; int len = in.read(col); - String echo = new String(col, 0, len, Configuration.getEncoding()); + String echo; + + try { + echo = new String(col, 0, len, Configuration.getEncoding()); + } + catch (StringIndexOutOfBoundsException e) { + // this happens if there is some other input on stdin (for example a pipe) + // TODO: the input is now read and can't be processed again. + echo = ""; + } if (!echo.startsWith("\u001B[") || !echo.contains(";")) { return -1; @@ -439,14 +448,6 @@ static String moveUp(int n) { return "\u001B[" + n + "F"; } - static String overlined() { - return "\u001B[53m"; - } - - static String underlined() { - return "\u001B[4m"; - } - public static String printCursorPosition() { return "\u001B[6n"; } @@ -459,10 +460,6 @@ public static String normal() { return "\u001B[0m"; } - public static String lightBackground() { - return "\u001B[48;5;250m"; - } - static String moveDown(int n) { return "\u001B[" + n + "E"; } @@ -568,9 +565,7 @@ public synchronized int jobEnd(String name, boolean succeeded) { if (pb != null && --pb.nesting == -1) { eraseBars(); - // write it one last time into the scrollback buffer (on top) pb.done(); - pb.write(); bars.remove(pb); // print the left over bars under this one. printBars(); diff --git a/src/org/rascalmpl/semantics/dynamic/Expression.java b/src/org/rascalmpl/semantics/dynamic/Expression.java index ba5f629189d..9d4d6d9db59 100644 --- a/src/org/rascalmpl/semantics/dynamic/Expression.java +++ b/src/org/rascalmpl/semantics/dynamic/Expression.java @@ -1833,10 +1833,12 @@ public IMatchingResult buildMatcher(IEvaluatorContext eval, boolean bindTypePara } return new TypedMultiVariablePattern(eval, this, type, arg.getName(), bindTypeParameters); } + if(arg.hasQualifiedName()){ return new MultiVariablePattern(eval, this, arg.getQualifiedName()); } - throw new ImplementationError(null); + + throw new UnsupportedOperation("splice operator outside of list or set", this); } @Override @@ -1872,7 +1874,8 @@ public Type typeOf(Environment env, IEvaluator> eval, boolean ins if(arg.hasQualifiedName()){ return arg.getQualifiedName().typeOf(env, eval, instantiateTypeParameters); } - throw new ImplementationError(null); + + return arg.typeOf(env, eval, instantiateTypeParameters); } } diff --git a/src/org/rascalmpl/semantics/dynamic/Module.java b/src/org/rascalmpl/semantics/dynamic/Module.java index 00b88c2cf80..8a58e7a6e3f 100644 --- a/src/org/rascalmpl/semantics/dynamic/Module.java +++ b/src/org/rascalmpl/semantics/dynamic/Module.java @@ -26,8 +26,6 @@ import org.rascalmpl.interpreter.result.Result; import org.rascalmpl.interpreter.result.ResultFactory; import org.rascalmpl.interpreter.utils.Names; -import org.rascalmpl.uri.URIUtil; - import io.usethesource.vallang.IConstructor; import io.usethesource.vallang.ISourceLocation; import io.usethesource.vallang.IValue; diff --git a/src/org/rascalmpl/values/RascalFunctionValueFactory.java b/src/org/rascalmpl/values/RascalFunctionValueFactory.java index 268d049479f..876be4d9794 100644 --- a/src/org/rascalmpl/values/RascalFunctionValueFactory.java +++ b/src/org/rascalmpl/values/RascalFunctionValueFactory.java @@ -544,8 +544,8 @@ private IString printSymbol(IConstructor symbol) { } protected IValue parse(String methodName, ISet filters, ISourceLocation input, ISourceLocation origin, boolean allowAmbiguity, boolean hasSideEffects) { - if (origin == null) { - origin = input; + if (origin != null && !origin.equals(input)) { + throw new IllegalArgumentException("input and origin should be equal: != "); } try { diff --git a/test/org/rascalmpl/benchmark/CompareShortestPath.rsc b/test/org/rascalmpl/benchmark/CompareShortestPath.rsc index 574cdc02cf7..0d481940b19 100644 --- a/test/org/rascalmpl/benchmark/CompareShortestPath.rsc +++ b/test/org/rascalmpl/benchmark/CompareShortestPath.rsc @@ -23,7 +23,7 @@ private map[int, int] distance =(); private map[int, int] pred = (); private set[int] settled = {}; //private set[int] Q = {}; -private PriorityQueue Q = priorityQueue(); +private PriorityQueue Q = priorityQueue([], -1); private int MAXDISTANCE = 10000; @doc{Shortest path between pair of nodes} @@ -37,7 +37,7 @@ public list[int] shortestPathPair1(rel[int,int] G, int From, int To) pred = (); settled = {}; // Q = {From}; - Q = priorityQueue(0, From); + Q = priorityQueue([], From); // while (Q != {}){ while(!isEmpty(Q)){ @@ -75,7 +75,6 @@ private int extractMinimum() min = q; } } - Q = Q - min; return min; } @@ -105,35 +104,35 @@ public rel[int,int] Graph1 = {<5,8>,<1,2>,<3,4>,<3,3>,<2,3>,<2,2>,<6,7>,<6,6>,<7 public rel[int,int] randomGraph(int N, list[int] interval) { - return { | int n <- [1 .. N]}; + return { | int _ <- [1 .. N]}; } public void measure1(rel[int,int] Graph1){ G = Graph1; /* warm up for JVM */ - for(int i <- [1 .. 50]) + for(int _ <- [1 .. 50]) shortestPathPair(G, 1, 0); jtime = 0.0; jmin = 10000.0; jmax = 0.0; rtime = 0.0; rmin = 10000.0; rmax = 0.0; - for(int i <- [1 .. 20]){ - time1 = currentTimeMillis(); P1 = shortestPathPair(G, 1, 0); time2 = currentTimeMillis(); - P2 = shortestPathPair1(G, 1, 0); time3 = currentTimeMillis(); + for(int _ <- [1 .. 20]){ + time1 = getMilliTime(); P1 = shortestPathPair(G, 1, 0); time2 = getMilliTime(); + P2 = shortestPathPair1(G, 1, 0); time3 = getMilliTime(); d1 = time2 - time1; jtime = jtime + d1; jmin = min(d1, jmin); jmax = max(d1, jmax); d2 = time3 - time2; rtime = rtime + d2; rmin = min(d2, rmin); rmax = max(d2, rmax); println("Java version: in millis"); println("Rascal version: in millis"); } - println("Java average: ", jtime/20, " [ .. ]"); - println("Rascal average: ", rtime/20, " [ .. ]"); + println("Java average: [ .. ]"); + println("Rascal average: [ .. ]"); } public void measure2(rel[int,int] Graph2) { - for(int i <- [1 .. 2000]) + for(int _ <- [1 .. 2000]) shortestPathPair1(Graph2, 1, 0); } diff --git a/test/org/rascalmpl/benchmark/Matching/Sets.rsc b/test/org/rascalmpl/benchmark/Matching/Sets.rsc index acd293b0ace..ee63f8c1c31 100644 --- a/test/org/rascalmpl/benchmark/Matching/Sets.rsc +++ b/test/org/rascalmpl/benchmark/Matching/Sets.rsc @@ -1,8 +1,8 @@ module Matching::Sets import IO; -import Math; -import Benchmark; +import util::Math; +import util::Benchmark; import Grammar;import ParseTree;import IO; diff --git a/test/org/rascalmpl/benchmark/Visiting/visiting.rsc b/test/org/rascalmpl/benchmark/Visiting/visiting.rsc index 7edc99b9e8c..e08bff0470a 100644 --- a/test/org/rascalmpl/benchmark/Visiting/visiting.rsc +++ b/test/org/rascalmpl/benchmark/Visiting/visiting.rsc @@ -1,8 +1,8 @@ module Visiting::visiting import IO; -import Math; -import Benchmark; +import util::Math; +import util::Benchmark; data ColoredTree = leaf(int n) @@ -20,7 +20,7 @@ public ColoredTree genTree(int leafChance, int minDepth,int maxDepth){ switch(arbInt(3)){ case 0: return red(left,right); case 1: return black(left,right); - case 2: return green(left,right); + default: return green(left,right); } } diff --git a/test/org/rascalmpl/test/data/DS.trm b/test/org/rascalmpl/test/data/DS.trm deleted file mode 100644 index ec657ae2be3..00000000000 --- a/test/org/rascalmpl/test/data/DS.trm +++ /dev/null @@ -1 +0,0 @@ -d d d \ No newline at end of file diff --git a/test/org/rascalmpl/test/data/ExpressionGrammars.rsc b/test/org/rascalmpl/test/data/ExpressionGrammars.rsc index d3a98705276..813b59cb472 100644 --- a/test/org/rascalmpl/test/data/ExpressionGrammars.rsc +++ b/test/org/rascalmpl/test/data/ExpressionGrammars.rsc @@ -1,5 +1,7 @@ module ExpressionGrammars +import ParseTree; + lexical Id = [a-z] !<< [a-z]+ !>> [a-z]; lexical Num = [0-9]+; layout W = [\ \t\n\r]*; diff --git a/test/org/rascalmpl/test/data/GrammarABCDE.rsc b/test/org/rascalmpl/test/data/GrammarABCDE.rsc deleted file mode 100644 index 8d33ed76e99..00000000000 --- a/test/org/rascalmpl/test/data/GrammarABCDE.rsc +++ /dev/null @@ -1,20 +0,0 @@ -@license{ - Copyright (c) 2009-2011 CWI - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html -} -@contributor{Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI} -@contributor{Arnold Lankamp - Arnold.Lankamp@cwi.nl} -module GrammarABCDE - -layout Whitespace = [\ \t\n]*; - -start syntax A = "a"; -start syntax B = "b"; -start syntax C = A B; -start syntax D = "d"; -start syntax DS = D+; -start syntax E = "e"; -start syntax ES = {E ","}+; diff --git a/test/org/rascalmpl/test/data/RecoveryTests.rsc b/test/org/rascalmpl/test/data/RecoveryTests.rsc deleted file mode 100644 index 4bd9b04501b..00000000000 --- a/test/org/rascalmpl/test/data/RecoveryTests.rsc +++ /dev/null @@ -1,124 +0,0 @@ -@license{ - Copyright (c) 2009-2011 CWI - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html -} -@contributor{Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI} -@contributor{Tijs van der Storm - Tijs.van.der.Storm@cwi.nl} -@contributor{Paul Klint - Paul.Klint@cwi.nl - CWI} -module RecoveryTests - -@should{return 0} -public int recoveryOfLocalVariable() -{ - x = 0; - l = [1, 2, 3]; - visit (l) { - case int n: { - x = x + 1; - fail; - } - }; - return x; -} - -@should{return 3} -public int nestedRecoveryOfLocalVariable() -{ - x = 0; - l = [1, 2, 3]; - visit (l) { - case int n: { - x = x + 1; - visit (l) { - case int m: { - x = x + 1; - fail; - } - }; - } - }; - return x; -} - -@should{return 12} // but why? -public int noNestedRecovery() -{ - int x = 0; - l = [1, 2, 3]; - visit (l) { - case int n: { - x = x + 1; - visit (l) { - case int i: { - x = x + 1; - } - }; - } - }; - return x; -} - -@should{return 0} -public int recoveryOfLocalVariableUsingIfThen() -{ - x = 0; - l = [1, 2, 3]; - visit (l) { - case int n: { - x = x + 1; - if (n > 10) { - x = x + 1; // another update - } else - fail; - } - }; - return x; -} - -public int gx = 0; - -@should{return 0} -public int recoveryOfGlobalVariable() -{ - //global int gx; - l = [1, 2, 3]; - visit (l) { - case int n: { - gx = gx + 1; - fail; - } - }; - return gx; -} - -public int gt = 0; - -data City = amsterdam(); - -a1 amsterdam() { - gt = gt + 1; - fail; -} - -public int recoveryOfGlobalAfterFailingRule() { - x = amsterdam(); - return gt; -} - -public bool meddle() { - gt = 123; - return true; -} - -public int recoveryOfGlobalDuringComprehension() { - aset = {1, 2, 3}; - another = { x | int x <- aset, meddle() }; - return gt; -} - - - - diff --git a/test/org/rascalmpl/test/data/StrategyTests.rsc b/test/org/rascalmpl/test/data/StrategyTests.rsc deleted file mode 100644 index 51ab36b53bd..00000000000 --- a/test/org/rascalmpl/test/data/StrategyTests.rsc +++ /dev/null @@ -1,82 +0,0 @@ -@license{ - Copyright (c) 2009-2011 CWI - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html -} -@contributor{Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI} -@contributor{Arnold Lankamp - Arnold.Lankamp@cwi.nl} -module StrategyTests - -import IO; -import Strategy; -import TopologicalStrategy; - -data A = f(B I, B J) - | a() - | d() - | e() - | aa() - | dd() - | ee() - | h(A a); - - -data B = g(B I) - | b() - | c(); - -public &T(&T) rules = &T(&T t) { - switch (t) { - case g(b()): return b(); - default: return t; - }; - }; - -public &T(&T) rules2 = &T(&T t) { - switch (t) { - case c(): return b(); - case g(c()): return c(); - default: return t; - }; - }; - -public &T(&T) rules3 = &T(&T t) { - switch (t) { - case b(): return c(); - default: return t; - }; - }; - - - -public B rules4(B t) { - switch (t) { - case b(): return c(); - default: return t; - }; -} - - -public &T rules5(&T t) { - switch (t) { - case a(): return aa(); - case d(): return dd(); - case e(): return ee(); - default: return t; - }; -} - - -public &T rules6(&T t) { - switch (t) { - case a(): return aa(); - case d(): return dd(); - case e(): return ee(); - case aa(): return h(aa()); - case dd(): return h(dd()); - case ee(): return h(ee()); - default: return t; - }; -} diff --git a/test/org/rascalmpl/test/data/Test4.rsc b/test/org/rascalmpl/test/data/Test4.rsc deleted file mode 100644 index 3b0d9f2e47a..00000000000 --- a/test/org/rascalmpl/test/data/Test4.rsc +++ /dev/null @@ -1,17 +0,0 @@ -@license{ - Copyright (c) 2009-2011 CWI - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html -} -@contributor{Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI} -@contributor{Paul Klint - Paul.Klint@cwi.nl - CWI} -module Test4 - -import GrammarABCDE; -import ParseTree; - -public bool tst(){ - return (A) `a` := (A) `a`; -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/AugmentedType.java_src b/test/org/rascalmpl/test/data/patterns/micro/AugmentedType.java_src deleted file mode 100644 index 6baae8f4b3c..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/AugmentedType.java_src +++ /dev/null @@ -1,12 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public abstract class AugmentedType { - public static final int A = 1; - public static final int B = 2; - public static final int C = 3; - - public abstract int bla(); - public void doIt() { - - } -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/Canopy.java_src b/test/org/rascalmpl/test/data/patterns/micro/Canopy.java_src deleted file mode 100644 index da136416444..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/Canopy.java_src +++ /dev/null @@ -1,15 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public class Canopy { - - private int i; - - public Canopy(int i) { - this.i = i; - } - - public int getI() { - return i; - } - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/CobolLike.java_src b/test/org/rascalmpl/test/data/patterns/micro/CobolLike.java_src deleted file mode 100644 index 666860ef3ab..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/CobolLike.java_src +++ /dev/null @@ -1,11 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public class CobolLike { - - private static String HEADER = "Micro Patterns"; - - public static void main(String[] args) { - System.out.println("Header: " + HEADER); - } - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/CommonState.java_src b/test/org/rascalmpl/test/data/patterns/micro/CommonState.java_src deleted file mode 100644 index a6d307f66d6..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/CommonState.java_src +++ /dev/null @@ -1,11 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public class CommonState { - - private static int counter = 0; - - public int count() { - return counter++; - } - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/CompoundBox.java_src b/test/org/rascalmpl/test/data/patterns/micro/CompoundBox.java_src deleted file mode 100644 index 94d430f82f4..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/CompoundBox.java_src +++ /dev/null @@ -1,22 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public class CompoundBox { - - private Canopy c; - private int i; - - public CompoundBox(Canopy c, int i) { - this.c = c; - this.i = i; - } - - public Canopy toCanopy() { - return c; - } - - public int next() { - i = i+ 1; - return i; - } - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/Designator.java_src b/test/org/rascalmpl/test/data/patterns/micro/Designator.java_src deleted file mode 100644 index 8681e5d53e2..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/Designator.java_src +++ /dev/null @@ -1,5 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public interface Designator extends Cloneable { - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/Designator2.java_src b/test/org/rascalmpl/test/data/patterns/micro/Designator2.java_src deleted file mode 100644 index 50b3fbcfb4d..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/Designator2.java_src +++ /dev/null @@ -1,5 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public interface Designator2 { - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/Extender.java_src b/test/org/rascalmpl/test/data/patterns/micro/Extender.java_src deleted file mode 100644 index 1767bcdb081..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/Extender.java_src +++ /dev/null @@ -1,11 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -import java.io.Flushable; -import java.io.IOException; - -public class Extender extends Overrider implements Flushable { - - void doStuff() throws IOException { - super.write(0xff); - } -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/FunctionObjectAndBox.java_src b/test/org/rascalmpl/test/data/patterns/micro/FunctionObjectAndBox.java_src deleted file mode 100644 index 67f20b10c9c..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/FunctionObjectAndBox.java_src +++ /dev/null @@ -1,15 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public class FunctionObjectAndBox { - private int f; - - public FunctionObjectAndBox(int f) { - this.f = f; - } - - public int doStuff() { - f += 2; - return f * 2; - } - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/FunctionPointer.java_src b/test/org/rascalmpl/test/data/patterns/micro/FunctionPointer.java_src deleted file mode 100644 index f9dd1358e14..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/FunctionPointer.java_src +++ /dev/null @@ -1,8 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public class FunctionPointer { - public void doStuff() { - int a = 1 + 2; - } - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/ImmutableAndDataManagerAndSink.java_src b/test/org/rascalmpl/test/data/patterns/micro/ImmutableAndDataManagerAndSink.java_src deleted file mode 100644 index afa003c6e03..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/ImmutableAndDataManagerAndSink.java_src +++ /dev/null @@ -1,20 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public class ImmutableAndDataManagerAndSink { - private double f; - private int i; - - public ImmutableAndDataManagerAndSink(int i, double f) { - this.i = i; - this.f = f; - } - - public double getF() { - return f; - } - - public int getI() { - return i; - } - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/Implementor.java_src b/test/org/rascalmpl/test/data/patterns/micro/Implementor.java_src deleted file mode 100644 index c6d58af2feb..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/Implementor.java_src +++ /dev/null @@ -1,15 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public class Implementor extends PureType { - - @Override - public void a() { - - } - - @Override - public void b() { - - } - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/InterfaceWithMethods.java_src b/test/org/rascalmpl/test/data/patterns/micro/InterfaceWithMethods.java_src deleted file mode 100644 index acf5fff316d..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/InterfaceWithMethods.java_src +++ /dev/null @@ -1,6 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public interface InterfaceWithMethods { - void clear(); - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/Joiner.java_src b/test/org/rascalmpl/test/data/patterns/micro/Joiner.java_src deleted file mode 100644 index 69ed3ec1a84..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/Joiner.java_src +++ /dev/null @@ -1,5 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public interface Joiner extends Taxonomy, Designator { - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/Joiner2.java_src b/test/org/rascalmpl/test/data/patterns/micro/Joiner2.java_src deleted file mode 100644 index 0bc3d2d637d..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/Joiner2.java_src +++ /dev/null @@ -1,8 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public class Joiner2 implements Designator, Designator2 { - - public Joiner2() { - } - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/OutlineAndTrait.java_src b/test/org/rascalmpl/test/data/patterns/micro/OutlineAndTrait.java_src deleted file mode 100644 index ce60a720afa..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/OutlineAndTrait.java_src +++ /dev/null @@ -1,12 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public abstract class OutlineAndTrait { - abstract int doStuff(); - public void method1() { - doStuff(); - } - public void method2() { - doStuff(); - } - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/Overrider.java_src b/test/org/rascalmpl/test/data/patterns/micro/Overrider.java_src deleted file mode 100644 index 7f6f4b21735..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/Overrider.java_src +++ /dev/null @@ -1,38 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -import java.io.BufferedOutputStream; -import java.io.IOException; - - -public class Overrider extends BufferedOutputStream { - public Overrider() { - super(null); - } - @Override - public void close() throws IOException { - // TODO Auto-generated method stub - super.close(); - } - @Override - public void write(byte[] b) throws IOException { - // TODO Auto-generated method stub - super.write(b); - } - @Override - public synchronized void write(byte[] b, int off, int len) - throws IOException { - // TODO Auto-generated method stub - super.write(b, off, len); - } - @Override - public synchronized void write(int b) throws IOException { - // TODO Auto-generated method stub - super.write(b); - } - @Override - public synchronized void flush() throws IOException { - // TODO Auto-generated method stub - super.flush(); - } - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/PoolAndRestrictedCreation.java_src b/test/org/rascalmpl/test/data/patterns/micro/PoolAndRestrictedCreation.java_src deleted file mode 100644 index 6f67c9d4c62..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/PoolAndRestrictedCreation.java_src +++ /dev/null @@ -1,6 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public class PoolAndRestrictedCreation { - public static final PoolAndRestrictedCreation field1 = new PoolAndRestrictedCreation(); - public static final int field2 = 2; -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/PseudoClass.java_src b/test/org/rascalmpl/test/data/patterns/micro/PseudoClass.java_src deleted file mode 100644 index 67819e84f4a..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/PseudoClass.java_src +++ /dev/null @@ -1,10 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public abstract class PseudoClass { - abstract void a(); - abstract void b(); - public static final int C = 1; - public static void d() { - System.out.println(C * 2); - } -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/PureType.java_src b/test/org/rascalmpl/test/data/patterns/micro/PureType.java_src deleted file mode 100644 index dfcc066fab2..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/PureType.java_src +++ /dev/null @@ -1,8 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public abstract class PureType { - - abstract void a(); - abstract void b(); - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/Record.java_src b/test/org/rascalmpl/test/data/patterns/micro/Record.java_src deleted file mode 100644 index 0e9bb314e8a..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/Record.java_src +++ /dev/null @@ -1,7 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public class Record { - public int i; - public String s; - public Canopy c; -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/Sampler.java_src b/test/org/rascalmpl/test/data/patterns/micro/Sampler.java_src deleted file mode 100644 index 24a9b5d17a7..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/Sampler.java_src +++ /dev/null @@ -1,9 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public class Sampler { - public static Sampler field1 = new Sampler(); - - public Sampler() { - } - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/StateMachine.java_src b/test/org/rascalmpl/test/data/patterns/micro/StateMachine.java_src deleted file mode 100644 index 0d80028006f..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/StateMachine.java_src +++ /dev/null @@ -1,7 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public interface StateMachine { - boolean hasSteps(); - void doStep(); - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/StatelessAndSampler.java_src b/test/org/rascalmpl/test/data/patterns/micro/StatelessAndSampler.java_src deleted file mode 100644 index 8432a50021a..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/StatelessAndSampler.java_src +++ /dev/null @@ -1,24 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public class StatelessAndSampler { - - public static final StatelessAndSampler Instance = new StatelessAndSampler(); - - public StatelessAndSampler() { - } - - private static final int f = 0; - private static final String s = "s"; - - public int foo() { - return f * 2; - } - - public String bar() { - return s + s; - } - - public static String foobar() { - return s + f; - } -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/Taxonomy.java_src b/test/org/rascalmpl/test/data/patterns/micro/Taxonomy.java_src deleted file mode 100644 index de64f562a0f..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/Taxonomy.java_src +++ /dev/null @@ -1,5 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -public interface Taxonomy extends InterfaceWithMethods { - -} diff --git a/test/org/rascalmpl/test/data/patterns/micro/Taxonomy2.java_src b/test/org/rascalmpl/test/data/patterns/micro/Taxonomy2.java_src deleted file mode 100644 index 5661fc3753a..00000000000 --- a/test/org/rascalmpl/test/data/patterns/micro/Taxonomy2.java_src +++ /dev/null @@ -1,14 +0,0 @@ -package org.rascalmpl.test.data.patterns.micro; - -import java.util.*; - -public class Taxonomy2 extends ArrayList { - public Taxonomy2() { - super(); - } - - public Taxonomy2(Collection extends T> c) { - super(c); - } - -} diff --git a/test/org/rascalmpl/test/parser/StackNodeTest.java b/test/org/rascalmpl/test/parser/StackNodeTest.java index bfc52a4f5b8..6b849ca5fa7 100644 --- a/test/org/rascalmpl/test/parser/StackNodeTest.java +++ b/test/org/rascalmpl/test/parser/StackNodeTest.java @@ -3,7 +3,6 @@ import org.junit.Assert; import org.junit.Test; import org.rascalmpl.parser.gtd.stack.EpsilonStackNode; -import org.rascalmpl.parser.gtd.stack.LiteralStackNode; import org.rascalmpl.parser.gtd.stack.filter.ICompletionFilter; import org.rascalmpl.parser.gtd.stack.filter.IEnterFilter; import org.rascalmpl.parser.gtd.stack.filter.follow.AtEndOfLineRequirement;
${project.basedir}/src/org/rascalmpl/library/Prelude.rsc