protected Pattern toPattern(final TaskTags taskTags) { Pattern _xblockexpression = null; { int flags = Pattern.MULTILINE; boolean _isCaseSensitive = taskTags.isCaseSensitive(); boolean _not = (!_isCaseSensitive); if (_not) { flags = ((flags | Pattern.CASE_INSENSITIVE) | Pattern.UNICODE_CASE); } StringConcatenation _builder = new StringConcatenation(); _builder.append("^.*(("); final Function1<TaskTag, String> _function = (TaskTag it) -> { return Pattern.quote(it.getName()); }; String _join = IterableExtensions.join(IterableExtensions.<TaskTag, String>map(taskTags, _function), "|"); _builder.append(_join); _builder.append(")(.*)?)$"); _xblockexpression = Pattern.compile(_builder.toString(), flags); } return _xblockexpression; }
@Override public TaskTags getTaskTags(final Resource resource) { TaskTags _xblockexpression = null; { final IPreferenceValues prefs = this.preferenceValuesProvider.getPreferenceValues(resource); final String names = prefs.getPreference(PreferenceTaskTagProvider.TAGS_KEY); final String priorities = prefs.getPreference(PreferenceTaskTagProvider.PRIORITIES_KEY); TaskTags _taskTags = new TaskTags(); final Procedure1<TaskTags> _function = (TaskTags it) -> { it.setCaseSensitive((Boolean.valueOf(prefs.getPreference(PreferenceTaskTagProvider.CASE_SENSITIVE_KEY))).booleanValue()); List<TaskTag> _taskTags_1 = it.getTaskTags(); List<TaskTag> _parseTags = PreferenceTaskTagProvider.parseTags(names, priorities); Iterables.<TaskTag>addAll(_taskTags_1, _parseTags); }; _xblockexpression = ObjectExtensions.<TaskTags>operator_doubleArrow(_taskTags, _function); } return _xblockexpression; }
@Override public List<Task> parseTasks(final String source, final TaskTags taskTags) { ArrayList<Task> _xblockexpression = null; { boolean _isEmpty = IterableExtensions.isEmpty(taskTags); if (_isEmpty) { return Collections.<Task>unmodifiableList(CollectionLiterals.<Task>newArrayList()); } final Function<TaskTag, String> _function = (TaskTag it) -> { return it.getName().toLowerCase(); }; final ImmutableMap<String, TaskTag> taskTagsByName = Maps.<String, TaskTag>uniqueIndex(taskTags, _function); final Matcher matcher = this.toPattern(taskTags).matcher(source); final ArrayList<Task> tasks = CollectionLiterals.<Task>newArrayList(); int prevLine = 1; int prevOffset = 0; while (matcher.find()) { { final Task task = new Task(); task.setTag(taskTagsByName.get(matcher.group(2).toLowerCase())); task.setDescription(matcher.group(3)); task.setOffset(matcher.start(2)); int _countLineBreaks = Strings.countLineBreaks(source, prevOffset, task.getOffset()); int _plus = (_countLineBreaks + prevLine); task.setLineNumber(_plus); prevLine = task.getLineNumber(); prevOffset = task.getOffset(); tasks.add(task); } } _xblockexpression = tasks; } return _xblockexpression; }
public static List<TaskTag> parseTags(final String names, final String priorities) { final Splitter splitter = Splitter.on(",").omitEmptyStrings().trimResults(); final List<String> tags = IterableExtensions.<String>toList(splitter.split(names)); final List<String> prios = IterableExtensions.<String>toList(splitter.split(priorities)); final ArrayList<TaskTag> elements = CollectionLiterals.<TaskTag>newArrayList(); int _size = tags.size(); ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); for (final Integer i : _doubleDotLessThan) { TaskTag _taskTag = new TaskTag(); final Procedure1<TaskTag> _function = (TaskTag it) -> { it.setName(tags.get((i).intValue())); Priority _xifexpression = null; int _size_1 = prios.size(); boolean _greaterEqualsThan = (_size_1 >= (i).intValue()); if (_greaterEqualsThan) { Priority _xtrycatchfinallyexpression = null; try { _xtrycatchfinallyexpression = Priority.valueOf(prios.get((i).intValue())); } catch (final Throwable _t) { if (_t instanceof IllegalArgumentException) { _xtrycatchfinallyexpression = Priority.NORMAL; } else { throw Exceptions.sneakyThrow(_t); } } _xifexpression = _xtrycatchfinallyexpression; } else { _xifexpression = Priority.NORMAL; } it.setPriority(_xifexpression); }; TaskTag _doubleArrow = ObjectExtensions.<TaskTag>operator_doubleArrow(_taskTag, _function); elements.add(_doubleArrow); } return elements; }
@Pure public TaskTag getTag() { return this.tag; }
public void setTag(final TaskTag tag) { this.tag = tag; }
@Override public Iterator<TaskTag> iterator() { return this.taskTags.iterator(); }
@Pure public List<TaskTag> getTaskTags() { return this.taskTags; }
public static String serializeTags(final List<TaskTag> tags) { final Function1<TaskTag, String> _function = (TaskTag it) -> { return it.getName(); }; return Joiner.on(",").join(ListExtensions.<TaskTag, String>map(tags, _function)); }
public static String serializePriorities(final List<TaskTag> tags) { final Function1<TaskTag, Priority> _function = (TaskTag it) -> { return it.getPriority(); }; return Joiner.on(",").join(ListExtensions.<TaskTag, Priority>map(tags, _function)); }
public static void assertExactMatch(final TaskTag expected, final TaskTag actual) { Assert.assertEquals(expected.getName(), actual.getName()); Assert.assertEquals(expected.getPriority(), actual.getPriority()); }
public TaskTag getTag() { return delgate.getTag(); }
public void setTag(TaskTag tag) { delgate.setTag(tag); }