Skip to content

Commit

Permalink
[mwe2] Use version 2 of the MWE2 generation API.
Browse files Browse the repository at this point in the history
see #352

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Dec 22, 2015
1 parent c2802e5 commit e8dd2a3
Show file tree
Hide file tree
Showing 5 changed files with 710 additions and 418 deletions.
Expand Up @@ -243,7 +243,7 @@ Workflow {
}

fragment = formatting.Formatter2Fragment2 auto-inject {
generateStub = false
generateStub = true
}

fragment = generator.GeneratorFragment2 auto-inject {
Expand Down Expand Up @@ -295,7 +295,7 @@ Workflow {
fragment = ui.templates.CodetemplatesGeneratorFragment2 auto-inject {
}

fragment = Junit4Fragment2 auto-inject {
fragment = junit.Junit4Fragment2 auto-inject {
generateStub = false
}

Expand Down Expand Up @@ -360,6 +360,10 @@ Workflow {
bind = "org.eclipse.xtext.xbase.validation.FeatureNameValidator"
to = "io.sarl.lang.validation.SARLFeatureNameValidator"
}
runtime = {
bind = "org.eclipse.xtext.formatting2.FormatterPreferenceKeys"
to = "io.sarl.lang.formatting2.SARLFormatterPreferenceKeys"
}
runtime = {
bind = "org.eclipse.xtext.xbase.controlflow.IEarlyExitComputer"
to = "io.sarl.lang.controlflow.SARLEarlyExitComputer"
Expand Down Expand Up @@ -473,6 +477,10 @@ Workflow {
fragment = InjectionFragment2 auto-inject {
comment = "Bindings required by extended Xtend API"

runtime = {
bind = "org.eclipse.xtend.core.macro.AbstractFileSystemSupport"
to = "org.eclipse.xtend.core.macro.JavaIOFileSystemSupport"
}
runtime = {
bind = "org.eclipse.xtext.xbase.scoping.batch.ConstructorScopes"
to = "org.eclipse.xtend.core.scoping.AnonymousClassConstructorScopes"
Expand Down Expand Up @@ -539,21 +547,17 @@ Workflow {
runtime = {
bind = "org.eclipse.xtext.parser.antlr.IPartialParsingHelper"
to = "org.eclipse.xtend.core.parser.XtendPartialParsingHelper"
}
runtime = {
bind = "org.eclipse.xtext.preferences.IPreferenceValuesProvider"
annotatedWith = "org.eclipse.xtext.formatting2.FormatterPreferences"
to = "org.eclipse.xtext.formatting2.FormatterPreferenceValuesProvider"
functionName = "bindIPartialParserHelper"
}
runtime = {
bind = "org.eclipse.xtext.naming.IQualifiedNameProvider"
to = "org.eclipse.xtend.core.naming.XtendQualifiedNameProvider"
override = true
}
// runtime = {
// bind = "org.eclipse.xtend.core.macro.declaration.IResourceChangeRegistry"
// to = "org.eclipse.xtend.core.macro.declaration.NopResourceChangeRegistry"
// }
runtime = {
bind = "org.eclipse.xtend.core.macro.declaration.IResourceChangeRegistry"
to = "org.eclipse.xtend.core.macro.declaration.NopResourceChangeRegistry"
}
runtime = {
bind = "org.eclipse.xtext.resource.IResourceDescriptions"
to = "org.eclipse.xtext.resource.impl.EagerResourceSetBasedResourceDescriptions"
Expand All @@ -573,6 +577,7 @@ Workflow {
bind = "org.eclipse.xtext.scoping.IScopeProvider"
annotatedWith = "org.eclipse.xtext.serializer.tokens.SerializerScopeProviderBinding"
to = "org.eclipse.xtend.core.serializer.XtendSerializerScopeProvider"
functionName = "configureSerializerIScopeProvider"
}
runtime = {
bind = "org.eclipse.xtext.generator.IShouldGenerate"
Expand Down Expand Up @@ -639,6 +644,10 @@ Workflow {
bind = "org.eclipse.xtext.generator.AbstractFileSystemAccess2"
to = "io.sarl.lang.ui.builder.ProjectRelativeFileSystemAccess"
}
ui = {
bind = "org.eclipse.xtend.core.macro.AbstractFileSystemSupport"
to = "org.eclipse.xtend.ide.macro.EclipseFileSystemSupportImpl"
}
ui = {
bind = "org.eclipse.xtext.ui.editor.contentassist.PrefixMatcher$CamelCase"
to = "org.eclipse.xtend.ide.contentassist.EscapeSequenceAwarePrefixMatcher"
Expand Down Expand Up @@ -686,6 +695,10 @@ Workflow {
to = "org.eclipse.xtend.ide.refactoring.XtendRenameStrategy"
override = true
}
ui = {
bind = "org.eclipse.xtend.core.macro.declaration.IResourceChangeRegistry"
to = "org.eclipse.xtend.ide.builder.UIResourceChangeRegistry"
}
ui = {
bind = "org.eclipse.xtext.ui.resource.IResourceUIServiceProvider"
to = "org.eclipse.xtend.ide.XtendResourceUiServiceProvider"
Expand Down Expand Up @@ -713,6 +726,10 @@ Workflow {
}
}

// Injection recommender
fragment = InjectionRecommender2 auto-inject {
enable = false
}
}
}

Expand Down
Expand Up @@ -21,6 +21,9 @@

package io.sarl.lang.mwe2.binding;

import java.text.MessageFormat;
import java.util.Objects;

import org.eclipse.xtext.util.Strings;
import org.eclipse.xtext.xbase.lib.Pure;

Expand All @@ -33,6 +36,8 @@
* @mavenartifactid $ArtifactId$
*/
public class BindingElement {

private static final int HASH_VALUE = 31;

private String functionName;

Expand All @@ -52,6 +57,36 @@ public class BindingElement {

private boolean overridePreviousDefinition;

@Override
public boolean equals(Object obj) {
if (obj instanceof BindingElement) {
return Objects.equals(getBind(), ((BindingElement) obj).getBind())
&& Objects.equals(getAnnotatedWith(), ((BindingElement) obj).getAnnotatedWith())
&& Objects.equals(getAnnotatedWithName(), ((BindingElement) obj).getAnnotatedWithName());
}
return false;
}

@Override
public int hashCode() {
int h = 1;
h = h * HASH_VALUE + (getBind() != null ? getBind().hashCode() : 0);
h = h * HASH_VALUE + (getAnnotatedWith() != null ? getAnnotatedWith().hashCode() : 0);
h = h * HASH_VALUE + (getAnnotatedWithName() != null ? getAnnotatedWithName().hashCode() : 0);
return h;
}

@Override
public String toString() {
if (!Strings.isEmpty(getAnnotatedWith())) {
return MessageFormat.format("@{2} {0} => {1}", getBind(), getTo(), getAnnotatedWith()); //$NON-NLS-1$
}
if (!Strings.isEmpty(getAnnotatedWithName())) {
return MessageFormat.format("@Named({2}) {0} => {1}", getBind(), getTo(), getAnnotatedWithName()); //$NON-NLS-1$
}
return MessageFormat.format("{0} => {1}", getBind(), getTo()); //$NON-NLS-1$
}

/** Set the element could override a previously defined element.
*
* @param override <code>true</code> for overriding.
Expand Down

0 comments on commit e8dd2a3

Please sign in to comment.