<commit_before>package de.cooperateproject.modeling.textual.component.issues

import de.cooperateproject.modeling.textual.component.cmp.CmpPackage
import de.cooperateproject.modeling.textual.component.cmp.Method
import de.cooperateproject.modeling.textual.common.metamodel.textualCommons.TextualCommonsPackage
import de.cooperateproject.modeling.textual.common.metamodel.textualCommons.UMLReferencingElement
import de.cooperateproject.modeling.textual.xtext.runtime.issues.automatedfixing.IResolvableChecker
import org.eclipse.emf.ecore.EClass
import org.eclipse.uml2.uml.Element
import org.eclipse.uml2.uml.UMLPackage

import static extension de.cooperateproject.modeling.textual.common.issues.CommonIssueResolutionUtilities.*
import de.cooperateproject.modeling.textual.component.cmp.InterfaceRelation
import de.cooperateproject.modeling.textual.component.cmp.Attribute
import de.cooperateproject.modeling.textual.component.cmp.Component
import de.cooperateproject.modeling.textual.component.cmp.Member
import de.cooperateproject.modeling.textual.common.metamodel.textualCommons.NamedElement
import de.cooperateproject.modeling.textual.component.cmp.Port
import de.cooperateproject.modeling.textual.component.cmp.ConnectorEnd
import de.cooperateproject.modeling.textual.component.cmp.Connector
import de.cooperateproject.modeling.textual.component.cmp.Parameter
import org.apache.commons.lang3.StringUtils
import de.cooperateproject.modeling.textual.common.issues.DependingElementMissingElementResolvableCheckerBase

class ComponentMissingUMLElementResolvableChecker implements IResolvableChecker<UMLReferencingElement<Element>> {
	
	override isResolvable(UMLReferencingElement<Element> element) {
		element.resolvePossible
	}
	
	private def dispatch resolvePossible(UMLReferencingElement element) {
	    val referencedType = element.eClass.getFeatureType(TextualCommonsPackage.eINSTANCE.UMLReferencingElement_ReferencedElement).EClassifier as EClass
	    return (UMLPackage.eINSTANCE.classifier.isSuperTypeOf(referencedType) 
	         && UMLPackage.eINSTANCE.packageableElement.isSuperTypeOf(referencedType)
	         && (element.hasValidParent(CmpPackage.eINSTANCE.component) || element.hasValidParent(CmpPackage.eINSTANCE.rootPackage)))
	}
	
	private def dispatch resolvePossible(InterfaceRelation element) {
		return element.interface.hasReferencedElement && element.hasValidParent(CmpPackage.eINSTANCE.classifier)
		}
	
	private def dispatch resolvePossible(Attribute element) {
		return element.type !== null && element.hasValidParent(CmpPackage.eINSTANCE.classifier)
	}
	
	private def dispatch resolvePossible(Port element) {
		return element.realizedClassifier.hasReferencedElement && element.hasValidParent(CmpPackage.eINSTANCE.component)
	}
	
	private def dispatch resolvePossible(ConnectorEnd element) {
		return element.role.hasReferencedElement && element.hasValidParent(CmpPackage.eINSTANCE.connector)
	}
	
	private def dispatch resolvePossible(Connector element) {
		return element.name !== null && element.hasValidParent(CmpPackage.eINSTANCE.component)
	}
	
	private def dispatch resolvePossible(Method element) {
		return !element.parameters.map[type].contains(null) && !element.parameters.map[name].contains(null)
	}
	
    private def dispatch resolvePossible(Parameter element) {
        return element.type !== null && element.type.eResource !== null && StringUtils.isNotBlank(element.name)
    }
	
	
	
}<commit_msg>switched base class of resolvableChecker of cmp diagram #248<commit_after>package de.cooperateproject.modeling.textual.component.issues

import de.cooperateproject.modeling.textual.component.cmp.CmpPackage
import de.cooperateproject.modeling.textual.component.cmp.Method
import de.cooperateproject.modeling.textual.common.metamodel.textualCommons.TextualCommonsPackage
import de.cooperateproject.modeling.textual.common.metamodel.textualCommons.UMLReferencingElement
import de.cooperateproject.modeling.textual.xtext.runtime.issues.automatedfixing.IResolvableChecker
import org.eclipse.emf.ecore.EClass
import org.eclipse.uml2.uml.Element
import org.eclipse.uml2.uml.UMLPackage

import static extension de.cooperateproject.modeling.textual.common.issues.CommonIssueResolutionUtilities.*
import de.cooperateproject.modeling.textual.component.cmp.InterfaceRelation
import de.cooperateproject.modeling.textual.component.cmp.Attribute
import de.cooperateproject.modeling.textual.component.cmp.Component
import de.cooperateproject.modeling.textual.component.cmp.Member
import de.cooperateproject.modeling.textual.common.metamodel.textualCommons.NamedElement
import de.cooperateproject.modeling.textual.component.cmp.Port
import de.cooperateproject.modeling.textual.component.cmp.ConnectorEnd
import de.cooperateproject.modeling.textual.component.cmp.Connector
import de.cooperateproject.modeling.textual.component.cmp.Parameter
import org.apache.commons.lang3.StringUtils
import de.cooperateproject.modeling.textual.common.issues.DependingElementMissingElementResolvableCheckerBase
import org.eclipse.uml2.uml.AttributeOwner

class ComponentMissingUMLElementResolvableChecker extends DependingElementMissingElementResolvableCheckerBase {
	
	protected def dispatch localResolutionPossible(UMLReferencingElement element) {
	    val referencedType = element.eClass.getFeatureType(TextualCommonsPackage.eINSTANCE.UMLReferencingElement_ReferencedElement).EClassifier as EClass
	    return (UMLPackage.eINSTANCE.classifier.isSuperTypeOf(referencedType) 
	         && UMLPackage.eINSTANCE.packageableElement.isSuperTypeOf(referencedType)
	         && (element.hasValidParent(CmpPackage.eINSTANCE.component) || element.hasValidParent(CmpPackage.eINSTANCE.rootPackage)))
	}
	
	protected def dispatch resolvePossible(Component element) {
		if (!element.hasValidParent(TextualCommonsPackage.Literals.UML_REFERENCING_ELEMENT)) {
			return false;
		}
		val parent = element.eContainer as UMLReferencingElement<Element>
		return parent.referencedElementHasEitherType(UMLPackage.Literals.PACKAGE, UMLPackage.Literals.CLASS)
	}
	
	protected def dispatch localResolutionPossible(InterfaceRelation element) {
		return element.hasValidParent(CmpPackage.eINSTANCE.classifier)
	}
	
	protected def dispatch localResolutionPossible(Attribute element) {
		return element.type !== null && element.hasValidParent(CmpPackage.eINSTANCE.classifier)
	}
	
	protected def dispatch localResolutionPossible(Port element) {
		return element.hasValidParent(CmpPackage.eINSTANCE.component)
	}
	
	protected def dispatch localResolutionPossible(ConnectorEnd element) {
		return element.hasValidParent(CmpPackage.eINSTANCE.connector)
	}
	
	protected def dispatch localResolutionPossible(Connector element) {
		return element.name !== null && element.hasValidParent(CmpPackage.eINSTANCE.component) && !element.connectorEnds.map[role].contains(null)
	}
	
	protected def dispatch localResolutionPossible(Method element) {
		return !element.parameters.map[type].contains(null) && !element.parameters.map[name].contains(null) 
		&& element.eContainer !== null
	}
	
    protected def dispatch localResolutionPossible(Parameter element) {
        return element.type !== null && element.type.eResource !== null && StringUtils.isNotBlank(element.name)
    }
    
    protected def dispatch getDependencies(InterfaceRelation object) {
    	#[object.interface]
    }
    
    protected def dispatch getDependencies(Parameter object) {
        object.owner.parameters.take(object.owner.parameters.indexOf(object)).map[it as UMLReferencingElement<? extends Element>].toList => [
            add(0, object.owner)
        ]
    }
    
    protected def dispatch getDependencies(Port object) {
    	#[object.realizedClassifier]
    }
    
    protected def dispatch getDependencies(ConnectorEnd object) {
    	#[object.role]
    }
    
}
{'fraction_non_alphanumeric': 0.08520982599795292, 'fraction_numerical': 0.0014073694984646878, 'mean_word_length': 6.231267345050878, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2150766', 'n_tokens_mistral': 2344, 'n_tokens_neox': 2259, 'n_words': 309}