org.eclipse.xtext.tasks.TaskTags Java Examples

The following examples show how to use org.eclipse.xtext.tasks.TaskTags. 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: XtendTaskTagProvider.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public TaskTags getTaskTags(final Resource resource) {
  TaskTags _xblockexpression = null;
  {
    final IPreferenceValues prefs = this.preferenceValuesProvider.getPreferenceValues(resource);
    PreferenceKey _preferenceKey = new PreferenceKey(JavaCore.COMPILER_TASK_TAGS, "TODO,FIXME,XXX");
    final String namePref = prefs.getPreference(_preferenceKey);
    PreferenceKey _preferenceKey_1 = new PreferenceKey(JavaCore.COMPILER_TASK_PRIORITIES, "NORMAL,HIGH,NORMAL");
    final String prioritiesPref = prefs.getPreference(_preferenceKey_1);
    PreferenceKey _preferenceKey_2 = new PreferenceKey(JavaCore.COMPILER_TASK_CASE_SENSITIVE, JavaCore.ENABLED);
    final String caseSensitivePref = prefs.getPreference(_preferenceKey_2);
    final List<TaskTag> tags = PreferenceTaskTagProvider.parseTags(namePref, prioritiesPref);
    TaskTags _taskTags = new TaskTags();
    final Procedure1<TaskTags> _function = (TaskTags it) -> {
      List<TaskTag> _taskTags_1 = it.getTaskTags();
      Iterables.<TaskTag>addAll(_taskTags_1, tags);
      it.setCaseSensitive(caseSensitivePref.equals(JavaCore.ENABLED));
    };
    _xblockexpression = ObjectExtensions.<TaskTags>operator_doubleArrow(_taskTags, _function);
  }
  return _xblockexpression;
}
 
Example #2
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 #3
Source File: SarlTaskTagProvider.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
public TaskTags getTaskTags(Resource resource) {
	final IPreferenceValues prefs = this.preferenceValuesProvider.getPreferenceValues(resource);
	final String namePref = prefs.getPreference(new PreferenceKey(
			JavaCore.COMPILER_TASK_TAGS, "TODO,FIXME,XXX")); //$NON-NLS-1$
	final String prioritiesPref = prefs.getPreference(new PreferenceKey(
			JavaCore.COMPILER_TASK_PRIORITIES, "NORMAL,HIGH,NORMAL")); //$NON-NLS-1$
	final String caseSensitivePref = prefs.getPreference(new PreferenceKey(
			JavaCore.COMPILER_TASK_CASE_SENSITIVE, JavaCore.ENABLED));
	final List<TaskTag> tags = PreferenceTaskTagProvider.parseTags(namePref, prioritiesPref);

	final TaskTags taskTags = new TaskTags();
	taskTags.setCaseSensitive(caseSensitivePref.equals(JavaCore.ENABLED));
	taskTags.getTaskTags().addAll(tags);
	return taskTags;
}
 
Example #4
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 #5
Source File: BlockExpressionBuilderImpl.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Replies the string for "auto-generated" comments.
 * @param resource the resource for which the comment must be determined.
 * @return the comment text.
 */
@Pure
public String getAutoGeneratedActionString(Resource resource) {
	TaskTags tags = getTaskTagProvider().getTaskTags(resource);
	String taskTag;
	if (tags != null && tags.getTaskTags() != null && !tags.getTaskTags().isEmpty()) {
		taskTag = tags.getTaskTags().get(0).getName();
	} else {
		taskTag = "TODO";
	}
	return taskTag + " Auto-generated code.";
}
 
Example #6
Source File: SarlTaskTagProviderTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
public void getTaskTags() throws Exception {
	SarlScript script = file(multilineString(
			"/** TODO This is a comment */",
			"agent Foo {",
			"/** FIXME You must fix this!",
			"*/",
			"def foo { // XXX: Inside the code",
			"}",
			"}",
			"//TODO: Complete the code!"),
			true);
	TaskTag tag;
	TaskTags tags = this.provider.getTaskTags(script.eResource());
	assertTrue(tags.isCaseSensitive());
	Iterator<TaskTag> iterator = tags.iterator();

	assertTrue(iterator.hasNext());
	tag = iterator.next();
	assertEquals("TODO", tag.getName());
	assertEquals(Priority.NORMAL, tag.getPriority());

	assertTrue(iterator.hasNext());
	tag = iterator.next();
	assertEquals("FIXME", tag.getName());
	assertEquals(Priority.HIGH, tag.getPriority());

	assertTrue(iterator.hasNext());
	tag = iterator.next();
	assertEquals("XXX", tag.getName());
	assertEquals(Priority.NORMAL, tag.getPriority());

	assertFalse(iterator.hasNext());
}