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; } } 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/ContentParserRegistryReader.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_PARSER))
1
if (element.getName().equals(TAG_PARSER))
2
    {
2
    {
3
      String contentTypeIdentifier = element.getAttribute(ATT_CONTENT_TYPE_IDENTIFIER);
3
      String type = element.getAttribute(ATT_
4
      if (contentTypeIdentifier
4
TYPE);
5
 == null)
5
      if (type == null)
6
      {
6
      {
7
        logMissingAttribute(element, ATT_CONTENT_TYPE_IDENTIFIER);
7
        logMissingAttribute(element, ATT_TYPE);
8
      }
8
      }
9
      else if (element.getAttribute(ATT_CLASS) == null)
9
      else if (element.getAttribute(ATT_CLASS) == null)
10
      {
10
      {
11
        logMissingAttribute(element, ATT_CLASS);
11
        logMissingAttribute(element, ATT_CLASS);
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 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(type, new ResourceFactoryDescriptor(element, ATT_CLASS));
16
        if (previous instanceof ResourceFactoryDescriptor)
16
        if (previous instanceof ResourceFactoryDescriptor)
17
        {
17
        {
18
          ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;
18
          ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)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 an extension parser for '" + type + "'");
21
        }
21
        }
22
        return true;
22
        return true;
23
      }
23
      }
24
      else
24
      else
25
      {
25
      {
26
        Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().remove(contentTypeIdentifier);
26
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove(type);
27
        return true;
27
        return true;
28
      }
28
      }
29
    }
29
    }
30
    return false;
30
    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)0.7
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)3.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (element.getName().equals(TAG_PARSER))
    1
    if (element.getName().equals(TAG_PARSER))
    2
    String contentTypeIdentifier = element.getAttribute(ATT_CONTENT_TYPE_IDENTIFIER);
    2
    String contentTypeIdentifier = element.getAttribute(ATT_CONTENT_TYPE_IDENTIFIER);
    2
    String type = element.getAttribute(ATT_TYPE);
    Differences
    Expression1Expression2Difference
    contentTypeIdentifiertypeVARIABLE_NAME_MISMATCH
    ATT_CONTENT_TYPE_IDENTIFIERATT_TYPEVARIABLE_NAME_MISMATCH
    2
    String type = element.getAttribute(ATT_TYPE);
    3
    if (contentTypeIdentifier == null)
    3
    if (contentTypeIdentifier == null)
    3
    if (type == null)
    Differences
    Expression1Expression2Difference
    contentTypeIdentifiertypeVARIABLE_NAME_MISMATCH
    3
    if (type == null)
    4
    logMissingAttribute(element, ATT_CONTENT_TYPE_IDENTIFIER);
    4
    logMissingAttribute(element, ATT_CONTENT_TYPE_IDENTIFIER);
    4
    logMissingAttribute(element, ATT_TYPE);
    Differences
    Expression1Expression2Difference
    ATT_CONTENT_TYPE_IDENTIFIERATT_TYPEVARIABLE_NAME_MISMATCH
    4
    logMissingAttribute(element, ATT_TYPE);
    5
    else if (element.getAttribute(ATT_CLASS) == null)
    5
    else if (element.getAttribute(ATT_CLASS) == null)
    6
    logMissingAttribute(element, ATT_CLASS);
    6
    logMissingAttribute(element, ATT_CLASS);
    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 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(type, new ResourceFactoryDescriptor(element, ATT_CLASS));
    Differences
    Expression1Expression2Difference
    contentTypeIdentifiertypeVARIABLE_NAME_MISMATCH
    getContentTypeToFactoryMapgetExtensionToFactoryMapMETHOD_INVOCATION_NAME_MISMATCH
    8
    Object previous = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(type, new ResourceFactoryDescriptor(element, ATT_CLASS));
    9
    if (previous instanceof ResourceFactoryDescriptor)
    9
    if (previous instanceof ResourceFactoryDescriptor)
    10
    ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;
    10
    ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)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 an extension parser for '" + type + "'");
    Differences
    Expression1Expression2Difference
    "' register a content parser for '""' register an extension parser for '"LITERAL_VALUE_MISMATCH
    contentTypeIdentifiertypeVARIABLE_NAME_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
    Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().remove(contentTypeIdentifier);
    13
    Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().remove(contentTypeIdentifier);
    13
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove(type);
    Differences
    Expression1Expression2Difference
    contentTypeIdentifiertypeVARIABLE_NAME_MISMATCH
    getContentTypeToFactoryMapgetExtensionToFactoryMapMETHOD_INVOCATION_NAME_MISMATCH
    13
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove(type);
    14
    return true;
    14
    return true;
    15
    return false;
    15
    return false;
    Precondition Violations (0)
    Row Violation