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; } }
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; } }
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/plugin/ExtensionParserRegistryReader.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/plugin/ProtocolParserRegistryReader.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_PARSER))
2
    {
2
    {
3
      String type = element.getAttribute(ATT_TYPE);
3
      String protocolName = element.getAttribute(ATT_PROTOCOLNAME);
4
      if (type == null)
4
      if (protocolName == null)
5
      {
5
      {
6
        logMissingAttribute(element, ATT_TYPE);
6
        logMissingAttribute(element, ATT_PROTOCOLNAME);
7
      }
7
      }
8
      else if (element.getAttribute(ATT_CLASS) == null)
8
      else if (element.getAttribute(ATT_CLASS) == null)
9
      {
9
      {
10
        logMissingAttribute(element, ATT_CLASS);
10
        logMissingAttribute(element, ATT_CLASS);
11
      }
11
      }
12
      else if (add)
12
      else if (add)
13
      {
13
      {
14
        Object previous = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(type, new ResourceFactoryDescriptor(element, ATT_CLASS));
14
        Object previous = Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().put(protocolName, new ResourceFactoryDescriptor(element, ATT_CLASS));
15
        if (previous instanceof ResourceFactoryDescriptor)
15
        if (previous instanceof ResourceFactoryDescriptor)
16
        {
16
        {
17
          ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)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 an extension parser for '" + type + "'");
19
            ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a protocol parser for '" + protocolName + "'");
20
        }
20
        }
21
        return true;
21
        return true;
22
      }
22
      }
23
      else
23
      else
24
      {
24
      {
25
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove(type);
25
        Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().remove(protocolName);
26
        return true;
26
        return true;
27
      }
27
      }
28
    }
28
    }
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.5
Clones locationClones are in different classes having the same super class
Number of node comparisons51
  1. {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)3.0
    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 type = element.getAttribute(ATT_TYPE);
    2
    String type = element.getAttribute(ATT_TYPE);
    2
    String protocolName = element.getAttribute(ATT_PROTOCOLNAME);
    Differences
    Expression1Expression2Difference
    typeprotocolNameVARIABLE_NAME_MISMATCH
    ATT_TYPEATT_PROTOCOLNAMEVARIABLE_NAME_MISMATCH
    2
    String protocolName = element.getAttribute(ATT_PROTOCOLNAME);
    3
    if (type == null)
    3
    if (type == null)
    3
    if (protocolName == null)
    Differences
    Expression1Expression2Difference
    typeprotocolNameVARIABLE_NAME_MISMATCH
    3
    if (protocolName == null)
    4
    logMissingAttribute(element, ATT_TYPE);
    4
    logMissingAttribute(element, ATT_TYPE);
    4
    logMissingAttribute(element, ATT_PROTOCOLNAME);
    Differences
    Expression1Expression2Difference
    ATT_TYPEATT_PROTOCOLNAMEVARIABLE_NAME_MISMATCH
    4
    logMissingAttribute(element, ATT_PROTOCOLNAME);
    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.getExtensionToFactoryMap().put(type, new ResourceFactoryDescriptor(element, ATT_CLASS));
    8
    Object previous = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(type, new ResourceFactoryDescriptor(element, ATT_CLASS));
    8
    Object previous = Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().put(protocolName, new ResourceFactoryDescriptor(element, ATT_CLASS));
    Differences
    Expression1Expression2Difference
    typeprotocolNameVARIABLE_NAME_MISMATCH
    getExtensionToFactoryMapgetProtocolToFactoryMapMETHOD_INVOCATION_NAME_MISMATCH
    8
    Object previous = Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().put(protocolName, 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 an extension parser for '" + type + "'");
    11
    EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register an extension parser for '" + type + "'");
    11
    EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a protocol parser for '" + protocolName + "'");
    Differences
    Expression1Expression2Difference
    "' register an extension parser for '""' register a protocol parser for '"LITERAL_VALUE_MISMATCH
    typeprotocolNameVARIABLE_NAME_MISMATCH
    11
    EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a protocol parser for '" + protocolName + "'");
    12
    return true;
    12
    return true;
    else
    else
    13
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove(type);
    13
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove(type);
    13
    Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().remove(protocolName);
    Differences
    Expression1Expression2Difference
    typeprotocolNameVARIABLE_NAME_MISMATCH
    getExtensionToFactoryMapgetProtocolToFactoryMapMETHOD_INVOCATION_NAME_MISMATCH
    13
    Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().remove(protocolName);
    14
    return true;
    14
    return true;
    Precondition Violations (0)
    Row Violation