forked from eclipse-xtext/xtext
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recreated test for the issue eclipse-xtext#2920 (#1)
Test case that effectively demonstrates the problem the customization happens at the level of the executable extension factory
- Loading branch information
1 parent
b41d4c4
commit 5ee75f0
Showing
5 changed files
with
143 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...text.builder.tests/src/org/eclipse/xtext/builder/tests/internal/TestsActivatorCustom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 itemis AG (http://www.itemis.eu) and others. | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package org.eclipse.xtext.builder.tests.internal; | ||
|
||
import org.eclipse.xtext.Constants; | ||
import org.eclipse.xtext.builder.tests.BuilderTestLanguageRuntimeModule; | ||
import org.eclipse.xtext.builder.tests.ui.BuilderTestLanguageUiModule; | ||
import org.eclipse.xtext.ui.shared.JdtHelper; | ||
import org.eclipse.xtext.ui.util.IJdtHelper; | ||
|
||
import com.google.inject.Binder; | ||
import com.google.inject.Module; | ||
import com.google.inject.Provider; | ||
import com.google.inject.name.Names; | ||
|
||
/** | ||
* This allows customizations in the UI, specific for some test scenarions, without creating new languages. | ||
* | ||
* @author Lorenzo Bettini - Initial contribution and API | ||
*/ | ||
public class TestsActivatorCustom extends TestsActivator { | ||
|
||
public static final String ORG_ECLIPSE_XTEXT_BUILDER_TESTS_BUILDERTESTLANGUAGE_GH2920 = ORG_ECLIPSE_XTEXT_BUILDER_TESTS_BUILDERTESTLANGUAGE | ||
+ "GH2920"; | ||
|
||
@Override | ||
protected Module getRuntimeModule(String grammar) { | ||
if (ORG_ECLIPSE_XTEXT_BUILDER_TESTS_BUILDERTESTLANGUAGE_GH2920.equals(grammar)) | ||
return new BuilderTestLanguageRuntimeModule() { | ||
@Override | ||
public void configureFileExtensions(Binder binder) { | ||
if (properties == null || properties.getProperty(Constants.FILE_EXTENSIONS) == null) | ||
binder.bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)) | ||
.toInstance("buildertestlanguageGH2920"); | ||
} | ||
}; | ||
return super.getRuntimeModule(grammar); | ||
} | ||
|
||
@Override | ||
protected Module getUiModule(String grammar) { | ||
if (ORG_ECLIPSE_XTEXT_BUILDER_TESTS_BUILDERTESTLANGUAGE_GH2920.equals(grammar)) | ||
return new BuilderTestLanguageUiModule(this) { | ||
/** | ||
* By default, the {@link IJdtHelper} is bound by the {@link org.eclipse.xtext.ui.shared.SharedStateModule}, but since the | ||
* UI module is mixed as the last one in {@link TestsActivator}, we can "override" its binding here. | ||
*/ | ||
@SuppressWarnings("unused") | ||
public Provider<IJdtHelper> provideJdtHelper() { | ||
return new Provider<>() { | ||
@Override | ||
public IJdtHelper get() { | ||
return new JdtHelper() { | ||
@Override | ||
protected boolean computeJavaCoreAvailable() { | ||
return false; | ||
} | ||
}; | ||
} | ||
}; | ||
} | ||
}; | ||
return super.getUiModule(grammar); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...g/eclipse/xtext/builder/tests/ui/BuilderTestLanguageExecutableExtensionFactoryGH2920.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 itemis AG (http://www.itemis.eu) and others. | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package org.eclipse.xtext.builder.tests.ui; | ||
|
||
import org.eclipse.xtext.builder.tests.internal.TestsActivator; | ||
import org.eclipse.xtext.builder.tests.internal.TestsActivatorCustom; | ||
|
||
import com.google.inject.Injector; | ||
|
||
/** | ||
* This allows customizations in the UI, specific for some test scenarions, without creating new languages. | ||
* | ||
* @author Lorenzo Bettini - Initial contribution and API | ||
*/ | ||
public class BuilderTestLanguageExecutableExtensionFactoryGH2920 extends BuilderTestLanguageExecutableExtensionFactory { | ||
|
||
@Override | ||
protected Injector getInjector() { | ||
TestsActivator activator = TestsActivator.getInstance(); | ||
return activator != null ? activator.getInjector(TestsActivatorCustom.ORG_ECLIPSE_XTEXT_BUILDER_TESTS_BUILDERTESTLANGUAGE_GH2920) | ||
: null; | ||
} | ||
} |