final Map<Object, Object> saveOptions = new HashMap<Object, Object>(); saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); // Do the work within an operation because this is a long running activity that modifies the workbench. // WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { // This is the method that gets invoked when the operation runs. // @Override public void execute(IProgressMonitor monitor) { // Save the resources to the file system. // boolean first = true; for (Resource resource : editingDomain.getResourceSet().getResources()) { if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) { try { long timeStamp = resource.getTimeStamp(); resource.save(saveOptions); if (resource.getTimeStamp() != timeStamp) { savedResources.add(resource); } } catch (Exception exception) { resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); } first = false; } } } }; updateProblemIndication = false; try { // This runs the options, and shows progress. // new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation); // Refresh the necessary state. // ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone(); firePropertyChange(IEditorPart.PROP_DIRTY); } catch (Exception exception) { // Something went wrong that shouldn't. // Ecore2XMLUIPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication();
final Map<Object, Object> saveOptions = new HashMap<Object, Object>(); saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); // Do the work within an operation because this is a long running activity that modifies the workbench. // WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { // This is the method that gets invoked when the operation runs. // @Override public void execute(IProgressMonitor monitor) { // Save the resources to the file system. // boolean first = true; for (Resource resource : editingDomain.getResourceSet().getResources()) { if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) { try { long timeStamp = resource.getTimeStamp(); resource.save(saveOptions); if (resource.getTimeStamp() != timeStamp) { savedResources.add(resource); } } catch (Exception exception) { resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); } first = false; } } } }; updateProblemIndication = false; try { // This runs the options, and shows progress. // new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation); // Refresh the necessary state. // ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone(); firePropertyChange(IEditorPart.PROP_DIRTY); } catch (Exception exception) { // Something went wrong that shouldn't. // EcoreEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication();
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/mapping/ecore2xml/presentation/Ecore2XMLEditor.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/presentation/EcoreEditor.java
Method name: void doSave(IProgressMonitor) Method name: void doSave(IProgressMonitor)
Number of AST nodes: 10 Number of AST nodes: 10
1
final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
1
final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
2
    saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
2
    saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
3
    // Do the work within an operation because this is a long running activity that modifies the workbench.
3
    // Do the work within an operation because this is a long running activity that modifies the workbench.
4
    //
4
    //
5
    WorkspaceModifyOperation operation =
5
    WorkspaceModifyOperation operation =
6
      new WorkspaceModifyOperation()
6
      new WorkspaceModifyOperation()
7
      {
7
      {
8
        // This is the method that gets invoked when the operation runs.
8
        // This is the method that gets invoked when the operation runs.
9
        //
9
        //
10
        @Override
10
        @Override
11
        public void execute(IProgressMonitor monitor)
11
        public void execute(IProgressMonitor monitor)
12
        {
12
        {
13
          // Save the resources to the file system.
13
          // Save the resources to the file system.
14
          //
14
          //
15
          boolean first = true;
15
          boolean first = true;
16
          for (Resource resource : editingDomain.getResourceSet().getResources())
16
          for (Resource resource : editingDomain.getResourceSet().getResources())
17
          {
17
          {
18
            if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource))
18
            if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource))
19
            {
19
            {
20
              try
20
              try
21
              {
21
              {
22
                long timeStamp = resource.getTimeStamp();
22
                long timeStamp = resource.getTimeStamp();
23
                resource.save(saveOptions);
23
                resource.save(saveOptions);
24
                if (resource.getTimeStamp() != timeStamp)
24
                if (resource.getTimeStamp() != timeStamp)
25
                {
25
                {
26
                  savedResources.add(resource);
26
                  savedResources.add(resource);
27
                }
27
                }
28
              }
28
              }
29
              catch (Exception exception)
29
              catch (Exception exception)
30
              {
30
              {
31
                resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
31
                resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
32
              }
32
              }
33
              first = false;
33
              first = false;
34
            }
34
            }
35
          }
35
          }
36
        }
36
        }
37
      };
37
      };
38
    updateProblemIndication = false;
38
    updateProblemIndication = false;
39
    try
39
    try
40
    {
40
    {
41
      // This runs the options, and shows progress.
41
      // This runs the options, and shows progress.
42
      //
42
      //
43
      new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);
43
      new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);
44
      // Refresh the necessary state.
44
      // Refresh the necessary state.
45
      //
45
      //
46
      ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();
46
      ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();
47
      firePropertyChange(IEditorPart.PROP_DIRTY);
47
      firePropertyChange(IEditorPart.PROP_DIRTY);
48
    }
48
    }
49
    catch (Exception exception)
49
    catch (Exception exception)
50
    {
50
    {
51
      // Something went wrong that shouldn't.
51
      // Something went wrong that shouldn't.
52
      //
52
      //
53
      Ecore2XMLUIPlugin.INSTANCE.log(exception);
53
      EcoreEditorPlugin.INSTANCE.log(exception);
54
    }
54
    }
55
    updateProblemIndication = true;
55
    updateProblemIndication = true;
56
    updateProblemIndication();
56
    updateProblemIndication();
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.3
Clones locationClones are in different classes having the same super class
Number of node comparisons36
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)6.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
    1
    final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
    2
    saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
    2
    saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
    3
    WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {...};
    3
    WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {...};
    4
    updateProblemIndication = false;
    4
    updateProblemIndication = false;
    5
    try
    5
    try
    5
    try
    Differences
    Expression1Expression2Difference
    org.eclipse.emf.mapping.ecore2xml.ui.Ecore2XMLUIPluginorg.eclipse.emf.ecore.presentation.EcoreEditorPluginSUBCLASS_TYPE_MISMATCH
    5
    try
    6
    new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);
    6
    new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);
    7
    ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();
    7
    ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();
    8
    firePropertyChange(IEditorPart.PROP_DIRTY);
    8
    firePropertyChange(IEditorPart.PROP_DIRTY);
    9
    updateProblemIndication = true;
    9
    updateProblemIndication = true;
    10
    updateProblemIndication();
    10
    updateProblemIndication();
    Precondition Violations (0)
    Row Violation