eclipse-xtext / eclipse-xtext/xtext

Xtend Active annotation that remove Declaration raise BatchLinkableResourceStorageWritable messages

Open
#2,318 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
831
Forks
330
Avg merge
3d 7h
Merged PRs (30d)
12

Description

I have a project where I move some declaration (FieldDeclaration and MethodDeclaration) from one class to another using xtend active annotations

This was working fine with xtend 2.25 but since I moved to xtend 2.27 I get a lot of errors in the Error log such as:

org.eclipse.xtext.xbase.resource.BatchLinkableResourceStorageWritable  - Object (JvmParameterizedTypeReference:  (type uri: platform:/resource/test_remove_with_annotation/src/test_remove_with_annotation/TestClass.xtend#|3)) is not contained in any resource

I've extracted a subset of the active annotation that illustrate the issue (on Field only but the same occurs when deleting Method)
Annotation code:

@Retention(RetentionPolicy::RUNTIME)
@Active(typeof(MyAnnotationProcessor)) 
@Target(ElementType.TYPE)
annotation  MyAnnotation {
	
}

class MyAnnotationProcessor extends AbstractClassProcessor {

	/**
	 * Phase 2: Transform class' fields and methods
	 */
	override doTransform(List<? extends MutableClassDeclaration> classes, extension TransformationContext context) {
	    val	List<MutableFieldDeclaration> toRemove = newArrayList
		for (clazz : classes) {
			// remove fields starting with "_"
			for (f : clazz.declaredFields) {
				if(f.simpleName.startsWith("_")) {
					toRemove.add(f)
				}
			}
		}
		toRemove.forEach[ f | f.remove]
	}
}

The code generated in xend-gen is Ok (cf. screenshot

Annotation project (run in the first Eclipse):
annotation_projet.zip

Annotated project (run in the runtime workbench):
annotated_projet.zip

image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the attached annotation and annotated projects using Xtend 2.27, starting from MyAnnotationProcessor.doTransform and the generated xend-gen output. Compare field removal with the reported BatchLinkableResourceStorageWritable messages; done when the declarations are removed without those errors and the generated code remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.