From 770689f30f106a06b94b29ae04468ddc0d2125ad Mon Sep 17 00:00:00 2001 From: Gerard Dethier Date: Tue, 2 Mar 2021 11:11:17 +0100 Subject: [PATCH] feat: align with latest pc. https://github.com/pousse-cafe/pousse-cafe/issues/206 --- META-INF/MANIFEST.MF | 6 +- README.md | 2 - .../plugin/editors/EmilHyperlinkDetector.java | 5 +- .../MessageListenerHyperlinkDetector.java | 56 ------------------- 4 files changed, 5 insertions(+), 64 deletions(-) diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF index 59bb403..e3d8f67 100644 --- a/META-INF/MANIFEST.MF +++ b/META-INF/MANIFEST.MF @@ -2,13 +2,13 @@ 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", @@ -16,8 +16,6 @@ Require-Bundle: org.eclipse.ui, 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" diff --git a/README.md b/README.md index f52a6f3..65f7c30 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/src/poussecafe/eclipse/plugin/editors/EmilHyperlinkDetector.java b/src/poussecafe/eclipse/plugin/editors/EmilHyperlinkDetector.java index 3949b0d..18fb660 100644 --- a/src/poussecafe/eclipse/plugin/editors/EmilHyperlinkDetector.java +++ b/src/poussecafe/eclipse/plugin/editors/EmilHyperlinkDetector.java @@ -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; @@ -340,8 +341,8 @@ private Function> listenerExtractor( private static final Set 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) { diff --git a/src/poussecafe/eclipse/plugin/hyperlink/MessageListenerHyperlinkDetector.java b/src/poussecafe/eclipse/plugin/hyperlink/MessageListenerHyperlinkDetector.java index 8518859..4715095 100644 --- a/src/poussecafe/eclipse/plugin/hyperlink/MessageListenerHyperlinkDetector.java +++ b/src/poussecafe/eclipse/plugin/hyperlink/MessageListenerHyperlinkDetector.java @@ -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; @@ -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; @@ -192,12 +189,6 @@ private List 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; } @@ -258,53 +249,6 @@ private IRegion region(ISourceRange sourceRange) { return new Region(sourceRange.getOffset(), sourceRange.getLength()); } - private List buildLinksToOnAddHooks( - IRegion region, - IJavaProject project, - List aggregates) throws JavaModelException { - var links = new ArrayList(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