CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

21
CrossLanguageSpotter: CrossLanguageSpotter: A Library for Detecting Relations A Library for Detecting Relations in Polyglot Frameworks in Polyglot Frameworks Federico Tomassetti, Giuseppe Rizzo, Raphaël Troncy @giusepperizzo @rtroncy @raindancer

description

Talk "CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks" event during WWW'14 Dev track, Seoul, Korea

Transcript of CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

Page 1: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

CrossLanguageSpotter: CrossLanguageSpotter: A Library for Detecting RelationsA Library for Detecting Relations

in Polyglot Frameworksin Polyglot Frameworks

Federico Tomassetti, Giuseppe Rizzo, Raphaël Troncy

@giusepperizzo @rtroncy@raindancer

Page 2: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

CREATE TABLE Persons ( ID int, FirstName varchar(255), LastName varchar(255), City varchar(255));

String query = "select ID, FirstName, LastName, " + "City " + "from " + dbName + ".Persons"; try { ... while (rs.next()) { int id = rs.getInt("ID"); String firstName = rs.getString("FirstName"); String lastName = rs.getString("LastName"); String city= rs.getString("City"); } } catch (SQLException e ) { ......}

data.sql

Person.java

Page 3: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

CREATE TABLE Persons ( ID int, FirstName varchar(255), LastName varchar(255), City varchar(255));

String query = "select ID, FirstName, LastName, " + "City " + "from " + dbName + ".Persons"; try { ... while (rs.next()) { int id = rs.getInt("ID"); String firstName = rs.getString("FirstName"); String lastName = rs.getString("LastName"); String city= rs.getString("City"); } } catch (SQLException e ) { (Hopefully it does not happen)}

data.sql

Person.java

Page 4: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

We were able to identify cross-language relations at compile time?

Page 5: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

So I am aware that this ID is related to something else

If we could automatically identifyIf we could automatically identifycross-language relations we could:cross-language relations we could:

- Highlight them- Highlight them

- Support refactoring- Support refactoring

- Validate them- Validate them

- Navigate them- Navigate them

Page 6: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

If I change one end, the connected elements are updated

If we could automatically identifyIf we could automatically identifycross-language relations we could:cross-language relations we could:

- Highlight them- Highlight them

- Support refactoring- Support refactoring

- Validate them- Validate them

- Navigate them- Navigate them

Page 7: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

If we could automatically identifyIf we could automatically identifycross-language relations we could:cross-language relations we could:

- Highlight them- Highlight them

- Support refactoring- Support refactoring

- Validate them- Validate them

- Navigate them- Navigate them

See broken relations as errors

Page 8: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

If we could automatically identify If we could automatically identify cross-language relations we could:cross-language relations we could:

- Highlight them- Highlight them

- Support refactoring- Support refactoring

- Validate them- Validate them

- Navigate them- Navigate themClick to see the other side of the relation

Page 9: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

Shared id

Page 10: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

Shared id

HOW?

Page 11: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

Shared id

1. Build ASTs1. Build ASTs2. Look for pairs of ID2. Look for pairs of ID3. Understand if each pair is 3. Understand if each pair is really related or not really related or not exploiting the semantic of exploiting the semantic of the contextthe context

HOW?

Page 12: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

<ul id="types"><li ng-repeat="t in types" ng-class="{'selected': t.id == type}">

<a ng-href="#/{{t.id}}">{{t.title}}</a></li>

</ul>

var types = [ { id: 'sliding-puzzle', title: 'Sliding puzzle' }, { id: 'word-search-puzzle', title: 'Word search puzzle' }];

index.html

app.js

app.controller('slidingAdvancedCtrl', function($scope) { $scope.puzzles = [ { src: './img/misko.jpg', title: 'Miško Hevery', rows: 4, cols: 4 }, { src: './img/igor.jpg', title: 'Igor Minár', rows: 3, cols: 3 }, { src: './img/vojta.jpg', title: 'Vojta Jína', rows: 4, cols: 3 } ];});

<div ng-repeat="puzzle in puzzles"><h2>{{puzzle.title}}</h2>…

</div>

Page 13: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

April 10, 2014 13/2123rd World Wide Web Conference (WWW'14) Dev Track

What about web applications?

Large use of several programming

languages within the same application (HTML, CSS, JS,

python, Java, C#, … )

Page 14: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

April 10, 2014 14/2123rd World Wide Web Conference (WWW'14) Dev Track

Page 15: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

April 10, 2014 15/2123rd World Wide Web Conference (WWW'14) Dev Track

Let's pick up an example

http://git.io/yh_Q0Qangular-puzzle

Page 16: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

April 10, 2014 16/2123rd World Wide Web Conference (WWW'14) Dev Track

How to integrate?

http://youtu.be/4vi46nCl1Xw

Page 17: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

April 10, 2014 17/2123rd World Wide Web Conference (WWW'14) Dev Track

CrossLanguageSpotter

does the magic

AST builder

RandomTree

Classifier

.js

.html

<p1> <conf> <true><p2> <conf> <false>…<pn> <conf> <false>

FeatureExtraction

Page 18: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

Embedded AST (prendo immagine da paper)

AST Builder

Page 19: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

April 10, 2014 19/2123rd World Wide Web Conference (WWW'14) Dev Track

Feature Extraction and Relations Spotter

Feature Extraction(contextual features)

Tomassetti F., Rizzo G., Torchiano M. (2014), Spotting Automatically Cross-Language Relations. In Conference on Software Maintenance, Reengineering and Reverse Engineering (CSMR-WCRE'14), Antwerp, Belgium.

<p1> f(1,1) f(1,2) ...<p2> f(2,1) f(2,2) ...…<pn> f(n,1) f(n,2) ...

shar

ed_l

engt

hitf

idf_

shar

ed%

_sha

red_

leng

th_m

in

%_s

hare

d_le

ngth

_max

diff_

min

Leve

nsht

ein

Jacc

ard

Jaro

Tver

sky

<p1> <conf> <true><p2> <conf> <false>…<pn> <conf> <false>

RandomTree(classifier)

Page 20: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

April 10, 2014 20/2123rd World Wide Web Conference (WWW'14) Dev Track

Principles and experimentally assessed

Tomassetti F., Rizzo G., Torchiano M. (2014), Spotting Automatically Cross-Language Relations. In Conference on Software Maintenance, Reengineering and Reverse Engineering (CSMR-WCRE'14), Antwerp, Belgium.

Page 21: CrossLanguageSpotter: A Library for Detecting Relations in Polyglot Frameworks

April 10, 2014 21/2123rd World Wide Web Conference (WWW'14) Dev Track

Thanks for your time and attention

http://www.slideshare.net/giusepperizzo

http://git.io/rlHrvg

http://youtu.be/4vi46nCl1Xw