Search in sources :

Example 6 with Task

use of org.eclipse.xtext.tasks.Task in project xtext-core by eclipse.

the class DefaultTaskFinderTest method testSpecialEndTag.

@Test
public void testSpecialEndTag() {
    try {
        this.with(DefaultTaskFinderTest.NoJdtTestLanguageStandaloneSetupCustom.class);
        this.finder = this.<DefaultTaskFinder>get(DefaultTaskFinder.class);
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("/* TODO Get rid of this ***/");
        _builder.newLine();
        _builder.append("Hello notATODO!");
        _builder.newLine();
        Task _task = new Task();
        final Procedure1<Task> _function = (Task it) -> {
            TaskTag _taskTag = new TaskTag();
            final Procedure1<TaskTag> _function_1 = (TaskTag it_1) -> {
                it_1.setName("TODO");
                it_1.setPriority(Priority.NORMAL);
            };
            TaskTag _doubleArrow = ObjectExtensions.<TaskTag>operator_doubleArrow(_taskTag, _function_1);
            it.setTag(_doubleArrow);
            it.setDescription(" Get rid of this ");
            it.setOffset(3);
            it.setLineNumber(1);
        };
        Task _doubleArrow = ObjectExtensions.<Task>operator_doubleArrow(_task, _function);
        this.assertContainsTasks(this.getResourceFromString(LineDelimiters.toUnix(_builder.toString())), Collections.<Task>unmodifiableList(CollectionLiterals.<Task>newArrayList(_doubleArrow)));
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : DefaultTaskFinder(org.eclipse.xtext.tasks.DefaultTaskFinder) Task(org.eclipse.xtext.tasks.Task) TaskTag(org.eclipse.xtext.tasks.TaskTag) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 7 with Task

use of org.eclipse.xtext.tasks.Task in project xtext-core by eclipse.

the class DefaultTaskParserTest method testCaseSensitve.

@Test
public void testCaseSensitve() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("/* TODO this is a task");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* FIXME this cannot work");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* XXX: god, this is bad");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* TODO");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* FixMe this should not match");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("*/");
    _builder.newLine();
    Task _task = new Task();
    final Procedure1<Task> _function = (Task it) -> {
        TaskTag _taskTag = new TaskTag();
        final Procedure1<TaskTag> _function_1 = (TaskTag it_1) -> {
            it_1.setName("TODO");
            it_1.setPriority(Priority.NORMAL);
        };
        TaskTag _doubleArrow = ObjectExtensions.<TaskTag>operator_doubleArrow(_taskTag, _function_1);
        it.setTag(_doubleArrow);
        it.setDescription(" this is a task");
        it.setLineNumber(1);
        it.setOffset(3);
    };
    Task _doubleArrow = ObjectExtensions.<Task>operator_doubleArrow(_task, _function);
    Task _task_1 = new Task();
    final Procedure1<Task> _function_1 = (Task it) -> {
        TaskTag _taskTag = new TaskTag();
        final Procedure1<TaskTag> _function_2 = (TaskTag it_1) -> {
            it_1.setName("FIXME");
            it_1.setPriority(Priority.HIGH);
        };
        TaskTag _doubleArrow_1 = ObjectExtensions.<TaskTag>operator_doubleArrow(_taskTag, _function_2);
        it.setTag(_doubleArrow_1);
        it.setDescription(" this cannot work");
        it.setLineNumber(2);
        it.setOffset(26);
    };
    Task _doubleArrow_1 = ObjectExtensions.<Task>operator_doubleArrow(_task_1, _function_1);
    Task _task_2 = new Task();
    final Procedure1<Task> _function_2 = (Task it) -> {
        TaskTag _taskTag = new TaskTag();
        final Procedure1<TaskTag> _function_3 = (TaskTag it_1) -> {
            it_1.setName("XXX");
            it_1.setPriority(Priority.NORMAL);
        };
        TaskTag _doubleArrow_2 = ObjectExtensions.<TaskTag>operator_doubleArrow(_taskTag, _function_3);
        it.setTag(_doubleArrow_2);
        it.setDescription(": god, this is bad");
        it.setLineNumber(3);
        it.setOffset(52);
    };
    Task _doubleArrow_2 = ObjectExtensions.<Task>operator_doubleArrow(_task_2, _function_2);
    Task _task_3 = new Task();
    final Procedure1<Task> _function_3 = (Task it) -> {
        TaskTag _taskTag = new TaskTag();
        final Procedure1<TaskTag> _function_4 = (TaskTag it_1) -> {
            it_1.setName("TODO");
            it_1.setPriority(Priority.NORMAL);
        };
        TaskTag _doubleArrow_3 = ObjectExtensions.<TaskTag>operator_doubleArrow(_taskTag, _function_4);
        it.setTag(_doubleArrow_3);
        it.setDescription("");
        it.setLineNumber(4);
        it.setOffset(77);
    };
    Task _doubleArrow_3 = ObjectExtensions.<Task>operator_doubleArrow(_task_3, _function_3);
    this.assertContainsTasks(_builder, Collections.<Task>unmodifiableList(CollectionLiterals.<Task>newArrayList(_doubleArrow, _doubleArrow_1, _doubleArrow_2, _doubleArrow_3)));
}
Also used : Task(org.eclipse.xtext.tasks.Task) TaskTag(org.eclipse.xtext.tasks.TaskTag) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 8 with Task

