Skip to content

Xtend Active annotation that remove Declaration raise BatchLinkableResourceStorageWritable messages #2318

@dvojtise

Description

@dvojtise

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions