Eclipse freezes after applying an ISemanticModification [message #670513] |
Sat, 14 May 2011 15:43 |
Victor Noël Messages: 112 Registered: June 2010 |
Senior Member |
|
|
Hi,
I have a really strange problem.
Using the DomainModel project as an example, I tried to add a quickfix for adding missing references.
As with the TypeRef of the DomainModel example, if the referenced type is not resolved, then I would like to create the missing referenced entity with a ISemanticModification.
When I try the example, it works, but with my implementation, what happens is that while the ISemanticModification is called and the newly created element is added to the model, my Eclipse sssion just seems to freeze and nothing happens, anywhere, and no errors appears in the console.
Here is the code I modified:
public class SpeADLLinkingDiagnosticMessageProvider extends LinkingDiagnosticMessageProvider {
public static final String MISSING_TRANSVERSE_TYPE = "fr.irit.smac.may.spead.MISSING_TRANSVERSE_TYPE";
@Override
public DiagnosticMessage getUnresolvedProxyMessage(final ILinkingDiagnosticContext context) {
DiagnosticMessage diagnosticMessage = new SpeADLSwitch<DiagnosticMessage>() {
@Override
public DiagnosticMessage caseParameterizedTransverseReference(ParameterizedTransverseReference object) {
return new DiagnosticMessage("Couldn't resolve reference to transverse " + context.getLinkText(),
DiagnosticSeverity.ERROR, MISSING_TRANSVERSE_TYPE, context.getLinkText());
};
}.doSwitch(context.getContext());
return diagnosticMessage != null ? diagnosticMessage : super.getUnresolvedProxyMessage(context);
}
}
This is added to the UiModule
public class SpeADLQuickfixProvider extends DefaultQuickfixProvider {
@Fix(SpeADLLinkingDiagnosticMessageProvider.MISSING_TRANSVERSE_TYPE)
public void createTransverseType(final Issue issue, IssueResolutionAcceptor acceptor) {
final String linkText = issue.getData()[0];
acceptor.accept(issue, "Create transverse '" + linkText + "'", "Create transverse '" + linkText + "'", null,
new ISemanticModification() {
public void apply(final EObject element, IModificationContext context) {
createNewTransverse((ParameterizedElement) element.eContainer().eContainer(), linkText);
}
});
createLinkingIssueResolutions(issue, acceptor);
}
protected boolean createNewTransverse(ParameterizedElement sibling, String name) {
Transverse newElement = SpeADLFactory.eINSTANCE.createTransverse();
newElement.setName(name);
PortHolder agent = SpeADLFactory.eINSTANCE.createPortHolder();
PortHolder infra = SpeADLFactory.eINSTANCE.createPortHolder();
newElement.setAgent(agent);
newElement.setInfra(infra);
return addTypeAsSibling(sibling, newElement);
}
protected boolean addTypeAsSibling(ParameterizedElement sibling, ParameterizedElement newElement) {
EObject container = sibling.eContainer();
EList<ModelElement> elements = null;
if (container instanceof Namespace) {
elements = ((Namespace) container).getElements();
} else {
return false;
}
int index = elements.indexOf(sibling) + 1;
elements.add(index, newElement);
return true;
}
}
|
|
|
|
Powered by
FUDForum. Page generated in 0.03414 seconds