diff --git a/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/JaxRSRules.xtend b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/JaxRSRules.xtend index 99597f9b..5e4b3fbe 100644 --- a/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/JaxRSRules.xtend +++ b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/JaxRSRules.xtend @@ -44,6 +44,8 @@ class JaxRSRules implements Rule { if(identifier.toString.endsWith("Test")) return; + if(isAbstraction(unit)) return; + // technology based and general recognition if (isConverter) { detectDefault(blackboard, unit) @@ -90,10 +92,13 @@ class JaxRSRules implements Rule { detectDefault(blackboard, unit) } - for (iface : getAllInterfaces(unit)) { - pcmDetector.detectProvidedInterfaceWeakly(identifier, iface.resolveBinding) - for (m : getMethods(iface)) { - pcmDetector.detectProvidedOperationWeakly(identifier, iface.resolveBinding, m) + for (parent : getAllAbstractParents(unit)) { + System.out.println(identifier.name + ": " + parent) + val parentBinding = parent.resolveBinding + pcmDetector.detectProvidedInterfaceWeakly(identifier, parentBinding) + for (m : getMethods(parent)) { + System.out.println("\t " + m.name) + pcmDetector.detectProvidedOperationWeakly(identifier, parentBinding, m) } } } diff --git a/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/SpringRules.xtend b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/SpringRules.xtend index 8e3a4b5f..eacbd3ac 100644 --- a/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/SpringRules.xtend +++ b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/SpringRules.xtend @@ -149,7 +149,7 @@ class SpringRules implements Rule { if(identifier.toString.endsWith("Test")) return; - pcmDetector.detectComponent(identifier) + if(!isAbstraction(unit) || isClient || isRepository) pcmDetector.detectComponent(identifier) if (isComponent) { getConstructors(unit).stream.filter[c|isMethodAnnotatedWithName(c, "Autowired")].flatMap [ c | @@ -215,13 +215,13 @@ class SpringRules implements Rule { } } - for (iface : getAllInterfaces(unit)) { - val ifaceBinding = iface.resolveBinding + for (parent : getAllAbstractParents(unit)) { + val parentBinding = parent.resolveBinding // Hide Repository interface implementations, they tend to connect composites in unrepresentative ways - if (ifaceBinding !== null && !ifaceBinding.name.endsWith("Repository")) { - pcmDetector.detectProvidedInterfaceWeakly(identifier, ifaceBinding) - for (m : getMethods(iface)) { - pcmDetector.detectProvidedOperationWeakly(identifier, ifaceBinding, m) + if (parentBinding !== null && !parentBinding.name.endsWith("Repository")) { + pcmDetector.detectProvidedInterfaceWeakly(identifier, parentBinding) + for (m : getMethods(parent)) { + pcmDetector.detectProvidedOperationWeakly(identifier, parentBinding, m) } } } diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/ProvisionsBuilder.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/ProvisionsBuilder.java index fe2c453e..ded7141c 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/ProvisionsBuilder.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/ProvisionsBuilder.java @@ -25,10 +25,18 @@ public synchronized void addWeakly(final OperationInterface iface) { } public synchronized void strengthenIfPresent(final OperationInterface iface) { - if (this.weakProvisions.contains(iface)) { - this.weakProvisions.remove(iface); - this.provisions.add(iface); + List remainingProvisions = new LinkedList<>(); + for (final OperationInterface provision : this.weakProvisions) { + final boolean partlyProvided = provision.isPartOf(iface); + final boolean entirelyProvided = iface.isPartOf(provision); + if (partlyProvided || entirelyProvided) { + this.provisions.add(provision); + } else { + remainingProvisions.add(provision); + } } + this.weakProvisions.clear(); + this.weakProvisions.addAll(remainingProvisions); } public synchronized boolean containsRelated(final OperationInterface requirement) { diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/RuleHelper.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/RuleHelper.java index 03bb65a0..8b8c7735 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/RuleHelper.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/RuleHelper.java @@ -32,6 +32,7 @@ import org.eclipse.jdt.core.dom.TypeParameter; import org.eclipse.jdt.core.dom.VariableDeclarationExpression; import org.eclipse.jdt.core.dom.VariableDeclarationStatement; +import org.eclipse.jdt.core.util.IModifierConstants; /** * This class is used as a supporting library for writing rules for Retriever. It contains numerous @@ -61,7 +62,8 @@ public static boolean isAbstraction(final CompilationUnit unit) { final List types = cast(unit.types(), AbstractTypeDeclaration.class); for (final AbstractTypeDeclaration abstType : types) { - if ((abstType instanceof TypeDeclaration) && ((TypeDeclaration) abstType).isInterface()) { + if (abstType instanceof TypeDeclaration typeDecl && (typeDecl.isInterface() || typeDecl.modifiers() + .contains(Modifier.ABSTRACT))) { return true; } } @@ -320,17 +322,31 @@ public static boolean isUnitAnEnum(final CompilationUnit unit) { return false; } - public static List getAllInterfaces(final CompilationUnit unit) { + /** + * Returns everything listed after "implements" and "extends" in the type declaration that is + * either abstract or an interface. + */ + public static List getAllAbstractParents(final CompilationUnit unit) { final List interfaces = new ArrayList<>(); final List types = cast(unit.types(), AbstractTypeDeclaration.class); for (final AbstractTypeDeclaration abstType : types) { - if (abstType instanceof TypeDeclaration) { - final TypeDeclaration type = (TypeDeclaration) abstType; - + if (abstType instanceof TypeDeclaration type) { final List interfaceTypes = cast(type.superInterfaceTypes(), Type.class); interfaces.addAll(interfaceTypes); + + Type superclassType = type.getSuperclassType(); + if (superclassType == null) { + continue; + } + ITypeBinding superclassBinding = superclassType.resolveBinding(); + if (superclassBinding == null) { + continue; + } + if ((superclassBinding.getModifiers() & IModifierConstants.ACC_ABSTRACT) != 0) { + interfaces.add(superclassType); + } } }