Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor plugins to allow reducing dependencies to ddk.xtext and ddk.xtext.builder #998

Merged
merged 1 commit into from
Sep 24, 2024
Merged
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
1 change: 1 addition & 0 deletions com.avaloq.tools.ddk.xtext.builder/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Bundle-Version: 14.2.0.qualifier
Bundle-Vendor: Avaloq Group AG
Require-Bundle: org.eclipse.xtext.builder,
org.eclipse.xtext.ui,
com.avaloq.tools.ddk,
com.avaloq.tools.ddk.xtext,
org.eclipse.xtext.common.types.ui
Bundle-RequiredExecutionEnvironment: JavaSE-17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import org.eclipse.xtext.resource.impl.ResourceDescriptionsData;

import com.avaloq.tools.ddk.xtext.builder.layered.NullResourceDescriptionsData;
import com.avaloq.tools.ddk.xtext.extensions.DelegatingResourceDescriptionsData;
import com.avaloq.tools.ddk.xtext.extensions.IResourceDescriptionsData;
import com.avaloq.tools.ddk.xtext.extensions.ResourceDescriptions2;
import com.avaloq.tools.ddk.xtext.resource.extensions.DelegatingResourceDescriptionsData;
import com.avaloq.tools.ddk.xtext.resource.extensions.IResourceDescriptions2;
import com.avaloq.tools.ddk.xtext.resource.extensions.IResourceDescriptionsData;
import com.avaloq.tools.ddk.xtext.resource.extensions.ResourceDescriptions2;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,17 @@
import com.avaloq.tools.ddk.xtext.builder.tracing.ResourceLinkingMemoryEvent;
import com.avaloq.tools.ddk.xtext.builder.tracing.ResourceProcessingEvent;
import com.avaloq.tools.ddk.xtext.builder.tracing.ResourceValidationEvent;
import com.avaloq.tools.ddk.xtext.extensions.AbstractResourceDescriptionsData;
import com.avaloq.tools.ddk.xtext.extensions.IResourceDescriptionsData;
import com.avaloq.tools.ddk.xtext.extensions.ResourceDescriptions2;
import com.avaloq.tools.ddk.xtext.linking.ILazyLinkingResource2;
import com.avaloq.tools.ddk.xtext.resource.AbstractCachingResourceDescriptionManager;
import com.avaloq.tools.ddk.xtext.resource.AbstractResourceDescriptionDelta;
import com.avaloq.tools.ddk.xtext.resource.DerivedObjectAssociations;
import com.avaloq.tools.ddk.xtext.resource.FixedCopiedResourceDescription;
import com.avaloq.tools.ddk.xtext.resource.IDerivedObjectAssociationsStore;
import com.avaloq.tools.ddk.xtext.resource.extensions.AbstractResourceDescriptionsData;
import com.avaloq.tools.ddk.xtext.resource.extensions.ForwardingResourceDescriptions;
import com.avaloq.tools.ddk.xtext.resource.extensions.IResourceDescriptions2;
import com.avaloq.tools.ddk.xtext.resource.extensions.IResourceDescriptionsData;
import com.avaloq.tools.ddk.xtext.resource.extensions.ResourceDescriptions2;
import com.avaloq.tools.ddk.xtext.resource.persistence.DirectLinkingResourceStorageFacade;
import com.avaloq.tools.ddk.xtext.scoping.ImplicitReferencesAdapter;
import com.avaloq.tools.ddk.xtext.tracing.ITraceSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import org.eclipse.xtext.resource.impl.ResourceDescriptionsData;

import com.avaloq.tools.ddk.xtext.builder.IBinaryModelStore;
import com.avaloq.tools.ddk.xtext.builder.IDerivedObjectAssociationsStore;
import com.avaloq.tools.ddk.xtext.extensions.DelegatingResourceDescriptionsData;
import com.avaloq.tools.ddk.xtext.extensions.IResourceDescriptionsData;
import com.avaloq.tools.ddk.xtext.resource.IDerivedObjectAssociationsStore;
import com.avaloq.tools.ddk.xtext.resource.extensions.DelegatingResourceDescriptionsData;
import com.avaloq.tools.ddk.xtext.resource.extensions.IResourceDescriptionsData;
import com.google.inject.Inject;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
import org.eclipse.core.runtime.IProgressMonitor;

import com.avaloq.tools.ddk.xtext.builder.IBinaryModelStore;
import com.avaloq.tools.ddk.xtext.builder.IDerivedObjectAssociationsStore;
import com.avaloq.tools.ddk.xtext.extensions.IResourceDescriptionsData;
import com.avaloq.tools.ddk.xtext.builder.layered.DefaultXtextTargetPlatform;
import com.avaloq.tools.ddk.xtext.resource.IDerivedObjectAssociationsStore;
import com.avaloq.tools.ddk.xtext.resource.extensions.IResourceDescriptionsData;
import com.google.inject.ImplementedBy;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import org.eclipse.xtext.resource.IResourceDescription;
import org.eclipse.xtext.resource.impl.ResourceDescriptionsData;

