org.eclipse.xtext.generator.OutputConfigurationProvider Java Examples
The following examples show how to use
org.eclipse.xtext.generator.OutputConfigurationProvider.
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: XStatefulIncrementalBuilder.java From n4js with Eclipse Public License 1.0 | 6 votes |
private boolean isResourceInOutputDirectory(Resource resource, IResourceServiceProvider serviceProvider) { XWorkspaceManager workspaceManager = serviceProvider.get(XWorkspaceManager.class); if (workspaceManager == null) { return false; } OutputConfigurationProvider outputConfProvider = serviceProvider.get(OutputConfigurationProvider.class); URI resourceUri = resource.getURI(); IProjectConfig projectConfig = workspaceManager.getProjectConfig(resourceUri); Set<OutputConfiguration> outputConfigurations = outputConfProvider.getOutputConfigurations(resource); URI projectBaseUri = projectConfig.getPath(); Path resourcePath = URIUtils.toPath(resourceUri); for (OutputConfiguration outputConf : outputConfigurations) { for (String outputDir : outputConf.getOutputDirectories()) { URI outputUri = projectBaseUri.appendSegment(outputDir); Path outputPath = URIUtils.toPath(outputUri); if (resourcePath.startsWith(outputPath)) { return true; } } } return false; }
Example #2
Source File: BuilderParticipantTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@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 #3
Source File: N4JSIdeModule.java From n4js with Eclipse Public License 1.0 | 4 votes |
public Class<? extends OutputConfigurationProvider> bindOutputConfigurationProvider() { return N4JSOutputConfigurationProvider.class; }
Example #4
Source File: BuilderParticipantTest.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@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 #5
Source File: BuilderParticipantTest.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@After public void resetPrefs() { BuilderPreferenceAccess.Initializer initializer = new BuilderPreferenceAccess.Initializer(); initializer.setOutputConfigurationProvider(new OutputConfigurationProvider()); initializer.initialize(preferenceStoreAccess); }