org.eclipse.xtext.tasks.Task Java Examples

The following examples show how to use org.eclipse.xtext.tasks.Task. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: STextTaskFinder.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: DefaultTaskParserTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testCaseInSensitive() {
  this.definitions.setCaseSensitive(false);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("/*");
  _builder.newLine();
  _builder.append(" ");
  _builder.append("* FixMe case insensitive match");
  _builder.newLine();
  _builder.append(" ");
  _builder.append("*/");
  _builder.newLine();
  Task _task = new Task();
  final Procedure1<Task> _function = (Task it) -> {
    it.setTag(DefaultTaskParserTest.createTaskTag("FIXME", Priority.HIGH));
    it.setDescription(" case insensitive 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)));
}
 
Example #3
Source File: DefaultTaskParserTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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());
  }
}
 
Example #4
Source File: TaskMarkerContributor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void updateMarkers(IFile file, Resource resource, IProgressMonitor monitor) {
	try {
		List<Task> tasks = taskFinder.findTasks(resource);
		if (monitor.isCanceled()) {
			throw new OperationCanceledException();
		}
		deleteMarkers(file, monitor);
		createTaskMarkers(file, tasks, monitor);
	} catch (CoreException e) {
		LOG.error(e.getMessage(), e);
	}
}
 
Example #5
Source File: DomainSpecificTaskFinder.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@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();
}
 
Example #6
Source File: TaskMarkerCreator.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void setMarkerAttributes(Task task, IResource resource, IMarker marker) throws CoreException {
	marker.setAttribute(IMarker.LOCATION, "line " + task.getLineNumber());
	marker.setAttribute(IMarker.PRIORITY, getPriority(task.getTag().getPriority()));
	marker.setAttribute(IMarker.MESSAGE, task.getFullText());
	marker.setAttribute(IMarker.LINE_NUMBER, task.getLineNumber());
	marker.setAttribute(IMarker.CHAR_START, task.getOffset());
	marker.setAttribute(IMarker.CHAR_END, task.getOffset() + task.getTotalLength());
	marker.setAttribute(IMarker.USER_EDITABLE, false);
}
 
Example #7
Source File: STextTaskFinder.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example #8
Source File: XtendTaskFinderTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
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) {
    XtendTaskFinderTest.assertExactMatch(expectedTasks.get((i).intValue()), actualTasks.get((i).intValue()));
  }
}
 
Example #9
Source File: STextTaskFinder.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public List<Task> findTasks(Resource resource) {
	if (resource instanceof StextResource) {
		return findTasks((StextResource) resource);
	}
	return super.findTasks(resource);
}
 
Example #10
Source File: DefaultTaskFinderTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
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) {
    Assert.assertEquals(expectedTasks.get((i).intValue()), actualTasks.get((i).intValue()));
  }
}
 
Example #11
Source File: DefaultTaskParserTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
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) {
    Assert.assertEquals(expectedTasks.get((i).intValue()), actualTasks.get((i).intValue()));
  }
}
 
Example #12
Source File: SCTTaskMarkerCreator.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@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());
	}
}
 
Example #13
Source File: DomainSpecificTaskFinderTest.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@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());
}
 
Example #14
Source File: DomainSpecificTaskFinderTest.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@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());
}
 
Example #15
Source File: GamlSemanticHighlightingCalculator.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
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);
	}
}
 
Example #16
Source File: SCTTaskMarkerTypeProvider.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
public String getMarkerType(Task task) {
	return SCT_TASK_TYPE;
}
 
Example #17
Source File: SCTTask.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
public SCTTask(Task delgate) {
	this.delgate = delgate;
}
 
Example #18
Source File: DefaultSemanticHighlightingCalculator.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
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);
	}
}
 
Example #19
Source File: DefaultTaskFinderTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testNonXtextResource() {
  this.assertContainsTasks(new ResourceImpl(), Collections.<Task>unmodifiableList(CollectionLiterals.<Task>newArrayList()));
}
 
Example #20
Source File: XtendTaskFinderTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public static void assertExactMatch(final Task expected, final Task actual) {
  XtendTaskFinderTest.assertExactMatch(expected.getTag(), actual.getTag());
  Assert.assertEquals(expected.getDescription(), actual.getDescription());
  Assert.assertEquals(expected.getLineNumber(), actual.getLineNumber());
  Assert.assertEquals(expected.getOffset(), actual.getOffset());
}
 
Example #21
Source File: LanguageAwareTaskMarkerTypeProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public String getMarkerType(Task task) {
	return taskMarkerType;
}
 
Example #22
Source File: TaskMarkerCreator.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void createMarker(Task task, IResource resource, String markerType) throws CoreException {
	IMarker marker = resource.createMarker(markerType);
	setMarkerAttributes(task, resource, marker);
}
 
Example #23
Source File: TaskMarkerTypeProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public String getMarkerType(Task task) {
	return XTEXT_TASK_TYPE;
}
 
Example #24
Source File: TaskMarkerContributor.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected void createTaskMarkers(IFile file, List<Task> tasks, IProgressMonitor monitor) throws CoreException {
	for (Task task : tasks) {
		markerCreator.createMarker(task, file, typeProvider.getMarkerType(task));
	}
}