if (element.getName().equals(TAG_PARSER)) { String protocolName = element.getAttribute(ATT_PROTOCOLNAME); if (protocolName == null) { logMissingAttribute(element, ATT_PROTOCOLNAME); } else if (element.getAttribute(ATT_CLASS) == null) { logMissingAttribute(element, ATT_CLASS); } else if (add) { Object previous = Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().put(protocolName, 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 protocol parser for '" + protocolName + "'"); } return true; } else { Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().remove(protocolName); return true; } } return false;
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;
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/plugin/ProtocolParserRegistryReader.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: 15 Number of AST nodes: 15
1
if (element.getName().equals(TAG_PARSER))
1
if (element.getName().equals(TAG_RESOURCE))
2
    {
2
    {
3
      String protocolName = element.getAttribute(ATT_PROTOCOLNAME);
3
      String packageURI = element.getAttribute(ATT_URI);
4
      if (protocolName == null)
4
      if (packageURI == null)
5
      {
5
      {
6
        logMissingAttribute(element, ATT_PROTOCOLNAME);
6
        logMissingAttribute(element, ATT_URI);
7
      }
7
      }
8
      else if (element.getAttribute(ATT_CLASS) == null)
8
      else if (element.getAttribute(ATT_LOCATION) == null)
9
      {
9
      {
10
        logMissingAttribute(element, ATT_CLASS);
10
        logMissingAttribute(element, ATT_LOCATION);
11
      }
11
      }
12
      else if (add)
12
      else if (add)
13
      {
13
      {
14
        Object previous = Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().put(protocolName, new ResourceFactoryDescriptor(element, ATT_CLASS));
14
        Object previous = EPackage.Registry.INSTANCE.put(packageURI, new EPackageDescriptor.Dynamic(element, ATT_LOCATION));
15
        if (previous instanceof ResourceFactoryDescriptor)
15
        if (previous instanceof PluginClassDescriptor)
16
        {
16
        {
17
          ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;
17
          PluginClassDescriptor descriptor = (PluginClassDescriptor)previous;
18
          EcorePlugin.INSTANCE.log
18
          EcorePlugin.INSTANCE.log
19
            ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a protocol parser for '" + protocolName + "'");
19
            ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a package for '" + packageURI + "'");
20
        }
20
        }
21
        
21
        return true;
22
        return true;
22
      }
23
      }
23
      else
24
      else
24
      {
25
      {
25
        Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().remove(protocolName);
26
        EPackage.Registry.INSTANCE.remove(packageURI);
26
        return true;
27
        return true;
27
      }
28
      }
28
    }
29
    }
29
    return false;
30
    return false;
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.7
Clones locationClones are in different classes having the same super class
Number of node comparisons52
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements13
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)3.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 protocolName = element.getAttribute(ATT_PROTOCOLNAME);
    2
    String protocolName = element.getAttribute(ATT_PROTOCOLNAME);
    2
    String packageURI = element.getAttribute(ATT_URI);
    Differences
    Expression1Expression2Difference
    protocolNamepackageURIVARIABLE_NAME_MISMATCH
    ATT_PROTOCOLNAMEATT_URIVARIABLE_NAME_MISMATCH
    2
    String packageURI = element.getAttribute(ATT_URI);
    3
    if (protocolName == null)
    3
    if (protocolName == null)
    3
    if (packageURI == null)
    Differences
    Expression1Expression2Difference
    protocolNamepackageURIVARIABLE_NAME_MISMATCH
    3
    if (packageURI == null)
    4
    logMissingAttribute(element, ATT_PROTOCOLNAME);
    4
    logMissingAttribute(element, ATT_PROTOCOLNAME);
    4
    logMissingAttribute(element, ATT_URI);
    Differences
    Expression1Expression2Difference
    ATT_PROTOCOLNAMEATT_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 = EPackage.Registry.INSTANCE.put(packageURI, new EPackageDescriptor.Dynamic(element, ATT_LOCATION));
    Preondition Violations
    Unmatched statement Object previous=EPackage.Registry.INSTANCE.put(packageURI,new EPackageDescriptor.Dynamic(element,ATT_LOCATION)); cannot be moved before or after the extracted code, 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));
    8
    Object previous = Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().put(protocolName, new ResourceFactoryDescriptor(element, ATT_CLASS));
    8
    Object previous = Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().put(protocolName, new ResourceFactoryDescriptor(element, ATT_CLASS));
    Preondition Violations
    Unmatched statement Object previous=Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().put(protocolName,new ResourceFactoryDescriptor(element,ATT_CLASS)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                                                                                                                                                          
    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
    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
    10
    PluginClassDescriptor descriptor = (PluginClassDescriptor)previous;
    11
    EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a protocol parser for '" + protocolName + "'");
    11
    EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a protocol parser for '" + protocolName + "'");
    11
    EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a package for '" + packageURI + "'");
    Differences
    Expression1Expression2Difference
    "' register a protocol parser for '""' register a package for '"LITERAL_VALUE_MISMATCH
    protocolNamepackageURIVARIABLE_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
    EPackage.Registry.INSTANCE.remove(packageURI);
    13
    Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().remove(protocolName);
                                                                                                                                                                                
    14
    return true;
    14
    return true;
    15
    return false;
    15
    return false;
    Precondition Violations (2)
    Row Violation
    1Unmatched statement Object previous=EPackage.Registry.INSTANCE.put(packageURI,new EPackageDescriptor.Dynamic(element,ATT_LOCATION)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement Object previous=Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().put(protocolName,new ResourceFactoryDescriptor(element,ATT_CLASS)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted