Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the generated testing InjectorProvider more flexible #3042

Merged
merged 11 commits into from
May 21, 2024

Conversation

LorenzoBettini
Copy link
Contributor

Part of #3001

As hinted here #3001 (comment) instead of generating an injector provider of this shape:

protected MyDslRuntimeModule createRuntimeModule() {
	return new MyDslRuntimeModule() {
			@Override
			public ClassLoader bindClassLoaderToInstance() {
				return MyDslInjectorProvider.class
						.getClassLoader();
			}
	};
}

This PR generates it like that (main commit 1181731):

protected MyDslRuntimeModule createRuntimeModule() {
	return new MyDslRuntimeModule() {
			@Override
			public ClassLoader bindClassLoaderToInstance() {
				return MyDslInjectorProvider.this.getClass()
						.getClassLoader();
			}
	};
}

This section was introduced in the past for running tests in OSGI, e.g., by Maven Tycho, to get the correct class loader.

This new version makes the class loader be retrieved from the instance of the injector provider, NOT from the static class of the injector provider, as before.

Thus, simply inheriting an injector provider in another test bundle will make Guice take the correct class loader.

Instead, before, one had also to redefine the createRuntimeModule.

This makes things easier in testing. Some examples of simplification due to this change are:

I regenerated all our languages accordingly.

Concerning purexbase, I cleaned up things a bit 8230ada : the old RuntimeInjectorProvider was already useless, maybe something from the past.

The PR can be seen as a first step/preparation in case we want to address #3001

@szarnekow
Copy link
Contributor

I think I like this. Small change and nice improvement.

@LorenzoBettini LorenzoBettini added this to the Release_2.35 milestone May 21, 2024
@cdietrich
Copy link
Member

find . -name "*InjectorProvider.java" | grep -v /ide/ | grep -v UiInjectorProvider | wc -l
108

 did you double check if you really regenerated all files?

@LorenzoBettini
Copy link
Contributor Author

find . -name "*InjectorProvider.java" | grep -v /ide/ | grep -v UiInjectorProvider | wc -l 108

 did you double check if you really regenerated all files?

@cdietrich With "Quick Search" I searched for the string show_bug.cgi?id=493672 and regenerated the languages in each project with such an occurrence, so I should have caught them all. I haven't touched the injector providers that were not generated, but manually crafted, like XbaseInjectorProvider and the one of Xtend.

@cdietrich
Copy link
Member

ok

@LorenzoBettini LorenzoBettini merged commit f629b30 into eclipse:main May 21, 2024
7 checks passed
@LorenzoBettini LorenzoBettini deleted the lb_3001 branch May 21, 2024 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants