770 likes | 864 Views
Presentation 7 Summary. Cross Language Clone Analysis Team 2 November 22, 2010. Agenda. Feasibility Study Release Plan Architecture Parsing CodeDOM Clone Analysis Testing Demonstration Team Collaboration Path Forward. Our Team. Allen Tucker Patricia Bradford Greg Rodgers
E N D
Presentation 7 Summary Cross Language Clone Analysis Team 2 November 22, 2010
Agenda • Feasibility Study • Release Plan • Architecture • Parsing • CodeDOM • Clone Analysis • Testing • Demonstration • Team Collaboration • Path Forward
Our Team • Allen Tucker • Patricia Bradford • Greg Rodgers • Brian Bentley • Ashley Chafin
Feasibility Study Our evaluation of the project to determine the difficulty in carrying out the task.
Task Summary • Our Customers: Dr. Etzkorn and Dr. Kraft • Customer Request: • A tool that will abstract programs in C++, C#, Java, and (Python or VB) to the Dagstuhl Middle Metamodel, Microsoft CodeDOM or something similar, and detect cross-language clones. • Areas to Note: • the user interface • easy comparisons of clones • visualization of clones • sub-clones • clone detection for large bodies of code
Task Summary (cont.) • Per our task, in order to find clones across different programming languages, we will have to first convert the code from each language over to a language independent object model. • Some Language Independent Object Models: • Dagstuhl Middle Metamodel (DMM) • Microsoft CodeDOM • Both of these models provide a language independent object model for representing the structure of source code.
Task Understanding • Three Step Process • Step 1 Code Translation • Step 2 Clone Detection • Step 3 Visualization Common Model Translator Source Files Detected Clones Inspector Common Model Clone Visualization UI Detected Clones
Benefits • Fact: Modularity is a key characteristic in today’s software world • Why? Allows us to divide software into a decomposed separation of concerns • Attributes to maintainability, reusability, testability and reliability • Clone Detection allows us to detect common software spread across large bodies of code • Identify code that is subject to further modularity
Features • Clone Detection Software Suite • Identifies • Tracks • Manages Software Clones • Multi-language support • C++ • C# • Java
Features (cont) • Provides complete code coverage • Multi-Application Support • Stand-alone • Plug-in based (Eclipse) • Backend service (Ant task) • Extendible • Built on a Plug-in Framework • Add new languages • Easy to Navigate between Clones • Persists Clones for easy Retrieval
Risk Analysis • Complexity of problem proves more difficult than initial estimates. • Technology to be applied is neither well-established or has yet to be developed. • Unable to complete defined project scope within schedule. • Volatile user requirements leading to redefinition of project objectives.
Release Plan Release Plan and User Stories
Re-tooled User Stories • Came out with original Release Plan on 9/15/20 • Due to customer wants/needs, we had to re-tool our user stories. • Dr. Etzkorn’s main concerns: • Load source code and translate to a language independent model • Analyze the translated source code for clones • Results from meeting: • Created two new user stories (see next two slides) • These two user stories have been pushed to the front of our card stack
CS 666 Studio I User Stories Phase I
Source Code Load & Translate 017 1 14 Days As an analyst I want the to load and translate my source code projectsso I can analyze the source for clones.
Source Code Analyze 018 1 14 Days As an analyst I want the to analyze my source code projectsso I can see the clones.
Code Clone Highlights 002 1 14 Days As a analyst I want the capability to have the source code associated with clones highlighted within source files so that they are easy to identify.
Current Tasks Requirements & Models
Current Tasks’ Requirements • Requirements modeling for the first user story “Source Code Load & Translate”: • Load & parse C#, Java, C++ source code. • Translate the parsed C#, Java, C++ source code to CodeDOM. • Associate the CodeDOM to the original source code. • Requirements modeling for the second user story “Source Code Analyze”: • Analyze CodeDom for clones.
Architecture Design and Architecture
Key Architecture Points • Multilanguage support • Configurable for different platforms • Stand-along application • plug-in • backend service • Extendable
Architecture Application User Interface Web Interface Core Clone Detection Algorithms Code Model Service API Language Support (Interface) Eclipse Plug-in C# Service Java Service C++ Service Etc…
Core Unit • Code Model • Stores the code in common format • Application Programming Interface • Used to embed clone detection in applications • Language Service Interface • Communication layer between the core and the specific language services Core Clone Detection Algorithms Code Model API Language Service Interface
CRC Card Sampling Class Responsibility Collaboration Cards
Parsing Our struggles and our successes.
Parsing Struggles & Successes • We explored and conducted spikes on CSParser and CS CodeDOM Parser. • They both had advantages and disadvantage. • We came to the conclusion that neither of them were going to fit our needs. • We explored and conducted a spike on GOLD Parser. • We ultimately chose the GOLD Parser because it best fit our needs. • This gave us a way to manage multiple language grammars with one engine.
GOLD Parsing System GOLD Parsing Populating CodeDOM
How It Works (Block Structure) Source Code Grammar Builder Compiled Grammar Table (*.cgt) Engine Parsed Data
How It Works (Process) Source Code Grammar Builder Compiled Grammar Table (*.cgt) Engine Parsed Data Typical output from engine: a long nested tree
Usage within CloneDigger Source Code Compiled Grammar Table (*.cgt) Engine Parsed Data CodeDOM Conversion AST • CodeDOM Conversion • Need to write routine to move data from Parsed Tree to CodeDOM • Parsed data trees from parser are stored in consistent data structure, but are based on rules defined within grammars
Grammar Updates Bookkeeping for parsing the multiple grammars.
Grammar Updates • Currently the grammars we have for the Gold parser are out dated. • Current Gold Grammars • C# version 2.0 • Java version 1.4 • Current available software versions • C# version 4.0 • Java version 6
Grammar Update Issues • Grammars for C# and Java are very complex and require a lot of work to build. • Antler and Gold Parser grammars use completely different syntax. • Positive note: Other development not halted by use of older grammars.
Our Bookkeeping Bookkeeping for parsing the multiple grammars
Compiled Grammar Table • For Java, there is… • 359 production rules • 249 distinctive symbols (terminal & non-terminal) • For C#, there is… • 415 production rules • 279 distinctive symbols (terminal & non-terminal)
Our Grammar Bookkeeping Since there are so many production rules, we came up with the following bookkeeping: • A spreadsheet of the compiled grammar table (for each language) with each production rule indexed. • This spreadsheet covers: • various aspects of language • what we have/have not handled from the parser • what we have/have not implemented into CodeDOM • percentage complete
Parsing & CodeDOM Status • Parsing Handlers’ Status: • C# = 100% complete • Java = 100% complete