org.eclipse.xtext.xbase.jvmmodel.JvmModelAssociator Java Examples

The following examples show how to use org.eclipse.xtext.xbase.jvmmodel.JvmModelAssociator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourceStorageTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test(expected = IOException.class)
public void testFailedWrite() throws Exception {
  final XtendFile file = this.file("class C{}");
  ByteArrayOutputStream _byteArrayOutputStream = new ByteArrayOutputStream();
  Resource _eResource = file.eResource();
  new BatchLinkableResourceStorageWritable(_byteArrayOutputStream, false) {
    @Override
    protected void writeAssociationsAdapter(final BatchLinkableResource resource, final OutputStream zipOut) throws IOException {
      final Function1<Adapter, Boolean> _function = (Adapter it) -> {
        return Boolean.valueOf((it instanceof JvmModelAssociator.Adapter));
      };
      final Adapter removeMe = IterableExtensions.<Adapter>findFirst(resource.eAdapters(), _function);
      Assert.assertTrue(resource.eAdapters().remove(removeMe));
      super.writeAssociationsAdapter(resource, zipOut);
    }
  }.writeResource(((StorageAwareResource) _eResource));
}
 
Example #2
Source File: SARLDescriptionLabelProviderTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
private <T extends XtendMember> T mockMember(Class<T> type, JvmVisibility visibility, JvmMember member) {
	T m = mock(type);
	when(m.getVisibility()).thenReturn(visibility);
	if (member != null) {
		EList<Adapter> adapters = new BasicEList<>();
		adapters.add(new JvmModelAssociator.Adapter());
		XtextResource r = mock(XtextResource.class);
		when(r.getLanguageName()).thenReturn("io.sarl.lang.SARL"); //$NON-NLS-1$
		when(r.eAdapters()).thenReturn(adapters);
		when(member.eResource()).thenReturn(r);
		when(m.eResource()).thenReturn(r);
		this.jvmModelAssociator.associate(m, member);
	}
	return m;
}
 
Example #3
Source File: SARLLabelProviderTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
private <T extends XtendMember> T mockMember(Class<T> type, JvmVisibility visibility, JvmMember member) {
	T m = mock(type);
	when(m.getVisibility()).thenReturn(visibility);
	if (member != null) {
		EList<Adapter> adapters = new BasicEList<>();
		adapters.add(new JvmModelAssociator.Adapter());
		XtextResource r = mock(XtextResource.class);
		when(r.getLanguageName()).thenReturn("io.sarl.lang.SARL"); //$NON-NLS-1$
		when(r.eAdapters()).thenReturn(adapters);
		when(member.eResource()).thenReturn(r);
		when(m.eResource()).thenReturn(r);
		this.jvmModelAssociator.associate(m, member);
	}
	return m;
}
 
Example #4
Source File: DefaultXbaseRuntimeModule.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDerivedStateComputer> bindIDerivedStateComputer() {
	return JvmModelAssociator.class;
}
 
Example #5
Source File: JvmModelAssociatorTest.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Before
public void createAssociator() {
  JvmModelAssociator _jvmModelAssociator = new JvmModelAssociator();
  this.assoc = _jvmModelAssociator;
  this.associatorInjector.injectMembers(this.assoc);
}
 
Example #6
Source File: XtendRuntimeModule.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends JvmModelAssociator> bindJvmModelAssociator() {
	return IXtendJvmAssociations.Impl.class;
}
 
Example #7
Source File: AbstractSARLRuntimeModule.java    From sarl with Apache License 2.0 4 votes vote down vote up
public Class<? extends JvmModelAssociator> bindJvmModelAssociator() {
	return SarlJvmModelAssociations.Impl.class;
}