Project

General

Profile

Bug #5723

references to parameter are not always renamed

Added by Daniel Crawl about 7 years ago. Updated over 6 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
actors
Target version:
Start date:
10/12/2012
Due date:
% Done:

0%

Estimated time:
Bugzilla-Id:
5723

Description

If a parameter is referenced by another parameter, then renaming the former is not always reflected in the latter. The seems to happen when the latter is a string parameter.

To reproduce:

1. add a String Parameter to the canvas
2. rename to x
3. add a String Replace actor to the canvas
4. double-click on String Replace, set pattern to $x, close dialog
5. rename x to y
6. double-click on String Replace, pattern is set to y instead of $y

History

#1 Updated by Christopher Brooks about 7 years ago

That's a strange bug.
I think the problem is with the $x syntax in the pattern PortParameter that is in string mode.

ptolemy/actor/gui/RenameConfigurer.java generates a MoMLChangeRequest
that looks like:
<property name="x"><rename name="y"/></property>

MoMLParser parses it and calls ptolemy.data.expr.Variable.setName() which
finds the listeners and sets the expression in an unusual manner:
--start--
if (_valueListeners != null) {
Iterator listeners = _valueListeners.iterator();
while (listeners.hasNext()) {
ValueListener listener = (ValueListener) listeners
.next();
if (listener instanceof Variable) {
// The listener could be referencing this variable.
ParseTreeFreeVariableRenamer renamer = new ParseTreeFreeVariableRenamer();
((Variable) listener)._parseIfNecessary();
renamer.renameVariables(
((Variable) listener)._parseTree,
(Variable) listener, this, name);
ParseTreeWriter writer = new ParseTreeWriter();
((Variable) listener)
.setExpression(writer
.parseTreeToExpression(((Variable) listener)._parseTree));
changed.add(listener);
}
}
}
super.setName(name);
// With the new name, we may now shadow variables that
// were not previously shadowed. Invalidate those. _invalidateShadowedSettables(getContainer());
validate();
--end---

I think the problem is that the $x expression is getting evaluated somewhere.

#2 Updated by Daniel Crawl almost 7 years ago

I added some test cases for this to $PTII/ptolemy/data/expr/test/Parameter.tcl.

#3 Updated by Redmine Admin over 6 years ago

Original Bugzilla ID was 5723

#4 Updated by Daniel Crawl over 6 years ago

  • Status changed from New to Resolved

Fixed. I also added another test to Rename.tcl.

Also available in: Atom PDF