protected List<Task> findTasks(final ILeafNode node, final TaskTags taskTags) { boolean _canContainTaskTags = this.canContainTaskTags(node); if (_canContainTaskTags) { final List<Task> tasks = this.parser.parseTasks(this.stripText(node, node.getText()), taskTags); final Consumer<Task> _function = (Task it) -> { int _offset = it.getOffset(); int _offset_1 = node.getOffset(); int _plus = (_offset + _offset_1); it.setOffset(_plus); int _lineNumber = it.getLineNumber(); int _startLine = node.getStartLine(); int _plus_1 = (_lineNumber + _startLine); int _minus = (_plus_1 - 1); it.setLineNumber(_minus); }; tasks.forEach(_function); return tasks; } return Collections.<Task>unmodifiableList(CollectionLiterals.<Task>newArrayList()); }
@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()); } }
public List<Task> findTasks(StextResource resource) { TaskTags taskTags = taskTagProvider.getTaskTags(resource); List<Task> result = Lists.newArrayList(); TreeIterator<EObject> allContents = resource.getAllContents(); while (allContents.hasNext()) { EObject eObject = (EObject) allContents.next(); if (eObject instanceof SpecificationElement) { List<Task> parseTasks = parseTasks(eObject, SGraphPackage.Literals.SPECIFICATION_ELEMENT__SPECIFICATION, taskTags); result.addAll(parseTasks); } if (eObject instanceof DocumentedElement) { result.addAll(parseTasks(eObject, BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION, taskTags)); } } return result; }
@Override public List<Task> findTasks(final Resource resource) { List<Task> _xblockexpression = null; { final TaskTags taskTags = this.taskTagProvider.getTaskTags(resource); boolean _isEmpty = IterableExtensions.isEmpty(taskTags); if (_isEmpty) { return Collections.<Task>unmodifiableList(CollectionLiterals.<Task>newArrayList()); } List<Task> _xifexpression = null; if ((resource instanceof XtextResource)) { List<Task> _elvis = null; IParseResult _parseResult = ((XtextResource)resource).getParseResult(); ICompositeNode _rootNode = null; if (_parseResult!=null) { _rootNode=_parseResult.getRootNode(); } List<Task> _findTasks = null; if (_rootNode!=null) { _findTasks=this.findTasks(_rootNode, taskTags); } if (_findTasks != null) { _elvis = _findTasks; } else { _elvis = Collections.<Task>unmodifiableList(CollectionLiterals.<Task>newArrayList()); } _xifexpression = _elvis; } else { _xifexpression = Collections.<Task>unmodifiableList(CollectionLiterals.<Task>newArrayList()); } _xblockexpression = _xifexpression; } 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; }
private void assertContainsTasks(final Resource resource, final List<Task> expectedTasks) { final List<Task> actualTasks = this.finder.findTasks(resource); 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())); } }
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())); } }
@Test public void testFindTODOs() { assertEquals(EXPECT_TODO_FOUND, Collections2.filter(foundTasks, new Predicate<Task>() { @Override public boolean apply(Task task) { return task.getTag().getName().equals(TAG_TODO); } }).size()); }
@Test public void testFindFIXMEs() { assertEquals(EXPECT_FIXME_FOUND, Collections2.filter(foundTasks, new Predicate<Task>() { @Override public boolean apply(Task task) { return task.getTag().getName().equals(TAG_FIXME); } }).size()); }
@Override protected void setMarkerAttributes(Task task, IResource resource, IMarker marker) throws CoreException { super.setMarkerAttributes(task, resource, marker); if (task instanceof SCTTask) { marker.setAttribute(SEMANTIC_ELEMENT_ID, ((SCTTask) task).getSemanticURI()); } }
@Override public List<Task> findTasks(Resource resource) { if (resource instanceof StextResource) { return findTasks((StextResource) resource); } return super.findTasks(resource); }
protected List<Task> parseTasks(EObject element, EStructuralFeature feature, TaskTags tags) { String expression = (String) element.eGet(feature); if (expression == null) return Collections.emptyList(); List<Task> tasks = parser.parseTasks(expression, tags); List<Task> result = Lists.newArrayList(); for (Task task : tasks) { SCTTask sctTask = new SCTTask(task); sctTask.setSemanticURI(EcoreUtil.getURI(element).fragment()); result.add(sctTask); } return result; }
@Override public List<Task> findTasks(Resource resource) { if (resource instanceof AbstractSCTResource) { IDomain domain = DomainRegistry.getDomain( (EObject) EcoreUtil2.getObjectByType(resource.getContents(), SGraphPackage.Literals.STATECHART)); ITaskFinder taskFinder = domain.getInjector(IDomain.FEATURE_RESOURCE).getInstance(ITaskFinder.class); if (taskFinder != null) return taskFinder.findTasks(resource); } return Collections.emptyList(); }
protected List<Task> findTasks(final ICompositeNode it, final TaskTags taskTags) { final Function1<ILeafNode, List<Task>> _function = (ILeafNode it_1) -> { return this.findTasks(it_1, taskTags); }; return IterableExtensions.<Task>toList(Iterables.<Task>concat(IterableExtensions.<ILeafNode, List<Task>>map(it.getLeafNodes(), _function))); }
@Test public void testNonXtextResource() { this.assertContainsTasks(new ResourceImpl(), Collections.<Task>unmodifiableList(CollectionLiterals.<Task>newArrayList())); }
public static void assertExactMatch(final Task expected, final Task actual) { TaskAssert.assertExactMatch(expected.getTag(), actual.getTag()); Assert.assertEquals(expected.getDescription(), actual.getDescription()); Assert.assertEquals(expected.getLineNumber(), actual.getLineNumber()); Assert.assertEquals(expected.getOffset(), actual.getOffset()); }
protected void highlightTasks(XtextResource resource, IHighlightedPositionAcceptor acceptor) { List<Task> tasks = taskFinder.findTasks(resource); for (Task task : tasks) { acceptor.addPosition(task.getOffset(), task.getTagLength(), HighlightingStyles.TASK_ID); } }
public SCTTask(Task delgate) { this.delgate = delgate; }
public String getMarkerType(Task task) { return SCT_TASK_TYPE; }
protected void highlightTasks(final XtextResource resource, final IHighlightedPositionAcceptor acceptor) { final List<Task> tasks = taskFinder.findTasks(resource); for (final Task task : tasks) { acceptor.addPosition(task.getOffset(), task.getTagLength(), TASK_ID); } }