Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Eclipse freezes after applying an ISemanticModification
Eclipse freezes after applying an ISemanticModification [message #670513] Sat, 14 May 2011 15:43 Go to next message
Victor Noël is currently offline Victor NoëlFriend
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;
	}
}
Re: Eclipse freezes after applying an ISemanticModification [message #671227 is a reply to message #670513] Tue, 17 May 2011 07:53 Go to previous message
Victor Noël is currently offline Victor NoëlFriend
Messages: 112
Registered: June 2010
Senior Member
Hi,

I was hoping someone had an idea about how to debug it...

Thank you!
Previous Topic:XText-generated Editor as a MultiPageEditor?
Next Topic:XText + DataInterchangeFormat + data structure
Goto Forum:
  


Current Time: Fri Apr 26 11:24:59 GMT 2024

Powered by FUDForum. Page generated in 0.03414 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top