mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 16:58:56 +00:00
[generator] Added builder integration fragment,
added ${year} variable in copyright headers Signed-off-by: Miro Spönemann <miro.spoenemann@itemis.de>
This commit is contained in:
parent
3a78c9c842
commit
03d9f55611
3 changed files with 76 additions and 1 deletions
|
@ -24,5 +24,6 @@ Import-Package: com.ibm.icu.text;version="4.0.0",
|
|||
org.apache.commons.logging;version="1.0.4";resolution:=optional;x-installation:=greedy,
|
||||
org.apache.log4j;version="1.2.15"
|
||||
Export-Package: org.eclipse.xtext.xtext.generator,
|
||||
org.eclipse.xtext.xtext.generator.builder,
|
||||
org.eclipse.xtext.xtext.generator.model,
|
||||
org.eclipse.xtext.xtext.generator.xbase
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 itemis AG (http://www.itemis.eu) and others.
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.builder
|
||||
|
||||
import com.google.inject.Inject
|
||||
import com.google.inject.name.Names
|
||||
import org.eclipse.xtend2.lib.StringConcatenationClient
|
||||
import org.eclipse.xtext.resource.IContainer
|
||||
import org.eclipse.xtext.resource.IResourceDescriptions
|
||||
import org.eclipse.xtext.resource.containers.IAllContainersState
|
||||
import org.eclipse.xtext.resource.containers.ResourceSetBasedAllContainersStateProvider
|
||||
import org.eclipse.xtext.resource.containers.StateBasedContainerManager
|
||||
import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider
|
||||
import org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions
|
||||
import org.eclipse.xtext.xtext.generator.AbstractGeneratorFragment2
|
||||
import org.eclipse.xtext.xtext.generator.IXtextProjectConfig
|
||||
import org.eclipse.xtext.xtext.generator.LanguageConfig2
|
||||
import org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess
|
||||
|
||||
import static extension org.eclipse.xtext.xtext.generator.model.TypeReference.*
|
||||
|
||||
class BuilderIntegrationFragment2 extends AbstractGeneratorFragment2 {
|
||||
|
||||
@Inject IXtextProjectConfig projectConfig
|
||||
|
||||
override generate(LanguageConfig2 language) {
|
||||
addRuntimeGuiceBindings(language)
|
||||
addEclipsePluginGuiceBindings(language)
|
||||
|
||||
if (projectConfig.eclipsePluginManifest !== null) {
|
||||
projectConfig.eclipsePluginManifest.requiredBundles.addAll(#[
|
||||
'org.eclipse.xtext.builder', 'org.eclipse.xtext.ui'
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
protected def addRuntimeGuiceBindings(LanguageConfig2 language) {
|
||||
val StringConcatenationClient statement1 =
|
||||
'''binder.bind(«IResourceDescriptions».class).to(«ResourceSetBasedResourceDescriptions».class);'''
|
||||
val StringConcatenationClient statement2 =
|
||||
'''binder.bind(«IResourceDescriptions».class).annotatedWith(«Names».named(«ResourceDescriptionsProvider».PERSISTED_DESCRIPTIONS)).to(«ResourceSetBasedResourceDescriptions».class);'''
|
||||
val bindingFactory = new GuiceModuleAccess.BindingFactory()
|
||||
.addTypeToType(IContainer.Manager.typeRef,
|
||||
StateBasedContainerManager.typeRef)
|
||||
.addTypeToType(IAllContainersState.Provider.typeRef,
|
||||
ResourceSetBasedAllContainersStateProvider.typeRef)
|
||||
.addConfiguredBinding(IResourceDescriptions.simpleName, statement1)
|
||||
.addConfiguredBinding(IResourceDescriptions.simpleName + 'Persisted', statement2)
|
||||
bindingFactory.contributeTo(language.runtimeGenModule)
|
||||
}
|
||||
|
||||
protected def addEclipsePluginGuiceBindings(LanguageConfig2 language) {
|
||||
val StringConcatenationClient statement1 =
|
||||
'''binder.bind(«IResourceDescriptions».class).annotatedWith(«Names».named(«ResourceDescriptionsProvider».NAMED_BUILDER_SCOPE)).to(«'org.eclipse.xtext.builder.clustering.CurrentDescriptions.ResourceSetAware'.typeRef».class);'''
|
||||
val StringConcatenationClient statement2 =
|
||||
'''binder.bind(«IResourceDescriptions».class).annotatedWith(«Names».named(«ResourceDescriptionsProvider».PERSISTED_DESCRIPTIONS)).to(«'org.eclipse.xtext.builder.builderState.IBuilderState'.typeRef».class);'''
|
||||
val bindingFactory = new GuiceModuleAccess.BindingFactory()
|
||||
.addConfiguredBinding(IResourceDescriptions.simpleName + 'BuilderScope', statement1)
|
||||
.addTypeToType('org.eclipse.xtext.ui.editor.IXtextEditorCallback'.typeRef,
|
||||
'org.eclipse.xtext.builder.nature.NatureAddingEditorCallback'.typeRef)
|
||||
.addTypeToType('org.eclipse.xtext.generator.IContextualOutputConfigurationProvider'.typeRef,
|
||||
'org.eclipse.xtext.builder.EclipseOutputConfigurationProvider'.typeRef)
|
||||
.addConfiguredBinding(IResourceDescriptions.simpleName + 'Persisted', statement2)
|
||||
.addTypeToType('org.eclipse.xtext.ui.editor.DocumentBasedDirtyResource'.typeRef,
|
||||
'org.eclipse.xtext.builder.impl.PersistentDataAwareDirtyResource'.typeRef)
|
||||
bindingFactory.contributeTo(language.eclipsePluginGenModule)
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue