if (element.getName().equals(TAG_PARSER)) { String contentTypeIdentifier = element.getAttribute(ATT_CONTENT_TYPE_IDENTIFIER); if (contentTypeIdentifier == null) { logMissingAttribute(element, ATT_CONTENT_TYPE_IDENTIFIER); } else if (element.getAttribute(ATT_CLASS) == null) { logMissingAttribute(element, ATT_CLASS); } else if (add) { Object previous = Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().put(contentTypeIdentifier, new ResourceFactoryDescriptor(element, ATT_CLASS)); if (previous instanceof ResourceFactoryDescriptor) { ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous; EcorePlugin.INSTANCE.log ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a content parser for '" + contentTypeIdentifier + "'"); } return true; } else { Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().remove(contentTypeIdentifier); return true; } }
if (element.getName().equals(TAG_RESOURCE)) { String packageURI = element.getAttribute(ATT_URI); if (packageURI == null) { logMissingAttribute(element, ATT_URI); } else if (element.getAttribute(ATT_LOCATION) == null) { logMissingAttribute(element, ATT_LOCATION); } else if (add) { Object previous = EPackage.Registry.INSTANCE.put(packageURI, new EPackageDescriptor.Dynamic(element, ATT_LOCATION)); if (previous instanceof PluginClassDescriptor) { PluginClassDescriptor descriptor = (PluginClassDescriptor)previous; EcorePlugin.INSTANCE.log ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a package for '" + packageURI + "'"); } return true; } else { EPackage.Registry.INSTANCE.remove(packageURI); return true; } }
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/plugin/ContentParserRegistryReader.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/plugin/DynamicPackageRegistryReader.java
Method name: boolean readElement(IConfigurationElement, boolean) Method name: boolean readElement(IConfigurationElement, boolean)
Number of AST nodes: 14 Number of AST nodes: 14
1
if (element.getName().equals(TAG_PARSER))
1
if (element.getName().equals(TAG_RESOURCE))
2
    {
2
    {
3
      String contentTypeIdentifier = element.getAttribute(ATT_CONTENT_TYPE_IDENTIFIER);
3
      String packageURI = element.getAttribute(ATT_
4
      if (contentTypeIdentifier
4
URI);
5
 == null)
5
      if (packageURI == null)
6
      {
6
      {
7
        logMissingAttribute(element, ATT_CONTENT_TYPE_IDENTIFIER);
7
        logMissingAttribute(element, ATT_URI);
8
      }
8
      }
9
      else if (element.getAttribute(ATT_CLASS) == null)
9
      else if (element.getAttribute(ATT_LOCATION) == null)
10
      {
10
      {
11
        logMissingAttribute(element, ATT_CLASS);
11
        logMissingAttribute(element, ATT_LOCATION);
12
      }
12
      }
13
      else if (add)
13
      else if (add)
14
      {
14
      {
15
        Object previous = Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().put(contentTypeIdentifier, new ResourceFactoryDescriptor(element, ATT_CLASS));
15
        Object previous = EPackage.Registry.INSTANCE.put(packageURI, new EPackageDescriptor.Dynamic(element, ATT_LOCATION));
16
        if (previous instanceof ResourceFactoryDescriptor)
16
        if (previous instanceof PluginClassDescriptor)
17
        {
17
        {
18
          ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;
18
          PluginClassDescriptor descriptor = (PluginClassDescriptor)previous;
19
          EcorePlugin.INSTANCE.log
19
          EcorePlugin.INSTANCE.log
20
            ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a content parser for '" + contentTypeIdentifier + "'");
20
            ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a package for '" + packageURI + "'");
21
        }
21
        }
22
        
22
        return true;
23
        return true;
23
      }
24
      }
24
      else
25
      else
25
      {
26
      {
26
        Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().remove(contentTypeIdentifier);
27
        EPackage.Registry.INSTANCE.remove(packageURI);
27
        return true;
28
        return true;
28
      }
29
      }
29
    }
30
    }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.8
Clones locationClones are in different classes having the same super class
Number of node comparisons51
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements14
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)23.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (element.getName().equals(TAG_PARSER))
    1
    if (element.getName().equals(TAG_PARSER))
    1
    if (element.getName().equals(TAG_RESOURCE))
    Differences
    Expression1Expression2Difference
    TAG_PARSERTAG_RESOURCEVARIABLE_NAME_MISMATCH
    1
    if (element.getName().equals(TAG_RESOURCE))
    2
    String contentTypeIdentifier = element.getAttribute(ATT_CONTENT_TYPE_IDENTIFIER);
    2
    String contentTypeIdentifier = element.getAttribute(ATT_CONTENT_TYPE_IDENTIFIER);
    2
    String packageURI = element.getAttribute(ATT_URI);
    Differences
    Expression1Expression2Difference
    contentTypeIdentifierpackageURIVARIABLE_NAME_MISMATCH
    ATT_CONTENT_TYPE_IDENTIFIERATT_URIVARIABLE_NAME_MISMATCH
    2
    String packageURI = element.getAttribute(ATT_URI);
    3
    if (contentTypeIdentifier == null)
    3
    if (contentTypeIdentifier == null)
    3
    if (packageURI == null)
    Differences
    Expression1Expression2Difference
    contentTypeIdentifierpackageURIVARIABLE_NAME_MISMATCH
    3
    if (packageURI == null)
    4
    logMissingAttribute(element, ATT_CONTENT_TYPE_IDENTIFIER);
    4
    logMissingAttribute(element, ATT_CONTENT_TYPE_IDENTIFIER);
    4
    logMissingAttribute(element, ATT_URI);
    Differences
    Expression1Expression2Difference
    ATT_CONTENT_TYPE_IDENTIFIERATT_URIVARIABLE_NAME_MISMATCH
    4
    logMissingAttribute(element, ATT_URI);
    5
    else if (element.getAttribute(ATT_CLASS) == null)
    5
    else if (element.getAttribute(ATT_CLASS) == null)
    5
    else if (element.getAttribute(ATT_LOCATION) == null)
    Differences
    Expression1Expression2Difference
    ATT_CLASSATT_LOCATIONVARIABLE_NAME_MISMATCH
    5
    else if (element.getAttribute(ATT_LOCATION) == null)
    6
    logMissingAttribute(element, ATT_CLASS);
    6
    logMissingAttribute(element, ATT_CLASS);
    6
    logMissingAttribute(element, ATT_LOCATION);
    Differences
    Expression1Expression2Difference
    ATT_CLASSATT_LOCATIONVARIABLE_NAME_MISMATCH
    6
    logMissingAttribute(element, ATT_LOCATION);
    7
    else if (add)
    7
    else if (add)
    8
    Object previous = Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().put(contentTypeIdentifier, new ResourceFactoryDescriptor(element, ATT_CLASS));
    8
    Object previous = Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().put(contentTypeIdentifier, new ResourceFactoryDescriptor(element, ATT_CLASS));
    8
    Object previous = EPackage.Registry.INSTANCE.put(packageURI, new EPackageDescriptor.Dynamic(element, ATT_LOCATION));
    Differences
    Expression1Expression2Difference
    contentTypeIdentifierpackageURIVARIABLE_NAME_MISMATCH
    org.eclipse.emf.ecore.plugin.RegistryReader.ResourceFactoryDescriptororg.eclipse.emf.ecore.plugin.RegistryReader.EPackageDescriptor.DynamicSUBCLASS_TYPE_MISMATCH
    ResourceFactoryDescriptorEPackageDescriptor.DynamicTYPE_COMPATIBLE_REPLACEMENT
    ATT_CLASSATT_LOCATIONVARIABLE_NAME_MISMATCH
    java.util.Maporg.eclipse.emf.ecore.EPackage.RegistrySUBCLASS_TYPE_MISMATCH
    Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap()EPackage.Registry.INSTANCETYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression new ResourceFactoryDescriptor(element,ATT_CLASS) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new EPackageDescriptor.Dynamic(element,ATT_LOCATION) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8
    Object previous = EPackage.Registry.INSTANCE.put(packageURI, new EPackageDescriptor.Dynamic(element, ATT_LOCATION));
    9
    if (previous instanceof ResourceFactoryDescriptor)
    9
    if (previous instanceof ResourceFactoryDescriptor)
    9
    if (previous instanceof PluginClassDescriptor)
    Differences
    Expression1Expression2Difference
    org.eclipse.emf.ecore.plugin.RegistryReader.ResourceFactoryDescriptororg.eclipse.emf.ecore.plugin.RegistryReader.PluginClassDescriptorSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression previous instanceof ResourceFactoryDescriptor cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression previous instanceof PluginClassDescriptor cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9
    if (previous instanceof PluginClassDescriptor)
    10
    ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;
    10
    ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;
    10
    PluginClassDescriptor descriptor = (PluginClassDescriptor)previous;
    Differences
    Expression1Expression2Difference
    org.eclipse.emf.ecore.plugin.RegistryReader.ResourceFactoryDescriptororg.eclipse.emf.ecore.plugin.RegistryReader.PluginClassDescriptorSUBCLASS_TYPE_MISMATCH
    org.eclipse.emf.ecore.plugin.RegistryReader.ResourceFactoryDescriptororg.eclipse.emf.ecore.plugin.RegistryReader.PluginClassDescriptorSUBCLASS_TYPE_MISMATCH
    org.eclipse.emf.ecore.plugin.RegistryReader.ResourceFactoryDescriptororg.eclipse.emf.ecore.plugin.RegistryReader.PluginClassDescriptorSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (ResourceFactoryDescriptor)previous cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (PluginClassDescriptor)previous cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    PluginClassDescriptor descriptor = (PluginClassDescriptor)previous;
    11
    EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a content parser for '" + contentTypeIdentifier + "'");
    11
    EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a content parser for '" + contentTypeIdentifier + "'");
    11
    EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a package for '" + packageURI + "'");
    Differences
    Expression1Expression2Difference
    "' register a content parser for '""' register a package for '"LITERAL_VALUE_MISMATCH
    contentTypeIdentifierpackageURIVARIABLE_NAME_MISMATCH
    org.eclipse.emf.ecore.plugin.RegistryReader.ResourceFactoryDescriptororg.eclipse.emf.ecore.plugin.RegistryReader.PluginClassDescriptorSUBCLASS_TYPE_MISMATCH
    11
    EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a package for '" + packageURI + "'");
    12
    return true;
    12
    return true;
    else
    else
    13
    Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().remove(contentTypeIdentifier);
    13
    Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().remove(contentTypeIdentifier);
    13
    EPackage.Registry.INSTANCE.remove(packageURI);
    Differences
    Expression1Expression2Difference
    contentTypeIdentifierpackageURIVARIABLE_NAME_MISMATCH
    java.util.Maporg.eclipse.emf.ecore.EPackage.RegistrySUBCLASS_TYPE_MISMATCH
    Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap()EPackage.Registry.INSTANCETYPE_COMPATIBLE_REPLACEMENT
    13
    EPackage.Registry.INSTANCE.remove(packageURI);
    14
    return true;
    14
    return true;
    Precondition Violations (7)
    Row Violation
    1Expression new ResourceFactoryDescriptor(element,ATT_CLASS) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new EPackageDescriptor.Dynamic(element,ATT_LOCATION) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression previous instanceof ResourceFactoryDescriptor cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression previous instanceof PluginClassDescriptor cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression (ResourceFactoryDescriptor)previous cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression (PluginClassDescriptor)previous cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Not all possible execution flows end in a return statement