Java Code Examples for org.eclipse.xtext.util.Modules2

The following examples show how to use org.eclipse.xtext.util.Modules2. These examples are extracted from open source projects. 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 Project: xtext-core   Source File: MultiProjectTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Before
public void setup() {
  ServerModule _serverModule = new ServerModule();
  final Injector injector = Guice.createInjector(Modules2.mixin(_serverModule, new AbstractModule() {
    @Override
    protected void configure() {
      this.<IMultiRootWorkspaceConfigFactory>bind(IMultiRootWorkspaceConfigFactory.class).to(MultiProjectWorkspaceConfigFactory.class);
    }
  }));
  injector.injectMembers(this);
  final File workspaceRoot = this.getRoot("test-data");
  File _file = new File(workspaceRoot, "test-project0");
  this.project0 = _file;
  File _file_1 = new File(workspaceRoot, "test-project1");
  this.project1 = _file_1;
  this.project0.mkdir();
  this.project1.mkdir();
  final Procedure2<URI, Iterable<Issue>> _function = (URI $0, Iterable<Issue> $1) -> {
    this.diagnostics.put($0, IterableExtensions.<Issue>toList($1));
  };
  this.workspaceManager.initialize(URI.createFileURI(workspaceRoot.getAbsolutePath()), _function, null);
}
 
Example 2
Source Project: xtext-eclipse   Source File: ContentAssistTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public ISetup doGetSetup() {
	return new ContentAssistTestLanguageStandaloneSetup() {
		@Override
		public Injector createInjector() {
			return Guice.createInjector(Modules2.mixin(
					new ContentAssistTestLanguageRuntimeModule(),
					new ContentAssistTestLanguageUiModule(TestsActivator.getInstance()) {
						@Override
						public Class<? extends IJavaProjectProvider> bindIJavaProjectProvider() {
							return MockJavaProjectProvider.class;
						}
					}, 
					new SharedStateModule()));
		}
	};
}
 
Example 3
/**
 * @return
 */
private ISetup getGrammarSetup() {
	return new TwoContextsTestLanguageStandaloneSetup() {
		@Override
		public Injector createInjector() {
			return Guice.createInjector(Modules2.mixin(
					new TwoContextsTestLanguageRuntimeModule(),
					new TwoContextsTestLanguageUiModule(TestsActivator.getInstance()){
				@Override
				public Class<? extends IContentProposalProvider> bindIContentProposalProvider() {
					return TwoContextsTestLanguageTestProposals.class;
				}
			},
			new SharedStateModule()));
		}
	};
}
 
Example 4
Source Project: xtext-eclipse   Source File: CurrentModelBugTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private ISetup getSetup() {
	return new DomainModelTestLanguageStandaloneSetup() {
		@Override
		public Injector createInjector() {
			return Guice.createInjector(Modules2.mixin(new DomainModelTestLanguageRuntimeModule(), new DomainModelTestLanguageUiModule(TestsActivator.getInstance()){

				@Override
				public Class<? extends IContentProposalProvider> bindIContentProposalProvider() {
					return MockedProposals.class;
				}
				
				@SuppressWarnings("unused")
				public CurrentModelBugTest bindCurrentModelBugTest() {
					return CurrentModelBugTest.this;
				}
			}, new SharedStateModule()));
		}
	};
}
 
Example 5
Source Project: xtext-eclipse   Source File: Bug297909Test.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public ISetup doGetSetup() {
	return new ContentAssistTestLanguageStandaloneSetup() {
		@Override
		public Injector createInjector() {
			return Guice.createInjector(Modules2.mixin(new ContentAssistTestLanguageRuntimeModule(), new ContentAssistTestLanguageUiModule(TestsActivator
					.getInstance()), new SharedStateModule()));
		}
		
		@Override
		public void register(Injector injector) {
			super.register(injector);
			// simulate a EPackage that was not registered
			EPackage.Registry.INSTANCE.remove("http://www.eclipse.org/2008/xtext/ui/common/tests/ContentAssist");
			Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove("contentassisttestlanguage");
		}
	};
}
 
