Java Code Examples for org.eclipse.xtext.builder.preferences.BuilderPreferenceAccess#Initializer

The following examples show how to use org.eclipse.xtext.builder.preferences.BuilderPreferenceAccess#Initializer . 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: BuilderParticipantTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testNoOutputFolderCreation() throws Exception {
	OutputConfigurationProvider outputConfigurationProvider = new OutputConfigurationProvider() {
		@Override
		public Set<OutputConfiguration> getOutputConfigurations() {
			final Set<OutputConfiguration> result = super.getOutputConfigurations();
			OutputConfiguration configuration = result.iterator().next();
			configuration.setCreateOutputDirectory(false);
			return result;
		}
	};
	BuilderPreferenceAccess.Initializer initializer = new BuilderPreferenceAccess.Initializer();
	initializer.setOutputConfigurationProvider(outputConfigurationProvider);
	initializer.initialize(preferenceStoreAccess);

	IJavaProject project = createJavaProject("foo");
	addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
	IFolder folder = project.getProject().getFolder("src");
	IFile file = folder.getFile("Foo" + F_EXT);
	file.create(new StringInputStream("object Foo"), true, monitor());
	build();
	final IFile generatedFile = project.getProject().getFile("./src-gen/Foo.txt");
	assertFalse(generatedFile.exists());
}
 
Example 2
Source File: BuilderParticipantTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testNoCleanUpNoDerived() throws Exception {
	OutputConfigurationProvider outputConfigurationProvider = new OutputConfigurationProvider() {
		@Override
		public Set<OutputConfiguration> getOutputConfigurations() {
			final Set<OutputConfiguration> result = super.getOutputConfigurations();
			OutputConfiguration configuration = result.iterator().next();
			configuration.setCanClearOutputDirectory(false);
			configuration.setCleanUpDerivedResources(false);
			configuration.setSetDerivedProperty(false);
			return result;
		}
	};
	BuilderPreferenceAccess.Initializer initializer = new BuilderPreferenceAccess.Initializer();
	initializer.setOutputConfigurationProvider(outputConfigurationProvider);
	initializer.initialize(preferenceStoreAccess);

	IJavaProject project = createJavaProject("foo");
	addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
	IFolder folder = project.getProject().getFolder("src");
	IFile file = folder.getFile("Foo" + F_EXT);
	file.create(new StringInputStream("object Foo"), true, monitor());
	build();
	IFile generatedFileFoo = project.getProject().getFile("./src-gen/Foo.txt");
	assertTrue(generatedFileFoo.exists());
	assertFalse(generatedFileFoo.isDerived());
	assertTrue(generatedFileFoo.findMarkers(DerivedResourceMarkers.MARKER_ID, false, IResource.DEPTH_ZERO).length == 1);
	assertEquals("object Foo", readFile(generatedFileFoo).trim());
	file.setContents(new StringInputStream("object Bar"), true, true, monitor());
	build();
	assertTrue(generatedFileFoo.exists());
	IFile generatedFileBar = project.getProject().getFile("./src-gen/Bar.txt");
	assertTrue(generatedFileBar.exists());
	assertFalse(generatedFileBar.isDerived());
	assertTrue(generatedFileBar.findMarkers(DerivedResourceMarkers.MARKER_ID, false, IResource.DEPTH_ZERO).length == 1);
	assertEquals("object Bar", readFile(generatedFileBar).trim());
	file.delete(true, monitor());
	build();
	assertTrue(generatedFileBar.exists());
	disableAutobuild(()->{
		cleanBuild();
		assertTrue(generatedFileBar.exists());	
	});
}
 
Example 3
Source File: BuilderParticipantTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@After
public void resetPrefs() {
	BuilderPreferenceAccess.Initializer initializer = new BuilderPreferenceAccess.Initializer();
	initializer.setOutputConfigurationProvider(new OutputConfigurationProvider());
	initializer.initialize(preferenceStoreAccess);
}
 
Example 4
Source File: DefaultXbaseUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends BuilderPreferenceAccess.Initializer> bindBuilderPreferenceAccess$Initializer() {
	return XbaseBuilderPreferenceAccess.Initializer.class;
}
 
Example 5
Source File: CheckUiModule.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
@SuppressWarnings("PMD.AvoidDollarSigns") // that's how it's defined in Xtext
public Class<? extends BuilderPreferenceAccess.Initializer> bindBuilderPreferenceAccess$Initializer() {
  return CheckBuilderPreferenceAccess.Initializer.class;
}