org.eclipse.xtext.xbase.scoping.featurecalls.OperatorMapping Java Examples

The following examples show how to use org.eclipse.xtext.xbase.scoping.featurecalls.OperatorMapping. 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: DynamicExtensionsScope.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
public DynamicExtensionsScope(
		IScope parent,
		IFeatureScopeSession session, 
		XExpression firstArgument,
		LightweightTypeReference argumentType,
		boolean implicit,
		XAbstractFeatureCall context,
		OperatorMapping operatorMapping) {
	super(parent, session, context, operatorMapping);
	this.firstArgument = firstArgument;
	this.argumentType = argumentType;
	this.implicit = implicit;
	if (argumentType != null)
		this.helper = new ExtensionScopeHelper(argumentType);
	else
		this.helper = null;
}
 
Example #2
Source File: XbaseQuickfixProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Fix(IssueCodes.EQUALS_WITH_NULL)
public void fixEqualsWithNull(final Issue issue, IssueResolutionAcceptor acceptor) {
	String message = "Replace '==' with '===' and '!=' with '!=='";
	acceptor.acceptMulti(issue, message, message, null, new ICompositeModification<XBinaryOperation>() {
		@Override
		public void apply(XBinaryOperation element, ICompositeModificationContext<XBinaryOperation> context) {
			context.setUpdateCrossReferences(false);
			context.setUpdateRelatedFiles(false);
			context.addModification(element, (object) -> {
				replaceOperator(object, OperatorMapping.EQUALS, OperatorMapping.TRIPLE_EQUALS);
				replaceOperator(object, OperatorMapping.NOT_EQUALS, OperatorMapping.TRIPLE_NOT_EQUALS);
			});
		}
	});
}
 
Example #3
Source File: StaticFeatureOnTypeLiteralScope.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public StaticFeatureOnTypeLiteralScope(IScope parent, IFeatureScopeSession session, XAbstractFeatureCall featureCall, XExpression receiver,
		LightweightTypeReference receiverType, TypeBucket bucket, OperatorMapping operatorMapping) {
	super(parent, session, featureCall, receiver, receiverType, bucket, operatorMapping);
	if (bucket.getTypes().size() != 1) {
		throw new IllegalArgumentException("Unexpected bucket structure");
	}
}
 
Example #4
Source File: ReceiverFeatureScope.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public ReceiverFeatureScope(IScope parent, IFeatureScopeSession session, XExpression receiver, LightweightTypeReference receiverType, boolean implicit,
		XAbstractFeatureCall featureCall, TypeBucket bucket, JvmIdentifiableElement receiverFeature, OperatorMapping operatorMapping, boolean validStaticState) {
	super(parent, session, featureCall, operatorMapping);
	this.receiver = receiver;
	this.receiverType = receiverType;
	this.implicit = implicit;
	this.bucket = bucket;
	this.receiverFeature = receiverFeature;
	this.validStaticState = validStaticState;
}
 
Example #5
Source File: XExpressionHelper.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public boolean isShortCircuitOperation(XAbstractFeatureCall featureCall) {
	if (featureCall instanceof XBinaryOperation) {
		if (isOperatorFromExtension(featureCall, OperatorMapping.ELVIS, ObjectExtensions.class))
			return true;
		else 
			return isBooleanAndOrOr(featureCall);
	}
	return false;
}
 
Example #6
Source File: StaticExtensionImportsScope.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public StaticExtensionImportsScope(IScope parent, IFeatureScopeSession session, 
		XExpression receiver, LightweightTypeReference receiverType, boolean implicit,
		XAbstractFeatureCall context, OperatorMapping operatorMapping) {
	super(parent, session, context, operatorMapping);
	this.receiver = receiver;
	this.receiverType = receiverType;
	this.implicit = implicit;
	this.helper = new ExtensionScopeHelper(receiverType);
}
 
