eclipse code recommenders @ majug 2011
TRANSCRIPT
Eclipse Code Recommenders
IDE 2.0: Leveraging the Wisdomof the So:ware Engineering Crowdstw: @MarcelBruchg+: +Marcel Bruch
Java U
ser Group M
annhei
m
2
Developers Who Called “new Text()” Method Also Called
What Do Developers Ultimately Override After Extending This Class?
setText()
89%
addListener()
53%
setLayout()
99%
setFont()
35%
100 % overwrotePreferencePage.createContents()
96 % overwrotePreferencePage.performOk()
5 % overwrotePreferencePage.performCancel()
Eclipse Code
CodeAll Frameworks
Eclipse Code Recommenders Code
3
INTELLIGENT CODE COMPLETION“Other developers frequently bought used the following methods…”
@Overrideprotected Control createDialogArea(final Composite parent) { Composite container = (Composite) super.createDialogArea(parent); swtTextWidget = new Text(container, SWT.BORDER); swtTextWidget.| return container;}
Code Comple+on…
What does the developer need, i.e., which methods should the code compleKon present to the user?
5
All 164 Methods of Text ?
JBuSon? 381 Methods.
@Override protected Control createDialogArea(final Composite parent) { final Composite container = (Composite) super.createDialogArea(parent); swtTextWidget = new Text(container, SWT.BORDER); swtTextWidget.| return container; }
Code Comple+on…
What does the developer need, i.e., which methods should the code compleKon present to the user?
8
Intelligent Code Comple+on
… or just the three missing ones?
9
How it works -‐ in a nutshell
10
How it works -‐ in a nutshell
10
Framework
How it works -‐ in a nutshell
10
Framework
Example ApplicaKon 1
Example ApplicaKon n...
How it works -‐ in a nutshell
10
extract facts about how the framework is reused
...«extends:A»
«overrides:A.d»«calls:B.c»
…
«extends:A»«overrides:A.b»
«calls:B.c»…
Framework
Example ApplicaKon 1
Example ApplicaKon n...
How it works -‐ in a nutshell
10
extract facts about how the framework is reused
...«extends:A»
«overrides:A.d»«calls:B.c»
…
«extends:A»«overrides:A.b»
«calls:B.c»…
Framework
Example ApplicaKon 1
Example ApplicaKon n...
How it works -‐ in a nutshell
10
If you extend A,you should call B.c
extract facts about how the framework is reused
...«extends:A»
«overrides:A.d»«calls:B.c»
…
«extends:A»«overrides:A.b»
«calls:B.c»…
Framework
Example ApplicaKon 1
Example ApplicaKon n...
From code to models...
11
class Example extends Page { Text t; @Override void createContents() { t = new Text(); t.setText(..); .. }}
in:Page.createContents()
in:Page.performOk()
Text.<init>()
Text.getText()
Text.setFont()
...
Text.setText()
1 0 1 1
1 1
0 0
0 0 0 0… … … … … …
……
…
From code to models...
12
class Example extends Page { Text t; @Override void performOk() { t.getText(); ..
}}
in:Page.createContents()
in:Page.performOk()
Text.<init>()
Text.getText()
Text.setFont()
...
Text.setText()
1 0 1 1
1 1
0 0
0 0 0 0… … … … … …
……
…
From models to recommenda+ons...
13
class MyPage extends Page { Text t; @Override void createContents() { t = new Text(); t.|<^space> }}
1 …1 ?? ?0in:Page.createContents()
in:Page.performOk()
Text.<init>()
Text.getText()
Text.setFont()
...
Text.setText()
From models to recommenda+ons...
14
1 …1 ?? ?0
in:Page.createContents()
in:Page.performOk()
Text.<init>()
Text.getText()
Text.setFont()
...
Text.setText()
01 10 0 …1 10 0 0 0
… … … … … ………
1
0 1 1 1 0 …101 00 0 …1
From models to recommenda+ons...
14
1 …1 ?? ?0
in:Page.createContents()
in:Page.performOk()
Text.<init>()
Text.getText()
Text.setFont()
...
Text.setText()
01 10 0 …1 10 0 0 0
… … … … … ………
1
0 1 1 1 0 …101 00 0 …1
⅔
From models to recommenda+ons...
14
1 …1 ?? ?0
in:Page.createContents()
in:Page.performOk()
Text.<init>()
Text.getText()
Text.setFont()
...
Text.setText()
01 10 0 …1 10 0 0 0
… … … … … ………
1
0 1 1 1 0 …101 00 0 …1
⅔ ⅓
From models to recommenda+ons...
14
1 …1 ?? ?0
in:Page.createContents()
in:Page.performOk()
Text.<init>()
Text.getText()
Text.setFont()
...
Text.setText()
01 10 0 …1 10 0 0 0
… … … … … ………
1
0 1 1 1 0 …101 00 0 …1
⅔ ⅓ 0
CALL-‐CHAIN COMPLETION“Welcome to the forest...”
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?
What we need...
17
public void updateMessage(final String newMessage) {
// How do I get an instance of final IStatusLineManager manager = this .getViewSite() .getActionBars() .getStatusLineManager();
manager.setMessage(newMessage);}
!"#$%&'(
)!"#$*"(#
)+,-./0&'1
)*(&(213"/#4&/&5#'
5#(*(&(213"/#4&/&5#'67
5#(+,-./8&'167
5#(!"#$*"(#67
!"#$%&'(
)#*"+#
,#+(&-./#
01/1'
234(#-5"1-
201-('"67(1'
28+91-:&'5
2;1'<6#-+=;"->1$
2?#/#+91-%'1*">#'
2;1'<6#-+=%&.#
?=#//
2;1'<6#-+=%&'(
2@#A:"->"-.?#'*"+#2;1'<6#-+=%&'(?"(#
2B&.#
201-C.7'&91-3/#B#-(
2!"#$?"(#
2B&.#)&(&
%1"-(
2D#-7D&-&.#'
2?#'*"+#E1+&(1'
2%&'(?#'*"+#
2;1'<6#-+=
28>&F(&6/#
2?#/#+91-
2;1'<6#-+=;"->1$
2G&*".&91-H"5(1'A
2;1'<"-.?#(
234(#-5"1-I'&+<#'
2!"#$,#J#'#-+#
2!"#$%&'(
23>"(1',#J#'#-+#
23>"(1'%&'(
,#."1-
01BF15"(#
D#-7
E"5(#-#'
E&A17(
2D3
)"5F/&A
?+'1//:&'
01-('1/
2?#'*"+#E1+&(1'
2D#-7D&-&.#'
2?(&(75E"-#D&-&.#'
28+91-
2I11/:&'D&-&.#'
2?#/#+91-?#'*"+#
However, someEmes you get...
Here, implicit user feedbacks (“clicks”) will help to find the right (read “the most commonly used”) paths.
In deve
lopme
nt...
Tools Outline
20
x=
Tools Outline
Intelligent Code CompleEon
20
x=
Smart Bug DetecEon
What have I missed?
Tools Outline
Intelligent Code CompleEon
20
x=
Smart Bug DetecEon
What have I missed?
Tools Outline
Extended DocumentaEon
Intelligent Code CompleEon
20
x=
Smart Bug DetecEon
What have I missed?
Tools Outline
Extended DocumentaEon
Intelligent Code CompleEon
Code Example Recommender
How do I get an instance of…?
20
x=
Smart Bug DetecEon
What have I missed?
Tools Outline
Extended DocumentaEon
Intelligent Code CompleEon
Code Example Recommender
How do I get an instance of…?
Stacktrace Search Engine
What caused that stacktrace?
20
x=
Smart Bug DetecEon
What have I missed?
Tools Outline
Extended DocumentaEon
Intelligent Code CompleEon
Code Example Recommender
How do I get an instance of…?
Stacktrace Search Engine
What caused that stacktrace?
20
x=
Smart Bug DetecEon
What have I missed?
Tools Outline
Extended DocumentaEon
Intelligent Code CompleEon
Code Example Recommender
How do I get an instance of…?
Stacktrace Search Engine
What caused that stacktrace?
20
x=
SMART BUG DETECTION – DRIVEN BY REAL USAGES
“The good ones in the crock, the bad ones in… the problem view.”
What’s wrong with this code?
“Hello!”
“id”
22
At run+me you get…
23
...and a lengthy stacktrace
24
org.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)
...
So what have we missed?25
If all of your colleagues do it – why don’t you?
26
If all of your colleagues do it – why don’t you?
26
How to detect such wrong uses?
27
How to detect such wrong uses?
27
How to detect such wrong uses?
27
How to detect such wrong uses?
27
How to detect such wrong uses?
That’s “strange”
27
How to detect such wrong uses?
28
Just one formula…
x = {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
10 .9.5
Missing Calls Detector in Eclipse
30In d
evelop
ment...
Applied on Eclipse 3.5...
31
USAGE-‐DRIVEN JAVADOC“Developers who bought overwrote this method typically also overwrote...”
In good documenta+on we trust...
33
/** * 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. */ @Override protected void doUnload() { super.doUnload(); }
In good documenta+on we trust...
33
/** * 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. */ @Override protected void doUnload() { super.doUnload(); }
In good documenta+on we trust...
33
/** * 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. */ @Override protected void doUnload() { super.doUnload(); }
No? Are you sure?
In good documenta+on we trust...
33
/** * 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. */ @Override protected void doUnload() { super.doUnload(); }
No? Are you sure?
good
Genera+ng high-‐quality API documenta+on
34
/** * 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; }
Genera+ng high-‐quality API documenta+on
34
/** * 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; }
Genera+ng high-‐quality API documenta+on
34
/** * 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; }
Genera+ng high-‐quality API documenta+on
34
/** * 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; }
Genera+ng high-‐quality API documenta+on
34
/** * 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; }
Genera+ng high-‐quality API documenta+on
34
/** * 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; }
Genera+ng high-‐quality API documenta+on
34
/** * 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; }
Genera+ng high-‐quality API documenta+on
34
/** * 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; }
Genera+ng high-‐quality API documenta+on
35
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; }
Genera+ng high-‐quality API documenta+on
35
high-‐quality
What people say about JAutodoc...
36
What people say about JAutodoc...
36
User: Anonymous Rating: 9 2009-08-02 11:32:37
Wow exactly what I needed!Wow exactly what I needed!Wow exactly what I needed!
What people say about JAutodoc...
36
User: Anonymous Rating: 9 2009-08-02 11:32:37
Wow exactly what I needed!Wow exactly what I needed!Wow exactly what I needed!
User: Anonymous Rating: 9 2009-02-13 19:58:32
Thank you... this plugin rocks!Thank you... this plugin rocks!Thank you... this plugin rocks!
What people say about JAutodoc...
36
User: Anonymous Rating: 9 2009-08-02 11:32:37
Wow exactly what I needed!Wow exactly what I needed!Wow exactly what I needed!
User: Anonymous Rating: 9 2009-02-13 19:58:32
Thank you... this plugin rocks!Thank you... this plugin rocks!Thank you... this plugin rocks!
User: Anonymous Rating: 9 2009-02-13 19:58:32
Works perfectly. Smarter than I expected!Works perfectly. Smarter than I expected!Works perfectly. Smarter than I expected!
What people say about JAutodoc...
36
User: Anonymous Rating: 9 2009-08-02 11:32:37
Wow exactly what I needed!Wow exactly what I needed!Wow exactly what I needed!
User: Anonymous Rating: 9 2009-02-13 19:58:32
Thank you... this plugin rocks!Thank you... this plugin rocks!Thank you... this plugin rocks!
User: Anonymous Rating: 9 2009-02-13 19:58:32
Works perfectly. Smarter than I expected!Works perfectly. Smarter than I expected!Works perfectly. Smarter than I expected!
WTH? What did you expect?!
How Recommenders is coming to rescue...
37
Some facts about thedocumentaEon of overridable methods
38
Overridable
Overridden
0 700 1400 2100
623
2.074
What clients do with your API...
39
Overridden
Documented *
0 325 650
155
623
* documented as overridable by using phrases like “clients may/should/must override/extend this method”
What clients do with your API...
39
Overridden
Documented *
0 325 650
155
623
* documented as overridable by using phrases like “clients may/should/must override/extend this method”
468
What documenta+on would you expect when subclassing Dialog?
40
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); } }
What Javadoc gives you...
41
org.eclipse.jface.dialogs.Dialog
What Javadoc gives you...
41
A dialog is a specialized window used for narrow-‐focused communicaEon with the user.
org.eclipse.jface.dialogs.Dialog
What Javadoc gives you...
41
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 disappearing behind the applicaEon's 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.
org.eclipse.jface.dialogs.Dialog
What Javadoc gives you...
41
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 disappearing behind the applicaEon's 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.
But what are the hot-spots of Dialog?
org.eclipse.jface.dialogs.Dialog
What code comple+on offers...
42
What code comple+on offers...
42
Which of the 56 methods should we override?
Recommending method overrides...
43
public class MyDialog extends Dialog {
public class MyWizard extends Wizard {
! @Override public void addPages() { };
Recommending Self-‐Calls
44
public class MyViewerSorter extends ViewerSorter {
Mining for Subclassing pa`erns
45
public class MyDialog extends Dialog { @Override protected Control createDialogArea(Composite parent) {
Mining example code snippets
46
Sca`ered Resources
47
Extended Documenta+on Plaaorm
48
+ Machine Learning
Extended Documenta+on Plaaorm
48
+ Machine Learning
Extended Documenta+on
49
How it works -‐ in a nutshell
50
CODE-‐SEARCH ENGINES LIFT OFF“Why is Google Codesearch not ‘google for code search’? ”
How many request per minutes docode search engines have?
52
53
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
Naviga+ng the API jungle…
54
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; }
Naviga+ng the API jungle…
How to solveString -‐> ASTParser -‐> CompilaKonUnit?
54
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; }
When asking Google code search...
55
When asking Google code search...
55
When asking Google code search...
55
When asking Google code search...
55
Why?
56
Why?
Text-basedretrieval!
56
Why?
Text-basedretrieval!
56
Inexpressive query language!
Why?
Text-basedretrieval!
Ignores prior knowledge!
56
Inexpressive query language!
Example code search engine
public 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
Example code search engine
public 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
Example code search engine
public 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
Query
Example code search engine
public 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
Query
Example code search engine
public 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
Query
Example code search engine
public 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
Query
Example code search engine
public 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
Query
Sample search query
58
Extracted 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)
In deve
lopme
nt...
LEVERAGING USER FEEDBACK TOIMPROVE CODE SEARCH ENGINES
“Why is Google Codesearch not ‘google for code search’? ”
Leveraging user feedback
60
Leveraging user feedback
60
Refine the ranking based on feedback
61
Refine the ranking based on feedback
61
Learning how to rank
62
Ranking the examples
63
Ranking the examples
63
document
Ranking the examples
63
documentquery
Ranking the examples
63
feature-‐score i[0..1]
documentquery
Ranking the examples
63
weight (-‐∞..+∞)
feature-‐score i[0..1]
documentquery
Upda+ng the feature weights...
64
Upda+ng the feature weights...
64
Upda+ng the feature weights...
64
10.000 ∗
Benefits of automated tweaking
65
baselineclick-‐through
# queries
# kend
all’s ι
Interac+ons diagram
66
ServerClient
1
«triggers»Developer
3 Code Snippet Ranking2 Search Invocation
«triggers»Developer
SearchIndex
RankingFunction
IncompleteSource Code Query
5 Feedback Processing
4 Code Snippet Presentation Code Examples
«updates»
Weights LearningFunction
5 Feedback ProcessingCode
Summarization
Cli kth h
CodeHighlighter
FunctionClickthroughdata
Applica+on scenarios for your company
67
Open SourceRepositories
CompanyRepositories
Applica+on scenarios for your company
67
Open SourceRepositories
CompanyRepositories
Applica+on scenarios for your company
67
Open SourceRepositories
CompanyRepositories
Applica+on scenarios for your company
67
Open SourceRepositories
CompanyRepositories
Applica+on scenarios for your company
67
Filesystem
Open SourceRepositories
CompanyRepositories
WHAT CAUSED THAT STACKTRACE?“People that bought had this NullPointerExcepKon, made this mistake:...”
So far we have…
69
So far we have…
69
Intelligent Code CompleEon
So far we have…
69
Extended DocumentaEonIntelligent Code CompleEon
So far we have…
69
Extended DocumentaEonIntelligent Code CompleEon
Code Example Recommender
How do I get an instance of…?
So far we have…
69
Smart Bug DetecEon
What have I missed?
Extended DocumentaEonIntelligent Code CompleEon
Code Example Recommender
How do I get an instance of…?
But what if you get this?
70
Debugging – the old way
71
Debugging – the old way
71
Debugging – the old way
72
But more ojen we get…
73
How can we fix that? Don’t stacktraces share some commonali+es?
74
How can we fix that? Don’t stacktraces share some commonali+es?
74
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)
How can we fix that? Don’t stacktraces share some commonali+es?
74
excepEon type
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)
How can we fix that? Don’t stacktraces share some commonali+es?
74
excepEon type message
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)
How can we fix that? Don’t stacktraces share some commonali+es?
74
excepEon type message
stackframes
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)
How can we fix that? Don’t stacktraces share some commonali+es?
74
excepEon type message
stackframes other informaEon
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)
How about stacktraces.org?
75
Knowledge sources
76
Eclipse Forums
Mailing ListsWebplasorm
htp://stacktraces.org
Applica+on scenarios for your company
77
Community-‐driven (forums, mailinglists,...)
CompanyKnowledgebase
SNIPMATCH“Templates meet Social -‐ reloaded!”
Eclipse Java Editor Templates
Eclipse Java Editor Templates
42x Java Templates.
Eclipse Java Editor Templates
42x Java Templates.35x SWT Templates.
Eclipse Java Editor Templates
42x Java Templates.35x SWT Templates.
7 Years.
The rise of code snippet repositories
and many more...
Searching snippets in your IDE...
ECLIPSE CODE RECOMMENDERS“IDE 2.0? Leveraging the wisdom of the (Eclipse) community…”
From IDE 1.0 to IDE 2.0
83
From IDE 1.0 to IDE 2.0
83
Build directly from version control-‐ or p2/m2 repository...
84
P2
Leveraging your IDE’s build environment
85
Leveraging your IDE’s build environment
project environment
85
Leveraging your IDE’s build environment
project environment
context
85
Leveraging your IDE’s build environment
object usage
project environment
context
85
Leveraging your IDE’s build environment
object usage
selectedproposals
project environment
context
85
Leveraging your IDE’s build environment
object usage
selectedproposals
project environment
context
clickfeedback
85
Leveraging your IDE’s build environment
object usage
selectedproposals
project environment
context
Stacktraces
clickfeedback
85
Crowd-‐sourcing...
86
BUT HOW ABOUT PRIVACY?“Yours is ours and mine is mine...”
Usage data sharing example
88
import 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(); }}
Usage data sharing example
88
import 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(); }}
Informa+on cleared by privacy selngs
89
import 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(); }}
Effec+ve usage data shared
90
import 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(); }}
Effec+ve usage data shared
90
import 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(); }}
Only the informaKon how you used Eclipse is shared.
RECOMMENDERS FOR ANDROID“Support your own framework. Live walk-‐through...”
92
ListAcEvity
TextViews
LinearLayout
TEAM SERVER FOR ANDROID“Support your own framework. Live walk-‐through...”
Code Recommenders team server
PowerBook G4
PowerBook G4PowerBook G4
server
devel #1
devel #2 devel #3
In deve
lopme
nt...
Demo setup
PowerBook G4
PowerBook G4
Eclipse “blue” Eclipse “red”
developer ws
examples ws
Summary
Smart Bug DetecEon
What have I missed?
Usage-‐Driven JavadocsIntelligent Code CompleEon
Code Example Recommender
How do I get an instance of…?
Stacktrace Search Engine
What caused that stacktrace?
96
x=
A developer’s day...
97
Edit Code
Testing
Comprehend Task
Handling Interruptions Comprehending
Code
Reading API Doc
Navigate Dependencies
Searching Code
Switching Applications
Source: Eclipse Mylyn Developer Techtalk 2011, IEEE TSE, Vol. 32, No. 12, 2006
Where does IDE 2.0 improve the process?
98
Edit Code Testing
Comprehend Task
Handling Interruptions
…
99
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, ...
Q & A
100
Q & A
Smart Bug DetecEon
What have I missed?
Usage-‐Driven JavadocsIntelligent Code CompleEon
Code Example Recommender
How do I get an instance of…?
Stacktrace Search Engine
What caused that stacktrace?
101
It’s there.
htp://eclipse.org/recommenders/Follow me on twiter: @MarcelBruch
google+: +Marcel Bruch 102