String settingsDirectory = jEdit.getSettingsDirectory(); if(settingsDirectory == null) return; File recent = new File(MiscUtilities.constructPath( settingsDirectory,"recent.xml")); if(!recent.exists()) return; recentModTime = recent.lastModified(); Log.log(Log.MESSAGE,BufferHistory.class,"Loading recent.xml"); RecentHandler handler = new RecentHandler(); XmlParser parser = new XmlParser(); Reader in = null; parser.setHandler(handler); try { in = new BufferedReader(new FileReader(recent)); parser.parse(null, null, in); } catch(XmlException xe) { int line = xe.getLine(); String message = xe.getMessage(); Log.log(Log.ERROR,BufferHistory.class,recent + ":" + line + ": " + message); } catch(FileNotFoundException fnf) { //Log.log(Log.DEBUG,BufferHistory.class,fnf); } catch(Exception e) { Log.log(Log.ERROR,BufferHistory.class,e); } finally { try { if(in != null) in.close(); } catch(IOException io) { Log.log(Log.ERROR,BufferHistory.class,io); } }
Log.log(Log.MESSAGE,jEdit.class,"Loading mode catalog file " + path); ModeCatalogHandler handler = new ModeCatalogHandler( MiscUtilities.getParentOfPath(path),resource); XmlParser parser = new XmlParser(); parser.setHandler(handler); Reader in = null; try { InputStream _in; if(resource) _in = jEdit.class.getResourceAsStream(path); else _in = new FileInputStream(path); in = new BufferedReader(new InputStreamReader(_in)); parser.parse(null, null, in); } catch(XmlException xe) { int line = xe.getLine(); String message = xe.getMessage(); Log.log(Log.ERROR,jEdit.class,path + ":" + line + ": " + message); } catch(Exception e) { Log.log(Log.ERROR,jEdit.class,e); } finally { try { if(in != null) in.close(); } catch(IOException io) { Log.log(Log.ERROR,jEdit.class,io); } }
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/org/gjt/sp/jedit/BufferHistory.java File path: /jEdit-4.2/src/org/gjt/sp/jedit/jEdit.java
Method name: void load() Method name: void loadModeCatalog(String, boolean)
Number of AST nodes: 15 Number of AST nodes: 12
1
String settingsDirectory = jEdit.getSettingsDirectory();
2
		if(settingsDirectory == null)
3
			return;
4
		File recent = new File(MiscUtilities.constructPath(
5
			settingsDirectory,"recent.xml"));
6
		if(!recent.exists())
7
			return;
8
		recentModTime = recent.lastModified();
9
		Log.log(Log.MESSAGE,BufferHistory.class,"Loading recent.xml");
1
Log.log(Log.MESSAGE,jEdit.class,"Loading 
10
		RecentHandler handler = new RecentHandler(
2
mode catalog file " + path);
3
		ModeCatalogHandler handler = new ModeCatalogHandler(
11
);
4
			MiscUtilities.getParentOfPath(path),resource);
12
		XmlParser parser = new XmlParser();
5
		XmlParser parser = new XmlParser();
13
		Reader in = null;
6
		
14
		parser.setHandler(handler
7
parser.setHandler(handler);
8
		Reader in = null;
9
		try
10
		{
11
			InputStream _in;
12
			if(resource)
15
);
13
				_in = jEdit.class.getResourceAsStream(path);
16
		try
14
			
17
		{
15
else
16
				_in = new FileInputStream(path);
18
			in = new BufferedReader(new FileReader(recent));
17
			in = new BufferedReader(new InputStreamReader(_in));
19
			parser.parse(null, null, in);
18
			parser.parse(null, null, in);
20
		}
19
		}
21
		catch(XmlException xe)
20
		catch(XmlException xe)
22
		{
21
		{
23
			int line = xe.getLine();
22
			int line = xe.getLine();
24
			String message = xe.getMessage();
23
			String message = xe.getMessage();
25
			Log.log(Log.ERROR,BufferHistory.class,recent + ":" + line
24
			Log.log(Log.ERROR,jEdit.class,path + ":" + line
26
				+ ": " + message);
25
				+ ": " + message);
27
		}
26
		}
28
		catch(FileNotFoundException fnf)
27
		
29
		{
30
			//Log.log(Log.DEBUG,BufferHistory.class,fnf);
31
		}
32
		catch(Exception e)
28
catch(Exception e)
33
		{
29
		{
34
			Log.log(Log.ERROR,BufferHistory.class,e);
30
			Log.log(Log.ERROR,jEdit.class,e);
35
		}
31
		}
36
		finally
32
		finally
37
		{
33
		{
38
			try
34
			try
39
			{
35
			{
40
				if(in != null)
36
				if(in != null)
41
					in.close();
37
					in.close();
42
			}
38
			}
43
			catch(IOException io)
39
			catch(IOException io)
44
			{
40
			{
45
				Log.log(Log.ERROR,BufferHistory.class,io);
41
				Log.log(Log.ERROR,jEdit.class,io);
46
			}
42
			}
47
		}
43
		}
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are in different classes
Number of node comparisons10
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)1.8
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    String settingsDirectory = jEdit.getSettingsDirectory();
                                                                                                                      
    2
    if (settingsDirectory == null)
                                                                    
    3
    return;
    3
    return;
    Preondition Violations
    Unmatched return;
                        
    4
    File recent = new File(MiscUtilities.constructPath(settingsDirectory, "recent.xml"));
                                                                                                                                                                              
    5
    if (!recent.exists())
    5
    if (!recent.exists())
    8
    if (resource)
    Differences
    Expression1Expression2Difference
    !recent.exists()resourceTYPE_COMPATIBLE_REPLACEMENT
    8
    if (resource)
    6
    return;
    6
    return;
    Preondition Violations
    Unmatched return;
                        
                                                                                              
    9
    _in = jEdit.class.getResourceAsStream(path);
    Preondition Violations
    Unmatched statement _in=jEdit.class.getResourceAsStream(path); cannot be moved, because it updates a variable modified in other unmapped statements
    9
    _in = jEdit.class.getResourceAsStream(path);
            
    else
                                                                        
    10
    _in = new FileInputStream(path);
    Preondition Violations
    Unmatched statement _in=new FileInputStream(path); cannot be moved, because it updates a variable modified in other unmapped statements
    10
    _in = new FileInputStream(path);
    Precondition Violations (4)
    Row Violation
    1Unmatched return;
    2Unmatched return;
    3Unmatched statement _in=jEdit.class.getResourceAsStream(path); cannot be moved, because it updates a variable modified in other unmapped statements
    4Unmatched statement _in=new FileInputStream(path); cannot be moved, because it updates a variable modified in other unmapped statements