Skip to content

Instantly share code, notes, and snippets.

@kthoms
Created March 14, 2016 21:05
Show Gist options
  • Save kthoms/0933c3720ab9725b84c4 to your computer and use it in GitHub Desktop.
Save kthoms/0933c3720ab9725b84c4 to your computer and use it in GitHub Desktop.
A custom implementation of org.eclipse.xtext.xbase.scoping.featurecalls.OperatorMapping that adds alternative to keywords '&&' and '||'
package org.eclipse.xtext.example.domainmodel;
import static org.eclipse.xtext.naming.QualifiedName.*;
import javax.inject.Singleton;
import org.eclipse.xtext.naming.QualifiedName;
import org.eclipse.xtext.xbase.scoping.featurecalls.OperatorMapping;
@Singleton
public class OperatorMappingCustom extends OperatorMapping {
public static final QualifiedName AND_2 = create("AND");
public static final QualifiedName OR_2 = create("OR");
@Override
public QualifiedName getMethodName(QualifiedName operator) {
if (AND_2.equals(operator)) {
return getMethodName(AND);
}
if (OR_2.equals(operator)) {
return getMethodName(OR);
}
return super.getMethodName(operator);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment