Mining Repositories for Systematic Edits Presenter: Reinout Stevens Cha-Q
2
adding feature resolving issue adding feature resolving issue 3
Systematic Edits 4
Systematic Edits 4
Systematic Edits 4
Systematic Edits 4
Overview of the Approach Compute Changes Mine Repository public <method-name>(View <param1>, <type> <param2>) { optionsfocuschange(OPTIONS_SHOW_SCHEDULE); } double <method-name>(View <param1>, <type> <param2>) { new Handler().post(new Runnable() { @Override public void run() { optionsfocuschange(OPTIONS_SHOW_SCHEDULE); })} Detect Systematic Edits 5
Computing Changes show_schedule.setOnFocusChangeListener(new … { show_schedule.setOnFocusChangeListener(new … { @Override @Override public void onFocusChange(View v, boolean hasFocus) { public void onFocusChange(View v, boolean hasFocus) { new Handler().post(new Runnable() { optionsfocuschange(OPTIONS_SHOW_SCHEDULE); @Override } public void run() { }); optionsfocuschange(OPTIONS_SHOW_SCHEDULE); }}); } }); show_schedule.setOnTouchListener(new …() { show_schedule.setOnTouchListener(new …() { @Override @Override public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) { new Handler().post(new Runnable() { optionsfocuschange(OPTIONS_SHOW_SCHEDULE); @Override return true; public void run() { } optionsfocuschange(OPTIONS_SHOW_SCHEDULE); }); }}); return true; } Move Insert }); 1. insert(:body, onFocusChange, new Handler()) 2. insert(:identifier,new Hander(),post()) 3. insert(:arguments,post(),new Runnable()) 4. insert(:bodyDeclaration,new Runnable(), public void run()) 5. … 6. move(:body, run(), optionsfocuschange()) 7. … 6
Frequent Itemset Mining Group Items 1 {Bread, Butter} 2 {Beer, Milk, Butter} 3 {Bread, Milk, Butter} 4 {Beer, Butter} 5 {Bread, Milk, Butter} Negara, S. et al. (2014). Mining Fine-grained Code Changes to Detect Unknown Change Patterns . In Proceedings of the 36 th International Conference on Software Engineering (ICSE) (pp. 803–813). May 31 - June 07, 2014, Hyderabad, IN. 7
Frequent Itemset Mining Frequent pattern (support 3) Group Items {Bread, Butter} 1 {Bread, Butter} 2 {Beer, Milk, Butter} Frequent pattern (support 3) {Bread} 3 {Bread, Milk, Butter} 4 {Beer, Butter} … 5 {Bread, Milk, Butter} Negara, S. et al. (2014). Mining Fine-grained Code Changes to Detect Unknown Change Patterns . In Proceedings of the 36 th International Conference on Software Engineering (ICSE) (pp. 803–813). May 31 - June 07, 2014, Hyderabad, IN. 7
Applied to Changes Group Items 1 {Bread, Butter} 2 {Beer, Milk, Butter} 3 {Bread, Milk, Butter} 4 {Beer, Butter} 5 {Bread, Milk, Butter} Q1. How to group changes? Q2. When are two changes considered equal? 8
Grouping Analogy Group Items 1 {Bread, Butter} 2 {Beer, Milk, Butter} 3 {Bread, Beer, Butter} Group Items 1 {Saw, Gloves, Nails} 2 {Hammer, Nails, Wood} 3 {Nails, Gloves, Hammer} Group Items 1 {Coughing Syrup} 2 {Band Aid, Painkillers, Rubbing Alcohol} 3 {Band Aid, Painkillers} 9
Grouping Analogy Group Items Group Items 1 {Bread, Butter, Saw, 1 {Bread, Butter} Gloves, Nails, Syrup} 2 {Beer, Milk, Butter} 2 {Beer, Milk, Butter, 3 {Bread, Beer, Butter} Hammer, Nails, Wood, Band Aid, Painkillers, Group Items Rubbing Alcohol} 1 {Saw, Gloves, Nails} 3 {Bread, Milk, Butter, Nails, Gloves, Hammer, Band 2 {Hammer, Nails, Wood} Aid, Painkillers} 3 {Nails, Gloves, Hammer} Group Items 1 {Coughing Syrup} 2 {Band Aid, Painkillers, Rubbing Alcohol} 3 {Band Aid, Painkillers} 9
Grouping Changes Group Changes insert(:body, onFocusChange, new Handler()) onFocusChange() insert(:identifier,new Hander(),post()) insert(:arguments,post(),new Runnable()) insert(:bodyDeclaration,new Runnable(), public void run()) move(:body, run(), optionsfocuschange()) … onTouch() insert(:body, onTouch, new Handler()) insert(:identifier,new Hander(),post()) insert(:arguments,post(),new Runnable()) insert(:bodyDeclaration,new Runnable(), public void run()) move(:body, run(), optionsfocuschange()) … Method File Package Commit 10
Equality Analogy Transaction Items 1 {White Bread, Butter} 2 {Alcohol-Free Beer, Soy Milk, Margarine} 3 {Brown Bread, Whole Milk, Butter} 4 {Trappist, Chocolate Paste} 5 {French Bread, Skimmed Milk, Butter} Frequent pattern (support 3) {Bread, Butter} 11
show_schedule.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { new Handler().post(new Runnable() { … @Override public void run() { optionsfocuschange(OPTIONS_SHOW_SCHEDULE); }}); setOnFoc setOnTou } usChange chListen Listener }); er show_schedule.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { new Handler().post(new Runnable() { @Override onFocus public void run() { onTouch Change optionsfocuschange(OPTIONS_SHOW_SCHEDULE); }}); return true; } }); new MotionEv new boolean View v Handler. View v ent Handler. hasFocus post() event post() new new Runnable Runnable … … Context options options focus focus change change Modified OPTIONS_ OPTIONS_ SHOW_SCH SHOW_SCH EDULE EDULE 12
TP Vision Data ~1650 Commits Grouped by method ~300 Classes =? Structurally equal ~27000 LOC
Results 500 467 450 400 #Systematic Edits 350 300 250 221 200 150 98 88 100 49 41 50 29 15 10 6 5 5 5 4 4 4 4 0 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 21 #Instances 14
Example: Threading show_schedule.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { + new Handler().post(new Runnable() { + @Override + public void run() { optionsfocuschange(OPTIONS_SHOW_SCHEDULE); + }}); } }); show_schedule.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { + new Handler().post(new Runnable() { + @Override + public void run() { optionsfocuschange(OPTIONS_SHOW_SCHEDULE); + }}); return true; } }); 15
Example: Disable - Log.i(TAG,"programdata dbSize >IPEPGClientServiceConstants.MAX_DB_SIZE"+ dbSize); +//Log.i(TAG,"programdata dbSize >IPEPGClientServiceConstants.MAX_DB_SIZE"+ dbSize); - Log.i(TAG,"programdata dbSize is greater than max limit, deleting programs for scid "+ scid); + //Log.i(TAG,"programdata dbSize is greater than max limit, deleting programs for scid "+ scid); ... 16
Example: Conversion - private Tuning plfTuning; - private TuningDvbC plfTuningDvbc ; - private TuningDvbT plfTuningDvbt; - private TuningDvbSEx plfTuningDvbs; - private OnChangeListener listener; + private ITuning plfTuning; + private ITuningDvbC plfTuningDvbc; + private ITuningDvbT plfTuningDvbt; + private ITuningDvbS plfTuningDvbs; + private TvMediaPlayer tvMpl; + private ITvMediaPlayerContext itvmplctxt; + private ITuning.OnChangeListener listener; 17
Conclusion 467 500 450 400 #SysEdits 350 300 221 250 200 150 98 88 Mine Repository for 100 49 41 29 15 10 5 6 4 5 5 4 4 4 50 0 Systematic Edits 3 4 5 6 7 8 9 10111213141516171821 #Instances 18
Recommend
More recommend