org.eclipse.xtext.util.Modules2 Java Examples

The following examples show how to use org.eclipse.xtext.util.Modules2. 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: Bug297909Test.java    From xtext-eclipse with 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 #2
Source File: CurrentModelBugTest.java    From xtext-eclipse with 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 #3
Source File: TwoContextsContentAssistTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @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 File: ContentAssistTest.java    From xtext-eclipse with 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 #5
Source File: MultiProjectTest.java    From xtext-core with 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 #6
Source File: SourceFolderCustomImplTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@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 #7
Source File: AbstractWebServerTest.java    From xtext-web with 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 #8
Source File: TestLanguageActivator.java    From dsl-devkit with 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 #9
Source File: CodetemplatesActivator.java    From xtext-eclipse with 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 #10
Source File: JsonActivator.java    From n4js with 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 #11
Source File: WorkspaceFoldersTest.java    From xtext-core with 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 #12
Source File: RegularExpressionActivator.java    From n4js with 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 #13
Source File: ValidActivator.java    From dsl-devkit with 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 File: EntitiesWebSetup.java    From xtext-web with 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 File: StatemachineWebSetup.java    From xtext-web with 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
Source File: TestLanguageIdeInjectorProvider.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Injector internalCreateInjector() {
	return new TestLanguageStandaloneSetup() {
		@Override
		public Injector createInjector() {
			return Guice.createInjector(Modules2.mixin(createRuntimeModule(), new TestLanguageIdeModule()));
		}
	}.createInjectorAndDoEMFRegistration();

}
 
Example #17
Source File: N4JSActivator.java    From n4js with 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 #18
Source File: XtextContentAssistTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
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
Source File: TestlanguagesActivator.java    From xtext-eclipse with 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 #20
Source File: AbstractSelectorFragmentProviderTest.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
@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 File: FowlerdslActivator.java    From xtext-eclipse with 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
Source File: DomainmodelActivator.java    From xtext-eclipse with 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 #23
Source File: HelloworldActivator.java    From dsl-devkit with 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 File: CheckActivator.java    From dsl-devkit with 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 File: CheckCfgActivator.java    From dsl-devkit with 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 File: FormatActivator.java    From dsl-devkit with 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 File: XbaseActivator.java    From xtext-eclipse with 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 File: ParameterizedExpressionsTestLanguageIdeSetup.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Injector createInjector() {
	return Guice.createInjector(Modules2.mixin(new ParameterizedExpressionsTestLanguageRuntimeModule(), new ParameterizedExpressionsTestLanguageIdeModule()));
}
 
Example #29
Source File: Bug309949TestLanguageIdeSetup.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Injector createInjector() {
	return Guice.createInjector(Modules2.mixin(new Bug309949TestLanguageRuntimeModule(), new Bug309949TestLanguageIdeModule()));
}
 
Example #30
Source File: DotRectIdeSetup.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Injector createInjector() {
	return Guice.createInjector(Modules2.mixin(new DotRectRuntimeModule(), new DotRectIdeModule()));
}