Example 6
Source Project: dsl-devkit   Source File: TestLanguageActivator.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected Injector createInjector(String language) {
	try {
		Module runtimeModule = getRuntimeModule(language);
		Module sharedStateModule = getSharedStateModule();
		Module uiModule = getUiModule(language);
		Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
		return Guice.createInjector(mergedModule);
	} catch (Exception e) {
		logger.error("Failed to create injector for " + language);
		logger.error(e.getMessage(), e);
		throw new RuntimeException("Failed to create injector for " + language, e);
	}
}
 
Example 7
Source Project: n4js   Source File: N4JSActivator.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected Injector createInjector(String language) {
	try {
		com.google.inject.Module runtimeModule = getRuntimeModule(language);
		com.google.inject.Module sharedStateModule = getSharedStateModule();
		com.google.inject.Module uiModule = getUiModule(language);
		com.google.inject.Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
		return Guice.createInjector(mergedModule);
	} catch (Exception e) {
		logger.error("Failed to create injector for " + language);
		logger.error(e.getMessage(), e);
		throw new RuntimeException("Failed to create injector for " + language, e);
	}
}
 
Example 8
Source Project: n4js   Source File: RegularExpressionActivator.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected Injector createInjector(String language) {
	try {
		com.google.inject.Module runtimeModule = getRuntimeModule(language);
		com.google.inject.Module sharedStateModule = getSharedStateModule();
		com.google.inject.Module uiModule = getUiModule(language);
		com.google.inject.Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
		return Guice.createInjector(mergedModule);
	} catch (Exception e) {
		logger.error("Failed to create injector for " + language);
		logger.error(e.getMessage(), e);
		throw new RuntimeException("Failed to create injector for " + language, e);
	}
}
 
Example 9
Source Project: n4js   Source File: JsonActivator.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected Injector createInjector(String language) {
	try {
		com.google.inject.Module runtimeModule = getRuntimeModule(language);
		com.google.inject.Module sharedStateModule = getSharedStateModule();
		com.google.inject.Module uiModule = getUiModule(language);
		com.google.inject.Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
		return Guice.createInjector(mergedModule);
	} catch (Exception e) {
		logger.error("Failed to create injector for " + language);
		logger.error(e.getMessage(), e);
		throw new RuntimeException("Failed to create injector for " + language, e);
	}
}
 
Example 10
Source Project: xtext-core   Source File: WorkspaceFoldersTest.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected com.google.inject.Module getServerModule() {
  final com.google.inject.Module defaultModule = super.getServerModule();
  final com.google.inject.Module customModule = new AbstractModule() {
    @Override
    protected void configure() {
      this.<WorkspaceManager>bind(WorkspaceManager.class).in(Scopes.SINGLETON);
    }
  };
  return Modules2.mixin(defaultModule, customModule);
}
 
Example 11
protected Injector createInjector(String language) {
	try {
		com.google.inject.Module runtimeModule = getRuntimeModule(language);
		com.google.inject.Module sharedStateModule = getSharedStateModule();
		com.google.inject.Module uiModule = getUiModule(language);
		com.google.inject.Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
		return Guice.createInjector(mergedModule);
	} catch (Exception e) {
		logger.error("Failed to create injector for " + language);
		logger.error(e.getMessage(), e);
		throw new RuntimeException("Failed to create injector for " + language, e);
	}
}
 
Example 12
Source Project: xtext-web   Source File: AbstractWebServerTest.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Injector internalCreateInjector() {
	return new StatemachineStandaloneSetup() {
		@Override
		public Injector createInjector() {
			StatemachineWebModule webModule = getWebModule();
			webModule.setResourceBaseProvider(resourceBaseProvider);
			return Guice.createInjector(Modules2.mixin(getRuntimeModule(),
					getIdeModule(), webModule));
		}
	}.createInjectorAndDoEMFRegistration();
}
 
Example 13
Source Project: dsl-devkit   Source File: ValidActivator.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected Injector createInjector(String language) {
	try {
		Module runtimeModule = getRuntimeModule(language);
		Module sharedStateModule = getSharedStateModule();
		Module uiModule = getUiModule(language);
		Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
		return Guice.createInjector(mergedModule);
	} catch (Exception e) {
		logger.error("Failed to create injector for " + language);
		logger.error(e.getMessage(), e);
		throw new RuntimeException("Failed to create injector for " + language, e);
	}
}
 
