use of org.eclipse.xtext.xbase.lib.IntegerRange in project xtext-lib by eclipse.
the class IntegerRangeTest method testContains_0.
@Test
public void testContains_0() {
IntegerRange range = new IntegerRange(-1, 1, 2);
assertFalse(range.contains(-2));
assertTrue(range.contains(-1));
assertFalse(range.contains(0));
assertTrue(range.contains(1));
assertFalse(range.contains(2));
}
use of org.eclipse.xtext.xbase.lib.IntegerRange in project xtext-lib by eclipse.
the class IntegerRangeTest method testContains_1.
@Test
public void testContains_1() {
IntegerRange range = new IntegerRange(-1, 2, 2);
assertFalse(range.contains(-2));
assertTrue(range.contains(-1));
assertFalse(range.contains(0));
assertTrue(range.contains(1));
assertFalse(range.contains(2));
}
use of org.eclipse.xtext.xbase.lib.IntegerRange in project xtext-core by eclipse.
the class TemplateNodeTest method testWeirdTemplateString.
@Test
public void testWeirdTemplateString() {
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("fooo bar");
_builder.newLine();
_builder.append("d ");
{
if ((2 > 1)) {
_builder.append("s");
_builder.newLineIfNotEmpty();
_builder.append("\t ");
_builder.append("ee ");
{
IntegerRange _upTo = new IntegerRange(1, 4);
for (final Integer i : _upTo) {
_builder.newLineIfNotEmpty();
_builder.newLineIfNotEmpty();
CharSequence _other = TemplateNodeTest.this.other();
_builder.append(_other);
_builder.append(" ");
_builder.append(i);
_builder.newLineIfNotEmpty();
String _multiLineString = TemplateNodeTest.this.multiLineString();
_builder.append(_multiLineString);
_builder.append(" ");
String _multiLineString_1 = TemplateNodeTest.this.multiLineString();
_builder.append(_multiLineString_1);
_builder.newLineIfNotEmpty();
}
}
}
}
}
};
this.assertEquals(_client);
}
use of org.eclipse.xtext.xbase.lib.IntegerRange in project xtext-xtend by eclipse.
the class XtendIncrementalBuilderPerformanceTest method doTestPerformance.
public void doTestPerformance(final int max) {
final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
final Function1<Integer, URI> _function_1 = (Integer it_1) -> {
return this.toFile((it_1).intValue(), max);
};
it.setDirtyFiles(IterableExtensions.<URI>toList(IterableExtensions.<Integer, URI>map(new IntegerRange(1, max), _function_1)));
};
final BuildRequest buildRequest = this.newBuildRequest(_function);
final Stopwatch sw = Stopwatch.createStarted();
this.build(buildRequest);
StringConcatenation _builder = new StringConcatenation();
_builder.append(max);
_builder.append(" file took ");
long _elapsed = sw.elapsed(TimeUnit.MILLISECONDS);
_builder.append(_elapsed);
_builder.append(" ms");
InputOutput.<String>println(_builder.toString());
}
use of org.eclipse.xtext.xbase.lib.IntegerRange in project xtext-xtend by eclipse.
the class LineNumberMappingTests method assertLineNumbers.
public void assertLineNumbers(final CharSequence xtendCodeWithLineNumbers) {
final AbstractTraceRegion region = this.getTraceRegion(xtendCodeWithLineNumbers);
final List<LineMappingProvider.LineMapping> normalizedMappings = this.lineMappingProvider.getLineMapping(region);
final String[] lines = xtendCodeWithLineNumbers.toString().split("\n");
int _size = ((List<String>) Conversions.doWrapArray(lines)).size();
int _minus = (_size - 1);
IntegerRange _upTo = new IntegerRange(0, _minus);
for (final Integer lineNumber : _upTo) {
{
final LineMappingProvider.LineMapping mapping = this.findMapping(normalizedMappings, lineNumber);
final String line = lines[(lineNumber).intValue()];
if ((mapping != null)) {
int _indexOf = line.indexOf("//");
boolean _equals = (_indexOf == (-1));
if (_equals) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("Line ");
_builder.append(lineNumber);
_builder.append(" is mapped to ");
_builder.append(mapping.targetStartLine);
_builder.append("(\'");
_builder.append(line);
_builder.append("\')");
Assert.fail(_builder.toString());
}
int _indexOf_1 = line.indexOf("//");
int _plus = (_indexOf_1 + 2);
final String expectation = line.substring(_plus).trim();
int expTargetStart = (-1);
int expTargetEnd = (-1);
int _indexOf_2 = expectation.indexOf("..");
boolean _notEquals = (_indexOf_2 != (-1));
if (_notEquals) {
final int idx = expectation.indexOf("..");
expTargetStart = Integer.parseInt(expectation.substring(0, idx));
expTargetEnd = Integer.parseInt(expectation.substring((idx + 2)));
} else {
expTargetStart = (expTargetEnd = Integer.parseInt(expectation));
}
Assert.assertEquals(line, expTargetStart, mapping.targetStartLine);
Assert.assertEquals(("unexpected end in line : " + line), expTargetEnd, mapping.targetEndLine);
} else {
int _indexOf_3 = line.indexOf("//");
boolean _notEquals_1 = (_indexOf_3 != (-1));
if (_notEquals_1) {
Assert.fail(("Unmatched expectation : " + line));
}
}
}
}
}
Aggregations