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; }
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: 13 Number of AST nodes: 13
1
String contentTypeIdentifier = element.getAttribute(ATT_CONTENT_TYPE_IDENTIFIER);
1
String packageURI = element.getAttribute(ATT_
2
      if (contentTypeIdentifier
2
URI);
3
 == null)
3
      if (packageURI == null)
4
      {
4
      {
5
        logMissingAttribute(element, ATT_CONTENT_TYPE_IDENTIFIER);
5
        logMissingAttribute(element, ATT_URI);
6
      }
6
      }
7
      else if (element.getAttribute(ATT_CLASS) == null)
7
      else if (element.getAttribute(ATT_LOCATION) == null)
8
      {
8
      {
9
        logMissingAttribute(element, ATT_CLASS);
9
        logMissingAttribute(element, ATT_LOCATION);
10
      }
10
      }
11
      else if (add)
11
      else if (add)
12
      {
12
      {
13
        Object previous = Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().put(contentTypeIdentifier, new ResourceFactoryDescriptor(element, ATT_CLASS));
13
        Object previous = EPackage.Registry.INSTANCE.put(packageURI, new EPackageDescriptor.Dynamic(element, ATT_LOCATION));
14
        if (previous instanceof ResourceFactoryDescriptor)
14
        if (previous instanceof PluginClassDescriptor)
15
        {
15
        {
16
          ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;
16
          PluginClassDescriptor descriptor = (PluginClassDescriptor)previous;
17
          EcorePlugin.INSTANCE.log
17
          EcorePlugin.INSTANCE.log
18
            ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a content parser for '" + contentTypeIdentifier + "'");
18
            ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a package for '" + packageURI + "'");
19
        }
19
        }
20
        
20
        return true;
21
        return true;
21
      }
22
      }
22
      else
23
      else
23
      {
24
      {
24
        Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().remove(contentTypeIdentifier);
25
        EPackage.Registry.INSTANCE.remove(packageURI);
25
        return true;
26
        return true;
26
      }
27
      }
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.5
Clones locationClones are in different classes having the same super class
Number of node comparisons49
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements11
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)4.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    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 = 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.getContentTypeToFactoryMap().put(contentTypeIdentifier, new ResourceFactoryDescriptor(element, ATT_CLASS));
    8
    Object previous = Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().put(contentTypeIdentifier, new ResourceFactoryDescriptor(element, ATT_CLASS));
    Preondition Violations
    Unmatched statement Object previous=Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().put(contentTypeIdentifier,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 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
    EPackage.Registry.INSTANCE.remove(packageURI);
    13
    Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().remove(contentTypeIdentifier);
                                                                                                                                                                                                        
    14
    return true;
    14
    return true;
    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.getContentTypeToFactoryMap().put(contentTypeIdentifier,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