for (int i = 0; i < dbObjs.length; i++) { ITableInfo ti = (ITableInfo) dbObjs[i]; /////////////////////////////////////////////////////////// // IBM DB 2 specific code to read view definitions. String sql = "SELECT TEXT " + "FROM SYSIBM.SYSVIEWS " + "WHERE NAME = '" + ti.getSimpleName() + "'"; ResultSet res = stat.executeQuery(sql); res.next(); script.append(res.getString("TEXT")); script.append(getStatementSeparator()); res.close(); // /////////////////////////////////////////////////////////// }
for (int i = 0; i < dbObjs.length; i++) { IProcedureInfo pi = (IProcedureInfo) dbObjs[i]; /////////////////////////////////////////////////////////// // SybaseASE specific code to read procedure definitions. String sql = "Select text " + "from sysobjects inner join syscomments on syscomments.id = sysobjects.id " + "where name = '" + pi.getSimpleName().replace(";1", "") + "'"; ResultSet res = stat.executeQuery(sql); while(res.next()) { script.append(res.getString("text")); } script.append(getStatementSeparator()); res.close(); // /////////////////////////////////////////////////////////// }
Clone fragments detected by clone detection tool
File path: /sql12/plugins/example/src/net/sourceforge/squirrel_sql/plugins/example/ScriptDB2ViewAction.java File path: /sql12/plugins/sybase/src/net/sourceforge/squirrel_sql/plugins/SybaseASE/ScriptSybaseASEProcedureAction.java
Method name: void actionPerformed(ActionEvent) Method name: void actionPerformed(ActionEvent)
Number of AST nodes: 8 Number of AST nodes: 8
1
for (int i = 0; i < dbObjs.length; i++)
1
for (int i = 0; i < dbObjs.length; i++)
2
         {
2
         {
3
            ITableInfo ti = (ITableInfo) dbObjs[i];
3
            IProcedureInfo pi = (IProcedureInfo) dbObjs[i];
4
            ///////////////////////////////////////////////////////////
4
            ///////////////////////////////////////////////////////////
5
            // IBM DB 2 specific code to read view definitions.
5
            // SybaseASE specific code to read procedure definitions.
6
            String sql =
6
            String sql =
7
               "SELECT TEXT " +
7
                "Select text " +
8
               "FROM SYSIBM.SYSVIEWS " +
8
                "from sysobjects inner join syscomments on syscomments.id = sysobjects.id " +
9
               "WHERE NAME = '" + ti.getSimpleName() + "'";
9
                "where name = '" + pi.getSimpleName().replace(";1", "") + "'";
10
            ResultSet res = stat.executeQuery(sql);
10
             ResultSet res = stat.executeQuery(sql);
11
            res.next();
11
             while(res.next()
12
)
13
             {
12
            script.append(res.getString("TEXT"));
14
                 script.append(res.getString("
15
text"));            
16
             }
13
            script.append(getStatementSeparator());
17
             script.append(getStatementSeparator());
14
            res.close();
18
             res.close();
15
            //
19
             //
16
            ///////////////////////////////////////////////////////////
20
             ///////////////////////////////////////////////////////////
17
         }
21
         }
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
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 comparisons1