Skip to content

Commit

Permalink
Adapted to new configuration settings
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Nov 13, 2024
1 parent fa9a53b commit d6c21a2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/analysis/typepal/Collector.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ Collector newCollector(str modelName, map[str,Tree] namedTrees, TypePalConfig co
throw TypePalUsage("Missing `leaveScope`(s): unclosed scopes <unclosed>");
}

tm = tmodel();
tm = tmodel()[usesPhysicalLocs=true];
tm.modelName = modelName;

tm.moduleLocs = (nm : getLoc(namedTrees[nm]) | nm <- namedTrees);
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/typepal/Solver.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ Solver newSolver(map[str,Tree] namedTrees, TModel tm){
} catch NoBinding(): {
roles = size(u.idRoles) > 5 ? "" : intercalateOr([prettyRole(idRole) | idRole <- u.idRoles]);
msg = error("Undefined <roles> `<getOrgId(u)>`", u.occ);
if(config.enableErrorFixes){
if(tm.config.enableErrorFixes){
msg.fixes = undefinedNameProposals(u, tm);
}
messages += msg;
Expand All @@ -1529,7 +1529,7 @@ Solver newSolver(map[str,Tree] namedTrees, TModel tm){
for(u <- notYetDefinedUses){
roles = size(u.idRoles) > 5 ? "" : intercalateOr([prettyRole(idRole) | idRole <- u.idRoles]);
msg = error("Undefined <roles> `<getOrgId(u)>`", u.occ);
if(config.enableErrorFixes){
if(tm.config.enableErrorFixes){
msg.fixes = undefinedNameProposals(u, tm);
}
messages += msg;
Expand Down
6 changes: 4 additions & 2 deletions src/analysis/typepal/StringSimilarity.rsc
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module analysis::typepal::StringSimilarity

import List;
import Set;
import String;
import analysis::typepal::TModel;
import analysis::typepal::ConfigurableScopeGraph;

@synopsis{Tryadic minimum function on integers}
int min(int a, int b, int c)
Expand Down Expand Up @@ -50,10 +52,10 @@ alias WordSim = tuple[str word, int sim];

@synopsis{Compute list of words from vocabulary, that are similar to give word w with at most maxDistance edits}
list[str] similarWords(str w, list[str] vocabulary, int maxDistance)
= sort([ <v, d> | str v <- vocabulary, d := lev(w, v), d <= maxDistance ], bool (WordSim x, WordSim y){ return x.sim < y.sim;}).word;
= sort({ <v, d> | str v <- vocabulary, d := lev(w, v), d <= maxDistance }, bool (WordSim x, WordSim y){ return x.sim < y.sim;}).word;

@synopsis{Find in TModel tm, names similar to w, in gives roles. Max edit distance comes from TypePal Configuration.}
list[str] similarNames(str w, set[IdRole] idRoles, TModel tm){
vocabulary = [ d.orgId | d <- tm.defines, d.idRole in idRoles ];
return similarWords(w, vocabulary, maxDistance,tm.config.cutoffForNameSimilarity);
return similarWords(w, vocabulary, tm.config.cutoffForNameSimilarity);
}

0 comments on commit d6c21a2

Please sign in to comment.