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; } } return false;
if (element.getName().equals(TAG_PARSER)) { String type = element.getAttribute(ATT_TYPE); if (type == null) { logMissingAttribute(element, ATT_TYPE); } else if (element.getAttribute(ATT_CLASS) == null) { logMissingAttribute(element, ATT_CLASS); } else if (add) { Object previous = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(type, 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 an extension parser for '" + type + "'"); } return true; } else { Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove(type); return true; } } return false;
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/plugin/DynamicPackageRegistryReader.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/plugin/ExtensionParserRegistryReader.java
Method name: boolean readElement(IConfigurationElement, boolean) Method name: boolean readElement(IConfigurationElement, boolean)
Number of AST nodes: 15 Number of AST nodes: 15
1
if (element.getName().equals(TAG_RESOURCE))
1
if (element.getName().equals(TAG_PARSER))
2
    {
2
    {
3
      String packageURI = element.getAttribute(ATT_URI);
3
      String type = element.getAttribute(ATT_TYPE);
4
      if (packageURI == null)
4
      if (type == null)
5
      {
5
      {
6
        logMissingAttribute(element, ATT_URI);
6
        logMissingAttribute(element, ATT_TYPE);
7
      }
7
      }
8
      else if (element.getAttribute(ATT_LOCATION) == null)
8
      else if (element.getAttribute(ATT_CLASS) == null)
9
      {
9
      {
10
        logMissingAttribute(element, ATT_LOCATION);
10
        logMissingAttribute(element, ATT_CLASS);
11
      }
11
      }
12
      else if (add)
12
      else if (add)
13
      {
13
      {
14
        Object previous = EPackage.Registry.INSTANCE.put(packageURI, new EPackageDescriptor.Dynamic(element, ATT_LOCATION));
14
        Object previous = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(type, new ResourceFactoryDescriptor(element, ATT_CLASS));
15
        if (previous instanceof PluginClassDescriptor)
15
        if (previous instanceof ResourceFactoryDescriptor)
16
        {
16
        {
17
          PluginClassDescriptor descriptor = (PluginClassDescriptor)previous;
17
          ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;
18
          EcorePlugin.INSTANCE.log
18
          EcorePlugin.INSTANCE.log
19
            ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a package for '" + packageURI + "'");
19
            ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register an extension parser for '" + type + "'");
20
        }
20
        }
21
        
22
        return true;
21
        return true;
23
      }
22
      }
24
      else
23
      else
25
      {
24
      {
26
        EPackage.Registry.INSTANCE.remove(packageURI);
25
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove(type);
27
        return true;
26
        return true;
28
      }
27
      }
29
    }
28
    }
30
    return false;
29
    return false;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)1.3
Clones locationClones are in different classes having the same super class
Number of node comparisons52
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements15
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)26.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (element.getName().equals(TAG_RESOURCE))
    1
    if (element.getName().equals(TAG_RESOURCE))
    1
    if (element.getName().equals(TAG_PARSER))
    Differences
    Expression1Expression2Difference
    TAG_RESOURCETAG_PARSERVARIABLE_NAME_MISMATCH
    1
    if (element.getName().equals(TAG_PARSER))
    2
    String packageURI = element.getAttribute(ATT_URI);
    2
    String packageURI = element.getAttribute(ATT_URI);
    2
    String type = element.getAttribute(ATT_TYPE);
    Differences
    Expression1Expression2Difference
    packageURItypeVARIABLE_NAME_MISMATCH
    ATT_URIATT_TYPEVARIABLE_NAME_MISMATCH
    2
    String type = element.getAttribute(ATT_TYPE);
    3
    if (packageURI == null)
    3
    if (packageURI == null)
    3
    if (type == null)
    Differences
    Expression1Expression2Difference
    packageURItypeVARIABLE_NAME_MISMATCH
    3
    if (type == null)
    4
    logMissingAttribute(element, ATT_URI);
    4
    logMissingAttribute(element, ATT_URI);
    4
    logMissingAttribute(element, ATT_TYPE);
    Differences
    Expression1Expression2Difference
    ATT_URIATT_TYPEVARIABLE_NAME_MISMATCH
    4
    logMissingAttribute(element, ATT_TYPE);
    5
    else if (element.getAttribute(ATT_LOCATION) == null)
    5
    else if (element.getAttribute(ATT_LOCATION) == null)
    5
    else if (element.getAttribute(ATT_CLASS) == null)
    Differences
    Expression1Expression2Difference
    ATT_LOCATIONATT_CLASSVARIABLE_NAME_MISMATCH
    5
    else if (element.getAttribute(ATT_CLASS) == null)
    6
    logMissingAttribute(element, ATT_LOCATION);
    6
    logMissingAttribute(element, ATT_LOCATION);
    6
    logMissingAttribute(element, ATT_CLASS);
    Differences
    Expression1Expression2Difference
    ATT_LOCATIONATT_CLASSVARIABLE_NAME_MISMATCH
    6
    logMissingAttribute(element, ATT_CLASS);
    7
    else if (add)
    7
    else if (add)
    8
    Object previous = EPackage.Registry.INSTANCE.put(packageURI, new EPackageDescriptor.Dynamic(element, ATT_LOCATION));
    8
    Object previous = EPackage.Registry.INSTANCE.put(packageURI, new EPackageDescriptor.Dynamic(element, ATT_LOCATION));
    8
    Object previous = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(type, new ResourceFactoryDescriptor(element, ATT_CLASS));
    Differences
    Expression1Expression2Difference
    packageURItypeVARIABLE_NAME_MISMATCH
    org.eclipse.emf.ecore.plugin.RegistryReader.EPackageDescriptor.Dynamicorg.eclipse.emf.ecore.plugin.RegistryReader.ResourceFactoryDescriptorSUBCLASS_TYPE_MISMATCH
    EPackageDescriptor.DynamicResourceFactoryDescriptorTYPE_COMPATIBLE_REPLACEMENT
    ATT_LOCATIONATT_CLASSVARIABLE_NAME_MISMATCH
    org.eclipse.emf.ecore.EPackage.Registryjava.util.MapSUBCLASS_TYPE_MISMATCH
    EPackage.Registry.INSTANCEResource.Factory.Registry.INSTANCE.getExtensionToFactoryMap()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression new EPackageDescriptor.Dynamic(element,ATT_LOCATION) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new ResourceFactoryDescriptor(element,ATT_CLASS) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8
    Object previous = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(type, new ResourceFactoryDescriptor(element, ATT_CLASS));
    9
    if (previous instanceof PluginClassDescriptor)
    9
    if (previous instanceof PluginClassDescriptor)
    9
    if (previous instanceof ResourceFactoryDescriptor)
    Differences
    Expression1Expression2Difference
    org.eclipse.emf.ecore.plugin.RegistryReader.PluginClassDescriptororg.eclipse.emf.ecore.plugin.RegistryReader.ResourceFactoryDescriptorSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression previous instanceof PluginClassDescriptor cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression previous instanceof ResourceFactoryDescriptor cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9
    if (previous instanceof ResourceFactoryDescriptor)
    10
    PluginClassDescriptor descriptor = (PluginClassDescriptor)previous;
    10
    PluginClassDescriptor descriptor = (PluginClassDescriptor)previous;
    10
    ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;
    Differences
    Expression1Expression2Difference
    org.eclipse.emf.ecore.plugin.RegistryReader.PluginClassDescriptororg.eclipse.emf.ecore.plugin.RegistryReader.ResourceFactoryDescriptorSUBCLASS_TYPE_MISMATCH
    org.eclipse.emf.ecore.plugin.RegistryReader.PluginClassDescriptororg.eclipse.emf.ecore.plugin.RegistryReader.ResourceFactoryDescriptorSUBCLASS_TYPE_MISMATCH
    org.eclipse.emf.ecore.plugin.RegistryReader.PluginClassDescriptororg.eclipse.emf.ecore.plugin.RegistryReader.ResourceFactoryDescriptorSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (PluginClassDescriptor)previous cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (ResourceFactoryDescriptor)previous cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;
    11
    EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a package for '" + packageURI + "'");
    11
    EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a package for '" + packageURI + "'");
    11
    EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register an extension parser for '" + type + "'");
    Differences
    Expression1Expression2Difference
    "' register a package for '""' register an extension parser for '"LITERAL_VALUE_MISMATCH
    packageURItypeVARIABLE_NAME_MISMATCH
    org.eclipse.emf.ecore.plugin.RegistryReader.PluginClassDescriptororg.eclipse.emf.ecore.plugin.RegistryReader.ResourceFactoryDescriptorSUBCLASS_TYPE_MISMATCH
    11
    EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register an extension parser for '" + type + "'");
    12
    return true;
    12
    return true;
    else
    else
    13
    EPackage.Registry.INSTANCE.remove(packageURI);
    13
    EPackage.Registry.INSTANCE.remove(packageURI);
    13
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove(type);
    Differences
    Expression1Expression2Difference
    packageURItypeVARIABLE_NAME_MISMATCH
    org.eclipse.emf.ecore.EPackage.Registryjava.util.MapSUBCLASS_TYPE_MISMATCH
    EPackage.Registry.INSTANCEResource.Factory.Registry.INSTANCE.getExtensionToFactoryMap()TYPE_COMPATIBLE_REPLACEMENT
    13
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove(type);
    14
    return true;
    14
    return true;
    15
    return false;
    15
    return false;
    Precondition Violations (6)
    Row Violation
    1Expression new EPackageDescriptor.Dynamic(element,ATT_LOCATION) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new ResourceFactoryDescriptor(element,ATT_CLASS) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression previous instanceof PluginClassDescriptor cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression previous instanceof ResourceFactoryDescriptor cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression (PluginClassDescriptor)previous cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression (ResourceFactoryDescriptor)previous cannot be parameterized, because it has dependencies to/from statements that will be extracted