Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4fcc1d1
borrowed upgrade folder from no-more-annotations branch to reuse refa…
jurgenvinju Jun 12, 2024
f07a9b0
ran update function on Assignment test module
jurgenvinju Jun 12, 2024
498719a
rewrote the annotation tests using the update refactoring
jurgenvinju Jun 12, 2024
20431c8
automatically refactored all declarations and uses of annotations
jurgenvinju Jun 12, 2024
be67999
folded src kw parameter into the primary definition of Tree
jurgenvinju Jun 12, 2024
8e56720
added deprecation messages of old annotations/keyword parameters that…
jurgenvinju Jun 12, 2024
af17d9c
added catch NoSuchAnnotation reporter and rewriter and fixed some test
jurgenvinju Jun 12, 2024
c00ab61
better nameTest
jurgenvinju Jun 12, 2024
08da919
upgrade reporter now has a progress bar
jurgenvinju Jun 12, 2024
93508ea
upgraders also have a progress bar
jurgenvinju Jun 12, 2024
90b0a71
fixed type check error
jurgenvinju Jun 12, 2024
88c41aa
fixing tests and improving refactorings
jurgenvinju Jun 12, 2024
b99059d
Merge branch 'main' into remove-tree-loc-annotation
jurgenvinju Jun 17, 2024
eafd290
made tests work better without annotations
jurgenvinju Jun 17, 2024
958934a
Merge branch 'main' into remove-tree-loc-annotation
jurgenvinju Jun 27, 2024
6733f04
Merge branch 'main' into remove-tree-loc-annotation
jurgenvinju Apr 7, 2026
e915560
re-applied anno to kw field upgrade tool to the library after merging…
jurgenvinju Apr 7, 2026
1dd0c8c
replaced irreplacable anno definitions
jurgenvinju Apr 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void addCommonKeywordFields(Solver s){
fieldName = "<kwf.name>";
fieldType = s.getType(kwf);
fieldType.alabel = fieldName;
moduleName = getRascalModuleName(kwf.expression@\loc, s.getConfig().typepalPathConfig);
moduleName = getRascalModuleName(kwf.expression.src, s.getConfig().typepalPathConfig);
commonKeywordFields += <adtType, kwField(fieldType, fieldName, moduleName, kwf.expression)>;
//commonKeywordFieldNames += <adtType, fieldName, fieldType>;
// TODO: reconsider this
Expand Down
8 changes: 4 additions & 4 deletions src/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,14 @@ ModuleStatus rascalTModelForLocs(
<success, pt, ms> = getModuleParseTree(m, ms);
if(success){
if(compilerConfig.infoModuleChecked){
imsgs += [info("Checked <moduleId2moduleName(m)>", pt.header.name@\loc)];
imsgs += [info("Checked <moduleId2moduleName(m)>", pt.header.name.src)];
}
check_imports:
for(imod <- pt.header.imports, imod has \module){
iname = unescape("<imod.\module.name>");
inameId = moduleName2moduleId(iname);
if(hasProperty(inameId, ms, tpl_version_error(), rsc_not_found())){
imsgs += error("Rascal TPL version error for `<iname>`, no source found", imod@\loc);
imsgs += error("Rascal TPL version error for `<iname>`, no source found", imod.src);
}
if(inameId notin usedModules){
if(iname == "ParseTree" && implicitlyUsesParseTree(ms.moduleLocs[m].path, tm)){
Expand All @@ -339,7 +339,7 @@ ModuleStatus rascalTModelForLocs(
}
if((inameId in component || hasProperty(inameId, ms, checked())) && hasNotProperty(inameId, ms, rsc_not_found())){
if(imod is \default){
imsgs += warning("Unused import of `<iname>`", imod@\loc);
imsgs += warning("Unused import of `<iname>`", imod.src);
} //else { //TODO: maybe add option to turn off info messages?
//imsgs += info("Extended module `<iname>` is unused in the current module", imod@\loc);
//}
Expand Down Expand Up @@ -469,7 +469,7 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[MODID] moduleIds, ModuleSt
tagsMap = getTags(pt.header.tags);

if(hasIgnoreCompilerTag(tagsMap)) {
ms.messages[mid] ? {} += { Message::info("Ignoring module <mid>", pt.header.name@\loc) };
ms.messages[mid] ? {} += { Message::info("Ignoring module <mid>", pt.header.name.src) };
ms = addProperty(mid, ms, ModuleProperty::ignored());
}
idTrees[mid] = pt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ void checkOverloading(map[str,Tree] namedTrees, Solver s){

set[Define] defines = s.getAllDefines();
facts = s.getFacts();
moduleScopes = { t@\loc | t <- range(namedTrees) };
moduleScopes = { t.src | t <- range(namedTrees) };

funDefs = {<define.id, define> | define <- defines, define.idRole == functionId() };
funIds = domain(funDefs);
Expand Down Expand Up @@ -516,7 +516,7 @@ void reportConstructorOverload(Expression current, overloadedAType(rel[loc def,
qualifyHint = size(adtNames) > 1 ? " you may use <intercalateOr(sort(adtNames))> as qualifier" : "";
argHint = "<isEmpty(qualifyHint) ? "" : " or ">make argument type(s) more precise";
msg = error("Constructor `<ovl1.atype.alabel>` is overloaded, maybe<qualifyHint><argHint>",
current@\loc);
current.src);
s.addMessages([msg]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,21 +204,21 @@ bool validateUseDefs(str moduleName, map[str, tuple[int, set[int]]] defuses, Mod
map[loc, str] loc2name = ();
top-down-break visit(pt){
case Name nm: {
names["<nm>"] ? [] += [nm@\loc];
loc2name[nm@\loc] = "<nm>";
names["<nm>"] ? [] += [nm.src];
loc2name[nm.src] = "<nm>";
}
case QualifiedName nm: {
names["<nm>"] ? [] += [nm@\loc];
loc2name[nm@\loc] = "<nm>";
names["<nm>"] ? [] += [nm.src];
loc2name[nm.src] = "<nm>";
}
case Nonterminal nm: {
names["<nm>"] ? [] += [nm@\loc];
loc2name[nm@\loc] = "<nm>";
names["<nm>"] ? [] += [nm.src];
loc2name[nm.src] = "<nm>";
}

case NonterminalLabel nm: {
names["<nm>"] ? [] += [nm@\loc];
loc2name[nm@\loc] = "<nm>";
names["<nm>"] ? [] += [nm.src];
loc2name[nm.src] = "<nm>";
}
}
println("names:"); iprintln(names);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,25 @@ tuple[Tree, TModel] parseConcreteFragments(Tree M, TModel tm, AGrammar gr) {
@doc{parse fragment or store parse error in the TModel}
Tree parseFragment(t:appl(prod(label("typed",lex("Concrete")), _, _),[_,_,Tree varsym,_,_,_,_, parts,_])) {
try {
sym = atype2symbol(getType(varsym@\loc));
sym = atype2symbol(getType(varsym.src));
return appl(prod(label("parsed",Symbol::lex("Concrete")), [sym], {}), [
doParseFragment(sym, parts.args, rules)
])[@\loc=t@\loc];
])[src=t.src];
}
catch ParseError(_) : {
throw CompileTimeError(error("Parse error in concrete syntax fragment `<for (p <- parts){><p><}>`", t@\loc));
throw CompileTimeError(error("Parse error in concrete syntax fragment `<for (p <- parts){><p><}>`", t.src));
}
catch Ambiguity(loc _location, str nonterminal, str sentence): {
throw CompileTimeError(error("Ambiguity in concrete syntax fragment for <nonterminal>: `<sentence>`", /*location*/ t@\loc));
throw CompileTimeError(error("Ambiguity in concrete syntax fragment for <nonterminal>: `<sentence>`", /*location*/ t.src));
}
}

ignoredFunctionLocs = {fd@\loc | /FunctionDeclaration fd := M, hasIgnoreCompilerTag(getTags(fd.tags)) };
ignoredFunctionLocs = {fd.src | /FunctionDeclaration fd := M, hasIgnoreCompilerTag(getTags(fd.tags)) };

M = top-down-break visit(M) {
case Tree t:appl(p:prod(label("concrete",sort(/Expression|Pattern/)), _, _),[Tree concrete])
=> appl(p, [parseFragment(concrete)])[@\loc=t@\loc]
when !any(loc ign <- ignoredFunctionLocs, isContainedIn(t@\loc, ign, tm.logical2physical))
=> appl(p, [parseFragment(concrete)])[src=t.src]
when !any(loc ign <- ignoredFunctionLocs, isContainedIn(t.src, ign, tm.logical2physical))
}

return <M, tm>;
Expand All @@ -96,7 +96,7 @@ Tree doParseFragment(Symbol sym, list[Tree] parts, map[Symbol, Production] rules

// here we weave in a unique and indexed sub-string for which a special rule
// was added by the parser generator:
holeType = atype2symbol(getType(hole.args[2]@\loc));
holeType = atype2symbol(getType(hole.args[2].src));
return "\u0000<denormalize(holeType)>:<index>\u0000";
}

Expand All @@ -106,9 +106,9 @@ Tree doParseFragment(Symbol sym, list[Tree] parts, map[Symbol, Production] rules
// now parse the input to get a Tree (or a ParseError is thrown)
if(type[Tree] tp := type(sym, rules)){
Tree tree = ParseTree::parse(tp, input, |todo:///|);
return isEmpty(parts) ? tree : restoreHoles(tree, holes, parts[0]@\loc);
return isEmpty(parts) ? tree : restoreHoles(tree, holes, parts[0].src);
} else {
throw InternalCompilerError(error("Illegal type <sym> in concrete syntax fragment `<for (p <- parts){><p><}>`", parts[0]@\loc));
throw InternalCompilerError(error("Illegal type <sym> in concrete syntax fragment `<for (p <- parts){><p><}>`", parts[0].src));
}
}

Expand Down Expand Up @@ -147,10 +147,10 @@ RestoreState restoreHoles(t:char(int c), map[int, Tree] _, loc _, int offset, in
RestoreState restoreHoles(Tree v:appl(prod(Symbol::label("$MetaHole", Symbol varType), _, {\tag("holeType"(Symbol ht))}), [char(0),_,_,Tree i,char(0)]),
map[int, Tree] holes, loc _, int _, int _, int _) {
Tree typedVar = holes[toInt("<i>")];
return <appl(prod(label("$MetaHole", varType),[Symbol::sort("ConcreteHole")], {\tag("holeType"(ht))}), [typedVar])[@\loc=typedVar@\loc],
typedVar@\loc.offset + typedVar@\loc.length,
typedVar@\loc.end.line,
typedVar@\loc.end.column
return <appl(prod(label("$MetaHole", varType),[Symbol::sort("ConcreteHole")], {\tag("holeType"(ht))}), [typedVar])[src=typedVar.src],
typedVar.src.offset + typedVar.src.length,
typedVar.src.end.line,
typedVar.src.end.column
>;
}

Expand All @@ -165,7 +165,7 @@ default RestoreState restoreHoles(Tree v:appl(Production p, list[Tree] args), ma
append a;
}

return <appl(p, newArgs)[@\loc=file(offset, curOffset - offset, <line, column>, <curLine, curColumn>)],
return <appl(p, newArgs)[src=file(offset, curOffset - offset, <line, column>, <curLine, curColumn>)],
curOffset, curLine, curColumn>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private void generateGettersForAdt(AType adtType, loc module_scope, set[AType] c
*/
consName = consType.alabel;

for(kw <- consType.kwFields, kw has defaultExp, isContainedIn(kw.defaultExp@\loc, module_scope, l2p)){
for(kw <- consType.kwFields, kw has defaultExp, isContainedIn(kw.defaultExp.src, module_scope, l2p)){
kwType = kw.fieldType;
defaultExp = kw.defaultExp;
str kwFieldName = kwType.alabel;
Expand Down Expand Up @@ -176,7 +176,7 @@ private void generateGettersForAdt(AType adtType, loc module_scope, set[AType] c
getterType = afunc(returnType, [adtType], []);
adtVar = muVar(adtName, getterName, 0, adtType, dataId());
failCode = muFailReturn(returnType);
for(Keyword kw <- common_keyword_fields, kw has defaultExp, isContainedIn(kw.defaultExp@\loc, module_scope, l2p)){
for(Keyword kw <- common_keyword_fields, kw has defaultExp, isContainedIn(kw.defaultExp.src, module_scope, l2p)){
kwType = kw.fieldType;
str commonKwFieldName = unescape(kwType.alabel);
if(commonKwFieldName == kwFieldName){
Expand All @@ -198,7 +198,7 @@ private void generateGettersForAdt(AType adtType, loc module_scope, set[AType] c
* Create getters for common keyword fields of this data type
*/
seen = {};
for(Keyword kw <- common_keyword_fields, kw has defaultExp, kw.fieldType notin seen, isContainedIn(kw.defaultExp@\loc, module_scope, l2p)){
for(Keyword kw <- common_keyword_fields, kw has defaultExp, kw.fieldType notin seen, isContainedIn(kw.defaultExp.src, module_scope, l2p)){
kwType = kw.fieldType;
defaultExp = kw.defaultExp;
seen += kwType;
Expand Down Expand Up @@ -491,8 +491,8 @@ public tuple[list[MuExp] formalVars, MuExp funBody] translateFunction(str fname,
formalVars = for(i <- index(formalsList)){
pname = getParameterName(formalsList, i);
ndummies += size(dummyFormalsInType(getType(formalsList[i])));
if(hasParameterName(formalsList, i) && !isUse(formalsList[i]@\loc)){
pos = getPositionInScope(pname, getParameterNameAsTree(formalsList, i)@\loc);
if(hasParameterName(formalsList, i) && !isUse(formalsList[i].src)){
pos = getPositionInScope(pname, getParameterNameAsTree(formalsList, i).src);
//println("<pname>: pos = <pos>, ndummies = <ndummies>, pos - ndummies = <pos - ndummies>");
//if(pos - ndummies > 0) pos -= ndummies;
append muVar(pname, fuid, pos, unsetRec(getType(formalsList[i]), "alabel"), formalId());
Expand Down
Loading
Loading