Example 14
Source Project: xtext-web   Source File: EntitiesWebSetup.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Injector createInjector() {
	EntitiesWebModule webModule = new EntitiesWebModule(this.resourceBaseProvider);
	EntitiesRuntimeModule runtimeModule = new EntitiesRuntimeModule();
	EntitiesIdeModule ideModule = new EntitiesIdeModule();
	return Guice.createInjector(Modules2.mixin(runtimeModule, ideModule, webModule));
}
 
Example 15
Source Project: xtext-web   Source File: StatemachineWebSetup.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Injector createInjector() {
	StatemachineWebModule webModule = new StatemachineWebModule(this.resourceBaseProvider);
	StatemachineRuntimeModule runtimeModule = new StatemachineRuntimeModule();
	StatemachineIdeModule ideModule = new StatemachineIdeModule();
	return Guice.createInjector(Modules2.mixin(runtimeModule, ideModule, webModule));
}
 
Example 16
@Override
protected Injector internalCreateInjector() {
	return new TestLanguageStandaloneSetup() {
		@Override
		public Injector createInjector() {
			return Guice.createInjector(Modules2.mixin(createRuntimeModule(), new TestLanguageIdeModule()));
		}
	}.createInjectorAndDoEMFRegistration();

}
 
Example 17
@Override
protected com.google.inject.Module getServerModule() {
	com.google.inject.Module defaultModule = super.getServerModule();
	com.google.inject.Module customModule = new AbstractModule() {
		@Override
		protected void configure() {
			bind(IMultiRootWorkspaceConfigFactory.class)
					.to(SourceFolderCustomImplTest.CustomWorkspaceConfigFactory.class);
			bind(WorkspaceManager.class).in(Scopes.SINGLETON);
		}
	};
	return Modules2.mixin(defaultModule, customModule);
}
 
Example 18
public ISetup doGetSetup() {
	return new XtextStandaloneSetup() {
		@Override
		public Injector createInjector() {
			return Guice.createInjector(Modules2.mixin(new XtextRuntimeModule(),new XtextUIModuleInternal(Activator.getDefault()) {
				@Override
				public void configureContentProposalLabelProvider(com.google.inject.Binder binder) {
					binder.bind(ILabelProvider.class).annotatedWith(ContentProposalLabelProvider.class).to(DefaultEObjectLabelProvider.class);
				}
			}, new SharedStateModule()));
		}
	};
}
 
Example 19
protected Injector createInjector(String language) {
	try {
		com.google.inject.Module runtimeModule = getRuntimeModule(language);
		com.google.inject.Module sharedStateModule = getSharedStateModule();
		com.google.inject.Module uiModule = getUiModule(language);
		com.google.inject.Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
		return Guice.createInjector(mergedModule);
	} catch (Exception e) {
		logger.error("Failed to create injector for " + language);
		logger.error(e.getMessage(), e);
		throw new RuntimeException("Failed to create injector for " + language, e);
	}
}
 
Example 20
@Before
@Override
public void setUp() throws Exception {
  super.setUp();
  with(Modules2.mixin(new XtextRuntimeModule(), new AbstractModule() {
    @Override
    protected void configure() {
      bind(IFragmentProvider.class).to(TestSelectorFragmentProvider.class);
    }
  }));
}
 
Example 21
Source Project: xtext-eclipse   Source File: FowlerdslActivator.java    License: Eclipse Public License 2.0 5 votes vote down vote up
protected Injector createInjector(String language) {
	try {
		com.google.inject.Module runtimeModule = getRuntimeModule(language);
		com.google.inject.Module sharedStateModule = getSharedStateModule();
		com.google.inject.Module uiModule = getUiModule(language);
		com.google.inject.Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
		return Guice.createInjector(mergedModule);
	} catch (Exception e) {
		logger.error("Failed to create injector for " + language);
		logger.error(e.getMessage(), e);
		throw new RuntimeException("Failed to create injector for " + language, e);
	}
}
 
