Skip to content

Commit

Permalink
feat: align with latest pc.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdethier committed Mar 2, 2021
1 parent 2281cf7 commit 770689f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 64 deletions.
6 changes: 2 additions & 4 deletions META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Pousse-Café Eclipse Plugin
Bundle-SymbolicName: poussecafe.eclipse.plugin;singleton:=true
Bundle-Version: 0.4.1.202102241414
Bundle-Version: 0.4.2.202103021049
Automatic-Module-Name: pousse.cafe.eclipse.plugin
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources,
poussecafe.source.eclipse.plugin;bundle-version="0.27.0",
poussecafe.source.eclipse.plugin;bundle-version="0.28.0",
org.eclipse.jface.text,
org.eclipse.ui.editors,
pousse-cafe-antlr4-runtime-eclipse-plugin;bundle-version="4.8.0",
org.slf4j.api,
org.eclipse.jdt.ui;bundle-version="3.22.0",
org.eclipse.ui.ide;bundle-version="3.18.0",
org.eclipse.jdt.core,
poussecafe.spring.mongo.eclipse.plugin;bundle-version="0.17.0",
poussecafe.spring.jpa.eclipse.plugin;bundle-version="0.5.0",
poussecafe.base.eclipse.plugin;bundle-version="0.26.0",
org.apache.commons.lang3,
org.eclipse.ui.workbench.texteditor;bundle-version="3.15.100"
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ The following projects must be cloned into the workspace:
- [pousse-cafe-core-eclipse-plugin](https://github.com/pousse-cafe/pousse-cafe-core-eclipse-plugin)
- [pousse-cafe-source-eclipse-plugin](https://github.com/pousse-cafe/pousse-cafe-source-eclipse-plugin)
- [pousse-cafe-attribute-eclipse-plugin](https://github.com/pousse-cafe/pousse-cafe-attribute-eclipse-plugin)
- [pousse-cafe-spring-data-eclipse-plugin](https://github.com/pousse-cafe/pousse-cafe-spring-data-eclipse-plugin)
- [pousse-cafe-spring-mongo-eclipse-plugin](https://github.com/pousse-cafe/pousse-cafe-spring-mongo-eclipse-plugin)

Each project must contain the "original" JAR file:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import poussecafe.source.model.Aggregate;
import poussecafe.source.model.Command;
import poussecafe.source.model.DomainEvent;
import poussecafe.source.model.Hooks;
import poussecafe.source.model.MessageListenerContainerType;
import poussecafe.source.model.ProcessModel;
import poussecafe.source.model.Runner;
Expand Down Expand Up @@ -340,8 +341,8 @@ private Function<IType, Optional<IMember>> listenerExtractor(

private static final Set<String> HOOK_NAMES = new HashSet<>();
static {
HOOK_NAMES.add(Aggregate.ON_ADD_METHOD_NAME);
HOOK_NAMES.add(Aggregate.ON_DELETE_METHOD_NAME);
HOOK_NAMES.add(Hooks.ON_ADD_METHOD_NAME);
HOOK_NAMES.add(Hooks.ON_DELETE_METHOD_NAME);
}

private void tryAddLinks(AggregateRootContext aggregateRoot) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.core.SourceRange;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
Expand All @@ -31,8 +30,6 @@
import poussecafe.eclipse.plugin.editors.ActionHyperlink;
import poussecafe.source.analysis.ClassName;
import poussecafe.source.analysis.CompilationUnitResolver;
import poussecafe.source.generation.NamingConventions;
import poussecafe.source.model.Aggregate;
import poussecafe.source.model.MessageListener;

import static java.util.Collections.emptyList;
Expand Down Expand Up @@ -192,12 +189,6 @@ private List<IHyperlink> producers(PousseCafeProject pousseCafeProject, String m
.collect(toList());
links.addAll(buildLinksToListeners(linkRegion, pousseCafeProject.getJavaProject(), listeners, "Producer"));

var hooks = pousseCafeProject.model().orElseThrow().aggregates().stream()
.filter(aggregate -> aggregate.onAddProducedEvents().stream()
.anyMatch(producedEvent -> producedEvent.message().name().equals(messageName)))
.collect(toList());
links.addAll(buildLinksToOnAddHooks(linkRegion, pousseCafeProject.getJavaProject(), hooks));

return links;
}

Expand Down Expand Up @@ -258,53 +249,6 @@ private IRegion region(ISourceRange sourceRange) {
return new Region(sourceRange.getOffset(), sourceRange.getLength());
}

private List<IHyperlink> buildLinksToOnAddHooks(
IRegion region,
IJavaProject project,
List<Aggregate> aggregates) throws JavaModelException {
var links = new ArrayList<IHyperlink>(aggregates.size());
ITextEditor editor = getAdapter(ITextEditor.class);
for(Aggregate aggregate : aggregates) {
IType containerType;
if(aggregate.standaloneRootSource().isPresent()) {
var source = (ResourceSource) aggregate.standaloneRootSource().get();
source.connect(project);
ICompilationUnit compilationUnit = (ICompilationUnit) JavaCore.create(source.file());
containerType = compilationUnit.findPrimaryType();
} else {
var source = (ResourceSource) aggregate.containerSource().orElseThrow();
source.connect(project);
ICompilationUnit compilationUnit = (ICompilationUnit) JavaCore.create(source.file());
containerType = compilationUnit.findPrimaryType().getType(NamingConventions.innerRootClassName());
}

IMethod hookMethod = locateOnAddHook(containerType);
if(hookMethod != null) {
var action = new OpenJavaEditorAction.Builder()
.member(hookMethod)
.site(editor.getEditorSite())
.build();
links.add(new ActionHyperlink.Builder()
.action(action)
.name("Hook " + aggregate.simpleName() + ".onAdd()")
.region(region)
.build());
}
}
return links;
}

private IMethod locateOnAddHook(IType type) throws JavaModelException {
for(IMethod method : type.getMethods()) {
if(Signature.SIG_VOID.equals(method.getReturnType())
&& method.getElementName().equals("onAdd")
&& method.getNumberOfParameters() == 0) {
return method;
}
}
return null;
}

private boolean isMessageListener(IMethod method, MessageListener listener) throws JavaModelException {
return isMessageListener(method)
&& method.getParameterTypes().length == 1
Expand Down

0 comments on commit 770689f

Please sign in to comment.