Example #7
Source File: StaticFeatureScope.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public StaticFeatureScope(
		IScope parent,
		IFeatureScopeSession session,
		XAbstractFeatureCall featureCall,
		XExpression receiver,
		LightweightTypeReference receiverType,
		TypeBucket bucket,
		OperatorMapping operatorMapping) {
	super(parent, session, featureCall, operatorMapping);
	this.receiver = receiver;
	this.receiverType = receiverType;
	this.bucket = bucket;
}
 
Example #8
Source File: CommonTypeComputationServices.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public OperatorMapping getOperatorMapping() {
	return operatorMapping;
}
 
Example #9
Source File: AbstractExpressionGenerator.java    From sarl with Apache License 2.0 4 votes vote down vote up
/** Change the mapping for the operators.
 *
 * @param mapping the mapping.
 */
@Inject
public void setOperatorMapping(OperatorMapping mapping) {
	this.operatorMapping = mapping;
}
 
Example #10
Source File: XExpressionHelper.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public boolean isBooleanAndOrOr(XAbstractFeatureCall featureCall) {
	return isOperatorFromExtension(featureCall, OperatorMapping.AND, BooleanExtensions.class) 
		|| isOperatorFromExtension(featureCall, OperatorMapping.OR, BooleanExtensions.class);
}
 
Example #11
Source File: XExpressionHelper.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public boolean isGetAndAssign(XAbstractFeatureCall featureCall) {
	if (!(featureCall instanceof XPostfixOperation)) {
		return false;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.MINUS_MINUS, DoubleExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.PLUS_PLUS, DoubleExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.MINUS_MINUS, FloatExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.PLUS_PLUS, FloatExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.MINUS_MINUS, LongExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.PLUS_PLUS, LongExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.MINUS_MINUS, IntegerExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.PLUS_PLUS, IntegerExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.MINUS_MINUS, ShortExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.PLUS_PLUS, ShortExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.MINUS_MINUS, CharacterExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.PLUS_PLUS, CharacterExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.MINUS_MINUS, ByteExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.PLUS_PLUS, ByteExtensions.class)) {
		return true;
	}
	return false;
}
 
Example #12
Source File: AbstractSessionBasedExecutableScope.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected OperatorMapping getOperatorMapping() {
	return operatorMapping;
}
 
Example #13
Source File: AbstractSessionBasedExecutableScope.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected AbstractSessionBasedExecutableScope(IScope parent, IFeatureScopeSession session, XAbstractFeatureCall featureCall, OperatorMapping operatorMapping) {
	super(parent, session, featureCall);
	this.operatorMapping = operatorMapping;
}
 
Example #14
Source File: AbstractStaticOrInstanceFeatureScope.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected AbstractStaticOrInstanceFeatureScope(IScope parent, IFeatureScopeSession session, XAbstractFeatureCall featureCall, OperatorMapping operatorMapping) {
	super(parent, session, featureCall, operatorMapping);
}
 
Example #15
Source File: AbstractStaticImportsScope.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public AbstractStaticImportsScope(IScope parent, IFeatureScopeSession session, XAbstractFeatureCall context, OperatorMapping operatorMapping) {
	super(parent, session, context, operatorMapping);
}
 
Example #16
Source File: FeatureScopes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected OperatorMapping getOperatorMapping() {
	return operatorMapping;
}
 
Example #17
Source File: CommonTypeComputationServices.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public void setOperatorMapping(OperatorMapping operatorMapping) {
	this.operatorMapping = operatorMapping;
}
 
Example #18
Source File: XbaseValidator.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected boolean isTripleEqualsOperation(XBinaryOperation binaryOperation){
	String syntax = binaryOperation.getConcreteSyntaxFeatureName();
	return syntax.equals(OperatorMapping.TRIPLE_EQUALS.toString()) || syntax.equals(OperatorMapping.TRIPLE_NOT_EQUALS.toString());
}
 
Example #19
Source File: AbstractExpressionGenerator.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** Replies the mapping for the operators.
 *
 * @return the mapping.
 */
public OperatorMapping getOperatorMapping() {
	return this.operatorMapping;
}