Example 22
protected Injector createInjector(String language) {
	try {
		com.google.inject.Module runtimeModule = getRuntimeModule(language);
		com.google.inject.Module sharedStateModule = getSharedStateModule();
		com.google.inject.Module uiModule = getUiModule(language);
		com.google.inject.Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
		return Guice.createInjector(mergedModule);
	} catch (Exception e) {
		logger.error("Failed to create injector for " + language);
		logger.error(e.getMessage(), e);
		throw new RuntimeException("Failed to create injector for " + language, e);
	}
}
 
Example 23
Source Project: dsl-devkit   Source File: HelloworldActivator.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected Injector createInjector(String language) {
	try {
		com.google.inject.Module runtimeModule = getRuntimeModule(language);
		com.google.inject.Module sharedStateModule = getSharedStateModule();
		com.google.inject.Module uiModule = getUiModule(language);
		com.google.inject.Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
		return Guice.createInjector(mergedModule);
	} catch (Exception e) {
		logger.error("Failed to create injector for " + language);
		logger.error(e.getMessage(), e);
		throw new RuntimeException("Failed to create injector for " + language, e);
	}
}
 
Example 24
Source Project: dsl-devkit   Source File: CheckActivator.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected Injector createInjector(String language) {
	try {
		Module runtimeModule = getRuntimeModule(language);
		Module sharedStateModule = getSharedStateModule();
		Module uiModule = getUiModule(language);
		Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
		return Guice.createInjector(mergedModule);
	} catch (Exception e) {
		logger.error("Failed to create injector for " + language);
		logger.error(e.getMessage(), e);
		throw new RuntimeException("Failed to create injector for " + language, e);
	}
}
 
Example 25
Source Project: dsl-devkit   Source File: CheckCfgActivator.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected Injector createInjector(String language) {
	try {
		Module runtimeModule = getRuntimeModule(language);
		Module sharedStateModule = getSharedStateModule();
		Module uiModule = getUiModule(language);
		Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
		return Guice.createInjector(mergedModule);
	} catch (Exception e) {
		logger.error("Failed to create injector for " + language);
		logger.error(e.getMessage(), e);
		throw new RuntimeException("Failed to create injector for " + language, e);
	}
}
 
Example 26
Source Project: dsl-devkit   Source File: FormatActivator.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected Injector createInjector(String language) {
	try {
		Module runtimeModule = getRuntimeModule(language);
		Module sharedStateModule = getSharedStateModule();
		Module uiModule = getUiModule(language);
		Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
		return Guice.createInjector(mergedModule);
	} catch (Exception e) {
		logger.error("Failed to create injector for " + language);
		logger.error(e.getMessage(), e);
		throw new RuntimeException("Failed to create injector for " + language, e);
	}
}
 
Example 27
Source Project: xtext-eclipse   Source File: XbaseActivator.java    License: Eclipse Public License 2.0 5 votes vote down vote up
protected Injector createInjector(String language) {
	try {
		com.google.inject.Module runtimeModule = getRuntimeModule(language);
		com.google.inject.Module sharedStateModule = getSharedStateModule();
		com.google.inject.Module uiModule = getUiModule(language);
		com.google.inject.Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
		return Guice.createInjector(mergedModule);
	} catch (Exception e) {
		logger.error("Failed to create injector for " + language);
		logger.error(e.getMessage(), e);
		throw new RuntimeException("Failed to create injector for " + language, e);
	}
}
 
Example 28
Source Project: xtext-core   Source File: TestLanguageIdeSetup.java    License: Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Injector createInjector() {
	return Guice.createInjector(Modules2.mixin(new TestLanguageRuntimeModule(), new TestLanguageIdeModule()));
}
 
Example 29
Source Project: n4js   Source File: N4JSIdeSetup.java    License: Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Injector createInjector() {
	return Guice.createInjector(
			Modules2.mixin(new ServerModule(), new N4JSRuntimeModule(), new N4JSIdeModule(), new TesterModule()));
}
 
Example 30
Source Project: n4js   Source File: JSONIdeSetup.java    License: Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Injector createInjector() {
	return Guice.createInjector(Modules2.mixin(new JSONRuntimeModule(), new JSONIdeModule()));
}