-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update infrastructure for changes of full qualfied instance names #811
base: develop
Are you sure you want to change the base?
Conversation
0ec6021
to
797d2c9
Compare
666971a
to
2018064
Compare
ef4d556
to
f64ae37
Compare
281f523
to
1b159c0
Compare
1b159c0
to
5c9a596
Compare
5c9a596
to
c59a4b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may have a simpler solution for handling qualified name changes in the listener:
- collect all execute/undo/redo changes in a single list,
- when performing the changes, first merge all changes for the same element in order.
This way, we should be able to avoid keeping a separate history for changes in addition to the command stack. What do you think?
import org.eclipse.fordiac.ide.model.typelibrary.TypeEntry; | ||
import org.eclipse.gef.commands.Command; | ||
|
||
public abstract class QualNameAffectedCommand extends Command implements ScopedCommand { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest changing this into an interface to make it easier to add to an existing class hierarchy of commands.
|
||
protected abstract String getNewQualName(); | ||
|
||
protected abstract INamedElement getNotifier(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest renaming this to getRenamedElement
(or something similar) to make it more clear what is being returned.
Assert.isTrue(rootContainer instanceof LibraryElement); | ||
if (rootContainer instanceof final LibraryElement element) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe having another instanceof check after an assertion makes little sense. I would suggest removing the assertion.
import org.eclipse.fordiac.ide.model.libraryElement.INamedElement; | ||
import org.eclipse.fordiac.ide.model.typelibrary.TypeEntry; | ||
|
||
public abstract class QualNameChangeListener { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please extract the implementation into a separeate class and change this into an interface.
listeners.add((QualNameChangeListener) obj); | ||
} | ||
} catch (final Exception e) { | ||
e.printStackTrace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please properly log the exception (including the contributing plugin).
if (typeEntry != null) { | ||
notifiyCommit(typeEntry); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about POST_FLUSH
(e.g., because a reload of the editor)?
} | ||
|
||
private static TypeEntry getTypeEntryKeyFromCommandStack(final CommandStack stack) { | ||
final IEditorPart currentActiveEditor = EditorUtils.getCurrentActiveEditor(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this does not handle the case where multiple editors are saved at once (e.g., Save All)? I would suggest adding a dedicated listener instance per editor to keep track of the type entry.
this.element = Objects.requireNonNull(element); | ||
this.name = name; | ||
this.validateName = validateName; | ||
this.oldName = element.getQualifiedName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The oldName
is supposed to be the (unqualified) name of the element and is assigned in execute()
.
final String[] split = getOldQualName().split("\\."); //$NON-NLS-1$ | ||
final StringBuilder sb = new StringBuilder(); | ||
for (int i = 0; i < split.length; i++) { | ||
if (i == split.length - 1) { | ||
sb.append(name); | ||
} else { | ||
sb.append(split[i]); | ||
sb.append("."); //$NON-NLS-1$ | ||
} | ||
} | ||
return sb.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final String[] split = getOldQualName().split("\\."); //$NON-NLS-1$ | |
final StringBuilder sb = new StringBuilder(); | |
for (int i = 0; i < split.length; i++) { | |
if (i == split.length - 1) { | |
sb.append(name); | |
} else { | |
sb.append(split[i]); | |
sb.append("."); //$NON-NLS-1$ | |
} | |
} | |
return sb.toString(); | |
return getOldQualName().substring(0, getOldQualName().length() - oldName.length()) + name; |
@@ -19,7 +19,10 @@ Require-Bundle: org.eclipse.core.resources, | |||
org.eclipse.fordiac.ide.ui, | |||
org.eclipse.fordiac.ide.typemanagement, | |||
org.eclipse.ui.ide, | |||
org.eclipse.ui.views.properties.tabbed | |||
org.eclipse.emf.mwe.core, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need org.eclipse.emf.mwe.core
as a dependency?
No description provided.