if(KeyEvent.VK_SPACE == keyCode && modifiers == KeyEvent.CTRL_MASK) { // Code Completion has been done within Code Completion. // and relaunch completion popup. CompletionCandidates completionCandidates = _model.getCompletionCandidates(_cc.getTextTillCarret()); _sqlEntryPanel.setSelectionStart(replaceBegin); _sqlEntryPanel.setSelectionEnd(_sqlEntryPanel.getCaretPosition()); _sqlEntryPanel.replaceSelection(completionCandidates.getAllCandidatesPrefix(false)); SwingUtilities.invokeLater(new Runnable() { public void run() { _cc.show(); } }); } else if(KeyEvent.VK_TAB == keyCode) { _sqlEntryPanel.setSelectionStart(replaceBegin); _sqlEntryPanel.setSelectionEnd(getNextWhiteSpacePos(_sqlEntryPanel.getCaretPosition())); _sqlEntryPanel.replaceSelection(completion.getCompletionString()); adjustCaret(completion); } else { _sqlEntryPanel.setSelectionStart(replaceBegin); _sqlEntryPanel.setSelectionEnd(_sqlEntryPanel.getCaretPosition()); _sqlEntryPanel.replaceSelection(completion.getCompletionString()); adjustCaret(completion); }
if(KeyEvent.VK_SPACE == keyCode && modifiers == KeyEvent.CTRL_MASK) { // Code Completion has been done within Code Completion. Now just replace what all candidates have in common. CompletionCandidates completionCandidates = _model.getCompletionCandidates(_cc.getTextTillCarret()); _hqlEntryPanel.setSelectionStart(replaceBegin); _hqlEntryPanel.setSelectionEnd(_hqlEntryPanel.getCaretPosition()); _hqlEntryPanel.replaceSelection(completionCandidates.getAllCandidatesPrefix(true)); SwingUtilities.invokeLater(new Runnable() { public void run() { _cc.show(); } }); } else if(KeyEvent.VK_TAB == keyCode) { _hqlEntryPanel.setSelectionStart(replaceBegin); _hqlEntryPanel.setSelectionEnd(getNextWhiteSpacePos(_hqlEntryPanel.getCaretPosition())); _hqlEntryPanel.replaceSelection(completion.getCompletionString()); } else { _hqlEntryPanel.setSelectionStart(replaceBegin); _hqlEntryPanel.setSelectionEnd(_hqlEntryPanel.getCaretPosition()); _hqlEntryPanel.replaceSelection(completion.getCompletionString()); }
Clone fragments detected by clone detection tool
File path: /sql12/plugins/codecompletion/src/net/sourceforge/squirrel_sql/plugins/codecompletion/CompleteCodeAction.java File path: /sql12/plugins/hibernate/src/net/sourceforge/squirrel_sql/plugins/hibernate/completion/HQLCompleteCodeAction.java
Method name: void performCompletionSelected(CodeCompletionInfo, int, int, int) Method name: void performCompletionSelected(CompletionInfo, int, int, int)
Number of AST nodes: 15 Number of AST nodes: 13
1
if(KeyEvent.VK_SPACE == keyCode && modifiers == KeyEvent.CTRL_MASK)
1
if(KeyEvent.VK_SPACE == keyCode && modifiers == KeyEvent.CTRL_MASK)
2
      {
2
      {
3
         // Code Completion has been done within Code Completion.
3
         // Code Completion has been done within Code Completion.
4
         // and relaunch completion popup.  
4
 Now just replace what all candidates have in common.
5
         CompletionCandidates completionCandidates = _model.getCompletionCandidates(_cc.getTextTillCarret());
5
         CompletionCandidates completionCandidates = _model.getCompletionCandidates(_cc.getTextTillCarret());
6
         _sqlEntryPanel.setSelectionStart(replaceBegin);
6
         _hqlEntryPanel.setSelectionStart(replaceBegin);
7
         _sqlEntryPanel.setSelectionEnd(_sqlEntryPanel.getCaretPosition());
7
         _hqlEntryPanel.setSelectionEnd(_hqlEntryPanel.getCaretPosition());
8
         _sqlEntryPanel.replaceSelection(completionCandidates.getAllCandidatesPrefix(false));
8
         _hqlEntryPanel.replaceSelection(completionCandidates.getAllCandidatesPrefix(true));
9
         SwingUtilities.invokeLater(new Runnable()
9
         SwingUtilities.invokeLater(new Runnable()
10
         {
10
         {
11
            public void run()
11
            public void run()
12
            {
12
            {
13
               _cc.show();
13
               _cc.show();
14
            }
14
            }
15
         });
15
         });
16
      }
16
      }
17
      else if(KeyEvent.VK_TAB == keyCode)
17
		else if(KeyEvent.VK_TAB == keyCode)
18
		{
18
		{
19
			_sqlEntryPanel.setSelectionStart(replaceBegin);
19
			_hqlEntryPanel.setSelectionStart(replaceBegin);
20
			_sqlEntryPanel.setSelectionEnd(getNextWhiteSpacePos(_sqlEntryPanel.getCaretPosition()));
20
			_hqlEntryPanel.setSelectionEnd(getNextWhiteSpacePos(_hqlEntryPanel.getCaretPosition()));
21
			_sqlEntryPanel.replaceSelection(completion.getCompletionString());
21
			_hqlEntryPanel.replaceSelection(completion.getCompletionString());
22
         adjustCaret(completion);
23
		}
22
		}
24
		else
23
		else
25
		{
24
		{
26
			_sqlEntryPanel.setSelectionStart(replaceBegin);
25
			_hqlEntryPanel.setSelectionStart(replaceBegin);
27
			_sqlEntryPanel.setSelectionEnd(_sqlEntryPanel.getCaretPosition());
26
			_hqlEntryPanel.setSelectionEnd(_hqlEntryPanel.getCaretPosition());
28
			_sqlEntryPanel.replaceSelection(completion.getCompletionString());
27
			_hqlEntryPanel.replaceSelection(completion.getCompletionString());
29
         adjustCaret(completion);
30
		}
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)2.2
Clones locationClones are in different classes having the same super class
Number of node comparisons142
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements13
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)890.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    if (KeyEvent.VK_SPACE == keyCode && modifiers == KeyEvent.CTRL_MASK)
    1
    if (KeyEvent.VK_SPACE == keyCode && modifiers == KeyEvent.CTRL_MASK)
    2
    CompletionCandidates completionCandidates = _model.getCompletionCandidates(_cc.getTextTillCarret());
    2
    CompletionCandidates completionCandidates = _model.getCompletionCandidates(_cc.getTextTillCarret());
    2
    CompletionCandidates completionCandidates = _model.getCompletionCandidates(_cc.getTextTillCarret());
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.plugins.codecompletion.CodeCompletorModelnet.sourceforge.squirrel_sql.plugins.hibernate.completion.HQLCodeCompletorModelSUBCLASS_TYPE_MISMATCH
    2
    CompletionCandidates completionCandidates = _model.getCompletionCandidates(_cc.getTextTillCarret());
    3
    _sqlEntryPanel.setSelectionStart(replaceBegin);
    3
    _sqlEntryPanel.setSelectionStart(replaceBegin);
    3
    _hqlEntryPanel.setSelectionStart(replaceBegin);
    Differences
    Expression1Expression2Difference
    _sqlEntryPanel_hqlEntryPanelVARIABLE_NAME_MISMATCH
    3
    _hqlEntryPanel.setSelectionStart(replaceBegin);
    4
    _sqlEntryPanel.setSelectionEnd(_sqlEntryPanel.getCaretPosition());
    4
    _sqlEntryPanel.setSelectionEnd(_sqlEntryPanel.getCaretPosition());
    4
    _hqlEntryPanel.setSelectionEnd(_hqlEntryPanel.getCaretPosition());
    Differences
    Expression1Expression2Difference
    _sqlEntryPanel_hqlEntryPanelVARIABLE_NAME_MISMATCH
    _sqlEntryPanel_hqlEntryPanelVARIABLE_NAME_MISMATCH
    4
    _hqlEntryPanel.setSelectionEnd(_hqlEntryPanel.getCaretPosition());
    5
    _sqlEntryPanel.replaceSelection(completionCandidates.getAllCandidatesPrefix(false));
    5
    _sqlEntryPanel.replaceSelection(completionCandidates.getAllCandidatesPrefix(false));
    5
    _hqlEntryPanel.replaceSelection(completionCandidates.getAllCandidatesPrefix(true));
    Differences
    Expression1Expression2Difference
    falsetrueLITERAL_VALUE_MISMATCH
    _sqlEntryPanel_hqlEntryPanelVARIABLE_NAME_MISMATCH
    5
    _hqlEntryPanel.replaceSelection(completionCandidates.getAllCandidatesPrefix(true));
    6
    SwingUtilities.invokeLater(new Runnable() {...});
    6
    SwingUtilities.invokeLater(new Runnable() {...});
    7
    else if (KeyEvent.VK_TAB == keyCode)
    7
    else if (KeyEvent.VK_TAB == keyCode)
    8
    _sqlEntryPanel.setSelectionStart(replaceBegin);
    8
    _sqlEntryPanel.setSelectionStart(replaceBegin);
    8
    _hqlEntryPanel.setSelectionStart(replaceBegin);
    Differences
    Expression1Expression2Difference
    _sqlEntryPanel_hqlEntryPanelVARIABLE_NAME_MISMATCH
    8
    _hqlEntryPanel.setSelectionStart(replaceBegin);
    9
    _sqlEntryPanel.setSelectionEnd(getNextWhiteSpacePos(_sqlEntryPanel.getCaretPosition()));
    9
    _sqlEntryPanel.setSelectionEnd(getNextWhiteSpacePos(_sqlEntryPanel.getCaretPosition()));
    9
    _hqlEntryPanel.setSelectionEnd(getNextWhiteSpacePos(_hqlEntryPanel.getCaretPosition()));
    Differences
    Expression1Expression2Difference
    _sqlEntryPanel_hqlEntryPanelVARIABLE_NAME_MISMATCH
    _sqlEntryPanel_hqlEntryPanelVARIABLE_NAME_MISMATCH
    9
    _hqlEntryPanel.setSelectionEnd(getNextWhiteSpacePos(_hqlEntryPanel.getCaretPosition()));
    10
    _sqlEntryPanel.replaceSelection(completion.getCompletionString());
    10
    _sqlEntryPanel.replaceSelection(completion.getCompletionString());
    10
    _hqlEntryPanel.replaceSelection(completion.getCompletionString());
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.plugins.codecompletion.CodeCompletionInfonet.sourceforge.squirrel_sql.fw.completion.CompletionInfoSUBCLASS_TYPE_MISMATCH
    _sqlEntryPanel_hqlEntryPanelVARIABLE_NAME_MISMATCH
    10
    _hqlEntryPanel.replaceSelection(completion.getCompletionString());
    11
    adjustCaret(completion);
                                                            
    else
    else
    12
    _sqlEntryPanel.setSelectionStart(replaceBegin);
    12
    _sqlEntryPanel.setSelectionStart(replaceBegin);
    11
    _hqlEntryPanel.setSelectionStart(replaceBegin);
    Differences
    Expression1Expression2Difference
    _sqlEntryPanel_hqlEntryPanelVARIABLE_NAME_MISMATCH
    11
    _hqlEntryPanel.setSelectionStart(replaceBegin);
    13
    _sqlEntryPanel.setSelectionEnd(_sqlEntryPanel.getCaretPosition());
    13
    _sqlEntryPanel.setSelectionEnd(_sqlEntryPanel.getCaretPosition());
    12
    _hqlEntryPanel.setSelectionEnd(_hqlEntryPanel.getCaretPosition());
    Differences
    Expression1Expression2Difference
    _sqlEntryPanel_hqlEntryPanelVARIABLE_NAME_MISMATCH
    _sqlEntryPanel_hqlEntryPanelVARIABLE_NAME_MISMATCH
    12
    _hqlEntryPanel.setSelectionEnd(_hqlEntryPanel.getCaretPosition());
    14
    _sqlEntryPanel.replaceSelection(completion.getCompletionString());
    14
    _sqlEntryPanel.replaceSelection(completion.getCompletionString());
    13
    _hqlEntryPanel.replaceSelection(completion.getCompletionString());
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.plugins.codecompletion.CodeCompletionInfonet.sourceforge.squirrel_sql.fw.completion.CompletionInfoSUBCLASS_TYPE_MISMATCH
    _sqlEntryPanel_hqlEntryPanelVARIABLE_NAME_MISMATCH
    13
    _hqlEntryPanel.replaceSelection(completion.getCompletionString());
    15
    adjustCaret(completion);
                                                            
    Precondition Violations (0)
    Row Violation