Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion com.avaloq.tools.ddk.xtext.export/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Export-Package: com.avaloq.tools.ddk.xtext.export,
com.avaloq.tools.ddk.xtext.export.formatting,
com.avaloq.tools.ddk.xtext.export.serializer,
com.avaloq.tools.ddk.xtext.export.generator,
com.avaloq.tools.ddk.xtext.export.jvmmodel
com.avaloq.tools.ddk.xtext.export.jvmmodel,
com.avaloq.tools.ddk.xtext.export.resource
Automatic-Module-Name: com.avaloq.tools.ddk.xtext.export
Import-Package: org.apache.log4j
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
import org.eclipse.xtext.formatting.ILineSeparatorInformation;
import org.eclipse.xtext.generator.IOutputConfigurationProvider;
import org.eclipse.xtext.naming.IQualifiedNameConverter;
import org.eclipse.xtext.resource.IResourceDescription;
import org.eclipse.xtext.xbase.compiler.JvmModelGenerator;

import com.avaloq.tools.ddk.xtext.export.conversion.ExportValueConverterService;
import com.avaloq.tools.ddk.xtext.export.generator.ExportJvmModelGenerator;
import com.avaloq.tools.ddk.xtext.export.generator.ExportOutputConfigurationProvider;
import com.avaloq.tools.ddk.xtext.export.naming.ExportQualifiedNameConverter;
import com.avaloq.tools.ddk.xtext.export.resource.ExportResourceDescriptionManager;
import com.avaloq.tools.ddk.xtext.formatting.LfLineSeparatorInformation;


Expand Down Expand Up @@ -70,6 +72,16 @@ public Class<? extends JvmModelGenerator> bindJvmModelGenerator() {
return ExportJvmModelGenerator.class;
}

/**
* Binds the description manager which keeps Java type changes from re-queuing export models.
*
* @return the export specific resource description manager
*/
@Override
public Class<? extends IResourceDescription.Manager> bindIResourceDescription$Manager() { // NOPMD
return ExportResourceDescriptionManager.class;
}

@Override
public Class<? extends org.eclipse.xtext.formatting.IFormatter> bindIFormatter() {
return com.avaloq.tools.ddk.xtext.export.formatting.ExportFormatter.class;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*******************************************************************************
* Copyright (c) 2026 Avaloq Group AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Avaloq Group AG - initial API and implementation
*******************************************************************************/
package com.avaloq.tools.ddk.xtext.export.resource;

import java.util.Collection;
import java.util.List;

import org.eclipse.xtext.common.types.access.impl.URIHelperConstants;
import org.eclipse.xtext.resource.IResourceDescription;
import org.eclipse.xtext.resource.IResourceDescription.Delta;
import org.eclipse.xtext.resource.IResourceDescriptions;
import org.eclipse.xtext.xbase.resource.XbaseResourceDescriptionManager;

import com.google.inject.Singleton;


/**
* Resource description manager for export models which ignores deltas of Java types.
* <p>
* The inferred JVM model of an export model references the Java interfaces of the exported EClasses, so the Xbase
* description manager records them as imported names and outgoing references. The builder then re-processes every export
* model whenever JDT reports a structural change to one of those interfaces, although the generated code only depends

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for sure not true, export language can use java classes at will from extensions. For example:

extension com::foo::^export::Bar

and the

export lookup x::TypeN as qualified name [isBlaBla(this.eContainer)]{
object-fingerprint;
}

where isBlaBla is defined in com.foo.exportBar

* on the EMF model (the ecore and genmodel), whose own changes still affect export models.
* </p>
*/
@Singleton
public class ExportResourceDescriptionManager extends XbaseResourceDescriptionManager {

@Override
public boolean isAffected(final Delta delta, final IResourceDescription candidate) {
return !isJavaTypeDelta(delta) && super.isAffected(delta, candidate);
}

@Override
public boolean isAffected(final Collection<Delta> deltas, final IResourceDescription candidate, final IResourceDescriptions context) {
final List<Delta> nonJavaDeltas = deltas.stream().filter(delta -> !isJavaTypeDelta(delta)).toList();
return !nonJavaDeltas.isEmpty() && super.isAffected(nonJavaDeltas, candidate, context);
}

/**
* Returns whether the given delta describes a Java type, as reported by JDT through the {@code java:/} URI scheme.
*
* @param delta
* the delta, must not be {@code null}
* @return {@code true} if the delta is about a Java type
*/
private static boolean isJavaTypeDelta(final Delta delta) {
return URIHelperConstants.PROTOCOL.equals(delta.getUri().scheme());
}
}