import com.avaloq.tools.ddk.xtext.extensions.DelegatingResourceDescriptionsData;
import com.avaloq.tools.ddk.xtext.extensions.IResourceDescriptionsData;
import com.avaloq.tools.ddk.xtext.resource.extensions.DelegatingResourceDescriptionsData;
import com.avaloq.tools.ddk.xtext.resource.extensions.IResourceDescriptionsData;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import org.eclipse.core.runtime.IProgressMonitor;

import com.avaloq.tools.ddk.xtext.builder.IBinaryModelStore;
import com.avaloq.tools.ddk.xtext.builder.IDerivedObjectAssociationsStore;
import com.avaloq.tools.ddk.xtext.extensions.IResourceDescriptionsData;
import com.avaloq.tools.ddk.xtext.resource.IDerivedObjectAssociationsStore;
import com.avaloq.tools.ddk.xtext.resource.extensions.IResourceDescriptionsData;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.eclipse.xtext.ui.notification.IStateChangeEventBroker;

import com.avaloq.tools.ddk.xtext.resource.extensions.IResourceDescriptions2;
import com.avaloq.tools.ddk.xtext.resource.extensions.ResourceDescriptions2;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
Expand Down
3 changes: 2 additions & 1 deletion com.avaloq.tools.ddk.xtext.test.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Require-Bundle: com.avaloq.tools.ddk.xtext,
org.hamcrest.library,
org.slf4j.ext,
com.avaloq.tools.ddk.check.runtime.core,
org.eclipse.emf.common
org.eclipse.emf.common,
com.avaloq.tools.ddk
Import-Package: org.apache.logging.log4j,org.apache.log4j
Export-Package: com.avaloq.tools.ddk.xtext.test,
com.avaloq.tools.ddk.xtext.test.contentassist,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
import org.eclipse.xtext.util.Triple;
import org.eclipse.xtext.xbase.lib.Pair;

import com.avaloq.tools.ddk.caching.Regexps;
import com.avaloq.tools.ddk.xtext.linking.AbstractFragmentProvider;
import com.avaloq.tools.ddk.xtext.naming.QualifiedNames;
import com.avaloq.tools.ddk.xtext.resource.IFingerprintComputer;
import com.avaloq.tools.ddk.xtext.scoping.ContainerQuery;
import com.avaloq.tools.ddk.xtext.scoping.IDomain;
import com.avaloq.tools.ddk.xtext.test.AbstractXtextMarkerBasedTest;
import com.avaloq.tools.ddk.xtext.util.Regexps;
import com.google.common.base.Function;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
Expand Down
5 changes: 2 additions & 3 deletions com.avaloq.tools.ddk.xtext/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ Require-Bundle: com.google.guava,
org.eclipse.core.runtime,
org.eclipse.emf.ecore,
org.eclipse.jdt.annotation,
com.avaloq.tools.ddk,
org.eclipse.xtext,
org.eclipse.xtext.builder,
org.eclipse.xtext.util
Export-Package: com.avaloq.tools.ddk.caching,
com.avaloq.tools.ddk.xtext.build,
Export-Package: com.avaloq.tools.ddk.xtext.build,
com.avaloq.tools.ddk.xtext.delegation,
com.avaloq.tools.ddk.xtext.documentation,
com.avaloq.tools.ddk.xtext.extension,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import org.eclipse.xtext.naming.QualifiedName;

import com.avaloq.tools.ddk.xtext.util.Regexps;
import com.avaloq.tools.ddk.caching.Regexps;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*******************************************************************************/
package com.avaloq.tools.ddk.xtext.naming;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand All @@ -18,8 +19,11 @@

import org.eclipse.xtext.naming.QualifiedName;

