int occurences = Collections.frequency(vars, var); if (occurences < 2) { getFirstPass().reportWarning(TestWarning.VARIABLE_UNUSED, var.getSourceInfo(), var.toString()); int occurences = Collections.frequency(vars, var); if (occurences < 2) { getFirstPass().reportWarning(TestWarning.VARIABLE_UNUSED, var.getSourceInfo(), var.toString()); int occurences = Collections.frequency(vars, var); if (occurences < 2) { getFirstPass().reportWarning(TestWarning.VARIABLE_UNUSED, var.getSourceInfo(), var.toString());
/** * Get a substitution that we can apply to term, such that it will not use given * varsInUse. * * @param varsToBeMadeUnique * vars that have to be renamed if occurring iin the varsInUse list. * @param varsInUse * set of {@link Var}s that are in use * @return A substitution that will standardize apart variables. */ // TODO: Move this method to KR interface? #3430. This is quick fix. private Substitution makeTermVarsUnique(Set<Var> varsToBeMadeUnique, Set<Var> varsInUse) { Set<Var> varsToRename = getSharedVariables(varsToBeMadeUnique, varsInUse); Map<Var, Term> subst = new LinkedHashMap<>(varsToRename.size()); for (Var var : varsToRename) { subst.put(var, var.getVariant(varsInUse)); } return this.program.getKRInterface().getSubstitution(subst); }
Term term = var.applySubst(substitution);
protected void reportUnusedVariables() { for (UserSpecAction spec : this.program.getActionSpecifications()) { List<Var> vars = new LinkedList<>(); try { CognitiveKR ckr = getFirstPass().getCognitiveKR(); if (spec.getPrecondition() != null) { for (MentalLiteral literal : spec.getPrecondition().getAllLiterals()) { vars.addAll(ckr.getAllVariables(literal.getFormula())); } } if (spec.getNegativePostcondition() != null) { vars.addAll(ckr.getAllVariables(spec.getNegativePostcondition().getPostCondition())); } if (spec.getPositivePostcondition() != null) { vars.addAll(ckr.getAllVariables(spec.getPositivePostcondition().getPostCondition())); } Set<Var> unique = new LinkedHashSet<>(vars); unique.removeAll(spec.getParameters()); for (Var var : unique) { int occurences = Collections.frequency(vars, var); if (occurences < 2) { getFirstPass().reportWarning(ActionSpecWarning.VARIABLE_UNUSED, var.getSourceInfo(), var.toString()); } } } catch (ParserException e) { getFirstPass().reportParsingException(e); } } }
int occurences = Collections.frequency(vars, var); if (occurences < 2) { getFirstPass().reportWarning(ModuleWarning.VARIABLE_UNUSED, var.getSourceInfo(), var.toString());
int occurences = Collections.frequency(vars, var); if (occurences < 2) { reportWarning(MASWarning.VARIABLE_UNUSED, var.getSourceInfo(), var.toString());