Hello, I’m Kunal. I’m proud to be a part of milky way.

Dependency Analysis


Author : Kunal Paliwal
Source : Jim Fawcett

Package Structure

Introduction: 
Imagine a continuous integration system that uses dependency analysis to determine all the tests a change transitively affects and
then runs only those tests for every change. 

Design: 
The Code Analyzer package structure can be found in the above tag with the author. The packages focus on three areas:
Building a List of Source Code Files:
1) The Window package is used to identify the root directory for the analysis and to pick file patterns for the language we want to
 analyze, e.g., *.h, *.cpp, or *.cs. 
2) FileMgr package constructs a list of fully qualified file names that match specifications provided by the window package. It uses
 FileSystem package to query the file system to find child directories and files3 using operating system APIs (we have implementations
  for both Windows and Linux). It does its work by recursively calling its search function with the root and then discovered child 
  directories.

Parsing each Source Code File:
1) The Parser package is responsible for analyzing a source file based on rules defined in the ActionsAndRules package. Parser collects 
its input from the scanner packages Tokenizer and SemiExp. That results in a list of tokens that has just enough information to make a 
decision about grammatical constructs without having to save left over information for the next round. What that last sentence means is 
that the token sequence has just enough tokens to search for matches in the rule collection. 
2) When a rule matches it invokes its actions. It is the actions that build the Abstract Syntax Tree (AST), using help from the Scope 
Stack. That process continues until all of the files have been analyzed. 
3) The AbstrSynTree and ScopeStack packages provide all the mechanics for building the AST. The AST serves as a container for all 
information that results from parsing all the selected files.

Displaying Results:
1) Each of the displays is build by the Display package from information contained in the AST. This package provides functionality to 
build:
2) Metrics Display which shows, for each function, size in line count and complexity as measured by the number of descendent scopes in 
the function.
3) Abstract Syntax Tree visualization, an indented list of all the nodes in the AST.
SLOC list, showing each file and its source line count.

The logger package is used by display to write to the console and to a log file. It has three different kinds of output, using three 
different specialized loggers:
Results mode - used to show normal output
Demonstration mode - used to help users understand how the program works, mostly by looking at rule firings and the resulting actions
Debug mode - used to look at parsing details to help make the parsing detections and actions correct.
Analyzser code has statements for each of these three specialized loggers. The user just turns them on and off to see the various types 
of output. That is done with checkboxes in the GUI Display Mode tab.

Read more