import com.avaloq.tools.ddk.caching.CacheManager;
import com.avaloq.tools.ddk.caching.CacheStatistics;
import com.avaloq.tools.ddk.caching.ICache;
import com.avaloq.tools.ddk.xtext.util.ArrayUtils;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
Expand Down Expand Up @@ -385,6 +389,33 @@ private abstract static class Visitor {
private long hits;
private long misses;

/**
* Creates a new cache to lookup qualified names.
*
* @param <K>
* the key type
* @param <V>
* the value type
* @param name
* the name of the cache, must not be {@code null}
* @param clazz
* the value class
* @param shareValues
* whether the value array of a node should be shared with its parent if they're equal
* @return the qualified name lookup, never {@code null}
*/
public static <K, V> QualifiedNameLookup<V> createNameLookupCache(final String name, final Class<V> clazz, final boolean shareValues) {
QualifiedNameLookup<V> cache = new QualifiedNameSegmentTreeLookup<V>(clazz, shareValues);
CacheManager cacheManager = CacheManager.getInstance();
if (cacheManager.isMonitoringEnabled()) {
ArrayListMultimap<String, WeakReference<ICache<?, ?>>> caches = cacheManager.getCaches();
synchronized (caches) {
caches.put(name, new WeakReference<ICache<?, ?>>(cache));
}
}
return cache;
}

public QualifiedNameSegmentTreeLookup(final Class<T> elementType, final boolean shareValues) { // NOPMD
root = shareValues ? new ValueSharingSegmentNode("") : new SegmentNode(""); //$NON-NLS-1$ //$NON-NLS-2$
init();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
/*******************************************************************************
Copy link
Member Author

Choose a reason for hiding this comment

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

@andrewL-avlq , all this files look fine in my workspace. Do you know if the old ones have the wrong format?

Copy link
Collaborator

Choose a reason for hiding this comment

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

They look fine in my workspace too, so not sure what formatting has changed (although I would guess the line endings).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, I think it is just recording the files that have moved as full diffs.

* Copyright (c) 2018 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.builder;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
/**
* Derived objects associated with resource description.
* <p>
* Instances of this class are attached to resource descriptions or resource description delta.
* </p>
* <p>
* Main purpose of the associations is to manage life cycle of the derived resources.
* Associations enable generators to identify what derived objects (sources) should be dropped.
* </p>
* <p>
* There can be many producers of derived objects, where generators executed by builder participants
* are the most common kind. Objects produced by generators may be other sources, but could also be some
* entities specific to the business application of a DSL (i.e. database objects). Derived objects
* could also be valid Xtext resources visible to the builder. Therefore the framework in not trying
* to interpret the information about the derived objects, but stores it grouped by the producer (generator id).
* </p>
* <p>
* For simplicity we will refer to all producers of derived objects as to generators.
* </p>
*/
public class DerivedObjectAssociations {
private final Map<String, Set<String>> derivedObjects = Maps.newHashMap();
/**
* Adds the association for a derived object created the given generator.
*
* @param generatorType
* an identifier of the generator that created the object, must not be {@code null}
* @param derivedObjectUri
* the URI of the derived object (freely defined by the generator), must not be {@code null}
*/
public void add(final String generatorType, final String derivedObjectUri) {
derivedObjects.computeIfAbsent(generatorType, s -> Sets.newHashSet()).add(derivedObjectUri);
}
/**
* Returns identifiers of all generators that created derived objects for the given resource.
*
* @return identifiers of generators that created derived objects, never {@code null}
*/
public Set<String> getGeneratorTypes() {
return derivedObjects.keySet();
}
/**
* Returns set of derived object URIs for the given generator.
*
* @param generatorType
* the identifier of the generator, must not be {@code null}
* @return set of URIs of derived objects, never {@code null}
*/
public Set<String> getDerivedObjects(final String generatorType) {
return derivedObjects.getOrDefault(generatorType, Collections.emptySet());
}
@Override
public String toString() {
return derivedObjects.toString();
}
}
/*******************************************************************************
* Copyright (c) 2018 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.resource;

import java.util.Collections;
import java.util.Map;
import java.util.Set;

import com.google.common.collect.Maps;
import com.google.common.collect.Sets;


/**
* Derived objects associated with resource description.
* <p>
* Instances of this class are attached to resource descriptions or resource description delta.
* </p>
* <p>
* Main purpose of the associations is to manage life cycle of the derived resources.
* Associations enable generators to identify what derived objects (sources) should be dropped.
* </p>
* <p>
* There can be many producers of derived objects, where generators executed by builder participants
* are the most common kind. Objects produced by generators may be other sources, but could also be some
* entities specific to the business application of a DSL (i.e. database objects). Derived objects
* could also be valid Xtext resources visible to the builder. Therefore the framework in not trying
* to interpret the information about the derived objects, but stores it grouped by the producer (generator id).
* </p>
* <p>
* For simplicity we will refer to all producers of derived objects as to generators.
* </p>
*/
public class DerivedObjectAssociations {

private final Map<String, Set<String>> derivedObjects = Maps.newHashMap();

/**
* Adds the association for a derived object created the given generator.
*
* @param generatorType
* an identifier of the generator that created the object, must not be {@code null}
* @param derivedObjectUri
* the URI of the derived object (freely defined by the generator), must not be {@code null}
*/
public void add(final String generatorType, final String derivedObjectUri) {
derivedObjects.computeIfAbsent(generatorType, s -> Sets.newHashSet()).add(derivedObjectUri);
}

/**
* Returns identifiers of all generators that created derived objects for the given resource.
*
* @return identifiers of generators that created derived objects, never {@code null}
*/
public Set<String> getGeneratorTypes() {
return derivedObjects.keySet();
}

/**
* Returns set of derived object URIs for the given generator.
*
* @param generatorType
* the identifier of the generator, must not be {@code null}
* @return set of URIs of derived objects, never {@code null}
*/
public Set<String> getDerivedObjects(final String generatorType) {
return derivedObjects.getOrDefault(generatorType, Collections.emptySet());
}

@Override
public String toString() {
return derivedObjects.toString();
}

}
Loading