use of org.eclipse.xtext.tasks.Task in project xtext-core by eclipse.

the class DefaultTaskParserTest method testLongInputManyTasks.

@Test
public void testLongInputManyTasks() {
    final int expectation = 100000;
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("/*");
    _builder.newLine();
    {
        IntegerRange _upTo = new IntegerRange(1, expectation);
        for (final Integer i : _upTo) {
            _builder.append(" ");
            _builder.append("* FIXME this cannot work");
            _builder.newLine();
        }
    }
    _builder.append(" ");
    _builder.append("*/");
    _builder.newLine();
    final String source = _builder.toString();
    final List<Task> parsed = this.parser.parseTasks(LineDelimiters.toUnix(source), this.definitions);
    Assert.assertEquals(expectation, parsed.size());
    ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, expectation, true);
    for (final Integer i_1 : _doubleDotLessThan) {
        Assert.assertEquals(((i_1).intValue() + 2), parsed.get((i_1).intValue()).getLineNumber());
    }
}
Also used : Task(org.eclipse.xtext.tasks.Task) IntegerRange(org.eclipse.xtext.xbase.lib.IntegerRange) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) ExclusiveRange(org.eclipse.xtext.xbase.lib.ExclusiveRange) Test(org.junit.Test)

Example 9 with Task

use of org.eclipse.xtext.tasks.Task in project xtext-core by eclipse.

the class DefaultTaskParserTest method testCaseInSensitive.

@Test
public void testCaseInSensitive() {
    this.definitions.setCaseSensitive(false);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("/*");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* FixMe case insensitve match");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("*/");
    _builder.newLine();
    Task _task = new Task();
    final Procedure1<Task> _function = (Task it) -> {
        TaskTag _taskTag = new TaskTag();
        final Procedure1<TaskTag> _function_1 = (TaskTag it_1) -> {
            it_1.setName("FIXME");
            it_1.setPriority(Priority.HIGH);
        };
        TaskTag _doubleArrow = ObjectExtensions.<TaskTag>operator_doubleArrow(_taskTag, _function_1);
        it.setTag(_doubleArrow);
        it.setDescription(" case insensitve match");
        it.setLineNumber(2);
        it.setOffset(6);
    };
    Task _doubleArrow = ObjectExtensions.<Task>operator_doubleArrow(_task, _function);
    this.assertContainsTasks(_builder, Collections.<Task>unmodifiableList(CollectionLiterals.<Task>newArrayList(_doubleArrow)));
}
Also used : Task(org.eclipse.xtext.tasks.Task) TaskTag(org.eclipse.xtext.tasks.TaskTag) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 10 with Task

use of org.eclipse.xtext.tasks.Task in project xtext-core by eclipse.

the class DefaultTaskParserTest method assertContainsTasks.

private void assertContainsTasks(final CharSequence source, final List<Task> expectedTasks) {
    final List<Task> actualTasks = this.parser.parseTasks(LineDelimiters.toUnix(source.toString()), this.definitions);
    Assert.assertEquals(expectedTasks.size(), actualTasks.size());
    int _size = expectedTasks.size();
    ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true);
    for (final Integer i : _doubleDotLessThan) {
        TaskAssert.assertExactMatch(expectedTasks.get((i).intValue()), actualTasks.get((i).intValue()));
    }
}
Also used : Task(org.eclipse.xtext.tasks.Task) ExclusiveRange(org.eclipse.xtext.xbase.lib.ExclusiveRange)

Aggregations

Task (org.eclipse.xtext.tasks.Task)10 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)6 TaskTag (org.eclipse.xtext.tasks.TaskTag)6 Test (org.junit.Test)6 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)5 ExclusiveRange (org.eclipse.xtext.xbase.lib.ExclusiveRange)4 Function (com.google.common.base.Function)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)1 DefaultTaskFinder (org.eclipse.xtext.tasks.DefaultTaskFinder)1 IntegerRange (org.eclipse.xtext.xbase.lib.IntegerRange)1