use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.
the class RecursionGuardBenchmark method timeTryNextFailsFast.
public int timeTryNextFailsFast(int reps) {
JvmTypeParameter candidate = parameters.get(0);
int result = 0;
for (int i = 0; i < reps; i++) {
if (populatedGuard.tryNext(candidate)) {
result++;
}
}
return result;
}
use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.
the class RecursionGuardBenchmark method timeTryNextFailsLast.
public int timeTryNextFailsLast(int reps) {
JvmTypeParameter candidate = parameters.get(size - 1);
int result = 0;
for (int i = 0; i < reps; i++) {
if (populatedGuard.tryNext(candidate)) {
result++;
}
}
return result;
}
use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.
the class XtendFormatter method _format.
protected void _format(final XtendFunction func, @Extension final IFormattableDocument format) {
this.formatAnnotations(func, format, XbaseFormatterPreferenceKeys.newLineAfterMethodAnnotations);
this.formatModifiers(func, format);
boolean _isEmpty = func.getTypeParameters().isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
format.append(this.textRegionExtensions.regionFor(func).keyword("<"), _function);
EList<JvmTypeParameter> _typeParameters = func.getTypeParameters();
for (final JvmTypeParameter arg : _typeParameters) {
{
format.<JvmTypeParameter>format(arg);
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
format.append(format.prepend(this.textRegionExtensions.immediatelyFollowing(arg).keyword(","), _function_1), _function_2);
}
}
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
format.append(format.prepend(this.textRegionExtensions.regionFor(func).keyword(">"), _function_1), _function_2);
}
final ISemanticRegion nameNode = this.textRegionExtensions.regionFor(func).feature(XtendPackage.Literals.XTEND_FUNCTION__NAME);
ISemanticRegionFinder _immediatelyFollowing = null;
if (nameNode != null) {
_immediatelyFollowing = nameNode.immediatelyFollowing();
}
ISemanticRegion _keyword = null;
if (_immediatelyFollowing != null) {
_keyword = _immediatelyFollowing.keyword("(");
}
final ISemanticRegion open = _keyword;
final ISemanticRegion close = this.textRegionExtensions.regionFor(func).keyword(")");
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
format.<JvmTypeReference>append(func.getReturnType(), _function_3);
final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
format.prepend(open, _function_4);
XExpression _expression = func.getExpression();
boolean _tripleNotEquals = (_expression != null);
if (_tripleNotEquals) {
format.append(close, XbaseFormatterPreferenceKeys.bracesInNewLine);
}
this.formatCommaSeparatedList(func.getParameters(), open, close, format);
format.<JvmTypeReference>format(func.getReturnType());
format.<XExpression>format(func.getExpression());
}
use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.
the class JvmExecutableDeclarationImpl method addTypeParameter.
public MutableTypeParameterDeclaration addTypeParameter(final String name, final TypeReference... upperBounds) {
this.checkMutable();
ConditionUtils.checkJavaIdentifier(name, "name");
ConditionUtils.checkIterable(((Iterable<?>) Conversions.doWrapArray(upperBounds)), "upperBounds");
ConditionUtils.checkInferredTypeReferences("parameter type", upperBounds);
final JvmTypeParameter param = TypesFactory.eINSTANCE.createJvmTypeParameter();
param.setName(name);
this.getDelegate().getTypeParameters().add(param);
for (final TypeReference upper : upperBounds) {
{
final JvmTypeReference typeRef = this.getCompilationUnit().toJvmTypeReference(upper);
final JvmUpperBound jvmUpperBound = TypesFactory.eINSTANCE.createJvmUpperBound();
jvmUpperBound.setTypeReference(typeRef);
param.getConstraints().add(jvmUpperBound);
}
}
TypeParameterDeclaration _typeParameterDeclaration = this.getCompilationUnit().toTypeParameterDeclaration(param);
return ((MutableTypeParameterDeclaration) _typeParameterDeclaration);
}
use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.
the class MutableJvmClassDeclarationImpl method addTypeParameter.
@Override
public MutableTypeParameterDeclaration addTypeParameter(final String name, final TypeReference... upperBounds) {
this.checkMutable();
ConditionUtils.checkJavaIdentifier(name, "name");
ConditionUtils.checkIterable(((Iterable<?>) Conversions.doWrapArray(upperBounds)), "upperBounds");
ConditionUtils.checkInferredTypeReferences("parameter type", upperBounds);
final JvmTypeParameter param = TypesFactory.eINSTANCE.createJvmTypeParameter();
param.setName(name);
this.getDelegate().getTypeParameters().add(param);
for (final TypeReference upper : upperBounds) {
{
final JvmTypeReference typeRef = this.getCompilationUnit().toJvmTypeReference(upper);
final JvmUpperBound jvmUpperBound = TypesFactory.eINSTANCE.createJvmUpperBound();
jvmUpperBound.setTypeReference(typeRef);
param.getConstraints().add(jvmUpperBound);
}
}
TypeParameterDeclaration _typeParameterDeclaration = this.getCompilationUnit().toTypeParameterDeclaration(param);
return ((MutableTypeParameterDeclaration) _typeParameterDeclaration);
}
Aggregations