Eclipse Code Recommenders @ MAJUG 2011

2,482 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,482
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
79
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Eclipse Code Recommenders @ MAJUG 2011

  1. 1. Eclipse CodeRecommendersIDE  2.0:  Leveraging  the  Wisdomof  the  So:ware  Engineering  Crowds eim nhtw:  @MarcelBruch ang+:  +Marcel  Bruch up  M ro r  G se a  U Jav
  2. 2. 2
  3. 3. Eclipse  Code  Recommenders             All Frameworks CodeCode Eclipse CodeDevelopers Who Called “new Text()” Method Also Called setText() addListener() setLayout() setFont() 89% 53% 99% 35%What Do Developers Ultimately Override After Extending This Class? 100 % overwrote PreferencePage.createContents() 96 % overwrote PreferencePage.performOk() 5 % overwrote PreferencePage.performCancel() 3
  4. 4. “Other  developers  frequently  bought  used  the  following  methods…”INTELLIGENT  CODE  COMPLETION
  5. 5. Code  Comple+on…@Overrideprotected Control createDialogArea(final Composite parent) { Composite container = (Composite) super.createDialogArea(parent); swtTextWidget = new Text(container, SWT.BORDER); swtTextWidget.| return container;} What  does  the  developer  need,  i.e.,  which  methods  should   the  code  compleKon  present  to  the  user? 5
  6. 6. All  164  Methods  of  Text  ?
  7. 7. JBuSon?  381  Methods.
  8. 8. Code  Comple+on…@Overrideprotected Control createDialogArea(final Composite parent) { final Composite container = (Composite) super.createDialogArea(parent); swtTextWidget = new Text(container, SWT.BORDER); swtTextWidget.| return container;} What  does  the  developer  need,  i.e.,  which  methods  should   the  code  compleKon  present  to  the  user? 8
  9. 9. Intelligent  Code  Comple+on …  or  just  the  three  missing  ones?   9
  10. 10. How  it  works  -­‐  in  a  nutshell 10
  11. 11. How  it  works  -­‐  in  a  nutshell Framework 10
  12. 12. How  it  works  -­‐  in  a  nutshell Framework Example   Example   ...ApplicaKon  1 ApplicaKon  n 10
  13. 13. How  it  works  -­‐  in  a  nutshell Framework Example   Example   ... ApplicaKon  1 ApplicaKon  nextract  facts  about  how  the  framework  is  reused «extends:A» «extends:A» «overrides:A.b» ... «overrides:A.d» «calls:B.c» «calls:B.c» … … 10
  14. 14. How  it  works  -­‐  in  a  nutshell Framework Example   Example   ... ApplicaKon  1 ApplicaKon  nextract  facts  about  how  the  framework  is  reused «extends:A» «extends:A» «overrides:A.b» ... «overrides:A.d» «calls:B.c» «calls:B.c» … … 10
  15. 15. How  it  works  -­‐  in  a  nutshell Framework If  you   extend  A, Example   Example   you  should   ... call  B.c ApplicaKon  1 ApplicaKon  nextract  facts  about  how  the  framework  is  reused «extends:A» «extends:A» «overrides:A.b» ... «overrides:A.d» «calls:B.c» «calls:B.c» … … 10
  16. 16. From  code  to  models... () ts en () nt Ok Co rm te fo () t() t() t() ea er t> ex on ex cr .p ni tT tF tT e. ge <i se se ge ag Pa t. t. t. t.class Example extends Page { :P n: ex ex ex ex .. Text t; in i T T T T . @Override 1 0 1 1 0 0 … void createContents() { t = new Text(); t.setText(..); .. } 0 1 0 0 0 1 …} … … … … … … … 11
  17. 17. From  code  to  models... () ts en () nt Ok Co rm te fo () t() t() t() ea er t> ex on ex cr .p ni tT tF tT e. ge <i se se ge ag Pa t. t. t. t.class Example extends Page { :P n: ex ex ex ex .. Text t; in i T T T T . @Override 1 0 1 1 0 0 … void performOk() { t.getText(); .. } 0 1 0 0 0 1 …} … … … … … … … 12
  18. 18. From  models  to  recommenda+ons... () ts en () nt Ok Co rmclass MyPage extends Page { te fo () t() t() t() ea er t> ex on ex Text t; cr .p ni tT tF tT @Override e. ge <i se se ge ag Pa t. t. t. t. void createContents() { :P n: ex ex ex ex .. t = new Text(); in i T T T T . t.|<^space> 1 0 1 ? ? ? … }} 13
  19. 19. From  models  to  recommenda+ons... () ts en () nt Ok Co rm te fo () t() t() t() ea er t> ex on ex cr .p ni tT tF tT e. ge <i se se ge ag Pa t. t. t. t. :P n: ex ex ex ex .. in i T T T T . 1 0 1 1 1 0 … 1 0 1 0 0 0 … 1 0 1 1 0 0 … 0 1 0 0 0 1 … … … … … … … … 1 0 1 ? ? ? … 14
  20. 20. From  models  to  recommenda+ons... () ts en () nt Ok Co rm te fo () t() t() t() ea er t> ex on ex cr .p ni tT tF tT e. ge <i se se ge ag Pa t. t. t. t. :P n: ex ex ex ex .. in i T T T T . 1 0 1 1 1 0 … 1 0 1 0 0 0 … 1 0 1 1 0 0 … 0 1 0 0 0 1 … … … … … … … … 1 0 1 ⅔ ? ? ? … 14
  21. 21. From  models  to  recommenda+ons... () ts en () nt Ok Co rm te fo () t() t() t() ea er t> ex on ex cr .p ni tT tF tT e. ge <i se se ge ag Pa t. t. t. t. :P n: ex ex ex ex .. in i T T T T . 1 0 1 1 1 0 … 1 0 1 0 0 0 … 1 0 1 1 0 0 … 0 1 0 0 0 1 … … … … … … … … 1 0 1 ⅔ ? ⅓ ? ? … 14
  22. 22. From  models  to  recommenda+ons... () ts en () nt Ok Co rm te fo () t() t() t() ea er t> ex on ex cr .p ni tT tF tT e. ge <i se se ge ag Pa t. t. t. t. :P n: ex ex ex ex .. in i T T T T . 1 0 1 1 1 0 … 1 0 1 0 0 0 … 1 0 1 1 0 0 … 0 1 0 0 0 1 … … … … … … … … 1 0 1 ⅔ ? ⅓ ? 0 ? … 14
  23. 23. “Welcome  to  the  forest...”CALL-­‐CHAIN  COMPLETION
  24. 24. How  to  obtain  an  instance  of...public class MyView extends ViewPart { public void updateMessage(final String newMessage) { // How do I get an instance of IStatusLineManager? final IStatusLineManager manager = | manager.setMessage(newMessage); } There is no trivial solution anymore. Again, what should code completion return?
  25. 25. What  we  need... !"#$%&( 5#(!"#$*"(#67public void updateMessage(final String newMessage) { // How do I get an instance of )!"#$*"(# final IStatusLineManager manager = this .getViewSite() 5#(+,-./8&167 .getActionBars() .getStatusLineManager(); manager.setMessage(newMessage); )+,-./0&1} 5#(*(&(213"/#4&/&5#67 )*(&(213"/#4&/&5# 17
  26. 26. 01/1 %1"-( 2B&.#)&(& ,#."1- 2B&.# )#*"+# 01BF15"(# ,#+(&-./# D#-7 201-("67(1 E"5(#-# 201-C.7&91-3/#B#-( 234(#-5"1- E&A17( ?=#// 2D3 )"5F/&A ?+1//:& 01-(1/ 23>"(1%&( 2D#-7D&-&.# 2?#*"+#E1+&(1!"#$%&( 28>&F(&6/# 2?#/#+91- 2;1<6#-+=;"->1$ 2G&*".&91-H"5(1A 2;1<6#-+=%&( 2;1<"-.?#( 2;1<6#-+=%&(?"(# 2@#A:"->"-.?#*"+# 234(#-5"1-I&+<# 2;1<6#-+=%&.# 2!"#$,#J##-+# 2!"#$?"(# 2?#/#+91-%1*"># 2!"#$%&( 23>"(1,#J##-+# 2;1<6#-+=;"->1$ 2%&(?#*"+# 2;1<6#-+= 2?#/#+91-?#*"+# 2?#*"+#E1+&(1 2D#-7D&-&.# 28+91-:&5 2?(&(75E"-#D&-&.# 28+91- 2I11/:&D&-&.#
  27. 27. However,  someEmes  you  get...Here,  implicit  user  feedbacks  (“clicks”)  will  help  to  find  the   nt... right  (read  “the  most  commonly  used”)  paths. me e lop ev In  d
  28. 28. Tools  Outline 20
  29. 29. Tools  OutlineIntelligent  Code  CompleEon 20
  30. 30. Tools  OutlineIntelligent  Code  CompleEon Smart  Bug  DetecEon What  have  I  missed? 20
  31. 31. Tools  OutlineIntelligent  Code  CompleEon Smart  Bug  DetecEon What  have  I  missed? Extended  DocumentaEon 20
  32. 32. Tools  OutlineIntelligent  Code  CompleEon Smart  Bug  DetecEon What  have  I  missed? Extended  DocumentaEon Code  Example  Recommender How  do  I  get  an  instance  of…? 20
  33. 33. Tools  OutlineIntelligent  Code  CompleEon Smart  Bug  DetecEon What  have  I  missed? Stacktrace  Search  Engine Extended  DocumentaEon Code  Example  Recommender What  caused  that  stacktrace? How  do  I  get  an  instance  of…? 20
  34. 34. Tools  OutlineIntelligent  Code  CompleEon Smart  Bug  DetecEon What  have  I  missed? Stacktrace  Search  Engine Extended  DocumentaEon Code  Example  Recommender What  caused  that  stacktrace? How  do  I  get  an  instance  of…? 20
  35. 35. Tools  OutlineIntelligent  Code  CompleEon Smart  Bug  DetecEon What  have  I  missed? Stacktrace  Search  Engine Extended  DocumentaEon Code  Example  Recommender x= What  caused  that  stacktrace? How  do  I  get  an  instance  of…? 20
  36. 36. “The  good  ones  in  the  crock,  the  bad  ones  in…  the  problem  view.”SMART  BUG  DETECTION  –  DRIVEN  BY  REAL  USAGES
  37. 37. What’s  wrong  with  this  code? “Hello!” “id” 22
  38. 38. At  run+me  you  get… 23
  39. 39. ...and  a  lengthy  stacktraceorg.eclipse.core.runEme.AsserEonFailedExcepEon:  null  argument: at  org.eclipse.core.runEme.Assert.isNotNull(Assert.java:85) at  org.eclipse.core.runEme.Assert.isNotNull(Assert.java:73) at  org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:174) at  org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:734) at  org.eclipse.jface.wizard.WizardDialog.setWizard(WizardDialog.java:1162) at  org.eclipse.jface.wizard.WizardDialog.updateForPage(WizardDialog.java:1221) at  org.eclipse.jface.wizard.WizardDialog.access$4(WizardDialog.java:1218) at  org.eclipse.jface.wizard.WizardDialog$6.run(WizardDialog.java:1207) at  org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at  org.eclipse.jface.wizard.WizardDialog.showPage(WizardDialog.java:1205) at  org.eclipse.ui.internal.dialogs.ImportExportPage.treeDoubleClicked(ImportExportPage.java) at  org.eclipse.ui.internal.dialogs.ImportPage$2.doubleClick(ImportPage.java:72) at  org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:824) at  org.eclipse.core.runEme.SafeRunner.run(SafeRunner.java:42) at  org.eclipse.ui.internal.JFaceUEl$1.run(JFaceUEl.java:49) at  org.eclipse.jface.uEl.SafeRunnable.run(SafeRunnable.java:175) at  org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:822) at  org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java) at  org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java) ... 24
  40. 40. So what have we missed? 25
  41. 41. If  all  of  your  colleagues  do  it  –  why  don’t  you? 26
  42. 42. If  all  of  your  colleagues  do  it  –  why  don’t  you? 26
  43. 43. How  to  detect  such  wrong  uses? 27
  44. 44. How  to  detect  such  wrong  uses? 27
  45. 45. How  to  detect  such  wrong  uses? 27
  46. 46. How  to  detect  such  wrong  uses? 27
  47. 47. How  to  detect  such  wrong  uses?That’s  “strange” 27
  48. 48. How  to  detect  such  wrong  uses? 28
  49. 49. Just  one  formula… 0 .5 .9 1x = {observed method calls on a variable}E(x) = {exact similar usages for variables of type x in the code base}A(x) = {almost similar usages, i.e., x+1 method call} 29
  50. 50. Missing  Calls  Detector  in  Eclipse . t.. m en elop dev In   30
  51. 51. Applied  on  Eclipse  3.5... 31
  52. 52. “Developers  who  bought  overwrote  this  method  typically  also  overwrote...”USAGE-­‐DRIVEN  JAVADOC
  53. 53. In  good  documenta+on  we  trust.../** * Rollsback the transaction if any and clears different lists to * start with an empty resource again. * Note that the super.doUnload is not called because that clears * the list resulting in all kinds of undesirable inverseremoves. */@Overrideprotected void doUnload() { super.doUnload();} 33
  54. 54. In  good  documenta+on  we  trust.../** * Rollsback the transaction if any and clears different lists to * start with an empty resource again. * Note that the super.doUnload is not called because that clears * the list resulting in all kinds of undesirable inverseremoves. */@Overrideprotected void doUnload() { super.doUnload();} 33
  55. 55. In  good  documenta+on  we  trust.../** * Rollsback the transaction if any and clears different lists to * start with an empty resource again. * Note that the super.doUnload is not called because that clears * the list resulting in all kinds of undesirable inverseremoves. */@Overrideprotected void doUnload() { super.doUnload();} No?  Are  you  sure? 33
  56. 56. In  good documenta+on  we  trust... good  /** * Rollsback the transaction if any and clears different lists to * start with an empty resource again. * Note that the super.doUnload is not called because that clears * the list resulting in all kinds of undesirable inverseremoves. */@Overrideprotected void doUnload() { super.doUnload();} No?  Are  you  sure? 33
  57. 57. Genera+ng  high-­‐quality  API  documenta+on 34
  58. 58. Genera+ng  high-­‐quality  API  documenta+on /** * The number of questions. */ private int numberOfQuestions; /** * Sets the number of questions. * * @param numberOfQuestions the number of questions * @throws IllegalArgumentException the illegal argument exception */ public void setNumberOfQuestions(int numberOfQuestions) throws IllegalArgumentException { if (numberOfQuestions < 0) { throw new IllegalArgumentException("numberOfQuestions < 0"); } this.numberOfQuestions = numberOfQuestions; } 34
  59. 59. Genera+ng  high-­‐quality  API  documenta+on /** * The number of questions. */ private int numberOfQuestions; /** * Sets the number of questions. * * @param numberOfQuestions the number of questions * @throws IllegalArgumentException the illegal argument exception */ public void setNumberOfQuestions(int numberOfQuestions) throws IllegalArgumentException { if (numberOfQuestions < 0) { throw new IllegalArgumentException("numberOfQuestions < 0"); } this.numberOfQuestions = numberOfQuestions; } 34
  60. 60. Genera+ng  high-­‐quality  API  documenta+on /** * The number of questions. */ private int numberOfQuestions; /** * Sets the number of questions. * * @param numberOfQuestions the number of questions * @throws IllegalArgumentException the illegal argument exception */ public void setNumberOfQuestions(int numberOfQuestions) throws IllegalArgumentException { if (numberOfQuestions < 0) { throw new IllegalArgumentException("numberOfQuestions < 0"); } this.numberOfQuestions = numberOfQuestions; } 34
  61. 61. Genera+ng  high-­‐quality  API  documenta+on /** * The number of questions. */ private int numberOfQuestions; /** * Sets the number of questions. * * @param numberOfQuestions the number of questions * @throws IllegalArgumentException the illegal argument exception */ public void setNumberOfQuestions(int numberOfQuestions) throws IllegalArgumentException { if (numberOfQuestions < 0) { throw new IllegalArgumentException("numberOfQuestions < 0"); } this.numberOfQuestions = numberOfQuestions; } 34
  62. 62. Genera+ng  high-­‐quality  API  documenta+on /** * The number of questions. */ private int numberOfQuestions; /** * Sets the number of questions. * * @param numberOfQuestions the number of questions * @throws IllegalArgumentException the illegal argument exception */ public void setNumberOfQuestions(int numberOfQuestions) throws IllegalArgumentException { if (numberOfQuestions < 0) { throw new IllegalArgumentException("numberOfQuestions < 0"); } this.numberOfQuestions = numberOfQuestions; } 34
  63. 63. Genera+ng  high-­‐quality  API  documenta+on /** * The number of questions. */ private int numberOfQuestions; /** * Sets the number of questions. * * @param numberOfQuestions the number of questions * @throws IllegalArgumentException the illegal argument exception */ public void setNumberOfQuestions(int numberOfQuestions) throws IllegalArgumentException { if (numberOfQuestions < 0) { throw new IllegalArgumentException("numberOfQuestions < 0"); } this.numberOfQuestions = numberOfQuestions; } 34
  64. 64. Genera+ng  high-­‐quality  API  documenta+on /** * The number of questions. */ private int numberOfQuestions; /** * Sets the number of questions. * * @param numberOfQuestions the number of questions * @throws IllegalArgumentException the illegal argument exception */ public void setNumberOfQuestions(int numberOfQuestions) throws IllegalArgumentException { if (numberOfQuestions < 0) { throw new IllegalArgumentException("numberOfQuestions < 0"); } this.numberOfQuestions = numberOfQuestions; } 34
  65. 65. Genera+ng  high-­‐quality API  documenta+on high-­‐quality   /** * The number of questions. */ private int numberOfQuestions; /** * Sets the number of questions. * * @param numberOfQuestions the number of questions * @throws IllegalArgumentException the illegal argument exception */ public void setNumberOfQuestions(int numberOfQuestions) throws IllegalArgumentException { if (numberOfQuestions < 0) { throw new IllegalArgumentException("numberOfQuestions < 0"); } this.numberOfQuestions = numberOfQuestions; } 35
  66. 66. Genera+ng  high-­‐quality  API  documenta+on /** * The number of questions. */ private int numberOfQuestions; /** * Sets the number of questions. * * @param numberOfQuestions the number of questions * @throws IllegalArgumentException the illegal argument exception */ public void setNumberOfQuestions(int numberOfQuestions) throws IllegalArgumentException { if (numberOfQuestions < 0) { throw new IllegalArgumentException("numberOfQuestions < 0"); } this.numberOfQuestions = numberOfQuestions; } 35
  67. 67. What  people  say  about  JAutodoc... 36
  68. 68. What  people  say  about  JAutodoc...User: Anonymous Rating: 9 2009-08-02 11:32:37Wow exactly what I needed! 36
  69. 69. What  people  say  about  JAutodoc...User: Anonymous Rating: 9 2009-08-02 11:32:37Wow exactly what I needed!User: Anonymous Rating: 9 2009-02-13 19:58:32Thank you... this plugin rocks! 36
  70. 70. What  people  say  about  JAutodoc...User: Anonymous Rating: 9 2009-08-02 11:32:37Wow exactly what I needed!User: Anonymous Rating: 9 2009-02-13 19:58:32Thank you... this plugin rocks!User: Anonymous Rating: 9 2009-02-13 19:58:32Works perfectly. Smarter than I expected! 36
  71. 71. What  people  say  about  JAutodoc...User: Anonymous Rating: 9 2009-08-02 11:32:37Wow exactly what I needed!User: Anonymous Rating: 9 2009-02-13 19:58:32Thank you... this plugin rocks!User: Anonymous Rating: 9 2009-02-13 19:58:32Works perfectly. Smarter than I expected! WTH?  What  did  you  expect?! 36
  72. 72. How  Recommenders  is  coming  to  rescue... 37
  73. 73. Some  facts  about  the documentaEon  of  overridable  methodsOverridable 2.074Overridden 623 0 700 1400 2100 38
  74. 74. What  clients  do  with  your  API... Overridden 623 Documented * 155 0 325 650*  documented  as  overridable  by  using  phrases  like  “clients  may/should/must  override/extend  this  method” 39
  75. 75. What  clients  do  with  your  API... Overridden 623 Documented * 155 468 0 325 650*  documented  as  overridable  by  using  phrases  like  “clients  may/should/must  override/extend  this  method” 39
  76. 76. What  documenta+on  would  you  expect  when   subclassing  Dialog? package org.eclipse.recommenders.examples.demo; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.window.IShellProvider; public class MyDialog extends Dialog { protected MyDialog(final IShellProvider parentShell) { super(parentShell); } } 40
  77. 77. What  Javadoc  gives  you...org.eclipse.jface.dialogs.Dialog 41
  78. 78. What  Javadoc  gives  you... org.eclipse.jface.dialogs.DialogA  dialog  is  a  specialized  window  used  for  narrow-­‐focused  communicaEon  with  the  user.   41
  79. 79. What  Javadoc  gives  you... org.eclipse.jface.dialogs.DialogA  dialog  is  a  specialized  window  used  for  narrow-­‐focused  communicaEon  with  the  user.  Dialogs  are  usually  modal.  Consequently,  it  is  generally  bad  pracEce  to  open  a  dialog  without  a  parent.  A  modal  dialog  without  a  parent  is  not  prevented  from  disappearing  behind  the  applicaEons  other  windows,  making  it  very  confusing  for  the  user.  If  there  is  more  than  one  modal  dialog  is  open  the  second  one  should  be  parented  off  of  the  shell  of  the  first  one  otherwise  it  is  possible  that  the  OS  will  cus  to  the  first  dialog  potenEally  blocking  the  UI.   41
  80. 80. What  Javadoc  gives  you... org.eclipse.jface.dialogs.Dialog A  dialog  is  a  specialized  window  used  for  narrow-­‐focused   communicaEon  with  the  user.   Dialogs  are  usually  modal.  Consequently,  it  is  generally   bad  pracEce  to  open  a  dialog  without  a  parent.  A  modal   dialog  without  a  parent  is  not  prevented  from   But what are the disappearing  behind  the  applicaEons  other  windows,   making  it  very  confusing  for  the  user.  hot-spots of Dialog? If  there  is  more  than  one  modal  dialog  is  open  the  second   one  should  be  parented  off  of  the  shell  of  the  first  one   otherwise  it  is  possible  that  the  OS  will  cus  to  the  first   dialog  potenEally  blocking  the  UI.   41
  81. 81. What  code  comple+on  offers... 42
  82. 82. What  code  comple+on  offers...Which of the 56 methods should we override? 42
  83. 83. Recommending  method  overrides...public class MyDialog extends Dialog { 43
  84. 84. Recommending  Self-­‐Callspublic class MyWizard extends Wizard {! @Override public void addPages() { }; 44
  85. 85. Mining  for  Subclassing  pa`ernspublic class MyViewerSorter extends ViewerSorter { 45
  86. 86. Mining  example  code  snippetspublic class MyDialog extends Dialog { @Override protected Control createDialogArea(Composite parent) { 46
  87. 87. Sca`ered  Resources 47
  88. 88. Extended  Documenta+on  Plaaorm + Machine Learning 48
  89. 89. Extended  Documenta+on  Plaaorm + Machine Learning 48
  90. 90. Extended  Documenta+on 49
  91. 91. How  it  works  -­‐  in  a  nutshell 50
  92. 92. “Why  is  Google  Codesearch  not  ‘google  for  code  search’?  ”CODE-­‐SEARCH  ENGINES  LIFT  OFF
  93. 93. How  many  request  per  minutes  do code  search  engines  have? 52
  94. 94. 20Number  for  koders.com  in  2009  according  to    “Analyzing  and  mining  a  code  search  engine  usage  log” h`p://dx.doi.org/10.1007/s10664-­‐010-­‐9144-­‐6 53
  95. 95. Naviga+ng  the  API  jungle…private CompilationUnit createCompilationUnit(String source) { // how can I create and configure an ASTParser? ASTParser parser = null; parser.setSource(source.toCharArray()); // ASTParser --> CompilationUnit: how? CompilationUnit cu = null; return cu;} 54
  96. 96. Naviga+ng  the  API  jungle… private CompilationUnit createCompilationUnit(String source) { // how can I create and configure an ASTParser? ASTParser parser = null; parser.setSource(source.toCharArray()); // ASTParser --> CompilationUnit: how? CompilationUnit cu = null; return cu; } How  to  solveString  -­‐>  ASTParser  -­‐>  CompilaKonUnit? 54
  97. 97. When  asking  Google  code  search... 55
  98. 98. When  asking  Google  code  search... 55
  99. 99. When  asking  Google  code  search... 55
  100. 100. When  asking  Google  code  search... 55
  101. 101. Why? 56
  102. 102. Why? Text-based retrieval! 56
  103. 103. Why? Text-based retrieval! Inexpressive query language! 56
  104. 104. Why? Text-based retrieval! Inexpressive query language! Ignores prior knowledge! 56
  105. 105. Example  code  search  enginepublic class MyJavaEditor extends EditorPart { private CompilationUnit createCompilationUnit(String source) { // how can I create and configure an ASTParser? ASTParser parser = null; parser.setSource(source.toCharArray()); // ASTParser --> CompilationUnit: how? CompilationUnit cu = null; return cu; } 57
  106. 106. Example  code  search  enginepublic class MyJavaEditor extends EditorPart { private CompilationUnit createCompilationUnit(String source) { // how can I create and configure an ASTParser? ASTParser parser = null; parser.setSource(source.toCharArray()); // ASTParser --> CompilationUnit: how? CompilationUnit cu = null; return cu; } 57
  107. 107. Example  code  search  enginepublic class MyJavaEditor extends EditorPart { private CompilationUnit createCompilationUnit(String source) { // how can I create and configure an ASTParser? ASTParser parser = null; parser.setSource(source.toCharArray()); Query // ASTParser --> CompilationUnit: how? CompilationUnit cu = null; return cu; } 57
  108. 108. Example  code  search  enginepublic class MyJavaEditor extends EditorPart { private CompilationUnit createCompilationUnit(String source) { // how can I create and configure an ASTParser? ASTParser parser = null; parser.setSource(source.toCharArray()); Query // ASTParser --> CompilationUnit: how? CompilationUnit cu = null; return cu; } 57
  109. 109. Example  code  search  enginepublic class MyJavaEditor extends EditorPart { private CompilationUnit createCompilationUnit(String source) { // how can I create and configure an ASTParser? ASTParser parser = null; parser.setSource(source.toCharArray()); Query // ASTParser --> CompilationUnit: how? CompilationUnit cu = null; return cu; } 57
  110. 110. Example  code  search  enginepublic class MyJavaEditor extends EditorPart { private CompilationUnit createCompilationUnit(String source) { // how can I create and configure an ASTParser? ASTParser parser = null; parser.setSource(source.toCharArray()); Query // ASTParser --> CompilationUnit: how? CompilationUnit cu = null; return cu; } 57
  111. 111. Example  code  search  enginepublic class MyJavaEditor extends EditorPart { private CompilationUnit createCompilationUnit(String source) { // how can I create and configure an ASTParser? ASTParser parser = null; parser.setSource(source.toCharArray()); Query // ASTParser --> CompilationUnit: how? CompilationUnit cu = null; return cu; } 57
  112. 112. Sample  search  queryExtracted from MyJavaEditor.createCompilationUnit():--- data ---extends: org.eclipse.ui.EditorPartuses: org.eclipse.jdt.core.CompilationUnituses: org.eclipse.jdt.core.ASTParsercalls: org.eclipse.jdt.core.ASTParser.setSource(char[])--- requested ---def: org.eclipse.jdt.core.CompilationUnit (def=null)def: org.eclipse.jdt.core.ASTParser (def=null) . t.. m en elop dev In   58
  113. 113. “Why  is  Google  Codesearch  not  ‘google  for  code  search’?  ”LEVERAGING  USER  FEEDBACK  TOIMPROVE  CODE  SEARCH  ENGINES
  114. 114. Leveraging  user  feedback 60
  115. 115. Leveraging  user  feedback 60
  116. 116. Refine  the  ranking  based  on  feedback 61
  117. 117. Refine  the  ranking  based  on  feedback 61
  118. 118. Learning  how  to  rank 62
  119. 119. Ranking  the  examples 63
  120. 120. Ranking  the  examplesdocument 63
  121. 121. Ranking  the  examplesdocument query 63
  122. 122. Ranking  the  examplesdocument query feature-­‐score  i [0..1] 63
  123. 123. Ranking  the  examplesdocument query weight   feature-­‐score  i (-­‐∞..+∞) [0..1] 63
  124. 124. Upda+ng  the  feature  weights... 64
  125. 125. Upda+ng  the  feature  weights... 64
  126. 126. Upda+ng  the  feature  weights...10.000  ∗ 64
  127. 127. Benefits  of  automated  tweaking#  kendall’s  ι #  queries baseline click-­‐through 65
  128. 128. Interac+ons  diagram Client Server 1 Developer «triggers»2 Search Invocation 3 Code Snippet Ranking Incomplete Source Code Query Ranking Search Function Index4 Code Snippet Presentation Code «updates» Examples 5 Feedback Processing Code Code Summarization Highlighter Weights Learning Clickthrough Cli kth h Function data 66
  129. 129. Applica+on  scenarios  for  your    company Open  Source Repositories Company Repositories 67
  130. 130. Applica+on  scenarios  for  your    company Open  Source Repositories Company Repositories 67
  131. 131. Applica+on  scenarios  for  your    company Open  Source Repositories Company Repositories 67
  132. 132. Applica+on  scenarios  for  your    company Open  Source Repositories Company Repositories 67
  133. 133. Applica+on  scenarios  for  your    company Open  Source Repositories Company Repositories Filesystem   67
  134. 134. “People  that  bought  had  this  NullPointerExcepKon,  made  this  mistake:...”WHAT  CAUSED  THAT  STACKTRACE?
  135. 135. So  far  we  have… 69
  136. 136. So  far  we  have…Intelligent  Code  CompleEon 69
  137. 137. So  far  we  have…Intelligent  Code  CompleEon Extended  DocumentaEon 69
  138. 138. So  far  we  have…Intelligent  Code  CompleEon Extended  DocumentaEon Code  Example  Recommender How  do  I  get  an  instance  of…? 69
  139. 139. So  far  we  have…Intelligent  Code  CompleEon Extended  DocumentaEon Smart  Bug  DetecEon Code  Example  Recommender What  have  I  missed? How  do  I  get  an  instance  of…? 69
  140. 140. But  what  if  you  get  this? 70
  141. 141. Debugging  –  the  old  way 71
  142. 142. Debugging  –  the  old  way 71
  143. 143. Debugging  –  the  old  way 72
  144. 144. But  more  ojen  we  get… 73
  145. 145. How  can  we  fix  that?  Don’t  stacktraces  share  some  commonali+es? 74
  146. 146. How  can  we  fix  that?   Don’t  stacktraces  share  some  commonali+es?org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:3884) at org.eclipse.swt.SWT.error(SWT.java:3799) at org.eclipse.swt.SWT.error(SWT.java:3770) at org.eclipse.swt.widgets.Widget.error(Widget.java:463) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:355) at org.eclipse.swt.widgets.ProgressBar.setSelection(ProgressBar.java:317) at org.eclipselabs.cr.stacktraces.demo.ThreadDemo$1.run(Unknown Source) at java.lang.Thread.run(Thread.java:619) 74
  147. 147. How  can  we  fix  that?   Don’t  stacktraces  share  some  commonali+es? excepEon  typeorg.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:3884) at org.eclipse.swt.SWT.error(SWT.java:3799) at org.eclipse.swt.SWT.error(SWT.java:3770) at org.eclipse.swt.widgets.Widget.error(Widget.java:463) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:355) at org.eclipse.swt.widgets.ProgressBar.setSelection(ProgressBar.java:317) at org.eclipselabs.cr.stacktraces.demo.ThreadDemo$1.run(Unknown Source) at java.lang.Thread.run(Thread.java:619) 74
  148. 148. How  can  we  fix  that?   Don’t  stacktraces  share  some  commonali+es? excepEon  type messageorg.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:3884) at org.eclipse.swt.SWT.error(SWT.java:3799) at org.eclipse.swt.SWT.error(SWT.java:3770) at org.eclipse.swt.widgets.Widget.error(Widget.java:463) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:355) at org.eclipse.swt.widgets.ProgressBar.setSelection(ProgressBar.java:317) at org.eclipselabs.cr.stacktraces.demo.ThreadDemo$1.run(Unknown Source) at java.lang.Thread.run(Thread.java:619) 74
  149. 149. How  can  we  fix  that?   Don’t  stacktraces  share  some  commonali+es? excepEon  type messageorg.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:3884) at org.eclipse.swt.SWT.error(SWT.java:3799) at org.eclipse.swt.SWT.error(SWT.java:3770) at org.eclipse.swt.widgets.Widget.error(Widget.java:463) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:355) at org.eclipse.swt.widgets.ProgressBar.setSelection(ProgressBar.java:317) at org.eclipselabs.cr.stacktraces.demo.ThreadDemo$1.run(Unknown Source) at java.lang.Thread.run(Thread.java:619) stackframes 74
  150. 150. How  can  we  fix  that?   Don’t  stacktraces  share  some  commonali+es? excepEon  type messageorg.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:3884) at org.eclipse.swt.SWT.error(SWT.java:3799) at org.eclipse.swt.SWT.error(SWT.java:3770) at org.eclipse.swt.widgets.Widget.error(Widget.java:463) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:355) at org.eclipse.swt.widgets.ProgressBar.setSelection(ProgressBar.java:317) at org.eclipselabs.cr.stacktraces.demo.ThreadDemo$1.run(Unknown Source) at java.lang.Thread.run(Thread.java:619) stackframes other  informaEon 74
  151. 151. How  about  stacktraces.org? 75
  152. 152. Knowledge  sources ForumsEclipse htp://stacktraces.orgWebplasorm Mailing  Lists 76
  153. 153. Applica+on  scenarios  for  your    company Community-­‐ driven  (forums,   mailinglists,...) Company Knowledgebase 77
  154. 154. “Templates  meet  Social  -­‐  reloaded!”SNIPMATCH
  155. 155. Eclipse  Java  Editor  Templates
  156. 156. Eclipse  Java  Editor  Templates 42x  Java  Templates.
  157. 157. Eclipse  Java  Editor  Templates 42x  Java  Templates. 35x  SWT  Templates.
  158. 158. Eclipse  Java  Editor  Templates 42x  Java  Templates. 35x  SWT  Templates. 7  Years.
  159. 159. The  rise  of  code  snippet  repositories and  many  more...
  160. 160. Searching  snippets  in  your  IDE...
  161. 161. “IDE  2.0?  Leveraging  the  wisdom  of  the  (Eclipse)  community…”ECLIPSE  CODE  RECOMMENDERS
  162. 162. From  IDE  1.0  to  IDE  2.0 83
  163. 163. From  IDE  1.0  to  IDE  2.0 83
  164. 164. Build  directly  from  version  control -­‐  or  p2/m2  repository... P2 84
  165. 165. Leveraging  your  IDE’s  build  environment 85
  166. 166. Leveraging  your  IDE’s  build  environment projectenvironment 85
  167. 167. Leveraging  your  IDE’s  build  environment context projectenvironment 85
  168. 168. Leveraging  your  IDE’s  build  environment context object usage projectenvironment 85
  169. 169. Leveraging  your  IDE’s  build  environment context object usage project selectedenvironment proposals 85
  170. 170. Leveraging  your  IDE’s  build  environment context object usage project selectedenvironment proposals click feedback 85
  171. 171. Leveraging  your  IDE’s  build  environment context object usage project selectedenvironment proposals click feedback Stacktraces 85
  172. 172. Crowd-­‐sourcing... 86
  173. 173. “Yours  is  ours  and  mine  is  mine...”BUT  HOW  ABOUT  PRIVACY?
  174. 174. Usage  data  sharing  exampleimport com.mycompany.*;import org.eclipse.*;public class MyCompanyDialog extends Dialog implements ICompanyService { MyCompanyController controller = new MyCompanyController(); @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); Button sync = new Button(container, SWT.CHECK); sync.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (sync.getSelection()) { controller.synchronize(); // lot of more things done with controller } } }); return container; } @Override public void myCompanyServiceMethod() { controller.setup(); }} 88
  175. 175. Usage  data  sharing  exampleimport com.mycompany.*;import org.eclipse.*;public class MyCompanyDialog extends Dialog implements ICompanyService { MyCompanyController controller = new MyCompanyController(); @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); Button sync = new Button(container, SWT.CHECK); sync.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (sync.getSelection()) { controller.synchronize(); // lot of more things done with controller } } }); return container; } @Override public void myCompanyServiceMethod() { controller.setup(); }} 88
  176. 176. Informa+on  cleared  by  privacy  selngsimport com.mycompany.*;import org.eclipse.*;public class MyCompanyDialog extends Dialog implements ICompanyService { MyCompanyController controller = new MyCompanyController(); @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); Button sync = new Button(container, SWT.CHECK); sync.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (sync.getSelection()) { controller.synchronize(); // lot of more things done with controller } } }); return container; } @Override public void myCompanyServiceMethod() { controller.setup(); }} 89
  177. 177. Effec+ve  usage  data  sharedimport com.mycompany.*;import org.eclipse.*;public class MyCompanyDialog extends Dialog implements ICompanyService { MyCompanyController controller = new MyCompanyController(); @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); Button sync = new Button(container, SWT.CHECK); sync.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (sync.getSelection()) { controller.synchronize(); } } }); return container; } @Override public void myCompanyServiceMethod() { controller.setup(); }} 90
  178. 178. Effec+ve  usage  data  sharedimport com.mycompany.*;import org.eclipse.*;public class MyCompanyDialog extends Dialog implements ICompanyService { MyCompanyController controller = new MyCompanyController(); @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); Button sync = new Button(container, SWT.CHECK); sync.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (sync.getSelection()) { controller.synchronize(); } Only  the  informaKon  how  you   } }); return container; } used  Eclipse  is  shared. @Override public void myCompanyServiceMethod() { controller.setup(); }} 90
  179. 179. “Support  your  own  framework.  Live  walk-­‐through...”RECOMMENDERS  FOR  ANDROID
  180. 180. TextViewsLinearLayout ListAcEvity 92
  181. 181. “Support  your  own  framework.  Live  walk-­‐through...”TEAM  SERVER  FOR  ANDROID
  182. 182. Code  Recommenders  team  server server PowerBook G4devel  #1 . PowerBook G4 PowerBook G4 t.. devel  #2 devel  #3 m en elop dev In  
  183. 183. Demo  setup PowerBook G4 developer  ws PowerBook G4 examples  wsEclipse  “blue” Eclipse  “red”
  184. 184. SummaryIntelligent  Code  CompleEon Usage-­‐Driven  Javadocs Stacktrace  Search  Engine Smart  Bug  DetecEon Code  Example  Recommender x= What  caused  that  stacktrace? What  have  I  missed? How  do  I  get  an  instance  of…? 96
  185. 185. A  developer’s  day... Switching Applications Edit Code Searching Code Testing NavigateDependenciesReading API Doc Comprehend Task Handling Comprehending Interruptions Code Source:  Eclipse  Mylyn  Developer  Techtalk  2011,  IEEE  TSE,  Vol.  32,  No.  12,  2006 97
  186. 186. Where  does  IDE  2.0  improve  the  process? Edit Code Testing Comprehend Task Handling Interruptions … 98
  187. 187. Contributors  so  far…Jan   Kassens,     Peter  Schroeder,  Daniel  Glöckner,  Maik   Görtz,  Johannes   Lerch,  Johannes  Born,  Mohsen  Parisay,  Andreas  Sewe,  SebasKan  Ahlfeld,  SebasKan  Kasten,  Daniel  Staesche,  David  Kalnischkies,   SebasKan   Wörner,   Boyan   Yurukov,   Jan   Stolzenburg,   Nico   Wombacher,   Dirk  Kröhan,   Florianrian   Jakob,   Julius   Rückert,   Steffen   Remus,   Christopher   Mann,   Stefan   Henss,  Andreas   Kaluza,   Nikolay   Shindov,   Michael   Novotny,   KrisKn   Arand,   Sinem   Emeröz,   Michael  Kutschke,   SebasKan   Proksch,   Tomasz   Kalbarczyk,   Marko   MarKn,   Sheip   Dargutev,   David  Schuld,   Jens   Krause,   KrisKjan   Madunic,   Daniel   Brandtner,   Roman   GeSo,   ChrisKan   Kilb,  Johannes   Kastl,   Dennis   Sänger,   Annie   Liu,   Markus   Migenda,   Tjark   Vandommele,   SebasKan  Denel,  Florian  Nöll,   Gary  Fritz,  Dennis  Siebert,  Peter  Sinzig,  Laura  Altmüller,  Paul  Schatygin,  Jan-­‐Michael  Heller,  Minh  Hoang  Nguyen,  Sascha  Nordquist,  Paul  Emmanuel  Faidherbe,  ... 99
  188. 188. Q  &  A 100
  189. 189. Q  &  AIntelligent  Code  CompleEon Usage-­‐Driven  Javadocs Stacktrace  Search  Engine Smart  Bug  DetecEon Code  Example  Recommender What  caused  that  stacktrace? What  have  I  missed? How  do  I  get  an  instance  of…? 101
  190. 190. It’s  there.htp://eclipse.org/recommenders/ Follow  me  on  twiter:  @MarcelBruch google+:  +Marcel  Bruch 102

×