*/
public static NamedList getScope(NamedObj object) {
try {
object.workspace().getReadAccess();
NamedList scope = new NamedList();
NamedObj container = object.getContainer();
while (container != null) {
Iterator level1 = container.attributeList().iterator();
Attribute var = null;
while (level1.hasNext()) {
// add the variables in the same NamedObj to scope,
// excluding this
var = (Attribute) level1.next();
if ((var instanceof Variable) && (var != object)) {
if (var.workspace() != object.workspace()) {
continue;
}
try {
scope.append(var);
} catch (NameDuplicationException ex) {
// This occurs when a variable is shadowed by one
// that has been previously entered in the scope.
} catch (IllegalActionException ex) {
// This should not happen since we are dealing with
// variables which are Nameable.
}
}
}
level1 = container.attributeList(ScopeExtender.class)
.iterator();
while (level1.hasNext()) {
ScopeExtender extender = (ScopeExtender) level1.next();
Iterator level2 = extender.attributeList().iterator();
while (level2.hasNext()) {
// add the variables in the scope extender to scope,
// excluding this
var = (Attribute) level2.next();
if ((var instanceof Variable) && (var != object)) {
if (var.workspace() != object.workspace()) {
continue;
}
try {
scope.append(var);
} catch (NameDuplicationException ex) {
// This occurs when a variable is shadowed by
// one that has been previously entered in the
// scope.
} catch (IllegalActionException ex) {