项目作者: GZoltar

项目描述 :
Java lines of code to Java statements
高级语言: Java
项目地址: git://github.com/GZoltar/locs-to-stms.git
创建时间: 2018-07-02T01:53:40Z
项目社区:https://github.com/GZoltar/locs-to-stms

开源协议:GNU Lesser General Public License v3.0

下载


Java lines of code to Java statements

Build Status

locs-to-stms is an utility Java program that parses java files to extract
the set of lines of code that are part of the same Java statement.

Considering the following snippet of code from
JFreeChart, class
org.jfree.chart.renderer.category.LineAndShapeRenderer:

  1. 762. if (this.useSeriesOffset) {
  2. 763. x0 = domainAxis.getCategorySeriesMiddle(
  3. 764. column - 1, dataset.getColumnCount(),
  4. 765. visibleRow, visibleRowCount,
  5. 766. this.itemMargin, dataArea,
  6. 767. plot.getDomainAxisEdge());
  7. 768. }

It can be seen there are 6 lines of code, but only 2 statements (as lines
763-767 are part of the same statement). So, locs-to-stms reads a list of
java files and prints to a file, information of each java statement. Each row
of the file contains two columns: First column represents a statement, and
the second column represents a line of code that is part of the statement.
For example:

  1. ...
  2. org/jfree/chart/renderer/category/LineAndShapeRenderer.java#763:org/jfree/chart/renderer/category/LineAndShapeRenderer.java#764
  3. org/jfree/chart/renderer/category/LineAndShapeRenderer.java#763:org/jfree/chart/renderer/category/LineAndShapeRenderer.java#765
  4. org/jfree/chart/renderer/category/LineAndShapeRenderer.java#763:org/jfree/chart/renderer/category/LineAndShapeRenderer.java#766
  5. org/jfree/chart/renderer/category/LineAndShapeRenderer.java#763:org/jfree/chart/renderer/category/LineAndShapeRenderer.java#767
  6. ...

I.e., lines #764, #765, #766, #767 are part of statement #763.

How to compile it?

  1. mvn clean package

How to use it?

  1. java -jar locs-to-stms-<version>-jar-with-dependencies.jar locstostms \
  2. <classes> ...
  3. --srcDirs <dir>
  4. [--outputFile <file>]

Where <classes> is the list of classes to parse, --srcDirs is the source
directory (more than one can be defined), --outputFile is the file to which
the output of locs-to-stms is written.

For example:

  1. java -jar locs-to-stms-0.0.1-jar-with-dependencies.jar locstostms
  2. org.jfree.chart.renderer.category.LineAndShapeRenderer \
  3. --srcDirs src/main/java \
  4. --outputFile locstostms.txt