Compare commits

...

81 Commits

Author SHA1 Message Date
anil 8eccfee179 changes 2020-09-03 10:11:15 +02:00
anil 1b57a9930c Merge branch 'test' of https://github.com/SerVal-DTF/fixminer_source into test 2020-08-28 17:42:04 +02:00
anil 70e3599d3a ordering 2020-08-28 17:41:11 +02:00
mimic 763a2ce2a3 Merge branch 'test' of https://github.com/SerVal-DTF/fixminer_source into test 2020-08-28 17:39:52 +02:00
mimic 78d9e2182c order 2020-08-28 17:37:01 +02:00
anil fbce8fe8c4 changes 2020-08-28 08:34:39 +02:00
mimic 6f52ca27b0 change 2020-08-27 01:12:31 +02:00
mimic c8aee92a52 change 2020-08-27 01:10:19 +02:00
anil a9437cd5ce code flaws 2020-08-26 15:43:32 +02:00
anil c8e16bd62f less patterns 2020-08-24 09:27:55 +02:00
anil f35da551db less patterns 2020-08-24 09:27:21 +02:00
anil c80c35b474 testing cr 2020-08-23 15:21:07 +02:00
anil 3077f6b05e move binary 2020-08-23 14:26:46 +02:00
anil 4eb33f7905 move binary 2020-08-23 14:24:50 +02:00
anil e4a45bc0ec codeflaws and whitebox 2020-08-23 14:10:43 +02:00
anil cb293de686 test list 2020-08-19 15:07:37 +02:00
anil bfcd2aacc5 Merge branch 'test' of https://github.com/SerVal-DTF/fixminer_source into test 2020-08-19 14:56:03 +02:00
anil 1469fc0afb main 2020-08-19 14:54:36 +02:00
anil 057f5d9136 changes 2020-08-19 14:53:20 +02:00
fixminer 660cefe1dd changes 2020-08-18 11:59:43 +02:00
fixminer 8332aba3d5 changes 2020-08-16 20:05:38 +02:00
fixminer d5d1c0d591 FIX: pjname bug 2020-08-16 19:03:26 +02:00
fixminer b5b57e9ba8 NEW: compare without target tree and use hset to store the compared index 2020-08-16 00:29:05 +02:00
fixminer d0b984e1cf fix pjname with _ 2020-08-15 22:30:16 +02:00
fixminer 656801b0ac fix _ - problem in pj name 2020-08-15 16:19:05 +02:00
anil 90179f143d limit change 2020-08-15 14:39:31 +02:00
anil 1ff30b9eaf some changes in python 2020-08-15 14:35:52 +02:00
anil c626b3981f changes 2020-08-08 10:18:39 +02:00
ANIL KOYUNCU a3e9804ead Merge branch 'master' of https://github.com/SerVal-DTF/fixminer_source 2020-06-09 16:02:21 +02:00
ANIL KOYUNCU 0b7539480f main change 2020-06-09 16:01:57 +02:00
mimic a26275cf4a enabled back token iteration 2020-06-09 14:51:19 +02:00
mimic aa2a17bc4a fix hang in rich edit, and updated readme 2020-06-08 12:54:02 +02:00
mimic 296120cf83 change 2020-06-08 11:43:24 +02:00
ANIL KOYUNCU 8a376e4f6b changes 2020-05-25 09:40:54 +02:00
fixminer e25310a882 java miner test cases 2020-04-11 20:54:48 +02:00
fixminer d9620acef6 update readme 2020-04-10 15:55:12 +02:00
fixminer 2af997b5fc add citation 2020-04-10 15:49:41 +02:00
fixminer 55dbf3a470 dependency suggestion of github 2020-04-10 15:41:48 +02:00
fixminer 841e2dbc74 coverage test 2020-04-10 15:28:30 +02:00
fixminer 5d2ad10b54 remove github workflow 2020-04-10 15:14:37 +02:00
Anil Koyuncu f579f7fee9 Update README.md 2020-04-10 15:13:45 +02:00
fixminer 23ae05c407 fix srcml path in test 2020-04-10 15:08:49 +02:00
fixminer 8fcb841858 srcml path 2020-04-10 14:58:25 +02:00
fixminer 26ee9c2a23 changes for srcml 1.0 2020-04-10 14:48:35 +02:00
fixminer 96f44555aa travis fix try7 2020-04-09 14:38:45 +02:00
fixminer 9f11458a5a travis fix try6 2020-04-09 14:35:58 +02:00
fixminer 27e88bcbce travis fix try5 2020-04-09 14:27:31 +02:00
fixminer 1f610aafd0 travis fix try4 2020-04-09 14:19:55 +02:00
fixminer e4746c9971 travis fix try3 2020-04-09 14:17:56 +02:00
fixminer 69c1b65573 travis fix try2 2020-04-09 14:16:20 +02:00
fixminer 0c1e98f8ee travis fix try 2020-04-09 14:13:57 +02:00
fixminer 77a45f5434 Merge branch 'master' of https://github.com/SerVal-DTF/fixminer_source 2020-04-09 14:11:37 +02:00
fixminer 569fad1985 test ricedit 2020-04-09 14:11:21 +02:00
Anil Koyuncu 60f3b82d6b Update README.md 2020-04-09 13:47:05 +02:00
Anil Koyuncu 689be7b0bb Update maven.yml 2020-04-09 13:46:18 +02:00
fixminer 3522b2039b test with multiple jdk 2020-04-09 13:43:50 +02:00
fixminer 5caf18a1c9 activate tests 2020-04-09 13:37:15 +02:00
fixminer ba831d4e5e fix gumtree test cases 2020-04-09 13:31:56 +02:00
fixminer 37763b2a63 java dataset collector fix 2020-04-09 13:08:05 +02:00
fixminer 753db4075a travis config 2020-04-07 18:11:42 +02:00
fixminer 40a8b0c290 changes for jar 2020-04-07 18:06:53 +02:00
fixminer c5463f91f8 merge python scripts 2020-04-06 21:30:39 +02:00
fixminer 61a9612345 travis disable test 2020-04-06 21:07:43 +02:00
fixminer f7259c6b57 Merge branch 'master' of https://github.com/SerVal-DTF/fixminer_source 2020-04-06 21:04:19 +02:00
fixminer 4a3f25e007 change travis config 2020-04-06 21:04:03 +02:00
Anil Koyuncu 7ad5c6777c Update README.md 2020-04-06 21:00:35 +02:00
Anil Koyuncu 0faed4713e Update README.md 2020-04-06 20:58:00 +02:00
fixminer 6c3dadac75 remove simple-utils 2020-04-06 20:50:22 +02:00
fixminer 3c65b45b8f Merge branch 'master' of https://github.com/SerVal-DTF/fixminer_source 2020-04-06 20:45:47 +02:00
fixminer 61ef6cbf1a remove simple utils 2020-04-06 20:45:26 +02:00
Anil Koyuncu 2b5884fa98 Create maven.yml 2020-04-06 20:42:14 +02:00
fixminer 3c91dd7ea3 merge all into single repo 2020-04-06 20:40:32 +02:00
fixminer 9dcdb6aafc changes 2020-04-06 13:49:51 +02:00
fixminer cdb2bc5c70 changes 2020-04-06 12:27:43 +02:00
fixminer 33d11eb680 rename 2020-04-06 12:19:58 +02:00
Anil Koyuncu 12adfa0194 Create maven.yml 2020-04-06 11:59:21 +02:00
Anil Koyuncu 8aab39ef4f Merge pull request #11 from SerVal-DTF/dockerC
c version
2020-04-06 11:51:34 +02:00
Martin Monperrus a855ea9fe6 Update README.md 2020-03-25 10:16:45 +00:00
Martin Monperrus f5b22c979c Merge pull request #10 from SerVal-DTF/travis
chore: add Travis configuration
2020-03-25 11:15:46 +01:00
Martin Monperrus 1983853c63 chore: add Travis configuration 2020-03-20 11:40:32 +01:00
Martin Monperrus ba34a91b8e Update README.md 2019-12-20 08:14:29 +00:00
897 changed files with 1771640 additions and 4285 deletions
+17 -22
View File
@@ -1,22 +1,17 @@
.cache-main
.DS_Store
.classpath
.project
.settings
target
OUTPUT/
*.class
*.list
*.csv
*.pdf
logs/
.idea/
GumTreeInput/
GumTreeInput1/
GumTreeOutput1/
GumTreeResults/
*/Test.java
*TestParser.java
# Package Files #
*.jar
target/
samples/
.settings/
.project
.classpath
.recommenders/
.metadata/
.idea/
*.iml
.DS_Store
OUTPUT/
Dataset/
logs/
gen.jdt/src/main/java/edu/lu/uni/serval/gumtree/GumTreeTester.java
*.pyc
app.log
*.rdb
Generated
+1 -1
View File
@@ -1 +1 @@
FixPatternMiner
gumtree
+9 -3
View File
@@ -6,17 +6,23 @@
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="FixPatternMiner" />
<module name="RichEdit" />
<module name="gen.jdt" />
<module name="gen.srcml" />
<module name="client.diff" />
<module name="fixminer_source" />
<module name="client" />
<module name="core" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="simple-utils" target="1.8" />
<module name="client" target="1.8" />
<module name="client.diff" target="1.8" />
<module name="core" target="1.8" />
<module name="fixminer_source" target="1.8" />
<module name="gen.jdt" target="1.8" />
<module name="gen.srcml" target="1.8" />
<module name="gumtree" target="1.8" />
<module name="RichEdit" target="1.8" />
</bytecodeTargetLevel>
</component>
</project>
+15 -7
View File
@@ -2,12 +2,20 @@
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../gumtree/client.diff/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../gumtree/client.diff/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../gumtree/client/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../gumtree/core/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../gumtree/gen.jdt/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../gumtree/gen.srcml/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/gumtree" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/gumtree/client" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/gumtree/client.diff" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/gumtree/client.diff/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/gumtree/client.diff/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/gumtree/client/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/gumtree/core" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/gumtree/core/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/gumtree/gen.jdt" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/gumtree/gen.jdt/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/gumtree/gen.srcml" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/gumtree/gen.srcml/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/richedit" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/richedit/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>
+2 -4
View File
@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
<option value="$PROJECT_DIR$/../gumtree/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/classes" />
</component>
</project>
Generated
+1 -2
View File
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/../gumtree" vcs="Git" />
<mapping directory="" vcs="Git" />
</component>
</project>
-445
View File
@@ -1,445 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="1c20f95f-4c0f-46a8-9b1c-3c643f73b30a" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>mk</find>
<find>ObjectInputStream</find>
<find>InputStre</find>
<find>resultMap</find>
<find>hget</find>
</findStrings>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="MavenImportPreferences">
<option name="importingSettings">
<MavenImportingSettings>
<option name="importAutomatically" value="true" />
</MavenImportingSettings>
</option>
</component>
<component name="ProjectId" id="1XwN74yK7nfe6Qw7o3T7vMcUoNV" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1567787706640" />
<property name="project.structure.last.edited" value="Modules" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.0" />
</component>
<component name="RunManager" selected="Application.Launcher">
<configuration name="CompareTrees" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="edu.lu.uni.serval.fixminer.akka.compare.CompareTrees" />
<module name="FixPatternMiner" />
<option name="PROGRAM_PARAMETERS" value="shape $PROJECT_DIR$/../fixminer-core/python/data/redis ALLdumps-gumInput.rdb clusterl0-gumInputALL.rdb $PROJECT_DIR$/../fixminer-core/python/data/richEditScript" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="edu.lu.uni.serval.fixminer.akka.compare.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="Launcher" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="edu.lu.uni.serval.fixminer.Launcher" />
<module name="fixminer_source" />
<option name="PROGRAM_PARAMETERS" value="$PROJECT_DIR$/../fixminer-core/python/data/app.properties L2 RICHEDITSCRIPT" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="edu.lu.uni.serval.fixminer.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="TestRealCases" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="fixminer_source" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="edu.lu.uni.serval.fixminer.akka.ediff.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="edu.lu.uni.serval.fixminer.akka.ediff" />
<option name="MAIN_CLASS_NAME" value="edu.lu.uni.serval.fixminer.akka.ediff.TestRealCases" />
<option name="TEST_OBJECT" value="class" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="TestRealCases.test_31_B_136044_136045" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="fixminer_source" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="edu.lu.uni.serval.fixminer.akka.ediff.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="edu.lu.uni.serval.fixminer.akka.ediff" />
<option name="MAIN_CLASS_NAME" value="edu.lu.uni.serval.fixminer.akka.ediff.TestRealCases" />
<option name="METHOD_NAME" value="test_31_B_136044_136045" />
<option name="TEST_OBJECT" value="method" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="gen.srcml [install]" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings" />
<option name="myRunnerSettings" />
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set />
</option>
<option name="goals">
<list>
<option value="install" />
<option value="-DskipTests" />
</list>
</option>
<option name="pomFileName" value="pom.xml" />
<option name="profilesMap">
<map />
</option>
<option name="resolveToWorkspace" value="false" />
<option name="workingDirPath" value="$PROJECT_DIR$/../gumtree/gen.srcml" />
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2" />
</configuration>
<configuration name="gumtree [install]" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings" />
<option name="myRunnerSettings" />
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set />
</option>
<option name="goals">
<list>
<option value="install" />
<option value="-DskipTests" />
</list>
</option>
<option name="pomFileName" value="pom.xml" />
<option name="profilesMap">
<map />
</option>
<option name="resolveToWorkspace" value="false" />
<option name="workingDirPath" value="$PROJECT_DIR$/../gumtree" />
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2" />
</configuration>
<list>
<item itemvalue="Application.Launcher" />
<item itemvalue="Application.CompareTrees" />
<item itemvalue="Maven.gen.srcml [install]" />
<item itemvalue="Maven.gumtree [install]" />
<item itemvalue="JUnit.TestRealCases" />
<item itemvalue="JUnit.TestRealCases.test_31_B_136044_136045" />
</list>
<recent_temporary>
<list>
<item itemvalue="Application.Launcher" />
<item itemvalue="JUnit.TestRealCases" />
<item itemvalue="JUnit.TestRealCases.test_31_B_136044_136045" />
<item itemvalue="Application.CompareTrees" />
</list>
</recent_temporary>
</component>
<component name="ServiceViewManager">
<option name="viewStates">
<list>
<serviceView>
<treeState>
<expand />
<select />
</treeState>
</serviceView>
</list>
</option>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="1c20f95f-4c0f-46a8-9b1c-3c643f73b30a" name="Default Changelist" comment="" />
<created>1567410812558</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1567410812558</updated>
</task>
<servers />
</component>
<component name="Vcs.Log.History.Properties">
<option name="COLUMN_ORDER">
<list>
<option value="0" />
<option value="2" />
<option value="3" />
<option value="1" />
</list>
</option>
</component>
<component name="WindowStateProjectService">
<state x="1166" y="-948" key="#Launcher" timestamp="1581954807122">
<screen x="0" y="-1440" width="2560" height="1440" />
</state>
<state x="1166" y="-948" key="#Launcher/0.-1440.2560.1440/0.0.1792.1120@0.-1440.2560.1440" timestamp="1581954807122" />
<state x="100" y="-1340" width="2360" height="1240" key="#com.intellij.execution.junit2.states.ComparisonFailureState$DiffDialog" timestamp="1581954640313">
<screen x="0" y="-1440" width="2560" height="1440" />
</state>
<state x="100" y="-1340" width="2360" height="1240" key="#com.intellij.execution.junit2.states.ComparisonFailureState$DiffDialog/0.-1440.2560.1440/0.0.1792.1120@0.-1440.2560.1440" timestamp="1581954640313" />
<state x="854" y="-1129" key="#gen.srcml_[install]" timestamp="1581953518814">
<screen x="0" y="-1440" width="2560" height="1440" />
</state>
<state x="854" y="-1129" key="#gen.srcml_[install]/0.-1440.2560.1440/0.0.1792.1120@0.-1440.2560.1440" timestamp="1581953518814" />
<state x="854" y="-1129" key="#gumtree_[install]" timestamp="1581953568803">
<screen x="0" y="-1440" width="2560" height="1440" />
</state>
<state x="854" y="-1129" key="#gumtree_[install]/0.-1440.2560.1440/0.0.1792.1120@0.-1440.2560.1440" timestamp="1581953568803" />
<state width="2518" height="423" key="GridCell.Tab.0.bottom" timestamp="1581958051741">
<screen x="0" y="-1440" width="2560" height="1440" />
</state>
<state width="2518" height="423" key="GridCell.Tab.0.bottom/0.-1440.2560.1440/0.0.1792.1120@0.-1440.2560.1440" timestamp="1581957957101" />
<state width="2518" height="423" key="GridCell.Tab.0.bottom/0.-1440.2560.1440/49.23.1743.1097@0.-1440.2560.1440" timestamp="1581958051741" />
<state width="2518" height="423" key="GridCell.Tab.0.center" timestamp="1581958051739">
<screen x="0" y="-1440" width="2560" height="1440" />
</state>
<state width="2518" height="423" key="GridCell.Tab.0.center/0.-1440.2560.1440/0.0.1792.1120@0.-1440.2560.1440" timestamp="1581957957100" />
<state width="2518" height="423" key="GridCell.Tab.0.center/0.-1440.2560.1440/49.23.1743.1097@0.-1440.2560.1440" timestamp="1581958051739" />
<state width="2518" height="423" key="GridCell.Tab.0.left" timestamp="1581958051738">
<screen x="0" y="-1440" width="2560" height="1440" />
</state>
<state width="2518" height="423" key="GridCell.Tab.0.left/0.-1440.2560.1440/0.0.1792.1120@0.-1440.2560.1440" timestamp="1581957957098" />
<state width="2518" height="423" key="GridCell.Tab.0.left/0.-1440.2560.1440/49.23.1743.1097@0.-1440.2560.1440" timestamp="1581958051738" />
<state width="2518" height="423" key="GridCell.Tab.0.right" timestamp="1581958051740">
<screen x="0" y="-1440" width="2560" height="1440" />
</state>
<state width="2518" height="423" key="GridCell.Tab.0.right/0.-1440.2560.1440/0.0.1792.1120@0.-1440.2560.1440" timestamp="1581957957100" />
<state width="2518" height="423" key="GridCell.Tab.0.right/0.-1440.2560.1440/49.23.1743.1097@0.-1440.2560.1440" timestamp="1581958051740" />
<state width="2518" height="519" key="GridCell.Tab.1.bottom" timestamp="1581955054072">
<screen x="0" y="-1440" width="2560" height="1440" />
</state>
<state width="2518" height="519" key="GridCell.Tab.1.bottom/0.-1440.2560.1440/0.0.1792.1120@0.-1440.2560.1440" timestamp="1581955054072" />
<state width="2518" height="519" key="GridCell.Tab.1.center" timestamp="1581955054071">
<screen x="0" y="-1440" width="2560" height="1440" />
</state>
<state width="2518" height="519" key="GridCell.Tab.1.center/0.-1440.2560.1440/0.0.1792.1120@0.-1440.2560.1440" timestamp="1581955054071" />
<state width="2518" height="519" key="GridCell.Tab.1.left" timestamp="1581955054070">
<screen x="0" y="-1440" width="2560" height="1440" />
</state>
<state width="2518" height="519" key="GridCell.Tab.1.left/0.-1440.2560.1440/0.0.1792.1120@0.-1440.2560.1440" timestamp="1581955054070" />
<state width="2518" height="519" key="GridCell.Tab.1.right" timestamp="1581955054071">
<screen x="0" y="-1440" width="2560" height="1440" />
</state>
<state width="2518" height="519" key="GridCell.Tab.1.right/0.-1440.2560.1440/0.0.1792.1120@0.-1440.2560.1440" timestamp="1581955054071" />
<state x="947" y="-1016" key="NewModule_or_Project.wizard" timestamp="1581953235296">
<screen x="0" y="-1440" width="2560" height="1440" />
</state>
<state x="947" y="-1016" key="NewModule_or_Project.wizard/0.-1440.2560.1440/0.0.1792.1120@0.-1440.2560.1440" timestamp="1581953235296" />
<state x="768" y="-1137" key="SettingsEditor" timestamp="1581953241154">
<screen x="0" y="-1440" width="2560" height="1440" />
</state>
<state x="768" y="-1137" key="SettingsEditor/0.-1440.2560.1440/0.0.1792.1120@0.-1440.2560.1440" timestamp="1581953241154" />
<state width="1280" height="720" key="XDebugger.FullValuePopup" timestamp="1581954433376">
<screen x="0" y="-1440" width="2560" height="1440" />
</state>
<state width="1280" height="720" key="XDebugger.FullValuePopup/0.-1440.2560.1440/0.0.1792.1120@0.-1440.2560.1440" timestamp="1581954433376" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/fixminer/Launcher.java</url>
<line>29</line>
<option name="timeStamp" value="1" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/fixminer/Launcher.java</url>
<line>50</line>
<option name="timeStamp" value="2" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/fixminer/jobs/EnhancedASTDiff.java</url>
<line>74</line>
<option name="timeStamp" value="5" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/fixminer/akka/ediff/EDiffHunkParser.java</url>
<line>56</line>
<option name="timeStamp" value="6" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/fixminer/akka/compare/CompareTrees.java</url>
<line>95</line>
<option name="timeStamp" value="11" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/fixminer/akka/compare/CompareTrees.java</url>
<line>56</line>
<option name="timeStamp" value="12" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/fixminer/akka/compare/CompareTrees.java</url>
<line>81</line>
<option name="timeStamp" value="14" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/utils/EDiffHelper.java</url>
<line>265</line>
<option name="timeStamp" value="15" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/fixminer/akka/compare/CompareTrees.java</url>
<line>107</line>
<option name="timeStamp" value="17" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/fixminer/akka/compare/AkkaTreeParser.java</url>
<line>44</line>
<option name="timeStamp" value="18" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/fixminer/akka/ediff/EDiffHunkParser.java</url>
<line>51</line>
<option name="timeStamp" value="24" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/fixminer/Launcher.java</url>
<line>98</line>
<option name="timeStamp" value="27" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/fixminer/Launcher.java</url>
<line>64</line>
<option name="timeStamp" value="28" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/utils/ClusterToPattern.java</url>
<line>28</line>
<option name="timeStamp" value="29" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/fixminer/Launcher.java</url>
<line>95</line>
<option name="timeStamp" value="31" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/fixminer/akka/ediff/TestRealCases.java</url>
<line>387</line>
<option name="timeStamp" value="32" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/../gumtree/gen.srcml/src/main/java/com/github/gumtreediff/gen/srcml/AbstractSrcmlTreeGenerator.java</url>
<line>133</line>
<option name="timeStamp" value="35" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/../gumtree/gen.srcml/src/main/java/com/github/gumtreediff/gen/srcml/AbstractSrcmlTreeGenerator.java</url>
<line>456</line>
<option name="timeStamp" value="36" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/fixminer/Launcher.java</url>
<line>81</line>
<option name="timeStamp" value="37" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/fixminer/jobs/EnhancedASTDiff.java</url>
<line>40</line>
<option name="timeStamp" value="38" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/edu/lu/uni/serval/fixminer/jobs/EnhancedASTDiff.java</url>
<line>42</line>
<option name="timeStamp" value="39" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
<component name="debuggerHistoryManager">
<expressions id="evaluateCodeFragment">
<expression>
<expression-string>String[] split = prefix.split(&quot;-&quot;);
String s = null;//inner.get(prefix.replace(&quot;-&quot;,&quot;/&quot;) +&quot;/&quot;+dist2load);
// Set&lt;String&gt; keys = outer.keys(split[0] + &quot;/&quot;+split[1]+&quot;/&quot; + dist2load);
String key = split[0] + &quot;/&quot;+split[1]+&quot;/&quot; + dist2load;</expression-string>
<language-id>JAVA</language-id>
<evaluation-mode>CODE_FRAGMENT</evaluation-mode>
</expression>
<expression>
<expression-string>actionSetRead.toString().equals(actionSet.toString())</expression-string>
<language-id>JAVA</language-id>
<evaluation-mode>CODE_FRAGMENT</evaluation-mode>
</expression>
<expression>
<expression-string>actionSetRead.toString()</expression-string>
<language-id>JAVA</language-id>
<evaluation-mode>CODE_FRAGMENT</evaluation-mode>
</expression>
<expression>
<expression-string>actionSetRead.equals(actionSet)</expression-string>
<language-id>JAVA</language-id>
<evaluation-mode>CODE_FRAGMENT</evaluation-mode>
</expression>
<expression>
<expression-string>HierarchicalActionSet actionSetRead = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(s);</expression-string>
<language-id>JAVA</language-id>
<evaluation-mode>CODE_FRAGMENT</evaluation-mode>
</expression>
<expression>
<expression-string>EDiffHelper.kryoSerialize(actionSet)</expression-string>
<language-id>JAVA</language-id>
<evaluation-mode>CODE_FRAGMENT</evaluation-mode>
</expression>
<expression>
<expression-string>s = outer.hget(&quot;dump&quot;,key);</expression-string>
<language-id>JAVA</language-id>
<evaluation-mode>CODE_FRAGMENT</evaluation-mode>
</expression>
<expression>
<expression-string>filenames.get(prefix + &quot;-&quot; + fn)</expression-string>
<language-id>JAVA</language-id>
<evaluation-mode>CODE_FRAGMENT</evaluation-mode>
</expression>
<expression>
<expression-string>filenames[prefix + &quot;-&quot; + fn]</expression-string>
<language-id>JAVA</language-id>
<evaluation-mode>CODE_FRAGMENT</evaluation-mode>
</expression>
</expressions>
</component>
</project>
+13
View File
@@ -0,0 +1,13 @@
sudo: required
dist: bionic
language: java
before_install:
- chmod +x .travis_native_dependencies.sh
- ./.travis_native_dependencies.sh
jdk:
- openjdk8
install: true
script: mvn clean package #-DskipTests=true
after_success:
- mvn clean test jacoco:report coveralls:report
+6
View File
@@ -0,0 +1,6 @@
# 0) Installing dependencies
sudo apt-get update
sudo apt-get install gdebi-core libarchive-tools
wget http://131.123.42.38/lmcrs/v1.0.0/srcml_1.0.0-1_ubuntu18.04.deb
sudo gdebi srcml_1.0.0-1_ubuntu18.04.deb -n
-61
View File
@@ -1,61 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resource" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.javatuples:javatuples:1.2" level="project" />
<orderEntry type="library" name="Maven: me.tongfei:progressbar:0.8.1" level="project" />
<orderEntry type="library" name="Maven: org.jline:jline:3.13.3" level="project" />
<orderEntry type="library" name="Maven: org.jline:jline-terminal-jansi:3.13.3" level="project" />
<orderEntry type="library" name="Maven: org.fusesource.jansi:jansi:1.18" level="project" />
<orderEntry type="library" name="Maven: org.jline:jline-terminal:3.13.3" level="project" />
<orderEntry type="library" name="Maven: com.typesafe.akka:akka-actor_2.11:2.4.17" level="project" />
<orderEntry type="library" name="Maven: org.scala-lang:scala-library:2.11.8" level="project" />
<orderEntry type="library" name="Maven: com.typesafe:config:1.3.0" level="project" />
<orderEntry type="library" name="Maven: org.scala-lang.modules:scala-java8-compat_2.11:0.7.0" level="project" />
<orderEntry type="module" module-name="core" />
<orderEntry type="library" name="Maven: com.github.mpkorstanje:simmetrics-core:3.0.3" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:18.0" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.10" level="project" />
<orderEntry type="library" name="Maven: net.sf.trove4j:trove4j:3.0.3" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.3" level="project" />
<orderEntry type="module" module-name="gen.jdt" />
<orderEntry type="library" name="Maven: edu.lu.uni:simple-utils:0.0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi:3.12" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml:3.12" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:3.12" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:2.6.0" level="project" />
<orderEntry type="library" name="Maven: stax:stax-api:1.0.1" level="project" />
<orderEntry type="library" name="Maven: net.sourceforge.jexcelapi:jxl:2.6.12" level="project" />
<orderEntry type="library" name="Maven: log4j:log4j:1.2.14" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.core:runtime:3.10.0-v20140318-2214" level="project" />
<orderEntry type="library" name="Maven: org.eclipse:osgi:3.10.0-v20140606-1445" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.equinox:common:3.6.200-v20130402-1505" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.core:jobs:3.6.0-v20140424-0053" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.equinox:registry:3.5.400-v20140428-1507" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.equinox:preferences:3.5.200-v20140224-1527" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.core:contenttype:3.4.200-v20140207-1251" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.equinox:app:1.3.200-v20130910-1609" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.birt.runtime:org.eclipse.core.resources:3.10.0.v20150423-0755" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.tycho:org.eclipse.jdt.core:3.12.2.v20161117-1814" level="project" />
<orderEntry type="module" module-name="gen.srcml" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.7" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.2" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.2" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" name="Maven: redis.clients:jedis:2.8.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.4.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-text:1.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.7" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.4" level="project" />
</component>
</module>
+341 -29
View File
File diff suppressed because one or more lines are too long
-210
View File
@@ -1,210 +0,0 @@
diff --git a/.gitignore b/.gitignore
index 24cae48..27c7ba3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,7 @@ GumTreeInput/
GumTreeInput1/
GumTreeOutput1/
GumTreeResults/
+.idea/*
*/Test.java
*TestParser.java
diff --git a/src/main/java/edu/lu/uni/serval/FixPatternParser/violations/FixedViolationHunkParser.java b/src/main/java/edu/lu/uni/serval/FixPatternParser/violations/FixedViolationHunkParser.java
index 4d885ea..eb1eca1 100644
--- a/src/main/java/edu/lu/uni/serval/FixPatternParser/violations/FixedViolationHunkParser.java
+++ b/src/main/java/edu/lu/uni/serval/FixPatternParser/violations/FixedViolationHunkParser.java
@@ -1,5 +1,9 @@
package edu.lu.uni.serval.FixPatternParser.violations;
+import com.github.gumtreediff.actions.model.Delete;
+import com.github.gumtreediff.actions.model.Insert;
+import com.github.gumtreediff.actions.model.Move;
+import com.github.gumtreediff.actions.model.Update;
import edu.lu.uni.serval.gumtree.regroup.HierarchicalActionSet;
import java.io.*;
@@ -30,27 +34,29 @@ public class FixedViolationHunkParser extends FixedViolationParser {
public void parseFixPatterns(File prevFile, File revFile, File diffentryFile,String project) {
List<HierarchicalActionSet> actionSets = parseChangedSourceCodeWithGumTree2(prevFile, revFile);
if (actionSets.size() != 0) {
-// boolean isUpdate =
-// actionSets.stream().allMatch(p -> p.getAction() instanceof Update);
-// boolean isInsert =
-// actionSets.stream().allMatch(p -> p.getAction() instanceof Insert);
-// boolean isDelete =
-// actionSets.stream().allMatch(p -> p.getAction() instanceof Delete);
-// boolean isMove =
-// actionSets.stream().allMatch(p -> p.getAction() instanceof Move);
int hunkSet = 0;
// if (isUpdate || isInsert || isDelete || isMove) {
for (HierarchicalActionSet actionSet : actionSets) {
- String folder = "/ALL/";
-// if (isUpdate) {
-// folder = "/UPD/";
-// } else if (isDelete) {
-// folder = "/DEL/";
-// } else if (isInsert) {
-// folder = "/INS/";
-// } else if (isMove) {
-// folder = "/MOV/";
-// }
+ boolean isUpdate =
+ actionSets.stream().allMatch(p -> p.getAction() instanceof Update);
+ boolean isInsert =
+ actionSets.stream().allMatch(p -> p.getAction() instanceof Insert);
+ boolean isDelete =
+ actionSets.stream().allMatch(p -> p.getAction() instanceof Delete);
+ boolean isMove =
+ actionSets.stream().allMatch(p -> p.getAction() instanceof Move);
+ String folder = "/MIX/";
+ if (isUpdate) {
+ folder = "/UPD/";
+ } else if (isDelete) {
+ folder = "/DEL/";
+ } else if (isInsert) {
+ folder = "/INS/";
+ } else if (isMove) {
+ folder = "/MOV/";
+ } else{
+ folder = "/MIX/";
+ }
FileOutputStream f = null;
diff --git a/src/main/java/edu/lu/uni/serval/MultipleThreadsParser/ParseFixPatternWorker.java b/src/main/java/edu/lu/uni/serval/MultipleThreadsParser/ParseFixPatternWorker.java
index 3084dbe..ffe1b01 100644
--- a/src/main/java/edu/lu/uni/serval/MultipleThreadsParser/ParseFixPatternWorker.java
+++ b/src/main/java/edu/lu/uni/serval/MultipleThreadsParser/ParseFixPatternWorker.java
@@ -61,7 +61,7 @@ public class ParseFixPatternWorker extends UntypedActor {
int testInfos = 0;
int timeouts = 0;
StringBuilder builder = new StringBuilder();
-
+// log.info("Work queue size " + files.size());
for (MessageFile msgFile : files) {
File revFile = msgFile.getRevFile();
File prevFile = msgFile.getPrevFile();
diff --git a/src/main/java/edu/lu/uni/serval/config/Configuration.java b/src/main/java/edu/lu/uni/serval/config/Configuration.java
index 4421c72..7162180 100644
--- a/src/main/java/edu/lu/uni/serval/config/Configuration.java
+++ b/src/main/java/edu/lu/uni/serval/config/Configuration.java
@@ -2,6 +2,6 @@ package edu.lu.uni.serval.config;
public class Configuration {
- public static final long SECONDS_TO_WAIT = 900L;
+ public static final long SECONDS_TO_WAIT = 90000L;
}
diff --git a/src/main/java/edu/lu/uni/serval/fixminer/EnhancedASTDiff.java b/src/main/java/edu/lu/uni/serval/fixminer/EnhancedASTDiff.java
index 43895e0..066b07d 100644
--- a/src/main/java/edu/lu/uni/serval/fixminer/EnhancedASTDiff.java
+++ b/src/main/java/edu/lu/uni/serval/fixminer/EnhancedASTDiff.java
@@ -5,7 +5,7 @@ import akka.actor.ActorSystem;
import edu.lu.uni.serval.MultipleThreadsParser.MessageFile;
import edu.lu.uni.serval.MultipleThreadsParser.ParseFixPatternActor;
import edu.lu.uni.serval.MultipleThreadsParser.WorkMessage;
-import edu.lu.uni.serval.utils.FileHelper;
+import edu.lu.uni.serval.FixPattern.utils.FileHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -13,6 +13,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Locale;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -31,6 +32,7 @@ public class EnhancedASTDiff {
Stream<File> stream = Arrays.stream(listOfFiles);
List<File> folders = stream
.filter(x -> !x.getName().startsWith("."))
+// .filter(x -> x.getName().startsWith("JDT"))
.collect(Collectors.toList());
@@ -49,11 +51,11 @@ public class EnhancedASTDiff {
FileHelper.createDirectory(GUM_TREE_OUTPUT + "/INS");
FileHelper.createDirectory(GUM_TREE_OUTPUT + "/DEL");
FileHelper.createDirectory(GUM_TREE_OUTPUT + "/MOV");
- FileHelper.createDirectory(GUM_TREE_OUTPUT + "/ALL");
+ FileHelper.createDirectory(GUM_TREE_OUTPUT + "/MIX");
int a = 0;
-
+ log.info("Work queue size " + msgFiles.size());
ActorSystem system = null;
ActorRef parsingActor = null;
final WorkMessage msg = new WorkMessage(0, msgFiles);
@@ -80,6 +82,11 @@ public class EnhancedASTDiff {
if (revFiles.length >= 0) {
for (File revFile : revFiles) {
String fileName = revFile.getName();
+ if(fileName.toLowerCase(Locale.ENGLISH).contains("test")){
+ log.info(fileName);
+ continue;
+ }
+
File prevFile = new File(gumTreeInput + "prevFiles/prev_" + fileName);// previous file
fileName = fileName.replace(".java", ".txt");
File diffentryFile = new File(gumTreeInput + "DiffEntries/" + fileName); // DiffEntry file
diff --git a/src/main/java/edu/lu/uni/serval/fixminer/TestHunkParserSingleFile.java b/src/main/java/edu/lu/uni/serval/fixminer/TestHunkParserSingleFile.java
index 44575a7..88f36c6 100644
--- a/src/main/java/edu/lu/uni/serval/fixminer/TestHunkParserSingleFile.java
+++ b/src/main/java/edu/lu/uni/serval/fixminer/TestHunkParserSingleFile.java
@@ -5,7 +5,7 @@ import akka.actor.ActorSystem;
import edu.lu.uni.serval.MultipleThreadsParser.MessageFile;
import edu.lu.uni.serval.MultipleThreadsParser.ParseFixPatternActor;
import edu.lu.uni.serval.MultipleThreadsParser.WorkMessage;
-import edu.lu.uni.serval.utils.FileHelper;
+import edu.lu.uni.serval.FixPattern.utils.FileHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/main/java/edu/lu/uni/serval/fixminer/cluster/CallShell.java b/src/main/java/edu/lu/uni/serval/fixminer/cluster/CallShell.java
index 9c1d05d..3dceda0 100644
--- a/src/main/java/edu/lu/uni/serval/fixminer/cluster/CallShell.java
+++ b/src/main/java/edu/lu/uni/serval/fixminer/cluster/CallShell.java
@@ -37,7 +37,7 @@ public class CallShell {
}
// Thread.sleep(Integer.valueOf(serverWait));
- String cmd = "redis-cli -p %s ping";
+ String cmd = "bash source activate redisEnv && redis-cli -p %s ping";
String cmd1 = String.format(cmd,Integer.valueOf(port));
runPing(cmd1);
diff --git a/src/main/java/edu/lu/uni/serval/fixminer/cluster/StoreEDiffInCache.java b/src/main/java/edu/lu/uni/serval/fixminer/cluster/StoreEDiffInCache.java
index 39bba51..8657dce 100644
--- a/src/main/java/edu/lu/uni/serval/fixminer/cluster/StoreEDiffInCache.java
+++ b/src/main/java/edu/lu/uni/serval/fixminer/cluster/StoreEDiffInCache.java
@@ -52,13 +52,15 @@ public class StoreEDiffInCache {
.filter(x -> x.getName().startsWith("UPD") ||
x.getName().startsWith("INS") ||
x.getName().startsWith("DEL") ||
+ x.getName().startsWith("MIX") ||
x.getName().startsWith("MOV"))
.collect(Collectors.toList());
File[] files1 = fs.get(0).listFiles();
File[] files2 = fs.get(1).listFiles();
File[] files3 = fs.get(2).listFiles();
File[] files4 = fs.get(3).listFiles();
- dumps = Stream.of(files1, files2, files3,files4).flatMap(Stream::of).toArray(File[]::new);
+ File[] files5 = fs.get(4).listFiles();
+ dumps = Stream.of(files1, files2, files3,files4,files5).flatMap(Stream::of).toArray(File[]::new);
}else{
fs = fileStream
.filter(x -> x.getName().startsWith(operation))
@@ -70,7 +72,7 @@ public class StoreEDiffInCache {
for (File f : dumps) {
String name = f.getName();
- String key = pjName + "/"+ operation+"/" + name;
+ String key = pjName + f.getPath().replace(pj.getPath(),"");
String result = key +","+f.getPath();
workList.add(result);
}
+13
View File
@@ -0,0 +1,13 @@
name: fixminerEnv
channels:
- anaconda
- defaults
dependencies:
- numpy
- tqdm
- pandas
- pyyaml
- redis-py
- scikit-learn
- networkx=2.1
+6
View File
@@ -0,0 +1,6 @@
#!/bin/bash
source activate fixminerEnv
PYTHONPATH=$(pwd) python -u python/main.py -root $(pwd)/python -job $2 -prop $1
+14
View File
@@ -0,0 +1,14 @@
target/
samples/
.settings/
.project
.classpath
.recommenders/
.metadata/
.idea/
*.iml
.DS_Store
OUTPUT/
Dataset/
logs/
gen.jdt/src/main/java/edu/lu/uni/serval/gumtree/GumTreeTester.java
+5
View File
@@ -0,0 +1,5 @@
language: java
jdk:
- oraclejdk8
after_success:
- mvn clean test jacoco:report coveralls:report
+165
View File
@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
+40
View File
@@ -0,0 +1,40 @@
# GumTree ![Build Status](https://travis-ci.org/GumTreeDiff/gumtree.svg?branch=master) [![Coverage Status](https://coveralls.io/repos/GumTreeDiff/gumtree/badge.svg?branch=master)](https://coveralls.io/r/GumTreeDiff/gumtree?branch=master)
GumTree is a complete framework to deal with source code as trees and compute differences between them. It includes possibilities such as:
* converting a source file into a language-agnostic tree format
* export the produced trees in various formats
* compute the differences between the trees
* export these differences in various formats
* visualize these differences graphically
Compared to classical code differencing tools, it has two important particularities:
* it works on a tree structure rather than a text structure,
* it can detect moved or renamed elements in addition of deleted and inserted elements.
We already deal with a wide range of languages: Java, C, JavaScript and Ruby. More languages are coming soon, if you want to help contact [me](www.labri.fr/perso/falleri).
## Citing GumTree
We are researchers, therefore if you use GumTree in an academic work we would be really glad if you cite our seminal paper using the following bibtex:
```
@inproceedings{DBLP:conf/kbse/FalleriMBMM14,
author = {Jean{-}R{\'{e}}my Falleri and
Flor{\'{e}}al Morandat and
Xavier Blanc and
Matias Martinez and
Martin Monperrus},
title = {Fine-grained and accurate source code differencing},
booktitle = {{ACM/IEEE} International Conference on Automated Software Engineering,
{ASE} '14, Vasteras, Sweden - September 15 - 19, 2014},
pages = {313--324},
year = {2014},
url = {http://doi.acm.org/10.1145/2642937.2642982},
doi = {10.1145/2642937.2642982}
}
```
## Documentation
Please consult our [wiki](https://github.com/GumTreeDiff/gumtree/wiki)
+76
View File
@@ -0,0 +1,76 @@
plugins {
id 'me.champeau.gradle.jmh' version '0.2.0'
}
apply plugin: 'me.champeau.gradle.jmh'
uploadArchives.enabled = false
jar.enabled = false
task checkActions(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'com.github.gumtree.dist.ActionsCollector'
args 'check'
}
task collectActions(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'com.github.gumtree.dist.ActionsCollector'
args 'collect'
}
if (project.hasProperty('trees')) {
task collectTrees(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'com.github.gumtree.dist.BenchmarkCollector'
args trees
}
}
def getGitHash = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--dirty=+', '--tags'
standardOutput = stdout
}
return stdout.toString().trim()
} catch (all) {
return '0000000'
}
}
jmh {
fork = 0
warmupIterations = 3
iterations = 3
benchmarkMode = 'avgt'
benchmarkParameters = [
'refPath' : new File("${project.projectDir}/src/jmh/resources/").listFiles()
.collect { it.getAbsolutePath() }
.findAll { it.matches(".*_v0_.*") }
.join(",")
]
humanOutputFile = project.file("${project.buildDir}/reports/jmh/human_${new Date().getTime()}_${getGitHash()}.txt")
resultsFile = project.file("${project.buildDir}/reports/jmh/results_${new Date().getTime()}_${getGitHash()}.csv")
resultFormat = 'CSV'
}
task jmhPlot(type: Exec, dependsOn: 'jmh') {
commandLine "R", "-f", "${project.projectDir}/src/main/r/plotBenchmark.R", "${project.buildDir}/reports/jmh/"
}
dependencies {
compile project(':client')
compile project(':client.diff')
compile project(':gen.antlr3')
compile project(':gen.antlr3-antlr')
compile project(':gen.antlr3-json')
compile project(':gen.antlr3-php')
compile project(':gen.antlr3-r')
compile project(':gen.antlr3-xml')
compile project(':gen.c')
compile project(':gen.jdt')
compile project(':gen.js')
compile project(':gen.ruby')
}
@@ -0,0 +1,58 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2016 Jean-Rémy Falleri <jr.falleri@gmail.com>
*/
package com.github.gumtree.dist;
import com.github.gumtreediff.io.TreeIoUtils;
import com.github.gumtreediff.matchers.CompositeMatchers;
import com.github.gumtreediff.matchers.MappingStore;
import com.github.gumtreediff.matchers.Matcher;
import com.github.gumtreediff.tree.ITree;
import org.openjdk.jmh.annotations.*;
public class MatcherAnalyzer {
@State(Scope.Benchmark)
public static class TreeData {
@Setup
public void load() {
try {
String otherPath = refPath.replace("_v0_", "_v1_");
src = TreeIoUtils.fromXml().generateFromFile(refPath).getRoot();
dst = TreeIoUtils.fromXml().generateFromFile(otherPath).getRoot();
} catch (Exception e) {
e.printStackTrace();
}
}
@Param({})
public String refPath;
public ITree src;
public ITree dst;
}
@Benchmark
public void testClassicGumtree(TreeData d) {
Matcher m = new CompositeMatchers.ClassicGumtree(d.src, d.dst, new MappingStore());
m.match();
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,145 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2016 Jean-Rémy Falleri <jr.falleri@gmail.com>
*/
package com.github.gumtree.dist;
import com.github.gumtreediff.actions.ActionGenerator;
import com.github.gumtreediff.actions.model.Action;
import com.github.gumtreediff.client.Run;
import com.github.gumtreediff.gen.Generators;
import com.github.gumtreediff.io.ActionsIoUtils;
import com.github.gumtreediff.io.TreeIoUtils;
import com.github.gumtreediff.matchers.CompositeMatchers;
import com.github.gumtreediff.matchers.MappingStore;
import com.github.gumtreediff.tree.ITree;
import com.github.gumtreediff.tree.TreeContext;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
public class ActionsCollector {
private static final String OUTPUT_DIR = "build/tmp/actions/";
private static final String RES_DIR = "src/jmh/resources/";
private static final String REF_DIR = "src/main/resources/";
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.err.println("Wrong number of arguments.");
System.exit(-1);
}
if (args[0].equals("collect"))
collectActions();
else if (args[0].equals("check"))
checkActions();
else {
System.err.println("Unknown argument: use collect or test.");
System.exit(-1);
}
}
public static void collectActions() throws Exception {
Run.initGenerators();
List<Path> paths = Files.walk(Paths.get(RES_DIR)).filter(
p -> p.getFileName().toString().matches(".*_v0_.*\\.xml")).collect(Collectors.toList());
Files.createDirectories(Paths.get(OUTPUT_DIR));
for (Path path : paths) {
Path otherPath = Paths.get(path.toString().replace("_v0_","_v1_"));
Path outputPath = Paths.get(path.toString().replace("_v0_","_actions_"));
TreeContext src = TreeIoUtils.fromXml().generateFromFile(path.toString());
TreeContext dst = TreeIoUtils.fromXml().generateFromFile(otherPath.toString());
CompositeMatchers.ClassicGumtree matcher = new CompositeMatchers.ClassicGumtree(
src.getRoot(), dst.getRoot(), new MappingStore());
matcher.match();
ActionGenerator g = new ActionGenerator(src.getRoot(), dst.getRoot(), matcher.getMappings());
List<Action> actions = g.generate();
String res = Paths.get(OUTPUT_DIR, outputPath.getFileName().toString()).toString();
ActionsIoUtils.toText(src, actions, matcher.getMappings()).writeTo(new FileWriter(res));
}
}
public static void checkActions() throws Exception {
Run.initGenerators();
List<Path> paths = Files.walk(Paths.get(RES_DIR)).filter(
p -> p.getFileName().toString().matches(".*_v0_.*\\.xml")).collect(Collectors.toList());
boolean dirty = false;
StringBuffer b = new StringBuffer();
for (Path path : paths) {
Path otherPath = Paths.get(path.toString().replace("_v0_","_v1_"));
TreeContext src = TreeIoUtils.fromXml().generateFromFile(path.toString());
TreeContext dst = TreeIoUtils.fromXml().generateFromFile(otherPath.toString());
CompositeMatchers.ClassicGumtree matcher = new CompositeMatchers.ClassicGumtree(
src.getRoot(), dst.getRoot(), new MappingStore());
matcher.match();
ActionGenerator g = new ActionGenerator(src.getRoot(), dst.getRoot(), matcher.getMappings());
List<Action> actions = g.generate();
StringWriter w = new StringWriter();
ActionsIoUtils.toText(src, actions, matcher.getMappings()).writeTo(w);
Path refPath = Paths.get(path.toString().replace("_v0_","_actions_"));
String ref = Paths.get(REF_DIR, refPath.getFileName().toString()).toString();
if (!contentEquals(new StringReader(w.toString()), new FileReader(ref))) {
dirty = true;
b.append(String.format("Content not equals for: %s. Now: %d Was: %d\n",
ref, countLines(new StringReader(w.toString())), countLines(new FileReader(ref))));
}
}
if (dirty) {
System.err.println(b.toString());
System.exit(-1);
}
}
public static boolean contentEquals(Reader cur, Reader ref) throws IOException {
try (Reader _cur = cur; Reader _ref = ref) {
int ch = _cur.read();
while (-1 != ch) {
int ch2 = _ref.read();
if (ch != ch2)
return false;
ch = _cur.read();
}
int ch2 = _ref.read();
return (ch2 == -1);
}
}
public static int countLines(Reader r) throws IOException {
try (Reader _r = r) {
char[] c = new char[1024];
int count = 0;
int readChars = 0;
boolean empty = true;
while ((readChars = _r.read(c)) != -1) {
empty = false;
for (int i = 0; i < readChars; ++i)
if (c[i] == '\n')
++count;
}
return (count == 0 && !empty) ? 1 : count;
}
}
}
@@ -0,0 +1,72 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2016 Jean-Rémy Falleri <jr.falleri@gmail.com>
*/
package com.github.gumtree.dist;
import com.github.gumtreediff.client.Run;
import com.github.gumtreediff.gen.Generators;
import com.github.gumtreediff.io.TreeIoUtils;
import com.github.gumtreediff.tree.TreeContext;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
public class BenchmarkCollector {
private static final String OUTPUT_DIR = "build/tmp/trees/";
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.err.println("Wrong number of arguments");
System.exit(-1);
}
collectTrees(args[0]);
}
public static void collectTrees(String dir) throws Exception {
Run.initGenerators();
List<Path> paths = Files.walk(Paths.get(dir)).filter(
p -> p.getFileName().toString().matches(".*_v0\\.(java|js|rb|c)")).collect(Collectors.toList());
Files.createDirectories(Paths.get(OUTPUT_DIR));
for (Path path : paths) {
Path otherPath = Paths.get(path.toString().replace("_v0.","_v1."));
String oldName = path.toString().replaceAll("[^a-zA-Z0-9_]", "_");
String newName = otherPath.toString().replaceAll("[^a-zA-Z0-9_]", "_");
TreeContext ctx = getTreeContext(path.toAbsolutePath().toString());
TreeIoUtils.toXml(ctx).writeTo(new File(OUTPUT_DIR + oldName + ".xml"));
ctx = getTreeContext(otherPath.toAbsolutePath().toString());
TreeIoUtils.toXml(ctx).writeTo(new File(OUTPUT_DIR + newName + ".xml"));
}
}
private static TreeContext getTreeContext(String file) {
try {
TreeContext t = Generators.getInstance().getTree(file);
return t;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
@@ -0,0 +1,42 @@
# This file is part of GumTree.
#
# GumTree is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GumTree is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with GumTree. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright 2016 Jean-Rémy Falleri <jr.falleri@gmail.com>
# Copyright 2016 Floréal Morandat <florealm@gmail.com>
library(ggplot2)
library(plyr)
folder <- commandArgs()[length(commandArgs())]
pdf(file = file.path(folder, "all_results.pdf"))
files <- list.files(path = folder, pattern = "*.csv", full.names = T)
d <- ldply(files, function (filename) {
fname = strsplit(gsub("^.*results_(\\d*)(_([^_]*))?.csv", "\\1 \\3 ???????", filename), " ")[[1]]
cbind(read.csv(filename), timestamp =
paste(as.POSIXct(as.numeric(fname[[1]])/1000, origin="1970-01-01"),
fname[[2]], sep='\n'))
})
d$name <- gsub('^.*perfs_(.*)_v0_(.*).xml$', '\\1_\\2', d$Param..refPath)
# according to my office mate we should change the size of each line from 0.5 to 0.1
# but I don't know how to do this (size=seq(0.5, 0.1) does not work)
ggplot(d, aes(timestamp, Score, group=d$name, colour=name)) +
geom_point() +
geom_line() +
ylab('Time (s)') +
theme(axis.text.x = element_text(angle = 45, hjust = 1),
axis.title.x=element_blank())
@@ -0,0 +1,54 @@
Insert ExprStatement(8983) into Compound(8987) at 1
Insert Some(8982) into ExprStatement(8983) at 0
Insert Ident(8985) into ReturnExpr(8986) at 0
Move ReturnExpr(37550) into If(37562) at 2
Move ReturnExpr(37572) into If(37582) at 2
Move ArrayAccess(42344) into Binary(42359) at 2
Insert FunCall(8980) into Some(8982) at 0
Insert GenericString: ;(8981) into Some(8982) at 1
Update GenericString: ENETDOWN(8972) to NETDEV_TX_OK
Move GenericString: ENETDOWN(8972) into Ident(8985) at 0
Move Ident(37555) into Binary(37576) at 0
Update GenericString: <(37556) to >=
Move GenericString: <(37556) into Binary(37576) at 1
Insert FunCall(37575) into Binary(37576) at 2
Move Binary(42350) into Binary(42359) at 0
Insert Ident(7105) into ReturnExpr(7106) at 0
Insert Ident(8524) into ReturnExpr(8525) at 0
Insert Ident(8975) into FunCall(8980) at 0
Insert GenericList(8979) into FunCall(8980) at 1
Insert Ident(9137) into ReturnExpr(9138) at 0
Insert Ident(37568) into FunCall(37575) at 0
Insert GenericList(37574) into FunCall(37575) at 1
Insert GenericString: NETDEV_TX_BUSY(7104) into Ident(7105) at 0
Insert GenericString: NETDEV_TX_BUSY(8523) into Ident(8524) at 0
Insert GenericString: dev_kfree_skb_any(8974) into Ident(8975) at 0
Insert Left(8978) into GenericList(8979) at 0
Insert GenericString: NETDEV_TX_BUSY(9136) into Ident(9137) at 0
Insert GenericString: ARRAY_SIZE(37567) into Ident(37568) at 0
Insert Left(37573) into GenericList(37574) at 0
Insert Ident(8977) into Left(8978) at 0
Insert RecordAccess(37572) into Left(37573) at 0
Insert GenericString: skb(8976) into Ident(8977) at 0
Insert Ident(37570) into RecordAccess(37572) at 0
Insert GenericString: ssids(37571) into RecordAccess(37572) at 1
Update GenericString: index(37561) to SSID_rid
Move GenericString: index(37561) into Ident(37570) at 0
Delete Constant: 1(7104)
Delete Constant: 1(8522)
Delete Ident(8973)
Delete GenericString: -(8974)
Delete Unary(8975)
Delete Constant: 1(9126)
Delete Compound(37551)
Delete Constant: 0(37557)
Delete Binary(37558)
Delete ParenExpr(37559)
Delete GenericString: ||(37560)
Delete Ident(37562)
Delete GenericString: >=(37563)
Delete Constant: 4(37564)
Delete Binary(37565)
Delete ParenExpr(37566)
Delete Compound(37573)
Delete ParenExpr(42351)
@@ -0,0 +1,864 @@
Insert Definition(17794) into Program(73177) at 275
Insert Declaration(18390) into Program(73177) at 282
Insert Definition(19619) into Program(73177) at 284
Insert Definition(17793) into Definition(17794) at 0
Insert DeclList(18389) into Declaration(18390) at 0
Insert Definition(19618) into Definition(19619) at 0
Move Storage(17552) into Definition(17793) at 0
Move ParamList(17561) into Definition(17793) at 1
Move GenericString: ipw_fw_dma_add_buffer(17562) into Definition(17793) at 2
Insert Compound(17792) into Definition(17793) at 3
Insert Storage(19068) into Definition(19618) at 0
Move ParamList(19068) into Definition(19618) at 1
Insert GenericString: ipw_load_firmware(19076) into Definition(19618) at 2
Insert Compound(19617) into Definition(19618) at 3
Insert DeclList(9708) into Compound(9729) at 0
Insert ParameterType(17626) into ParamList(17631) at 2
Move DeclList(17567) into Compound(17792) at 0
Move DeclList(17579) into Compound(17792) at 1
Move ExprStatement(17588) into Compound(17792) at 2
Move ExprStatement(17606) into Compound(17792) at 3
Insert For(17780) into Compound(17792) at 4
Move ExprStatement(17782) into Compound(17792) at 5
Insert ReturnExpr(17791) into Compound(17792) at 6
Insert GenericString: static(19067) into Storage(19068) at 0
Move DeclList(19075) into Compound(19617) at 0
Move DeclList(19079) into Compound(19617) at 1
Insert DeclList(19088) into Compound(19617) at 2
Insert DeclList(19092) into Compound(19617) at 3
Insert DeclList(19094) into Compound(19617) at 4
Insert DeclList(19096) into Compound(19617) at 5
Insert DeclList(19098) into Compound(19617) at 6
Insert DeclList(19100) into Compound(19617) at 7
Move ExprStatement(19094) into Compound(19617) at 8
Move ExprStatement(17683) into Compound(19617) at 9
Insert If(19155) into Compound(19617) at 10
Move ExprStatement(19159) into Compound(19617) at 11
Move ExprStatement(17701) into Compound(19617) at 12
Insert DoWhile(19495) into Compound(19617) at 13
Move ExprStatement(19298) into Compound(19617) at 14
Move If(19314) into Compound(19617) at 15
Move ExprStatement(19328) into Compound(19617) at 16
Move If(19344) into Compound(19617) at 17
Move Label(19367) into Compound(19617) at 18
Insert ExprStatement(19613) into Compound(19617) at 19
Move ReturnExpr(19370) into Compound(19617) at 20
Insert ExprStatement(70100) into Compound(70104) at 1
Insert ReturnExpr(70103) into Compound(70104) at 2
Insert GenericString: p(9699) into DeclList(9708) at 0
Insert InitExpr(9707) into DeclList(9708) at 1
Update GenericString: src_phys(17555) to src_address
Insert GenericString: nr(17625) into ParameterType(17626) at 0
Update GenericString: length(17559) to len
Update GenericString: bytes_left(17563) to ret
Insert GenericString: i(17634) into DeclList(17635) at 1
Update GenericString: status(17576) to size
Insert ExprStatement(17672) into For(17780) at 0
Insert ExprStatement(17681) into For(17780) at 1
Insert ExprStatement(17687) into For(17780) at 2
Insert Compound(17779) into For(17780) at 3
Insert Constant: 0(17790) into ReturnExpr(17791) at 0
Update GenericString: rc(19070) to ret
Insert GenericString: chunk(19087) into DeclList(19088) at 0
Insert GenericString: total_nr(19089) into DeclList(19092) at 0
Insert InitExpr(19091) into DeclList(19092) at 1
Insert GenericString: i(19093) into DeclList(19094) at 0
Insert GenericString: pool(19095) into DeclList(19096) at 0
Insert GenericString: virts(19097) into DeclList(19098) at 0
Insert GenericString: phys(19099) into DeclList(19100) at 0
Insert IfToken(19135) into If(19155) at 0
Insert Unary(19139) into If(19155) at 1
Insert Compound(19154) into If(19155) at 2
Insert Compound(19488) into DoWhile(19495) at 0
Move Binary(19283) into DoWhile(19495) at 1
Insert For(19602) into Label(19603) at 1
Insert Some(19612) into ExprStatement(19613) at 0
Insert Some(70099) into ExprStatement(70100) at 0
Insert Ident(70102) into ReturnExpr(70103) at 0
Insert FunCall(9368) into InitExpr(9369) at 0
Insert FunCall(9423) into InitExpr(9424) at 0
Insert FunCall(9478) into InitExpr(9479) at 0
Insert FunCall(9539) into InitExpr(9540) at 0
Insert FunCall(9626) into InitExpr(9627) at 0
Insert FunCall(9706) into InitExpr(9707) at 0
Insert FunCall(9751) into InitExpr(9752) at 0
Insert FunCall(9828) into InitExpr(9829) at 0
Insert FunCall(9885) into InitExpr(9886) at 0
Insert FunCall(9976) into InitExpr(9977) at 0
Insert FunCall(10032) into InitExpr(10033) at 0
Insert FunCall(10122) into InitExpr(10123) at 0
Insert FunCall(10197) into InitExpr(10198) at 0
Insert FunCall(10285) into InitExpr(10286) at 0
Insert FunCall(10360) into InitExpr(10361) at 0
Insert FunCall(10448) into InitExpr(10449) at 0
Insert FunCall(10523) into InitExpr(10524) at 0
Insert FunCall(10671) into InitExpr(10672) at 0
Insert FunCall(10985) into InitExpr(10986) at 0
Insert FunCall(11049) into InitExpr(11050) at 0
Insert FunCall(11163) into InitExpr(11164) at 0
Insert FunCall(11395) into InitExpr(11396) at 0
Insert FunCall(11443) into InitExpr(11444) at 0
Insert Some(17671) into ExprStatement(17672) at 0
Insert Some(17680) into ExprStatement(17681) at 0
Insert Some(17686) into ExprStatement(17687) at 0
Insert ExprStatement(17713) into Compound(17779) at 0
Move ExprStatement(17647) into Compound(17779) at 1
Move If(17674) into Compound(17779) at 2
Insert Constant: 0(19090) into InitExpr(19091) at 0
Insert Ident(19137) into Unary(19139) at 0
Insert GenericString: !(19138) into Unary(19139) at 1
Insert ExprStatement(19148) into Compound(19154) at 0
Move ReturnExpr(19128) into Compound(19154) at 1
Insert FunCall(19183) into Some(19185) at 0
Insert DeclList(19188) into Compound(19488) at 0
Insert DeclList(19190) into Compound(19488) at 1
Insert DeclList(19192) into Compound(19488) at 2
Insert DeclList(19196) into Compound(19488) at 3
Move ExprStatement(19195) into Compound(19488) at 4
Move ExprStatement(19203) into Compound(19488) at 5
Move ExprStatement(19276) into Compound(19488) at 6
Insert ExprStatement(19248) into Compound(19488) at 7
Insert ExprStatement(19269) into Compound(19488) at 8
Insert For(19420) into Compound(19488) at 9
Move ExprStatement(19244) into Compound(19488) at 10
Move If(19260) into Compound(19488) at 11
Insert ExprStatement(19487) into Compound(19488) at 12
Update GenericString: rc(19300) to ret
Update GenericString: rc(19330) to ret
Insert ExprStatement(19564) into For(19602) at 0
Insert ExprStatement(19573) into For(19602) at 1
Insert ExprStatement(19579) into For(19602) at 2
Insert ExprStatement(19601) into For(19602) at 3
Insert FunCall(19610) into Some(19612) at 0
Insert GenericString: ;(19611) into Some(19612) at 1
Update GenericString: rc(19368) to ret
Insert FunCall(70097) into Some(70099) at 0
Insert GenericString: ;(70098) into Some(70099) at 1
Insert GenericString: NETDEV_TX_OK(70101) into Ident(70102) at 0
Insert Ident(9363) into FunCall(9368) at 0
Insert GenericList(9367) into FunCall(9368) at 1
Insert Ident(9418) into FunCall(9423) at 0
Insert GenericList(9422) into FunCall(9423) at 1
Insert Ident(9473) into FunCall(9478) at 0
Insert GenericList(9477) into FunCall(9478) at 1
Insert Ident(9534) into FunCall(9539) at 0
Insert GenericList(9538) into FunCall(9539) at 1
Insert Ident(9621) into FunCall(9626) at 0
Insert GenericList(9625) into FunCall(9626) at 1
Insert Ident(9701) into FunCall(9706) at 0
Insert GenericList(9705) into FunCall(9706) at 1
Move Ident(9686) into RecordPtAccess(9713) at 0
Insert Ident(9746) into FunCall(9751) at 0
Insert GenericList(9750) into FunCall(9751) at 1
Insert Ident(9823) into FunCall(9828) at 0
Insert GenericList(9827) into FunCall(9828) at 1
Insert Ident(9880) into FunCall(9885) at 0
Insert GenericList(9884) into FunCall(9885) at 1
Insert Ident(9971) into FunCall(9976) at 0
Insert GenericList(9975) into FunCall(9976) at 1
Insert Ident(10027) into FunCall(10032) at 0
Insert GenericList(10031) into FunCall(10032) at 1
Insert Ident(10117) into FunCall(10122) at 0
Insert GenericList(10121) into FunCall(10122) at 1
Insert Ident(10192) into FunCall(10197) at 0
Insert GenericList(10196) into FunCall(10197) at 1
Insert Ident(10280) into FunCall(10285) at 0
Insert GenericList(10284) into FunCall(10285) at 1
Insert Ident(10355) into FunCall(10360) at 0
Insert GenericList(10359) into FunCall(10360) at 1
Insert Ident(10443) into FunCall(10448) at 0
Insert GenericList(10447) into FunCall(10448) at 1
Insert Ident(10518) into FunCall(10523) at 0
Insert GenericList(10522) into FunCall(10523) at 1
Insert Ident(10666) into FunCall(10671) at 0
Insert GenericList(10670) into FunCall(10671) at 1
Insert Ident(10980) into FunCall(10985) at 0
Insert GenericList(10984) into FunCall(10985) at 1
Insert Ident(11044) into FunCall(11049) at 0
Insert GenericList(11048) into FunCall(11049) at 1
Insert Ident(11158) into FunCall(11163) at 0
Insert GenericList(11162) into FunCall(11163) at 1
Insert Ident(11390) into FunCall(11395) at 0
Insert GenericList(11394) into FunCall(11395) at 1
Insert Ident(11438) into FunCall(11443) at 0
Insert GenericList(11442) into FunCall(11443) at 1
Insert Assignment(17669) into Some(17671) at 0
Insert GenericString: ;(17670) into Some(17671) at 1
Insert Binary(17678) into Some(17680) at 0
Insert GenericString: ;(17679) into Some(17680) at 1
Insert Postfix(17685) into Some(17686) at 0
Insert Some(17712) into ExprStatement(17713) at 0
Update GenericString: +=(17677) to =
Insert FunCall(19130) into Assignment(19131) at 2
Update GenericString: dest_offset(17684) to pool
Move GenericString: dest_offset(17684) into Ident(19137) at 0
Insert Some(19147) into ExprStatement(19148) at 0
Insert Ident(19171) into FunCall(19183) at 0
Insert GenericList(19182) into FunCall(19183) at 1
Insert GenericString: chunk_len(19187) into DeclList(19188) at 0
Insert GenericString: start(19189) into DeclList(19190) at 0
Insert GenericString: size(19191) into DeclList(19192) at 0
Insert GenericString: nr(19193) into DeclList(19196) at 0
Insert InitExpr(19195) into DeclList(19196) at 1
Insert Some(19247) into ExprStatement(19248) at 0
Insert Some(19268) into ExprStatement(19269) at 0
Insert ExprStatement(19277) into For(19420) at 0
Insert ExprStatement(19286) into For(19420) at 1
Insert ExprStatement(19292) into For(19420) at 2
Insert Compound(19419) into For(19420) at 3
Insert Some(19486) into ExprStatement(19487) at 0
Insert Some(19563) into ExprStatement(19564) at 0
Insert Some(19572) into ExprStatement(19573) at 0
Insert Some(19578) into ExprStatement(19579) at 0
Move Some(19365) into ExprStatement(19601) at 0
Insert Ident(19605) into FunCall(19610) at 0
Insert GenericList(19609) into FunCall(19610) at 1
Insert Ident(70092) into FunCall(70097) at 0
Insert GenericList(70096) into FunCall(70097) at 1
Update GenericString: d(9362) to dev_get_drvdata
Move GenericString: d(9362) into Ident(9363) at 0
Insert Left(9366) into GenericList(9367) at 0
Update GenericString: d(9414) to dev_get_drvdata
Move GenericString: d(9414) into Ident(9418) at 0
Insert Left(9421) into GenericList(9422) at 0
Update GenericString: d(9466) to dev_get_drvdata
Move GenericString: d(9466) into Ident(9473) at 0
Insert Left(9476) into GenericList(9477) at 0
Update GenericString: d(9524) to dev_get_drvdata
Move GenericString: d(9524) into Ident(9534) at 0
Insert Left(9537) into GenericList(9538) at 0
Update GenericString: d(9608) to dev_get_drvdata
Move GenericString: d(9608) into Ident(9621) at 0
Insert Left(9624) into GenericList(9625) at 0
Insert GenericString: dev_get_drvdata(9700) into Ident(9701) at 0
Insert Left(9704) into GenericList(9705) at 0
Update GenericString: d(9685) to p
Update GenericString: d(9724) to dev_get_drvdata
Move GenericString: d(9724) into Ident(9746) at 0
Insert Left(9749) into GenericList(9750) at 0
Update GenericString: d(9798) to dev_get_drvdata
Move GenericString: d(9798) into Ident(9823) at 0
Insert Left(9826) into GenericList(9827) at 0
Update GenericString: d(9852) to dev_get_drvdata
Move GenericString: d(9852) into Ident(9880) at 0
Insert Left(9883) into GenericList(9884) at 0
Update GenericString: d(9940) to dev_get_drvdata
Move GenericString: d(9940) into Ident(9971) at 0
Insert Left(9974) into GenericList(9975) at 0
Update GenericString: d(9993) to dev_get_drvdata
Move GenericString: d(9993) into Ident(10027) at 0
Insert Left(10030) into GenericList(10031) at 0
Update GenericString: d(10080) to dev_get_drvdata
Move GenericString: d(10080) into Ident(10117) at 0
Insert Left(10120) into GenericList(10121) at 0
Update GenericString: d(10152) to dev_get_drvdata
Move GenericString: d(10152) into Ident(10192) at 0
Insert Left(10195) into GenericList(10196) at 0
Update GenericString: d(10237) to dev_get_drvdata
Move GenericString: d(10237) into Ident(10280) at 0
Insert Left(10283) into GenericList(10284) at 0
Update GenericString: d(10309) to dev_get_drvdata
Move GenericString: d(10309) into Ident(10355) at 0
Insert Left(10358) into GenericList(10359) at 0
Update GenericString: d(10394) to dev_get_drvdata
Move GenericString: d(10394) into Ident(10443) at 0
Insert Left(10446) into GenericList(10447) at 0
Update GenericString: d(10466) to dev_get_drvdata
Move GenericString: d(10466) into Ident(10518) at 0
Insert Left(10521) into GenericList(10522) at 0
Update GenericString: d(10611) to dev_get_drvdata
Move GenericString: d(10611) into Ident(10666) at 0
Insert Left(10669) into GenericList(10670) at 0
Update GenericString: d(10922) to dev_get_drvdata
Move GenericString: d(10922) into Ident(10980) at 0
Insert Left(10983) into GenericList(10984) at 0
Update GenericString: d(10983) to dev_get_drvdata
Move GenericString: d(10983) into Ident(11044) at 0
Insert Left(11047) into GenericList(11048) at 0
Update GenericString: d(11095) to dev_get_drvdata
Move GenericString: d(11095) into Ident(11158) at 0
Insert Left(11161) into GenericList(11162) at 0
Update GenericString: d(11325) to dev_get_drvdata
Move GenericString: d(11325) into Ident(11390) at 0
Insert Left(11393) into GenericList(11394) at 0
Update GenericString: d(11371) to dev_get_drvdata
Move GenericString: d(11371) into Ident(11438) at 0
Insert Left(11441) into GenericList(11442) at 0
Move Left(19140) into GenericList(17660) at 3
Insert Ident(17666) into Assignment(17669) at 0
Insert GenericString: =(17667) into Assignment(17669) at 1
Insert Constant: 0(17668) into Assignment(17669) at 2
Insert Ident(17674) into Binary(17678) at 0
Insert GenericString: <(17675) into Binary(17678) at 1
Insert Ident(17677) into Binary(17678) at 2
Insert Ident(17683) into Postfix(17685) at 0
Insert GenericString: ++(17684) into Postfix(17685) at 1
Insert Assignment(17710) into Some(17712) at 0
Insert GenericString: ;(17711) into Some(17712) at 1
Update GenericString: status(17649) to ret
Update GenericString: src_offset(17675) to pool
Insert Ident(19114) into FunCall(19130) at 0
Insert GenericList(19129) into FunCall(19130) at 1
Insert FunCall(19145) into Some(19147) at 0
Move GenericString: ;(17690) into Some(19147) at 1
Update GenericString: rc(19146) to ret
Update GenericString: bytes_left(17693) to BUG_ON
Move GenericString: bytes_left(17693) into Ident(19171) at 0
Insert Left(19181) into GenericList(19182) at 0
Insert Constant: 0(19194) into InitExpr(19195) at 0
Insert Assignment(19245) into Some(19247) at 0
Insert GenericString: ;(19246) into Some(19247) at 1
Insert Assignment(19266) into Some(19268) at 0
Insert GenericString: ;(19267) into Some(19268) at 1
Move Some(17755) into ExprStatement(19277) at 0
Move Some(17769) into ExprStatement(19286) at 0
Insert Some(19291) into ExprStatement(19292) at 0
Move ExprStatement(19118) into Compound(19419) at 0
Move If(19129) into Compound(19419) at 1
Move ExprStatement(19145) into Compound(19419) at 2
Move ExprStatement(19176) into Compound(19419) at 3
Insert ExprStatement(19397) into Compound(19419) at 4
Insert ExprStatement(19404) into Compound(19419) at 5
Insert ExprStatement(19418) into Compound(19419) at 6
Update GenericString: rc(19246) to ret
Insert Assignment(19484) into Some(19486) at 0
Insert GenericString: ;(19485) into Some(19486) at 1
Update GenericString: rc(19285) to ret
Update GenericString: rc(19315) to ret
Insert Assignment(19561) into Some(19563) at 0
Insert GenericString: ;(19562) into Some(19563) at 1
Insert Binary(19570) into Some(19572) at 0
Insert GenericString: ;(19571) into Some(19572) at 1
Insert Postfix(19577) into Some(19578) at 0
Insert GenericString: pci_pool_destroy(19604) into Ident(19605) at 0
Insert Left(19608) into GenericList(19609) at 0
Update GenericString: EOPNOTSUPP(69842) to dev_kfree_skb
Move GenericString: EOPNOTSUPP(69842) into Ident(70092) at 0
Insert Left(70095) into GenericList(70096) at 0
Insert Ident(9365) into Left(9366) at 0
Insert Ident(9420) into Left(9421) at 0
Insert Ident(9475) into Left(9476) at 0
Insert Ident(9536) into Left(9537) at 0
Insert Ident(9623) into Left(9624) at 0
Insert Ident(9703) into Left(9704) at 0
Insert Ident(9748) into Left(9749) at 0
Insert Ident(9825) into Left(9826) at 0
Insert Ident(9882) into Left(9883) at 0
Insert Ident(9973) into Left(9974) at 0
Insert Ident(10029) into Left(10030) at 0
Insert Ident(10119) into Left(10120) at 0
Insert Ident(10194) into Left(10195) at 0
Insert Ident(10282) into Left(10283) at 0
Insert Ident(10357) into Left(10358) at 0
Insert Ident(10445) into Left(10446) at 0
Insert Ident(10520) into Left(10521) at 0
Insert Ident(10668) into Left(10669) at 0
Insert Ident(10982) into Left(10983) at 0
Insert Ident(11046) into Left(11047) at 0
Insert Ident(11160) into Left(11161) at 0
Insert Ident(11392) into Left(11393) at 0
Insert Ident(11440) into Left(11441) at 0
Update Constant: "src_phys=0x%x dest_address=0x%x length=0x%x\n"(17591) to "nr=%d dest_address=0x%x len=0x%x\n"
Insert GenericString: i(17665) into Ident(17666) at 0
Insert GenericString: i(17673) into Ident(17674) at 0
Insert GenericString: nr(17676) into Ident(17677) at 0
Insert GenericString: i(17682) into Ident(17683) at 0
Insert Ident(17689) into Assignment(17710) at 0
Insert GenericString: =(17690) into Assignment(17710) at 1
Insert FunCall(17709) into Assignment(17710) at 2
Insert GenericString: pci_pool_create(19113) into Ident(19114) at 0
Insert Left(19116) into GenericList(19129) at 0
Move Left(19104) into GenericList(19129) at 1
Insert Left(19124) into GenericList(19129) at 2
Insert Left(19126) into GenericList(19129) at 3
Insert Left(19128) into GenericList(19129) at 4
Insert Ident(19141) into FunCall(19145) at 0
Insert GenericList(19144) into FunCall(19145) at 1
Move Binary(19169) into Left(19181) at 0
Update GenericString: +=(19263) to =
Move Ident(17711) into Assignment(19245) at 0
Move GenericString: =(17712) into Assignment(19245) at 1
Insert Binary(19244) into Assignment(19245) at 2
Insert Ident(19250) into Assignment(19266) at 0
Insert GenericString: =(19251) into Assignment(19266) at 1
Insert Binary(19265) into Assignment(19266) at 2
Insert Assignment(19274) into Some(19276) at 0
Insert Binary(19283) into Some(19285) at 0
Insert Postfix(19290) into Some(19291) at 0
Insert Compound(19342) into If(19343) at 2
Insert Some(19396) into ExprStatement(19397) at 0
Insert Some(19403) into ExprStatement(19404) at 0
Insert Some(19417) into ExprStatement(19418) at 0
Insert Ident(19480) into Assignment(19484) at 0
Insert GenericString: +=(19481) into Assignment(19484) at 1
Insert Ident(19483) into Assignment(19484) at 2
Insert Ident(19558) into Assignment(19561) at 0
Insert GenericString: =(19559) into Assignment(19561) at 1
Insert Constant: 0(19560) into Assignment(19561) at 2
Insert Ident(19566) into Binary(19570) at 0
Insert GenericString: <(19567) into Binary(19570) at 1
Insert Ident(19569) into Binary(19570) at 2
Insert Ident(19575) into Postfix(19577) at 0
Insert GenericString: ++(19576) into Postfix(19577) at 1
Insert Ident(19607) into Left(19608) at 0
Insert Ident(70094) into Left(70095) at 0
Insert GenericString: d(9364) into Ident(9365) at 0
Insert GenericString: d(9419) into Ident(9420) at 0
Insert GenericString: d(9474) into Ident(9475) at 0
Insert GenericString: d(9535) into Ident(9536) at 0
Insert GenericString: d(9622) into Ident(9623) at 0
Insert GenericString: d(9702) into Ident(9703) at 0
Insert GenericString: d(9747) into Ident(9748) at 0
Insert GenericString: d(9824) into Ident(9825) at 0
Insert GenericString: d(9881) into Ident(9882) at 0
Insert GenericString: d(9972) into Ident(9973) at 0
Insert GenericString: d(10028) into Ident(10029) at 0
Insert GenericString: d(10118) into Ident(10119) at 0
Insert GenericString: d(10193) into Ident(10194) at 0
Insert GenericString: d(10281) into Ident(10282) at 0
Insert GenericString: d(10356) into Ident(10357) at 0
Insert GenericString: d(10444) into Ident(10445) at 0
Insert GenericString: d(10519) into Ident(10520) at 0
Insert GenericString: d(10667) into Ident(10668) at 0
Insert GenericString: d(10981) into Ident(10982) at 0
Insert GenericString: d(11045) into Ident(11046) at 0
Insert GenericString: d(11159) into Ident(11160) at 0
Insert GenericString: d(11391) into Ident(11392) at 0
Insert GenericString: d(11439) into Ident(11440) at 0
Update GenericString: src_phys(17593) to nr
Insert GenericString: size(17688) into Ident(17689) at 0
Insert Ident(17692) into FunCall(17709) at 0
Insert GenericList(17708) into FunCall(17709) at 1
Update GenericString: status(17613) to ret
Insert Constant: "ipw2200"(19115) into Left(19116) at 0
Insert Ident(19123) into Left(19124) at 0
Insert Constant: 0(19125) into Left(19126) at 0
Insert Constant: 0(19127) into Left(19128) at 0
Update GenericString: CB_MAX_LENGTH(17687) to IPW_ERROR
Move GenericString: CB_MAX_LENGTH(17687) into Ident(19141) at 0
Insert Left(19143) into GenericList(19144) at 0
Update GenericString: offset(19261) to chunk_len
Update GenericString: status(17710) to start
Move Ident(17719) into Binary(19244) at 0
Move GenericString: +(17720) into Binary(19244) at 1
Move Ident(17722) into Binary(19244) at 2
Insert GenericString: nr(19249) into Ident(19250) at 0
Insert ParenExpr(19261) into Binary(19265) at 0
Insert GenericString: /(19262) into Binary(19265) at 1
Insert Ident(19264) into Binary(19265) at 2
Insert Ident(19271) into Assignment(19274) at 0
Insert GenericString: =(19272) into Assignment(19274) at 1
Insert Constant: 0(19273) into Assignment(19274) at 2
Insert Ident(19279) into Binary(19283) at 0
Insert GenericString: <(19280) into Binary(19283) at 1
Insert Ident(19282) into Binary(19283) at 2
Insert Ident(19288) into Postfix(19290) at 0
Insert GenericString: ++(19289) into Postfix(19290) at 1
Insert ArrayAccess(19326) into Unary(19328) at 0
Insert ExprStatement(19339) into Compound(19342) at 0
Insert Goto(19341) into Compound(19342) at 1
Insert Assignment(19366) into Some(19368) at 0
Insert Assignment(19394) into Some(19396) at 0
Insert GenericString: ;(19395) into Some(19396) at 1
Insert Postfix(19401) into Some(19403) at 0
Insert GenericString: ;(19402) into Some(19403) at 1
Insert FunCall(19415) into Some(19417) at 0
Insert GenericString: ;(19416) into Some(19417) at 1
Update GenericString: rc(19204) to ret
Insert GenericString: offset(19479) into Ident(19480) at 0
Insert GenericString: chunk_len(19482) into Ident(19483) at 0
Insert GenericString: i(19557) into Ident(19558) at 0
Insert GenericString: i(19565) into Ident(19566) at 0
Insert GenericString: total_nr(19568) into Ident(19569) at 0
Insert GenericString: i(19574) into Ident(19575) at 0
Update GenericString: pci_free_consistent(19346) to pci_pool_free
Insert Left(19590) into GenericList(19597) at 1
Insert GenericString: pool(19606) into Ident(19607) at 0
Insert Binary(36133) into Binary(36134) at 2
Insert GenericString: skb(70093) into Ident(70094) at 0
Insert GenericString: min_t(17691) into Ident(17692) at 0
Insert ParameterType(17693) into GenericList(17708) at 0
Insert Left(17704) into GenericList(17708) at 1
Move Left(17637) into GenericList(17708) at 2
Move Left(17717) into GenericList(17746) at 0
Insert Left(17741) into GenericList(17746) at 3
Move GenericString: CB_MAX_LENGTH(17678) into Ident(19123) at 0
Insert Constant: "pci_pool_create failed\n"(19142) into Left(19143) at 0
Update GenericString: src_phys(17718) to data
Update GenericString: src_offset(17721) to offset
Insert Binary(19260) into ParenExpr(19261) at 0
Update GenericString: status(17746) to CB_MAX_LENGTH
Move GenericString: status(17746) into Ident(19264) at 0
Update GenericString: IPW_DEBUG_FW_INFO(17748) to i
Move GenericString: IPW_DEBUG_FW_INFO(17748) into Ident(19271) at 0
Update GenericString: IPW_DEBUG_FW_INFO(17762) to i
Move GenericString: IPW_DEBUG_FW_INFO(17762) into Ident(19279) at 0
Insert GenericString: nr(19281) into Ident(19282) at 0
Insert GenericString: i(19287) into Ident(19288) at 0
Insert ArrayAccess(19297) into Assignment(19317) at 0
Insert Ident(19323) into ArrayAccess(19326) at 0
Insert Ident(19325) into ArrayAccess(19326) at 1
Insert Some(19338) into ExprStatement(19339) at 0
Insert GenericString: out(19340) into Goto(19341) at 0
Insert Ident(19345) into Assignment(19366) at 0
Insert GenericString: =(19346) into Assignment(19366) at 1
Insert FunCall(19365) into Assignment(19366) at 2
Insert Ident(19390) into Assignment(19394) at 0
Insert GenericString: +=(19391) into Assignment(19394) at 1
Insert Ident(19393) into Assignment(19394) at 2
Insert Ident(19399) into Postfix(19401) at 0
Insert GenericString: ++(19400) into Postfix(19401) at 1
Insert Ident(19406) into FunCall(19415) at 0
Insert GenericList(19414) into FunCall(19415) at 1
Insert Left(19443) into GenericList(19457) at 2
Move Left(19235) into GenericList(19457) at 4
Insert Ident(19583) into Left(19584) at 0
Insert ArrayAccess(19589) into Left(19590) at 0
Insert ArrayAccess(19595) into Left(19596) at 0
Move Ident(35884) into Binary(36133) at 0
Insert GenericString: -(36131) into Binary(36133) at 1
Insert Constant: 1(36132) into Binary(36133) at 2
Insert Binary(17703) into Left(17704) at 0
Insert ArrayAccess(17726) into Left(17727) at 0
Insert Ident(17740) into Left(17741) at 0
Insert Binary(19257) into Binary(19260) at 0
Insert GenericString: -(19258) into Binary(19260) at 1
Insert Constant: 1(19259) into Binary(19260) at 2
Insert Ident(19294) into ArrayAccess(19297) at 0
Insert Ident(19296) into ArrayAccess(19297) at 1
Update GenericString: shared_virt(19120) to virts
Move GenericString: shared_virt(19120) into Ident(19323) at 0
Insert GenericString: total_nr(19324) into Ident(19325) at 0
Insert Assignment(19336) into Some(19338) at 0
Insert GenericString: ;(19337) into Some(19338) at 1
Insert GenericString: size(19344) into Ident(19345) at 0
Move Ident(19131) into FunCall(19365) at 0
Move GenericList(19141) into FunCall(19365) at 1
Update GenericString: BUG(19170) to memcpy
Insert Left(19377) into GenericList(19384) at 0
Insert Left(19380) into GenericList(19384) at 1
Insert Left(19383) into GenericList(19384) at 2
Insert GenericString: start(19389) into Ident(19390) at 0
Insert GenericString: size(19392) into Ident(19393) at 0
Insert GenericString: total_nr(19398) into Ident(19399) at 0
Insert GenericString: BUG_ON(19405) into Ident(19406) at 0
Insert Left(19413) into GenericList(19414) at 0
Insert Unary(19439) into Left(19440) at 0
Insert Ident(19442) into Left(19443) at 0
Insert Ident(19455) into Left(19456) at 0
Update GenericString: priv(19348) to pool
Move GenericString: priv(19348) into Ident(19583) at 0
Insert Ident(19586) into ArrayAccess(19589) at 0
Insert Ident(19588) into ArrayAccess(19589) at 1
Insert Ident(19592) into ArrayAccess(19595) at 0
Insert Ident(19594) into ArrayAccess(19595) at 1
Insert Ident(17695) into Binary(17703) at 0
Insert GenericString: -(17696) into Binary(17703) at 1
Insert Binary(17702) into Binary(17703) at 2
Insert Ident(17723) into ArrayAccess(17726) at 0
Insert Ident(17725) into ArrayAccess(17726) at 1
Insert Binary(17736) into Binary(17737) at 2
Insert GenericString: size(17739) into Ident(17740) at 0
Move Ident(17726) into Binary(19257) at 0
Move GenericString: +(17727) into Binary(19257) at 1
Move Ident(17729) into Binary(19257) at 2
Update GenericString: shared_virt(19095) to virts
Move GenericString: shared_virt(19095) into Ident(19294) at 0
Insert GenericString: total_nr(19295) into Ident(19296) at 0
Update GenericString: pci_alloc_consistent(19098) to pci_pool_alloc
Insert Left(19306) into GenericList(19315) at 1
Insert Ident(19330) into Assignment(19336) at 0
Insert GenericString: =(19331) into Assignment(19336) at 1
Insert Unary(19335) into Assignment(19336) at 2
Update GenericString: memmove(19130) to min_t
Insert ParameterType(19349) into GenericList(19364) at 0
Insert ArrayAccess(19376) into Left(19377) at 0
Insert Ident(19379) into Left(19380) at 0
Insert Ident(19382) into Left(19383) at 0
Insert Binary(19412) into Left(19413) at 0
Insert ArrayAccess(19437) into Unary(19439) at 0
Insert GenericString: &(19438) into Unary(19439) at 1
Update GenericString: le32_to_cpu(19229) to nr
Move GenericString: le32_to_cpu(19229) into Ident(19442) at 0
Update GenericString: chunk(19231) to chunk_len
Move GenericString: chunk(19231) into Ident(19455) at 0
Update GenericString: len(19353) to virts
Move GenericString: len(19353) into Ident(19586) at 0
Update GenericString: shared_virt(19356) to i
Move GenericString: shared_virt(19356) into Ident(19588) at 0
Update GenericString: shared_phys(19359) to phys
Move GenericString: shared_phys(19359) into Ident(19592) at 0
Insert GenericString: i(19593) into Ident(19594) at 0
Insert GenericString: len(17694) into Ident(17695) at 0
Move Ident(17608) into Binary(17702) at 0
Update GenericString: >(17609) to *
Move GenericString: >(17609) into Binary(17702) at 1
Move Ident(17611) into Binary(17702) at 2
Update GenericString: src_phys(17621) to src_address
Move GenericString: src_phys(17621) into Ident(17723) at 0
Update GenericString: src_offset(17624) to i
Move GenericString: src_offset(17624) into Ident(17725) at 0
Move Ident(17632) into Binary(17736) at 0
Insert GenericString: *(17733) into Binary(17736) at 1
Insert Ident(17735) into Binary(17736) at 2
Update GenericString: dest_address(17725) to chunk_len
Update GenericString: dest_offset(17728) to CB_MAX_LENGTH
Insert Ident(19305) into Left(19306) at 0
Insert GenericString: ret(19329) into Ident(19330) at 0
Insert Ident(19333) into Unary(19335) at 0
Insert GenericString: -(19334) into Unary(19335) at 1
Insert Binary(19359) into Left(19360) at 0
Insert Ident(19373) into ArrayAccess(19376) at 0
Insert Ident(19375) into ArrayAccess(19376) at 1
Insert GenericString: start(19378) into Ident(19379) at 0
Insert GenericString: size(19381) into Ident(19382) at 0
Insert Ident(19408) into Binary(19412) at 0
Insert GenericString: >(19409) into Binary(19412) at 1
Insert Ident(19411) into Binary(19412) at 2
Insert Ident(19430) into ArrayAccess(19437) at 0
Insert Binary(19436) into ArrayAccess(19437) at 1
Update GenericString: bytes_left(17607) to i
Update GenericString: dest_offset(17631) to i
Insert GenericString: CB_MAX_LENGTH(17734) into Ident(17735) at 0
Update GenericString: len(19105) to pool
Insert GenericString: GFP_KERNEL(19304) into Ident(19305) at 0
Insert ArrayAccess(19311) into Unary(19313) at 0
Insert GenericString: ENOMEM(19332) into Ident(19333) at 0
Insert Ident(19351) into Binary(19359) at 0
Insert GenericString: -(19352) into Binary(19359) at 1
Insert Binary(19358) into Binary(19359) at 2
Update GenericString: data(19135) to CB_MAX_LENGTH
Insert GenericString: virts(19372) into Ident(19373) at 0
Insert GenericString: total_nr(19374) into Ident(19375) at 0
Insert GenericString: total_nr(19407) into Ident(19408) at 0
Insert GenericString: CB_NUMBER_OF_ELEMENTS_SMALL(19410) into Ident(19411) at 0
Insert GenericString: phys(19429) into Ident(19430) at 0
Move Ident(19213) into Binary(19436) at 0
Update GenericString: +(19214) to -
Move GenericString: +(19214) into Binary(19436) at 1
Move Ident(19216) into Binary(19436) at 2
Insert Ident(19308) into ArrayAccess(19311) at 0
Insert Ident(19310) into ArrayAccess(19311) at 1
Update GenericString: shared_virt(19132) to chunk_len
Move GenericString: shared_virt(19132) into Ident(19351) at 0
Insert Ident(19354) into Binary(19358) at 0
Insert GenericString: *(19355) into Binary(19358) at 1
Insert Ident(19357) into Binary(19358) at 2
Update GenericString: shared_phys(19212) to total_nr
Update GenericString: offset(19215) to nr
Update GenericString: shared_phys(19108) to phys
Move GenericString: shared_phys(19108) into Ident(19308) at 0
Insert GenericString: total_nr(19309) into Ident(19310) at 0
Insert GenericString: i(19353) into Ident(19354) at 0
Insert GenericString: CB_MAX_LENGTH(19356) into Ident(19357) at 0
Delete Ident(9363)
Delete GenericString: driver_data(9364)
Delete RecordPtAccess(9365)
Delete Ident(9415)
Delete GenericString: driver_data(9416)
Delete RecordPtAccess(9417)
Delete Ident(9467)
Delete GenericString: driver_data(9468)
Delete RecordPtAccess(9469)
Delete Ident(9525)
Delete GenericString: driver_data(9526)
Delete RecordPtAccess(9527)
Delete Ident(9609)
Delete GenericString: driver_data(9610)
Delete RecordPtAccess(9611)
Delete GenericString: driver_data(9687)
Delete RecordPtAccess(9688)
Delete Cast(9689)
Delete ParenExpr(9690)
Delete Ident(9725)
Delete GenericString: driver_data(9726)
Delete RecordPtAccess(9727)
Delete Ident(9799)
Delete GenericString: driver_data(9800)
Delete RecordPtAccess(9801)
Delete Ident(9853)
Delete GenericString: driver_data(9854)
Delete RecordPtAccess(9855)
Delete Ident(9941)
Delete GenericString: driver_data(9942)
Delete RecordPtAccess(9943)
Delete Ident(9994)
Delete GenericString: driver_data(9995)
Delete RecordPtAccess(9996)
Delete Ident(10081)
Delete GenericString: driver_data(10082)
Delete RecordPtAccess(10083)
Delete Ident(10153)
Delete GenericString: driver_data(10154)
Delete RecordPtAccess(10155)
Delete Ident(10238)
Delete GenericString: driver_data(10239)
Delete RecordPtAccess(10240)
Delete Ident(10310)
Delete GenericString: driver_data(10311)
Delete RecordPtAccess(10312)
Delete Ident(10395)
Delete GenericString: driver_data(10396)
Delete RecordPtAccess(10397)
Delete Ident(10467)
Delete GenericString: driver_data(10468)
Delete RecordPtAccess(10469)
Delete Ident(10612)
Delete GenericString: driver_data(10613)
Delete RecordPtAccess(10614)
Delete Ident(10923)
Delete GenericString: driver_data(10924)
Delete RecordPtAccess(10925)
Delete Ident(10984)
Delete GenericString: driver_data(10985)
Delete RecordPtAccess(10986)
Delete Cast(10987)
Delete Ident(11096)
Delete GenericString: driver_data(11097)
Delete RecordPtAccess(11098)
Delete Cast(11099)
Delete Ident(11326)
Delete GenericString: driver_data(11327)
Delete RecordPtAccess(11328)
Delete Cast(11329)
Delete Ident(11372)
Delete GenericString: driver_data(11373)
Delete RecordPtAccess(11374)
Delete Cast(11375)
Delete GenericString: length(17564)
Delete Ident(17565)
Delete InitExpr(17566)
Delete Constant: 0(17577)
Delete InitExpr(17578)
Delete GenericString: length(17599)
Delete Ident(17600)
Delete Left(17601)
Delete GenericString: priv(17618)
Delete Ident(17619)
Delete Left(17620)
Delete Ident(17622)
Delete GenericString: +(17623)
Delete Ident(17625)
Delete Binary(17626)
Delete GenericString: src_offset(17568)
Delete Constant: 0(17569)
Delete InitExpr(17570)
Delete DeclList(17571)
Delete GenericString: dest_offset(17572)
Delete Constant: 0(17573)
Delete InitExpr(17574)
Delete DeclList(17575)
Delete Binary(17612)
Delete Ident(17685)
Delete GenericString: +=(17686)
Delete Ident(17688)
Delete Assignment(17689)
Delete Some(17691)
Delete ExprStatement(17692)
Delete Compound(17702)
Delete While(17703)
Delete IfToken(17704)
Delete GenericString: bytes_left(17705)
Delete Ident(17706)
Delete GenericString: >(17707)
Delete Constant: 0(17708)
Delete Binary(17709)
Delete GenericString: ipw_fw_dma_add_command_block(17713)
Delete Ident(17714)
Delete Binary(17723)
Delete Left(17724)
Delete Binary(17730)
Delete Left(17731)
Delete GenericString: bytes_left(17732)
Delete Ident(17733)
Delete Left(17734)
Delete Constant: 0(17735)
Delete Left(17736)
Delete Constant: 0(17737)
Delete Left(17738)
Delete GenericList(17739)
Delete FunCall(17740)
Delete Assignment(17741)
Delete GenericString: ;(17742)
Delete Some(17743)
Delete ExprStatement(17744)
Delete IfToken(17745)
Delete Ident(17747)
Delete ExprStatement(17756)
Delete Constant: 1(17757)
Delete GenericString: -(17758)
Delete Unary(17759)
Delete ReturnExpr(17760)
Delete Compound(17761)
Delete ExprStatement(17770)
Delete If(17771)
Delete Compound(17772)
Delete If(17773)
Delete Constant: 0(17783)
Delete ReturnExpr(17784)
Delete Compound(17785)
Delete Definition(17786)
Delete Definition(17787)
Delete DeclList(18382)
Delete Declaration(18383)
Delete Ident(17679)
Delete Ident(17694)
Delete GenericString: -=(17695)
Delete GenericString: CB_MAX_LENGTH(17696)
Delete Ident(17697)
Delete Assignment(17698)
Delete Ident(17749)
Delete Constant: ": Failed on the buffer tail\n"(17750)
Delete Left(17751)
Delete GenericList(17752)
Delete FunCall(17753)
Delete Ident(17763)
Delete Constant: ": Adding new cb - the buffer tail\n"(17764)
Delete Left(17765)
Delete GenericList(17766)
Delete FunCall(17767)
Delete Ident(19096)
Delete Ident(19109)
Delete Ident(19121)
Delete Ident(19133)
Delete FunCall(19142)
Delete Binary(19217)
Delete Ident(19232)
Delete GenericString: length(19233)
Delete RecordPtAccess(19234)
Delete Ident(19230)
Delete GenericList(19236)
Delete FunCall(19237)
Delete Left(19238)
Delete Ident(19349)
Delete GenericString: pci_dev(19350)
Delete RecordPtAccess(19351)
Delete Ident(19354)
Delete Left(19355)
Delete Ident(19357)
Delete Left(19358)
Delete Ident(19360)
Delete ExprStatement(19366)
Delete GenericString: static(19060)
Delete Storage(19061)
Delete GenericString: ipw_load_firmware(19069)
Delete GenericString: chunk(19080)
Delete DeclList(19081)
Delete GenericString: shared_phys(19082)
Delete DeclList(19083)
Delete GenericString: shared_virt(19084)
Delete DeclList(19085)
Delete IfToken(19160)
Delete GenericString: out(19177)
Delete Goto(19178)
Delete Compound(19179)
Delete If(19180)
Delete Compound(19277)
Delete DoWhile(19284)
Delete Compound(19371)
Delete Definition(19372)
Delete Definition(19373)
Delete Ident(69843)
Delete GenericString: -(69844)
Delete Unary(69845)
Delete ReturnExpr(69846)
@@ -0,0 +1,3 @@
Insert CppTop(40) into Program(79940) at 11
Insert Include(39) into CppTop(40) at 0
Insert GenericString: <linux/smp_lock.h>(38) into Include(39) at 0
@@ -0,0 +1,364 @@
Move CppTop(614) into Program(66952) at 53
Move Declaration(14152) into Program(66952) at 132
Insert CppTop(59) into Program(66952) at 19
Insert Declaration(14257) into Program(66952) at 137
Insert Declaration(14383) into Program(66952) at 143
Insert Include(58) into CppTop(59) at 0
Insert DeclList(14256) into Declaration(14257) at 0
Insert DeclList(14382) into Declaration(14383) at 0
Insert GenericString: <linux/list.h>(57) into Include(58) at 0
Insert Storage(14167) into DeclList(14189) at 0
Insert FullType(14171) into DeclList(14189) at 1
Insert GenericString: phy_ops_niu_10g_hotplug(14172) into DeclList(14189) at 2
Insert InitList(14188) into DeclList(14189) at 3
Insert Storage(14364) into DeclList(14382) at 0
Insert FullType(14368) into DeclList(14382) at 1
Insert GenericString: phy_template_niu_10g_hotplug(14369) into DeclList(14382) at 2
Insert InitList(14381) into DeclList(14382) at 3
Insert If(12686) into Compound(12927) at 3
Insert ReturnExpr(13827) into Compound(13828) at 7
Insert GenericString: static(14166) into Storage(14167) at 0
Insert TypeQualifier(14169) into FullType(14171) at 0
Insert StructUnionName: niu_phy_ops(14170) into FullType(14171) at 1
Insert InitDesignators(14177) into InitList(14188) at 0
Insert InitDesignators(14182) into InitList(14188) at 1
Insert InitDesignators(14187) into InitList(14188) at 2
Insert GenericString: static(14363) into Storage(14364) at 0
Insert TypeQualifier(14366) into FullType(14368) at 0
Insert StructUnionName: niu_phy_template(14367) into FullType(14368) at 1
Insert InitDesignators(14376) into InitList(14381) at 0
Insert InitDesignators(14380) into InitList(14381) at 1
Insert DeclList(40688) into Compound(41253) at 3
Insert If(61112) into Compound(61124) at 21
Insert Binary(8284) into If(8288) at 1
Move IfToken(12661) into If(12686) at 0
Insert Binary(12683) into If(12686) at 1
Insert Goto(12685) into If(12686) at 2
Insert Constant: 0(13826) into ReturnExpr(13827) at 0
Insert GenericString: const(14168) into TypeQualifier(14169) at 0
Insert DesignatorField: serdes_init(14173) into InitDesignators(14177) at 0
Insert InitExpr(14176) into InitDesignators(14177) at 1
Insert DesignatorField: xcvr_init(14178) into InitDesignators(14182) at 0
Insert InitExpr(14181) into InitDesignators(14182) at 1
Insert DesignatorField: link_status(14183) into InitDesignators(14187) at 0
Insert InitExpr(14186) into InitDesignators(14187) at 1
Insert GenericString: const(14365) into TypeQualifier(14366) at 0
Insert DesignatorField: ops(14370) into InitDesignators(14376) at 0
Insert InitExpr(14375) into InitDesignators(14376) at 1
Insert DesignatorField: phy_addr_base(14377) into InitDesignators(14380) at 0
Insert InitExpr(14379) into InitDesignators(14380) at 1
Insert Binary(15853) into If(15857) at 1
Move ReturnExpr(13747) into If(15857) at 2
Insert Binary(15896) into If(15912) at 1
Insert GenericString: ha(40687) into DeclList(40688) at 0
Insert IfToken(61076) into If(61112) at 0
Insert FunCall(61090) into If(61112) at 1
Insert Compound(61111) into If(61112) at 2
Move Binary(8274) into Binary(8284) at 0
Insert GenericString: ||(8278) into Binary(8284) at 1
Insert Binary(8283) into Binary(8284) at 2
Insert Binary(12676) into Binary(12683) at 0
Insert GenericString: ||(12677) into Binary(12683) at 1
Insert Binary(12682) into Binary(12683) at 2
Insert GenericString: out(12684) into Goto(12685) at 0
Insert Label(13806) into Compound(13807) at 3
Insert Ident(14175) into InitExpr(14176) at 0
Insert Ident(14180) into InitExpr(14181) at 0
Insert Ident(14185) into InitExpr(14186) at 0
Insert Unary(14374) into InitExpr(14375) at 0
Insert Constant: 8(14378) into InitExpr(14379) at 0
Insert Ident(15840) into Binary(15853) at 0
Insert GenericString: &&(15841) into Binary(15853) at 1
Insert Unary(15852) into Binary(15853) at 2
Move Unary(15689) into Binary(15896) at 0
Insert GenericString: ||(15886) into Binary(15896) at 1
Insert ParenExpr(15895) into Binary(15896) at 2
Insert MacroIteration(40962) into Compound(40963) at 1
Insert Ident(61078) into FunCall(61090) at 0
Insert GenericList(61089) into FunCall(61090) at 1
Insert ExprStatement(61110) into Compound(61111) at 0
Insert Ident(8280) into Binary(8283) at 0
Insert GenericString: ==(8281) into Binary(8283) at 1
Insert Constant: 0xffff(8282) into Binary(8283) at 2
Move Ident(12663) into Binary(12676) at 0
Move GenericString: <(12664) into Binary(12676) at 1
Move Constant: 0(12665) into Binary(12676) at 2
Insert Ident(12679) into Binary(12682) at 0
Insert GenericString: ==(12680) into Binary(12682) at 1
Insert Constant: 0xffff(12681) into Binary(12682) at 2
Insert GenericString: out(13733) into Label(13806) at 0
Move If(13725) into Label(13806) at 1
Insert GenericString: serdes_init_niu_10g_fiber(14174) into Ident(14175) at 0
Insert GenericString: xcvr_init_10g_bcm8706(14179) into Ident(14180) at 0
Insert GenericString: link_status_10g_hotplug(14184) into Ident(14185) at 0
Insert Ident(14372) into Unary(14374) at 0
Insert GenericString: &(14373) into Unary(14374) at 1
Move GenericString: err(15656) into Ident(15840) at 0
Insert ParenExpr(15850) into Unary(15852) at 0
Insert GenericString: !(15851) into Unary(15852) at 1
Insert Binary(15894) into ParenExpr(15895) at 0
Insert RecordAccess(40804) into Assignment(40805) at 2
Insert GenericString: list_for_each_entry(40849) into MacroIteration(40962) at 0
Insert Left(40852) into MacroIteration(40962) at 1
Insert Left(40861) into MacroIteration(40962) at 2
Insert Left(40864) into MacroIteration(40962) at 3
Move Compound(40760) into MacroIteration(40962) at 4
Insert GenericString: of_find_property(61077) into Ident(61078) at 0
Insert Left(61081) into GenericList(61089) at 0
Insert Left(61083) into GenericList(61089) at 1
Insert Left(61088) into GenericList(61089) at 2
Insert Some(61109) into ExprStatement(61110) at 0
Insert GenericString: err(8279) into Ident(8280) at 0
Move GenericString: err(12916) into Ident(12679) at 0
Insert IfToken(13734) into If(13805) at 0
Insert Compound(13804) into If(13805) at 2
Insert GenericString: phy_ops_niu_10g_hotplug(14371) into Ident(14372) at 0
Insert Binary(15849) into ParenExpr(15850) at 0
Insert RecordPtAccess(15890) into Binary(15894) at 0
Insert GenericString: &(15891) into Binary(15894) at 1
Insert Ident(15893) into Binary(15894) at 2
Insert RecordPtAccess(40802) into RecordAccess(40804) at 0
Insert GenericString: count(40803) into RecordAccess(40804) at 1
Insert Ident(40851) into Left(40852) at 0
Insert Unary(40860) into Left(40861) at 0
Insert Ident(40863) into Left(40864) at 0
Insert Ident(61080) into Left(61081) at 0
Insert Constant: "hot-swappable-phy"(61082) into Left(61083) at 0
Insert Unary(61087) into Left(61088) at 0
Insert Assignment(61107) into Some(61109) at 0
Insert GenericString: ;(61108) into Some(61109) at 1
Move ExprStatement(13724) into Compound(13804) at 0
Insert If(13803) into Compound(13804) at 1
Insert RecordPtAccess(15845) into Binary(15849) at 0
Insert GenericString: &(15846) into Binary(15849) at 1
Insert Ident(15848) into Binary(15849) at 2
Insert Ident(15888) into RecordPtAccess(15890) at 0
Insert GenericString: flags(15889) into RecordPtAccess(15890) at 1
Insert GenericString: NIU_FLAGS_HOTPLUG_PHY(15892) into Ident(15893) at 0
Move Ident(40591) into RecordPtAccess(40802) at 0
Update GenericString: uc_count(40592) to uc
Move GenericString: uc_count(40592) into RecordPtAccess(40802) at 1
Update GenericString: addr(40638) to ha
Move GenericString: addr(40638) into Ident(40851) at 0
Insert RecordAccess(40858) into Unary(40860) at 0
Insert GenericString: &(40859) into Unary(40860) at 1
Update GenericString: addr(40654) to list
Move GenericString: addr(40654) into Ident(40863) at 0
Insert GenericString: dp(61079) into Ident(61080) at 0
Insert Ident(61085) into Unary(61087) at 0
Insert GenericString: &(61086) into Unary(61087) at 1
Insert RecordPtAccess(61094) into Assignment(61107) at 0
Insert GenericString: |=(61095) into Assignment(61107) at 1
Insert ParenExpr(61106) into Assignment(61107) at 2
Insert If(13685) into Compound(13686) at 2
Move IfToken(13699) into If(13803) at 0
Insert Binary(13765) into If(13803) at 1
Insert Compound(13802) into If(13803) at 2
Insert If(15420) into Default(15421) at 0
Insert Ident(15843) into RecordPtAccess(15845) at 0
Insert GenericString: flags(15844) into RecordPtAccess(15845) at 1
Insert GenericString: NIU_FLAGS_HOTPLUG_PHY(15847) into Ident(15848) at 0
Insert GenericString: np(15887) into Ident(15888) at 0
Insert RecordPtAccess(40856) into RecordAccess(40858) at 0
Insert GenericString: list(40857) into RecordAccess(40858) at 1
Insert GenericString: prop_len(61084) into Ident(61085) at 0
Insert Ident(61092) into RecordPtAccess(61094) at 0
Insert GenericString: flags(61093) into RecordPtAccess(61094) at 1
Insert Binary(61105) into ParenExpr(61106) at 0
Insert IfToken(13633) into If(13685) at 0
Insert Ident(13635) into If(13685) at 1
Insert Compound(13684) into If(13685) at 2
Insert Ident(13762) into Binary(13765) at 0
Insert GenericString: ==(13763) into Binary(13765) at 1
Insert Constant: 0xffff(13764) into Binary(13765) at 2
Insert ExprStatement(13775) into Compound(13802) at 0
Insert ExprStatement(13788) into Compound(13802) at 1
Insert ExprStatement(13801) into Compound(13802) at 2
Insert IfToken(15342) into If(15420) at 0
Move Binary(12915) into If(15420) at 1
Insert Compound(15396) into If(15420) at 2
Insert Compound(15419) into If(15420) at 3
Update GenericString: err(15658) to np
Move GenericString: err(15658) into Ident(15843) at 0
Move Ident(40642) into RecordPtAccess(40856) at 0
Update GenericString: uc_list(40643) to uc
Move GenericString: uc_list(40643) into RecordPtAccess(40856) at 1
Insert GenericString: np(61091) into Ident(61092) at 0
Insert Binary(61101) into Binary(61105) at 0
Insert GenericString: |(61102) into Binary(61105) at 1
Insert Ident(61104) into Binary(61105) at 2
Insert GenericString: err(13634) into Ident(13635) at 0
Insert ExprStatement(13660) into Compound(13684) at 0
Move If(13651) into Compound(13684) at 1
Move ExprStatement(13649) into Compound(13684) at 2
Insert GenericString: err(13761) into Ident(13762) at 0
Insert Some(13774) into ExprStatement(13775) at 0
Insert Some(13787) into ExprStatement(13788) at 0
Insert Some(13800) into ExprStatement(13801) at 0
Insert ExprStatement(15361) into Compound(15396) at 0
Insert If(15378) into Compound(15396) at 1
Insert If(15395) into Compound(15396) at 2
Move ExprStatement(15226) into Compound(15419) at 0
Move ExprStatement(15239) into Compound(15419) at 1
Insert Ident(61097) into Binary(61101) at 0
Insert GenericString: |(61098) into Binary(61101) at 1
Insert Ident(61100) into Binary(61101) at 2
Insert GenericString: NIU_FLAGS_HOTPLUG_PHY(61103) into Ident(61104) at 0
Insert Some(13659) into ExprStatement(13660) at 0
Insert Binary(13666) into If(13670) at 1
Insert Assignment(13772) into Some(13774) at 0
Insert GenericString: ;(13773) into Some(13774) at 1
Insert Assignment(13785) into Some(13787) at 0
Insert GenericString: ;(13786) into Some(13787) at 1
Insert Assignment(13798) into Some(13800) at 0
Insert GenericString: ;(13799) into Some(13800) at 1
Insert Some(15360) into ExprStatement(15361) at 0
Insert IfToken(15362) into If(15378) at 0
Insert Binary(15369) into If(15378) at 1
Insert ExprStatement(15377) into If(15378) at 2
Insert IfToken(15379) into If(15395) at 0
Insert Binary(15386) into If(15395) at 1
Insert ExprStatement(15394) into If(15395) at 2
Insert GenericString: NIU_FLAGS_10G(61096) into Ident(61097) at 0
Insert GenericString: NIU_FLAGS_FIBER(61099) into Ident(61100) at 0
Insert Assignment(13657) into Some(13659) at 0
Insert GenericString: ;(13658) into Some(13659) at 1
Insert Ident(13663) into Binary(13666) at 0
Insert GenericString: ==(13664) into Binary(13666) at 1
Insert Constant: 0xffff(13665) into Binary(13666) at 2
Insert Goto(13668) into Compound(13669) at 0
Insert Unary(13769) into Assignment(13772) at 0
Insert GenericString: =(13770) into Assignment(13772) at 1
Insert Constant: 1(13771) into Assignment(13772) at 2
Insert RecordAccess(13781) into Assignment(13785) at 0
Insert GenericString: =(13782) into Assignment(13785) at 1
Insert Ident(13784) into Assignment(13785) at 2
Insert RecordAccess(13794) into Assignment(13798) at 0
Insert GenericString: =(13795) into Assignment(13798) at 1
Insert Ident(13797) into Assignment(13798) at 2
Insert Assignment(15358) into Some(15360) at 0
Insert GenericString: ;(15359) into Some(15360) at 1
Insert RecordPtAccess(15366) into Binary(15369) at 0
Insert GenericString: ==(15367) into Binary(15369) at 1
Insert Constant: 0(15368) into Binary(15369) at 2
Insert Some(15376) into ExprStatement(15377) at 0
Insert RecordPtAccess(15383) into Binary(15386) at 0
Insert GenericString: ==(15384) into Binary(15386) at 1
Insert Constant: 1(15385) into Binary(15386) at 2
Insert Some(15393) into ExprStatement(15394) at 0
Insert Ident(13637) into Assignment(13657) at 0
Insert GenericString: =(13638) into Assignment(13657) at 1
Insert FunCall(13656) into Assignment(13657) at 2
Move GenericString: err(13635) into Ident(13663) at 0
Insert GenericString: out(13667) into Goto(13668) at 0
Insert Ident(13767) into Unary(13769) at 0
Insert GenericString: *(13768) into Unary(13769) at 1
Insert RecordPtAccess(13779) into RecordAccess(13781) at 0
Insert GenericString: active_speed(13780) into RecordAccess(13781) at 1
Insert GenericString: SPEED_10000(13783) into Ident(13784) at 0
Insert RecordPtAccess(13792) into RecordAccess(13794) at 0
Insert GenericString: active_duplex(13793) into RecordAccess(13794) at 1
Insert GenericString: DUPLEX_FULL(13796) into Ident(13797) at 0
Insert Ident(15352) into Assignment(15358) at 0
Insert GenericString: =(15353) into Assignment(15358) at 1
Insert Unary(15357) into Assignment(15358) at 2
Insert Ident(15364) into RecordPtAccess(15366) at 0
Insert GenericString: port(15365) into RecordPtAccess(15366) at 1
Insert Assignment(15374) into Some(15376) at 0
Insert GenericString: ;(15375) into Some(15376) at 1
Insert Ident(15381) into RecordPtAccess(15383) at 0
Insert GenericString: port(15382) into RecordPtAccess(15383) at 1
Insert Assignment(15391) into Some(15393) at 0
Insert GenericString: ;(15392) into Some(15393) at 1
Update GenericString: da_addr(40677) to addr
Insert GenericString: err(13636) into Ident(13637) at 0
Insert Ident(13640) into FunCall(13656) at 0
Insert GenericList(13655) into FunCall(13656) at 1
Insert GenericString: link_up_p(13766) into Ident(13767) at 0
Insert Ident(13777) into RecordPtAccess(13779) at 0
Insert GenericString: link_config(13778) into RecordPtAccess(13779) at 1
Insert Ident(13790) into RecordPtAccess(13792) at 0
Insert GenericString: link_config(13791) into RecordPtAccess(13792) at 1
Insert GenericString: tp(15351) into Ident(15352) at 0
Insert Ident(15355) into Unary(15357) at 0
Insert GenericString: &(15356) into Unary(15357) at 1
Insert GenericString: np(15363) into Ident(15364) at 0
Insert Ident(15371) into Assignment(15374) at 0
Insert GenericString: =(15372) into Assignment(15374) at 1
Insert Constant: 8(15373) into Assignment(15374) at 2
Insert GenericString: np(15380) into Ident(15381) at 0
Insert Ident(15388) into Assignment(15391) at 0
Insert GenericString: =(15389) into Assignment(15391) at 1
Insert Constant: 12(15390) into Assignment(15391) at 2
Update GenericString: addr(40675) to ha
Insert GenericString: mdio_read(13639) into Ident(13640) at 0
Insert Left(13643) into GenericList(13655) at 0
Insert Left(13648) into GenericList(13655) at 1
Insert Left(13651) into GenericList(13655) at 2
Insert Left(13654) into GenericList(13655) at 3
Insert GenericString: np(13776) into Ident(13777) at 0
Insert GenericString: np(13789) into Ident(13790) at 0
Insert GenericString: phy_template_niu_10g_hotplug(15354) into Ident(15355) at 0
Insert GenericString: phy_addr_off(15370) into Ident(15371) at 0
Insert GenericString: phy_addr_off(15387) into Ident(15388) at 0
Insert Ident(13642) into Left(13643) at 0
Insert RecordPtAccess(13647) into Left(13648) at 0
Insert Ident(13650) into Left(13651) at 0
Insert Ident(13653) into Left(13654) at 0
Insert GenericString: np(13641) into Ident(13642) at 0
Insert Ident(13645) into RecordPtAccess(13647) at 0
Insert GenericString: phy_addr(13646) into RecordPtAccess(13647) at 1
Insert GenericString: BCM8704_PHYXS_DEV_ADDR(13649) into Ident(13650) at 0
Insert GenericString: MII_BMCR(13652) into Ident(13653) at 0
Insert GenericString: np(13644) into Ident(13645) at 0
Delete Binary(12666)
Delete GenericString: out(12667)
Delete Goto(12668)
Delete If(12669)
Delete IfToken(12907)
Delete Ident(12917)
Delete GenericString: =(12918)
Delete Constant: 0(12919)
Delete Assignment(12920)
Delete GenericString: ;(12921)
Delete Some(12922)
Delete ExprStatement(12923)
Delete If(12924)
Delete Ident(13636)
Delete Ident(15657)
Delete Ident(15659)
Delete ReturnExpr(15660)
Delete RecordPtAccess(40593)
Delete Ident(40639)
Delete GenericString: =(40640)
Delete RecordPtAccess(40644)
Delete Assignment(40645)
Delete GenericString: ;(40646)
Delete Some(40647)
Delete ExprStatement(40648)
Delete GenericString: addr(40649)
Delete Ident(40650)
Delete GenericString: ;(40651)
Delete Some(40652)
Delete ExprStatement(40653)
Delete Ident(40655)
Delete GenericString: =(40656)
Delete GenericString: addr(40657)
Delete Ident(40658)
Delete GenericString: next(40659)
Delete RecordPtAccess(40660)
Delete Assignment(40661)
Delete Some(40662)
Delete ExprStatement(40663)
Delete For(40761)
Delete GenericString: dev(43547)
Delete Ident(43548)
Delete GenericString: trans_start(43549)
Delete RecordPtAccess(43550)
Delete GenericString: =(43551)
Delete GenericString: jiffies(43552)
Delete Ident(43553)
Delete Assignment(43554)
Delete GenericString: ;(43555)
Delete Some(43556)
Delete ExprStatement(43557)
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress files=".*generated-sources.*" checks=".*"/>
<suppress files=".*IndentingXMLStreamWriter.java" checks=".*"/>
<suppress files=".*InfoTree.java" checks=".*"/>
<suppress files=".*LabelDictionary.java" checks=".*"/>
<suppress files=".*RtedAlgorithm.java" checks=".*"/>
<suppress files=".*StreamWriterDelegate.java" checks=".*"/>
</suppressions>
+37
View File
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>gumtree</artifactId>
<groupId>com.github.gumtreediff</groupId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>client.diff</artifactId>
<packaging>jar</packaging>
<name>GumTree Diff Client</name>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.sparkjava/spark-core -->
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>com.github.gumtreediff</groupId>
<artifactId>client</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.nanohttpd</groupId>
<artifactId>nanohttpd-webserver</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.rendersnake</groupId>
<artifactId>rendersnake</artifactId>
<version>1.8</version>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,136 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client.diff;
import com.github.gumtreediff.client.Option;
import com.github.gumtreediff.client.Client;
import com.github.gumtreediff.gen.Generators;
import com.github.gumtreediff.matchers.Matcher;
import com.github.gumtreediff.matchers.Matchers;
import com.github.gumtreediff.tree.TreeContext;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
public abstract class AbstractDiffClient<O extends AbstractDiffClient.Options> extends Client {
protected final O opts;
public static final String SYNTAX = "Syntax: diff [options] baseFile destFile";
private TreeContext src;
private TreeContext dst;
public static class Options implements Option.Context {
public String matcher;
public ArrayList<String> generators = new ArrayList<>();
public String src;
public String dst;
@Override
public Option[] values() {
return new Option[] {
new Option("-m", "The qualified name of the class implementing the matcher.", 1) {
@Override
protected void process(String name, String[] args) {
matcher = args[0];
}
},
new Option("-g", "Preferred generator to use (can be used more than once).", 1) {
@Override
protected void process(String name, String[] args) {
generators.add(args[0]);
}
},
new Option.Help(this) {
@Override
public void process(String name, String[] args) {
System.out.println(SYNTAX);
super.process(name, args);
}
}
};
}
void dump(PrintStream out) {
out.printf("Current path: %s\n", System.getProperty("user.dir"));
out.printf("Diff: %s %s\n", src, dst);
}
}
protected abstract O newOptions();
public AbstractDiffClient(String[] args) {
super(args);
opts = newOptions();
args = Option.processCommandLine(args, opts);
if (args.length < 2)
throw new Option.OptionException("arguments required." + SYNTAX, opts);
opts.src = args[0];
opts.dst = args[1];
if (Option.Verbose.verbose) {
opts.dump(System.out);
}
}
///////////////////
// TODO after this line it should be rewrote in a better way
private Matcher matcher;
protected Matcher matchTrees() {
Matchers matchers = Matchers.getInstance();
if (matcher != null)
return matcher;
matcher = (opts.matcher == null)
? matchers.getMatcher(getSrcTreeContext().getRoot(), getDstTreeContext().getRoot())
: matchers.getMatcher(opts.matcher, getSrcTreeContext().getRoot(), getDstTreeContext().getRoot());
matcher.match();
return matcher;
}
protected TreeContext getSrcTreeContext() {
if (src == null)
src = getTreeContext(opts.src);
return src;
}
protected TreeContext getDstTreeContext() {
if (dst == null)
dst = getTreeContext(opts.dst);
return dst;
}
private TreeContext getTreeContext(String file) {
try {
TreeContext t;
if (opts.generators.isEmpty())
t = Generators.getInstance().getTree(file);
else
t = Generators.getInstance().getTree(opts.generators.get(0), file);
return t;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
@@ -0,0 +1,77 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client.diff;
import com.github.gumtreediff.client.Option;
import com.github.gumtreediff.gen.Registry;
import com.github.gumtreediff.io.TreeIoUtils;
import com.github.gumtreediff.client.Register;
import com.github.gumtreediff.matchers.Matcher;
@Register(name = "axmldiff", description = "Dump annotated xml tree",
priority = Registry.Priority.LOW, options = AbstractDiffClient.Options.class)
public class AnnotatedXmlDiff extends AbstractDiffClient<AnnotatedXmlDiff.Options> {
public AnnotatedXmlDiff(String[] args) {
super(args);
}
static class Options extends AbstractDiffClient.Options {
protected boolean isSrc = true;
@Override
public Option[] values() {
return Option.Context.addValue(super.values(),
new Option("--src", String.format("Dump source tree (default: %s)", isSrc ? "yes" : "no"), 0) {
@Override
protected void process(String name, String[] args) {
isSrc = true;
}
},
new Option("--dst", String.format("Dump destination tree (default: %s)", !isSrc
? "yes" : "no"), 0) {
@Override
protected void process(String name, String[] args) {
isSrc = false;
}
}
);
}
}
@Override
protected Options newOptions() {
return new Options();
}
@Override
public void run() {
Matcher m = matchTrees();
try {
TreeIoUtils.toAnnotatedXml((opts.isSrc)
? getSrcTreeContext()
: getDstTreeContext(), opts.isSrc, m.getMappings()
).writeTo(System.out);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,57 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client.diff;
import com.github.gumtreediff.actions.ActionGenerator;
import com.github.gumtreediff.actions.model.Action;
import com.github.gumtreediff.client.Register;
import com.github.gumtreediff.io.ActionsIoUtils;
import com.github.gumtreediff.matchers.Matcher;
import java.util.List;
@Register(name = "jsondiff", description = "Dump actions in the JSON format",
options = AbstractDiffClient.Options.class)
public class JsonDiff extends AbstractDiffClient<AbstractDiffClient.Options> {
public JsonDiff(String[] args) {
super(args);
}
@Override
protected Options newOptions() {
return new Options();
}
@Override
public void run() {
Matcher m = matchTrees();
ActionGenerator g = new ActionGenerator(getSrcTreeContext().getRoot(),
getDstTreeContext().getRoot(), m.getMappings());
g.generate();
List<Action> actions = g.getActions();
try {
ActionsIoUtils.toJson(getSrcTreeContext(), actions, m.getMappings()).writeTo(System.out);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,141 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client.diff;
import com.github.gumtreediff.actions.ActionGenerator;
import com.github.gumtreediff.actions.model.Action;
import com.github.gumtreediff.client.Option;
import com.github.gumtreediff.client.Register;
import com.github.gumtreediff.io.ActionsIoUtils;
import com.github.gumtreediff.matchers.MappingStore;
import com.github.gumtreediff.matchers.Matcher;
import com.github.gumtreediff.tree.TreeContext;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.List;
@Register(name = "diff", description = "Dump actions in our textual format",
options = AbstractDiffClient.Options.class)
public class TextDiff extends AbstractDiffClient<TextDiff.Options> {
public TextDiff(String[] args) {
super(args);
if (opts.format == null) {
opts.format = OutputFormat.TEXT;
if (opts.output != null) {
if (opts.output.endsWith(".json"))
opts.format = OutputFormat.JSON;
else if (opts.output.endsWith(".xml"))
opts.format = OutputFormat.XML;
}
}
}
public static class Options extends AbstractDiffClient.Options {
protected OutputFormat format;
protected String output;
@Override
public Option[] values() {
return Option.Context.addValue(super.values(),
new Option("-f", String.format("format: %s", Arrays.toString(OutputFormat.values())), 1) {
@Override
protected void process(String name, String[] args) {
try {
format = OutputFormat.valueOf(args[0].toUpperCase());
} catch (IllegalArgumentException e) {
System.err.printf("No such format '%s', available formats are: %s\n",
args[0].toUpperCase(), Arrays.toString(OutputFormat.values()));
System.exit(-1);
}
}
},
new Option("-o", "output file", 1) {
@Override
protected void process(String name, String[] args) {
output = args[0];
}
}
);
}
@Override
void dump(PrintStream out) {
super.dump(out);
out.printf("format: %s\n", format);
out.printf("output file: %s\n", output == null ? "<Stdout>" : output);
}
}
@Override
protected Options newOptions() {
return new Options();
}
@Override
public void run() {
Matcher m = matchTrees();
ActionGenerator g = new ActionGenerator(getSrcTreeContext().getRoot(),
getDstTreeContext().getRoot(), m.getMappings());
g.generate();
List<Action> actions = g.getActions();
try {
ActionsIoUtils.ActionSerializer serializer = opts.format.getSerializer(
getSrcTreeContext(), actions, m.getMappings());
if (opts.output == null)
serializer.writeTo(System.out);
else
serializer.writeTo(opts.output);
} catch (Exception e) {
e.printStackTrace();
}
}
enum OutputFormat { // TODO make a registry for that also ?
TEXT {
@Override
ActionsIoUtils.ActionSerializer getSerializer(TreeContext sctx, List<Action> actions, MappingStore mappings)
throws IOException {
return ActionsIoUtils.toText(sctx, actions, mappings);
}
},
XML {
@Override
ActionsIoUtils.ActionSerializer getSerializer(TreeContext sctx, List<Action> actions, MappingStore mappings)
throws IOException {
return ActionsIoUtils.toXml(sctx, actions, mappings);
}
},
JSON {
@Override
ActionsIoUtils.ActionSerializer getSerializer(TreeContext sctx, List<Action> actions, MappingStore mappings)
throws IOException {
return ActionsIoUtils.toJson(sctx, actions, mappings);
}
};
abstract ActionsIoUtils.ActionSerializer getSerializer(TreeContext sctx, List<Action> actions,
MappingStore mappings) throws IOException;
}
}
@@ -0,0 +1,204 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client.diff.swing;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.io.FileReader;
import java.io.IOException;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.JTree;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultHighlighter;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreePath;
import com.github.gumtreediff.actions.TreeClassifier;
import com.github.gumtreediff.matchers.MappingStore;
import com.github.gumtreediff.actions.RootsClassifier;
import com.github.gumtreediff.matchers.Matcher;
import com.github.gumtreediff.tree.ITree;
import com.github.gumtreediff.tree.TreeContext;
public class MappingsPanel extends JPanel implements TreeSelectionListener {
private static final long serialVersionUID = 1L;
private TreeContext src;
private TreeContext dst;
private TreeClassifier classifyTrees;
private MappingStore mappings;
private TreePanel panSrc;
private TreePanel panDst;
private JTextArea txtSrc;
private JTextArea txtDst;
private static final Color DEL_COLOR = new Color(190, 0, 0);
private static final Color ADD_COLOR = new Color(0, 158, 0);
private static final Color UPD_COLOR = new Color(189, 162, 0);
//private static final Color MIS_COLOR = new Color(0, 0, 128);
private static final Color MV_COLOR = new Color(128, 0, 128);
public MappingsPanel(String srcPath, String dstPath, TreeContext src, TreeContext dst, Matcher m) {
super(new GridLayout(1, 0));
this.src = src;
this.dst = dst;
this.classifyTrees = new RootsClassifier(src, dst, m);
this.mappings = new MappingStore(m.getMappingSet());
this.panSrc = new TreePanel(this.src, new MappingsCellRenderer(true));
this.panSrc.getJTree().addTreeSelectionListener(this);
this.panDst = new TreePanel(this.dst, new MappingsCellRenderer(false));
this.panDst.getJTree().addTreeSelectionListener(this);
this.txtSrc = new JTextArea();
this.txtDst = new JTextArea();
JPanel top = new JPanel();
top.setLayout(new GridLayout(1, 2));
top.add(panSrc);
top.add(panDst);
JPanel bottom = new JPanel();
bottom.setLayout(new GridLayout(1, 2));
bottom.add(new JScrollPane(txtSrc));
bottom.add(new JScrollPane(txtDst));
JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, top, bottom);
split.setDividerLocation(650);
add(split);
try {
txtSrc.getUI().getEditorKit(txtSrc).read(new FileReader(srcPath), txtSrc.getDocument(), 0);
txtDst.getUI().getEditorKit(txtDst).read(new FileReader(dstPath), txtDst.getDocument(), 0);
} catch (IOException | BadLocationException e) {
e.printStackTrace();
}
setPreferredSize(new Dimension(1024, 768));
openNodes();
}
private void openNodes() {
for (ITree t: classifyTrees.getSrcDelTrees()) openNode(panSrc, t);
for (ITree t: classifyTrees.getDstAddTrees()) openNode(panDst, t);
for (ITree t: classifyTrees.getSrcUpdTrees()) openNode(panSrc, t);
for (ITree t: classifyTrees.getDstUpdTrees()) openNode(panDst, t);
for (ITree t: classifyTrees.getSrcMvTrees()) openNode(panSrc, t);
for (ITree t: classifyTrees.getDstMvTrees()) openNode(panDst, t);
panSrc.getJTree().scrollPathToVisible(new TreePath(panSrc.getTrees().get(src.getRoot()).getPath()));
panDst.getJTree().scrollPathToVisible(new TreePath(panDst.getTrees().get(dst.getRoot()).getPath()));
}
private void openNode(TreePanel p, ITree t) {
DefaultMutableTreeNode n = p.getTrees().get(t);
p.getJTree().scrollPathToVisible(new TreePath(n.getPath()));
}
@Override
public void valueChanged(TreeSelectionEvent e) {
JTree jtree = (JTree) e.getSource();
if (jtree.getSelectionPath() == null) return;
ITree sel = (ITree) ((DefaultMutableTreeNode) jtree.getLastSelectedPathComponent()).getUserObject();
JTextArea selJTextArea = null;
boolean isMapped = false;
ITree match = null;
TreePanel matchTreePanel = null;
JTextArea matchJTextArea = null;
if (jtree == panSrc.getJTree()) {
selJTextArea = txtSrc;
matchTreePanel = panDst;
matchJTextArea = txtDst;
if (mappings.hasSrc(sel)) {
isMapped = true;
match = mappings.getDst(sel);
}
} else {
selJTextArea = txtDst;
matchTreePanel = panSrc;
matchJTextArea = txtSrc;
if (mappings.hasDst(sel)) {
isMapped = true;
match = mappings.getSrc(sel);
}
}
try {
updateJTreeAndJTextArea(sel, selJTextArea, isMapped, match, matchTreePanel, matchJTextArea);
} catch (BadLocationException ex) {
ex.printStackTrace();
}
}
private void updateJTreeAndJTextArea(ITree sel, JTextArea selJTextArea, boolean isMapped,
ITree match, TreePanel matchTreePanel,
JTextArea matchJTextArea) throws BadLocationException {
selJTextArea.getHighlighter().removeAllHighlights();
selJTextArea.getHighlighter().addHighlight(sel.getPos(), sel.getEndPos(), DefaultHighlighter.DefaultPainter);
selJTextArea.setCaretPosition(sel.getPos());
if (isMapped) {
DefaultMutableTreeNode node = matchTreePanel.getTrees().get(match);
matchTreePanel.getJTree().scrollPathToVisible(new TreePath(node.getPath()));
matchTreePanel.getJTree().setSelectionPath(new TreePath(node.getPath()));
matchJTextArea.getHighlighter().removeAllHighlights();
matchJTextArea.getHighlighter().addHighlight(
match.getPos(), match.getEndPos(), DefaultHighlighter.DefaultPainter);
matchJTextArea.setCaretPosition(match.getPos());
} else {
matchTreePanel.getJTree().clearSelection();
matchJTextArea.getHighlighter().removeAllHighlights();
}
}
private class MappingsCellRenderer extends DefaultTreeCellRenderer {
private static final long serialVersionUID = 1L;
private boolean isSrc;
public MappingsCellRenderer(boolean left) {
this.isSrc = left;
}
@Override
public Component getTreeCellRendererComponent(JTree jtree, Object value,
boolean selected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(jtree, value, selected, expanded, leaf, row, hasFocus);
ITree tree = (ITree) ((DefaultMutableTreeNode) value).getUserObject();
if (isSrc && classifyTrees.getSrcDelTrees().contains(tree)) setForeground(DEL_COLOR);
else if (!isSrc && classifyTrees.getDstAddTrees().contains(tree)) setForeground(ADD_COLOR);
else if (isSrc && classifyTrees.getSrcUpdTrees().contains(tree)) setForeground(UPD_COLOR);
else if (!isSrc && classifyTrees.getDstUpdTrees().contains(tree)) setForeground(UPD_COLOR);
else if (isSrc && classifyTrees.getSrcMvTrees().contains(tree)) setForeground(MV_COLOR);
else if (!isSrc && classifyTrees.getDstMvTrees().contains(tree)) setForeground(MV_COLOR);
return this;
}
}
}
@@ -0,0 +1,55 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client.diff.swing;
import com.github.gumtreediff.client.Register;
import com.github.gumtreediff.client.diff.AbstractDiffClient;
import com.github.gumtreediff.client.diff.swing.MappingsPanel;
import com.github.gumtreediff.matchers.Matcher;
import javax.swing.*;
@Register(description = "A swing diff client", options = AbstractDiffClient.Options.class)
public final class SwingDiff extends AbstractDiffClient<AbstractDiffClient.Options> {
public SwingDiff(String[] args) {
super(args);
}
@Override
public void run() {
final Matcher matcher = matchTrees();
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame("GumTree");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new MappingsPanel(opts.src, opts.dst, getSrcTreeContext(), getDstTreeContext(), matcher));
frame.pack();
frame.setVisible(true);
}
});
}
@Override
protected AbstractDiffClient.Options newOptions() {
return new AbstractDiffClient.Options();
}
}
@@ -0,0 +1,50 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client.diff.swing;
import com.github.gumtreediff.gen.Generators;
import com.github.gumtreediff.tree.TreeContext;
import javax.swing.*;
import java.io.IOException;
public final class SwingTree {
public static void main(String[] args) throws IOException {
final TreeContext t = Generators.getInstance().getTree(args[0]);
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShow(t);
}
});
}
private SwingTree() {
}
private static void createAndShow(TreeContext tree) {
JFrame frame = new JFrame("Tree Viewer");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new TreePanel(tree));
frame.pack();
frame.setVisible(true);
}
}
@@ -0,0 +1,105 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client.diff.swing;
import com.github.gumtreediff.tree.ITree;
import com.github.gumtreediff.tree.TreeContext;
import javax.swing.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreeSelectionModel;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
public class TreePanel extends JPanel {
private static final long serialVersionUID = 1L;
private JTree jtree;
private TreeContext tree;
private Map<ITree, DefaultMutableTreeNode> trees;
public TreePanel(final TreeContext tree, TreeCellRenderer renderer) {
super(new GridLayout(1, 0));
trees = new HashMap<>();
this.tree = tree;
ITree root = tree.getRoot();
DefaultMutableTreeNode top = new DefaultMutableTreeNode(root);
trees.put(root, top);
for (ITree child: root.getChildren())
createNodes(top, child);
jtree = new JTree(top) {
private static final long serialVersionUID = 1L;
public String convertValueToText(Object value, boolean selected,
boolean expanded, boolean leaf, int row,
boolean hasFocus) {
if (value != null) {
ITree node = ((ITree) ((DefaultMutableTreeNode) value).getUserObject());
return node.toPrettyString(tree);
}
return "";
}
};
jtree.setCellRenderer(renderer);
jtree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
JScrollPane treeView = new JScrollPane(jtree);
Dimension minimumSize = new Dimension(100, 50);
treeView.setMinimumSize(minimumSize);
add(treeView);
}
public TreePanel(TreeContext tree) {
this(tree, new DefaultTreeCellRenderer());
}
public JTree getJTree() {
return jtree;
}
public Map<ITree, DefaultMutableTreeNode> getTrees() {
return trees;
}
public TreeContext getTree() {
return this.tree;
}
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) jtree.getLastSelectedPathComponent();
if (node == null) return;
Object nodeInfo = node.getUserObject();
System.out.println(nodeInfo);
}
private void createNodes(DefaultMutableTreeNode parent, ITree tree) {
DefaultMutableTreeNode node = new DefaultMutableTreeNode(tree);
trees.put(tree, node);
parent.add(node);
for (ITree child: tree.getChildren()) createNodes(node, child);
}
}
@@ -0,0 +1,37 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client.diff.web;
import org.rendersnake.HtmlCanvas;
import org.rendersnake.Renderable;
import java.io.IOException;
public class BootstrapFooterView implements Renderable {
@Override
public void renderOn(HtmlCanvas html) throws IOException {
html
.macros().javascript("/dist/jquery.min.js")
.macros().javascript("/dist/bootstrap.min.js");
}
}
@@ -0,0 +1,44 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client.diff.web;
import static org.rendersnake.HtmlAttributesFactory.*;
import java.io.IOException;
import org.rendersnake.HtmlCanvas;
import org.rendersnake.Renderable;
public class BootstrapHeaderView implements Renderable {
@Override
public void renderOn(HtmlCanvas html) throws IOException {
html
.head()
.meta(charset("utf8"))
.meta(name("viewport").content("width=device-width, initial-scale=1.0"))
.title().content("GumTree")
.macros().stylesheet("/dist/bootstrap.min.css")
.macros().stylesheet("/dist/gumtree.css")
._head();
}
}
@@ -0,0 +1,102 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client.diff.web;
import com.github.gumtreediff.gen.Generators;
import com.github.gumtreediff.matchers.Matcher;
import com.github.gumtreediff.matchers.Matchers;
import com.github.gumtreediff.tree.TreeContext;
import org.rendersnake.DocType;
import org.rendersnake.HtmlCanvas;
import org.rendersnake.Renderable;
import java.io.File;
import java.io.IOException;
import static org.rendersnake.HtmlAttributesFactory.class_;
import static org.rendersnake.HtmlAttributesFactory.lang;
public class DiffView implements Renderable {
private HtmlDiffs diffs;
private File fSrc;
private File fDst;
public DiffView(File fSrc, File fDst) throws IOException {
this.fSrc = fSrc;
this.fDst = fDst;
TreeContext src = Generators.getInstance().getTree(fSrc.getAbsolutePath());
TreeContext dst = Generators.getInstance().getTree(fDst.getAbsolutePath());
Matcher matcher = Matchers.getInstance().getMatcher(src.getRoot(), dst.getRoot());
matcher.match();
diffs = new HtmlDiffs(fSrc, fDst, src, dst, matcher);
diffs.produce();
}
@Override
public void renderOn(HtmlCanvas html) throws IOException {
html
.render(DocType.HTML5)
.html(lang("en"))
.render(new BootstrapHeaderView())
.body()
.div(class_("container-fluid"))
.div(class_("row"))
.render(new MenuBar())
._div()
.div(class_("row"))
.div(class_("col-lg-6 max-height"))
.h5().content(fSrc.getName())
.pre(class_("pre max-height")).content(diffs.getSrcDiff(), false)
._div()
.div(class_("col-lg-6 max-height"))
.h5().content(fDst.getName())
.pre(class_("pre max-height")).content(diffs.getDstDiff(), false)
._div()
._div()
._div()
.render(new BootstrapFooterView())
.macros().javascript("/dist/diff.js")
._body()
._html();
}
private static class MenuBar implements Renderable {
@Override
public void renderOn(HtmlCanvas html) throws IOException {
html
.div(class_("col-lg-12"))
.div(class_("btn-toolbar pull-right"))
.div(class_("btn-group"))
.a(class_("btn btn-default btn-xs").id("legend").href("#").add("data-toggle", "popover").add("data-html", "true").add("data-placement", "bottom").add("data-content", "<span class=&quot;del&quot;>&nbsp;&nbsp;</span> deleted<br><span class=&quot;add&quot;>&nbsp;&nbsp;</span> added<br><span class=&quot;mv&quot;>&nbsp;&nbsp;</span> moved<br><span class=&quot;upd&quot;>&nbsp;&nbsp;</span> updated<br>", false).add("data-original-title", "Legend").title("Legend").role("button")).content("Legend")
.a(class_("btn btn-default btn-xs").id("shortcuts").href("#").add("data-toggle", "popover").add("data-html", "true").add("data-placement", "bottom").add("data-content", "<b>q</b> quit<br><b>l</b> list<br><b>n</b> next<br><b>t</b> top<br><b>b</b> bottom", false).add("data-original-title", "Shortcuts").title("Shortcuts").role("button")).content("Shortcuts")
._div()
.div(class_("btn-group"))
.a(class_("btn btn-default btn-xs btn-danger").href("/quit")).content("Quit")
._div()
._div()
._div();
}
}
}
@@ -0,0 +1,174 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client.diff.web;
import com.github.gumtreediff.utils.Pair;
import com.github.gumtreediff.io.DirectoryComparator;
import org.rendersnake.DocType;
import org.rendersnake.HtmlCanvas;
import org.rendersnake.Renderable;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import java.util.Set;
import static org.rendersnake.HtmlAttributesFactory.*;
public class DirectoryComparatorView implements Renderable {
private DirectoryComparator comparator;
public DirectoryComparatorView(DirectoryComparator comparator) throws IOException {
this.comparator = comparator;
}
@Override
public void renderOn(HtmlCanvas html) throws IOException {
html
.render(DocType.HTML5)
.html(lang("en"))
.render(new BootstrapHeaderView())
.body()
.div(class_("container"))
.div(class_("row"))
.div(class_("col-lg-12"))
.div(class_("panel panel-default"))
.div(class_("panel-heading"))
.h4(class_("panel-title"))
.write("Modified files ")
.span(class_("badge")).content(comparator.getModifiedFiles().size())
._h4()
._div()
.div(class_("panel-body"))
.render_if(new ModifiedFiles(comparator.getModifiedFiles()), comparator.getModifiedFiles().size() > 0)
._div()
._div()
._div()
._div()
.div(class_("row"))
.div(class_("col-lg-6"))
.div(class_("panel panel-default"))
.div(class_("panel-heading"))
.h4(class_("panel-title"))
.write("Deleted files ")
.span(class_("badge")).content(comparator.getDeletedFiles().size())
._h4()
._div()
.div(class_("panel-body"))
.render_if(new AddedOrDeletedFiles(
comparator.getDeletedFiles(), comparator.getSrc(), "danger"),
comparator.getDeletedFiles().size() > 0)
._div()
._div()
._div()
.div(class_("col-lg-6"))
.div(class_("panel panel-default"))
.div(class_("panel-heading"))
.h4(class_("panel-title"))
.write("Added files ")
.span(class_("badge")).content(comparator.getAddedFiles().size())
._h4()
._div()
.div(class_("panel-body"))
.render_if(new AddedOrDeletedFiles(
comparator.getAddedFiles(), comparator.getDst(), "success"),
comparator.getAddedFiles().size() > 0)
._div()
._div()
._div()
._div()
._div()
.render(new BootstrapFooterView())
.macros().javascript("/dist/list.js")
._body()
._html();
}
private class ModifiedFiles implements Renderable {
private List<Pair<File, File>> files;
private ModifiedFiles(List<Pair<File, File>> files) {
this.files = files;
}
@Override
public void renderOn(HtmlCanvas html) throws IOException {
HtmlCanvas tbody = html
.table(class_("table table-striped table-condensed"))
.tbody();
int id = 0;
for (Pair<File, File> file : files) {
tbody
.tr()
.td(class_("col-md-10")).content(comparator.getSrc().relativize(file.getFirst().toPath()).toString())
.td(class_("col-md-2"))
.a(class_("btn btn-primary btn-xs").href("/diff/" + id)).content("diff")
.write(" ")
.a(class_("btn btn-primary btn-xs").href("/mergely/" + id)).content("mergely")
.write(" ")
.a(class_("btn btn-primary btn-xs").href("/script/" + id)).content("script")
._td()
._tr();
id++;
}
tbody
._tbody()
._table();
}
}
private class AddedOrDeletedFiles implements Renderable {
private Set<File> files;
private Path root;
private String tdClass;
private AddedOrDeletedFiles(Set<File> files, Path root, String tdClass) {
this.files = files;
this.root = root;
this.tdClass = tdClass;
}
@Override
public void renderOn(HtmlCanvas html) throws IOException {
HtmlCanvas tbody = html
.table(class_("table table-condensed"))
.tbody();
for (File file : files) {
tbody
.tr()
.td(class_(tdClass)).content(root.relativize(file.toPath()).toString())
._tr();
}
tbody
._tbody()
._table();
}
}
}
@@ -0,0 +1,177 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client.diff.web;
import com.github.gumtreediff.actions.RootAndLeavesClassifier;
import com.github.gumtreediff.actions.TreeClassifier;
import com.github.gumtreediff.utils.StringAlgorithms;
import com.github.gumtreediff.matchers.MappingStore;
import com.github.gumtreediff.matchers.Matcher;
import com.github.gumtreediff.tree.ITree;
import com.github.gumtreediff.tree.TreeContext;
import gnu.trove.map.TIntIntMap;
import gnu.trove.map.hash.TIntIntHashMap;
import java.io.*;
import java.util.List;
public final class HtmlDiffs {
private static final String SRC_MV_SPAN = "<span class=\"%s\" id=\"move-src-%d\" data-title=\"%s\">";
private static final String DST_MV_SPAN = "<span class=\"%s\" id=\"move-dst-%d\" data-title=\"%s\">";
private static final String ADD_DEL_SPAN = "<span class=\"%s\" data-title=\"%s\">";
private static final String UPD_SPAN = "<span class=\"cupd\">";
private static final String ID_SPAN = "<span class=\"marker\" id=\"mapping-%d\"></span>";
private static final String END_SPAN = "</span>";
private String srcDiff;
private String dstDiff;
private TreeContext src;
private TreeContext dst;
private File fSrc;
private File fDst;
private Matcher matcher;
private MappingStore mappings;
public HtmlDiffs(File fSrc, File fDst, TreeContext src, TreeContext dst, Matcher matcher) {
this.fSrc = fSrc;
this.fDst = fDst;
this.src = src;
this.dst = dst;
this.matcher = matcher;
this.mappings = matcher.getMappings();
}
public void produce() throws IOException {
TreeClassifier c = new RootAndLeavesClassifier(src, dst, matcher);
TIntIntMap mappingIds = new TIntIntHashMap();
int uId = 1;
int mId = 1;
TagIndex ltags = new TagIndex();
for (ITree t: src.getRoot().getTrees()) {
if (c.getSrcMvTrees().contains(t)) {
mappingIds.put(mappings.getDst(t).getId(), mId);
ltags.addStartTag(t.getPos(), String.format(ID_SPAN, uId++));
ltags.addTags(t.getPos(), String.format(
SRC_MV_SPAN, "token mv", mId++, tooltip(src, t)), t.getEndPos(), END_SPAN);
}
if (c.getSrcUpdTrees().contains(t)) {
mappingIds.put(mappings.getDst(t).getId(), mId);
ltags.addStartTag(t.getPos(), String.format(ID_SPAN, uId++));
ltags.addTags(t.getPos(), String.format(
SRC_MV_SPAN, "token upd", mId++, tooltip(src, t)), t.getEndPos(), END_SPAN);
List<int[]> hunks = StringAlgorithms.hunks(t.getLabel(), mappings.getDst(t).getLabel());
for (int[] hunk: hunks)
ltags.addTags(t.getPos() + hunk[0], UPD_SPAN, t.getPos() + hunk[1], END_SPAN);
}
if (c.getSrcDelTrees().contains(t)) {
ltags.addStartTag(t.getPos(), String.format(ID_SPAN, uId++));
ltags.addTags(t.getPos(), String.format(
ADD_DEL_SPAN, "token del", tooltip(src, t)), t.getEndPos(), END_SPAN);
}
}
TagIndex rtags = new TagIndex();
for (ITree t: dst.getRoot().getTrees()) {
if (c.getDstMvTrees().contains(t)) {
int dId = mappingIds.get(t.getId());
rtags.addStartTag(t.getPos(), String.format(ID_SPAN, uId++));
rtags.addTags(t.getPos(), String.format(
DST_MV_SPAN, "token mv", dId, tooltip(dst, t)), t.getEndPos(), END_SPAN);
}
if (c.getDstUpdTrees().contains(t)) {
int dId = mappingIds.get(t.getId());
rtags.addStartTag(t.getPos(), String.format(ID_SPAN, uId++));
rtags.addTags(t.getPos(), String.format(
DST_MV_SPAN, "token upd", dId, tooltip(dst, t)), t.getEndPos(), END_SPAN);
List<int[]> hunks = StringAlgorithms.hunks(mappings.getSrc(t).getLabel(), t.getLabel());
for (int[] hunk: hunks)
rtags.addTags(t.getPos() + hunk[2], UPD_SPAN, t.getPos() + hunk[3], END_SPAN);
}
if (c.getDstAddTrees().contains(t)) {
rtags.addStartTag(t.getPos(), String.format(ID_SPAN, uId++));
rtags.addTags(t.getPos(), String.format(
ADD_DEL_SPAN, "token add", tooltip(dst, t)), t.getEndPos(), END_SPAN);
}
}
StringWriter w1 = new StringWriter();
BufferedReader r = new BufferedReader(new FileReader(fSrc));
int cursor = 0;
while (r.ready()) {
char cr = (char) r.read();
w1.append(ltags.getEndTags(cursor));
w1.append(ltags.getStartTags(cursor));
append(cr, w1);
cursor++;
}
w1.append(ltags.getEndTags(cursor));
r.close();
srcDiff = w1.toString();
StringWriter w2 = new StringWriter();
r = new BufferedReader(new FileReader(fDst));
cursor = 0;
while (r.ready()) {
char cr = (char) r.read();
w2.append(rtags.getEndTags(cursor));
w2.append(rtags.getStartTags(cursor));
append(cr, w2);
cursor++;
}
w2.append(rtags.getEndTags(cursor));
r.close();
dstDiff = w2.toString();
}
public String getSrcDiff() {
return srcDiff;
}
public String getDstDiff() {
return dstDiff;
}
private static String tooltip(TreeContext ctx, ITree t) {
return (t.getParent() != null)
? ctx.getTypeLabel(t.getParent()) + "/" + ctx.getTypeLabel(t) : ctx.getTypeLabel(t);
}
private static void append(char cr, Writer w) throws IOException {
if (cr == '<') w.append("&lt;");
else if (cr == '>') w.append("&gt;");
else if (cr == '&') w.append("&amp;");
else w.append(cr);
}
}
@@ -0,0 +1,65 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client.diff.web;
import org.rendersnake.DocType;
import org.rendersnake.HtmlCanvas;
import org.rendersnake.Renderable;
import java.io.IOException;
import static org.rendersnake.HtmlAttributesFactory.*;
public class MergelyView implements Renderable {
private int id;
public MergelyView(int id) throws IOException {
this.id = id;
}
@Override
public void renderOn(HtmlCanvas html) throws IOException {
html
.render(DocType.HTML5)
.html(lang("en"))
.head()
.meta(charset("utf8"))
.meta(name("viewport").content("width=device-width, initial-scale=1.0"))
.title().content("GumTree")
.macros().javascript("/dist/jquery.min.js")
.macros().javascript("/dist/codemirror.min.js")
.macros().stylesheet("/dist/codemirror.css")
.macros().javascript("/dist/mergely.min.js")
.macros().javascript("/dist/mergely_shortcuts.js")
.macros().stylesheet("/dist/mergely.css")
.macros().stylesheet("/dist/mergely_custom.css")
._head()
.body()
.div(id("compare"))
._div()
.macros().script("lhs_url = \"/left/" + id + "\";")
.macros().script("rhs_url = \"/right/" + id + "\";")
.macros().javascript("/dist/mergely_ajax.js")
._body()
._html();
}
}
@@ -0,0 +1,93 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client.diff.web;
import com.github.gumtreediff.actions.ActionGenerator;
import com.github.gumtreediff.actions.model.Action;
import com.github.gumtreediff.gen.Generators;
import com.github.gumtreediff.io.ActionsIoUtils;
import com.github.gumtreediff.matchers.MappingStore;
import com.github.gumtreediff.matchers.Matcher;
import com.github.gumtreediff.matchers.Matchers;
import com.github.gumtreediff.tree.TreeContext;
import org.rendersnake.DocType;
import org.rendersnake.HtmlCanvas;
import org.rendersnake.Renderable;
import java.io.File;
import java.io.IOException;
import java.util.List;
import static org.rendersnake.HtmlAttributesFactory.class_;
import static org.rendersnake.HtmlAttributesFactory.lang;
public class ScriptView implements Renderable {
private final MappingStore mappings;
private final TreeContext src;
private final TreeContext dst;
private File fSrc;
private File fDst;
private List<Action> script;
public ScriptView(File fSrc, File fDst) throws IOException {
this.fSrc = fSrc;
this.fDst = fDst;
src = Generators.getInstance().getTree(fSrc.getAbsolutePath());
dst = Generators.getInstance().getTree(fDst.getAbsolutePath());
Matcher matcher = Matchers.getInstance().getMatcher(src.getRoot(), dst.getRoot());
matcher.match();
mappings = matcher.getMappings();
ActionGenerator g = new ActionGenerator(src.getRoot(), dst.getRoot(), mappings);
g.generate();
this.script = g.getActions();
}
@Override
public void renderOn(HtmlCanvas html) throws IOException {
html
.render(DocType.HTML5)
.html(lang("en"))
.render(new BootstrapHeaderView())
.body()
.div(class_("container"))
.div(class_("row"))
.div(class_("col-lg-12"))
.h3()
.write("Script ")
.small().content(String.format("%s -> %s", fSrc.getName(), fDst.getName()))
._h3()
.pre().content(ActionsIoUtils.toText(src, this.script, mappings).toString())
._div()
._div()
._div()
.render(new BootstrapFooterView())
.macros().javascript("/dist/script.js")
._body()
._html();
}
}
@@ -0,0 +1,70 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client.diff.web;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TagIndex {
private Map<Integer, List<String>> startTags;
private Map<Integer, List<String>> endTags;
public TagIndex() {
startTags = new HashMap<Integer, List<String>>();
endTags = new HashMap<Integer, List<String>>();
}
public void addTags(int pos, String startTag, int endPos, String endTag) {
addStartTag(pos, startTag);
addEndTag(endPos, endTag);
}
public void addStartTag(int pos, String tag) {
if (!startTags.containsKey(pos)) startTags.put(pos, new ArrayList<String>());
startTags.get(pos).add(tag);
}
public void addEndTag(int pos, String tag) {
if (!endTags.containsKey(pos)) endTags.put(pos, new ArrayList<String>());
endTags.get(pos).add(tag);
}
public String getEndTags(int pos) {
if (!endTags.containsKey(pos)) return "";
StringBuffer b = new StringBuffer();
for (String s: endTags.get(pos)) b.append(s);
return b.toString();
}
public String getStartTags(int pos) {
if (!startTags.containsKey(pos))
return "";
StringBuffer b = new StringBuffer();
for (String s: startTags.get(pos))
b.append(s);
return b.toString();
}
}
@@ -0,0 +1,150 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client.diff.web;
import com.github.gumtreediff.client.Option;
import com.github.gumtreediff.client.Register;
import com.github.gumtreediff.client.diff.AbstractDiffClient;
import com.github.gumtreediff.gen.Registry;
import com.github.gumtreediff.io.DirectoryComparator;
import com.github.gumtreediff.utils.Pair;
import org.rendersnake.HtmlCanvas;
import org.rendersnake.Renderable;
import spark.Spark;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import static spark.Spark.*;
@Register(description = "a web diff client", options = WebDiff.Options.class, priority = Registry.Priority.HIGH)
public class WebDiff extends AbstractDiffClient<WebDiff.Options> {
public WebDiff(String[] args) {
super(args);
}
static class Options extends AbstractDiffClient.Options {
protected int defaultPort = Integer.parseInt(System.getProperty("gumtree.client.web.port", "4567"));
boolean stdin = true;
@Override
public Option[] values() {
return Option.Context.addValue(super.values(),
new Option("--port", String.format("set server port (default to)", defaultPort), 1) {
@Override
protected void process(String name, String[] args) {
int p = Integer.parseInt(args[0]);
if (p > 0)
defaultPort = p;
else
System.err.printf("Invalid port number (%s), using %d\n", args[0], defaultPort);
}
},
new Option("--no-stdin", String.format("Do not listen to stdin"), 0) {
@Override
protected void process(String name, String[] args) {
stdin = false;
}
}
);
}
}
@Override
protected Options newOptions() {
return new Options();
}
@Override
public void run() {
DirectoryComparator comparator = new DirectoryComparator(opts.src, opts.dst);
comparator.compare();
configureSpark(comparator, opts.defaultPort);
Spark.awaitInitialization();
System.out.println(String.format("Starting server: %s:%d", "http://127.0.0.1", opts.defaultPort));
}
public static void configureSpark(final DirectoryComparator comparator, int port) {
port(port);
staticFiles.location("/web/");
get("/", (request, response) -> {
if (comparator.isDirMode())
response.redirect("/list");
else
response.redirect("/diff/0");
return "";
});
get("/list", (request, response) -> {
Renderable view = new DirectoryComparatorView(comparator);
return render(view);
});
get("/diff/:id", (request, response) -> {
int id = Integer.parseInt(request.params(":id"));
Pair<File, File> pair = comparator.getModifiedFiles().get(id);
Renderable view = new DiffView(pair.getFirst(), pair.getSecond());
return render(view);
});
get("/mergely/:id", (request, response) -> {
int id = Integer.parseInt(request.params(":id"));
Renderable view = new MergelyView(id);
return render(view);
});
get("/left/:id", (request, response) -> {
int id = Integer.parseInt(request.params(":id"));
Pair<File, File> pair = comparator.getModifiedFiles().get(id);
return readFile(pair.getFirst().getAbsolutePath(), Charset.defaultCharset());
});
get("/right/:id", (request, response) -> {
int id = Integer.parseInt(request.params(":id"));
Pair<File, File> pair = comparator.getModifiedFiles().get(id);
return readFile(pair.getSecond().getAbsolutePath(), Charset.defaultCharset());
});
get("/script/:id", (request, response) -> {
int id = Integer.parseInt(request.params(":id"));
Pair<File, File> pair = comparator.getModifiedFiles().get(id);
Renderable view = new ScriptView(pair.getFirst(), pair.getSecond());
return render(view);
});
get("/quit", (request, response) -> {
System.exit(0);
return "";
});
}
private static String render(Renderable r) {
HtmlCanvas c = new HtmlCanvas();
try {
r.renderOn(c);
} catch (IOException e) {
e.printStackTrace();
}
return c.toHtml();
}
private static String readFile(String path, Charset encoding) throws IOException {
byte[] encoded = Files.readAllBytes(Paths.get(path));
return new String(encoded, encoding);
}
}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,334 @@
/* BASICS */
.CodeMirror {
/* Set height, width, borders, and global font properties here */
font-family: monospace;
height: 300px;
color: black;
}
/* PADDING */
.CodeMirror-lines {
padding: 4px 0; /* Vertical padding around content */
}
.CodeMirror pre {
padding: 0 4px; /* Horizontal padding of content */
}
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
background-color: white; /* The little square between H and V scrollbars */
}
/* GUTTER */
.CodeMirror-gutters {
border-right: 1px solid #ddd;
background-color: #f7f7f7;
white-space: nowrap;
}
.CodeMirror-linenumbers {}
.CodeMirror-linenumber {
padding: 0 3px 0 5px;
min-width: 20px;
text-align: right;
color: #999;
white-space: nowrap;
}
.CodeMirror-guttermarker { color: black; }
.CodeMirror-guttermarker-subtle { color: #999; }
/* CURSOR */
.CodeMirror-cursor {
border-left: 1px solid black;
border-right: none;
width: 0;
}
/* Shown when moving in bi-directional text */
.CodeMirror div.CodeMirror-secondarycursor {
border-left: 1px solid silver;
}
.cm-fat-cursor .CodeMirror-cursor {
width: auto;
border: 0;
background: #7e7;
}
.cm-fat-cursor div.CodeMirror-cursors {
z-index: 1;
}
.cm-animate-fat-cursor {
width: auto;
border: 0;
-webkit-animation: blink 1.06s steps(1) infinite;
-moz-animation: blink 1.06s steps(1) infinite;
animation: blink 1.06s steps(1) infinite;
background-color: #7e7;
}
@-moz-keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
@-webkit-keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
@keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
/* Can style cursor different in overwrite (non-insert) mode */
.CodeMirror-overwrite .CodeMirror-cursor {}
.cm-tab { display: inline-block; text-decoration: inherit; }
.CodeMirror-ruler {
border-left: 1px solid #ccc;
position: absolute;
}
/* DEFAULT THEME */
.cm-s-default .cm-header {color: blue;}
.cm-s-default .cm-quote {color: #090;}
.cm-negative {color: #d44;}
.cm-positive {color: #292;}
.cm-header, .cm-strong {font-weight: bold;}
.cm-em {font-style: italic;}
.cm-link {text-decoration: underline;}
.cm-strikethrough {text-decoration: line-through;}
.cm-s-default .cm-keyword {color: #708;}
.cm-s-default .cm-atom {color: #219;}
.cm-s-default .cm-number {color: #164;}
.cm-s-default .cm-def {color: #00f;}
.cm-s-default .cm-variable,
.cm-s-default .cm-punctuation,
.cm-s-default .cm-property,
.cm-s-default .cm-operator {}
.cm-s-default .cm-variable-2 {color: #05a;}
.cm-s-default .cm-variable-3 {color: #085;}
.cm-s-default .cm-comment {color: #a50;}
.cm-s-default .cm-string {color: #a11;}
.cm-s-default .cm-string-2 {color: #f50;}
.cm-s-default .cm-meta {color: #555;}
.cm-s-default .cm-qualifier {color: #555;}
.cm-s-default .cm-builtin {color: #30a;}
.cm-s-default .cm-bracket {color: #997;}
.cm-s-default .cm-tag {color: #170;}
.cm-s-default .cm-attribute {color: #00c;}
.cm-s-default .cm-hr {color: #999;}
.cm-s-default .cm-link {color: #00c;}
.cm-s-default .cm-error {color: #f00;}
.cm-invalidchar {color: #f00;}
.CodeMirror-composing { border-bottom: 2px solid; }
/* Default styles for common addons */
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
.CodeMirror-activeline-background {background: #e8f2ff;}
/* STOP */
/* The rest of this file contains styles related to the mechanics of
the editor. You probably shouldn't touch them. */
.CodeMirror {
position: relative;
overflow: hidden;
background: white;
}
.CodeMirror-scroll {
overflow: scroll !important; /* Things will break if this is overridden */
/* 30px is the magic margin used to hide the element's real scrollbars */
/* See overflow: hidden in .CodeMirror */
margin-bottom: -30px; margin-right: -30px;
padding-bottom: 30px;
height: 100%;
outline: none; /* Prevent dragging from highlighting the element */
position: relative;
}
.CodeMirror-sizer {
position: relative;
border-right: 30px solid transparent;
}
/* The fake, visible scrollbars. Used to force redraw during scrolling
before actual scrolling happens, thus preventing shaking and
flickering artifacts. */
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
position: absolute;
z-index: 6;
display: none;
}
.CodeMirror-vscrollbar {
right: 0; top: 0;
overflow-x: hidden;
overflow-y: scroll;
}
.CodeMirror-hscrollbar {
bottom: 0; left: 0;
overflow-y: hidden;
overflow-x: scroll;
}
.CodeMirror-scrollbar-filler {
right: 0; bottom: 0;
}
.CodeMirror-gutter-filler {
left: 0; bottom: 0;
}
.CodeMirror-gutters {
position: absolute; left: 0; top: 0;
z-index: 3;
}
.CodeMirror-gutter {
white-space: normal;
height: 100%;
display: inline-block;
margin-bottom: -30px;
/* Hack to make IE7 behave */
*zoom:1;
*display:inline;
}
.CodeMirror-gutter-wrapper {
position: absolute;
z-index: 4;
background: none !important;
border: none !important;
}
.CodeMirror-gutter-background {
position: absolute;
top: 0; bottom: 0;
z-index: 4;
}
.CodeMirror-gutter-elt {
position: absolute;
cursor: default;
z-index: 4;
}
.CodeMirror-gutter-wrapper {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.CodeMirror-lines {
cursor: text;
min-height: 1px; /* prevents collapsing before first draw */
}
.CodeMirror pre {
/* Reset some styles that the rest of the page might have set */
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
border-width: 0;
background: transparent;
font-family: inherit;
font-size: inherit;
margin: 0;
white-space: pre;
word-wrap: normal;
line-height: inherit;
color: inherit;
z-index: 2;
position: relative;
overflow: visible;
-webkit-tap-highlight-color: transparent;
}
.CodeMirror-wrap pre {
word-wrap: break-word;
white-space: pre-wrap;
word-break: normal;
}
.CodeMirror-linebackground {
position: absolute;
left: 0; right: 0; top: 0; bottom: 0;
z-index: 0;
}
.CodeMirror-linewidget {
position: relative;
z-index: 2;
overflow: auto;
}
.CodeMirror-widget {}
.CodeMirror-code {
outline: none;
}
/* Force content-box sizing for the elements where we expect it */
.CodeMirror-scroll,
.CodeMirror-sizer,
.CodeMirror-gutter,
.CodeMirror-gutters,
.CodeMirror-linenumber {
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.CodeMirror-measure {
position: absolute;
width: 100%;
height: 0;
overflow: hidden;
visibility: hidden;
}
.CodeMirror-cursor { position: absolute; }
.CodeMirror-measure pre { position: static; }
div.CodeMirror-cursors {
visibility: hidden;
position: relative;
z-index: 3;
}
div.CodeMirror-dragcursors {
visibility: visible;
}
.CodeMirror-focused div.CodeMirror-cursors {
visibility: visible;
}
.CodeMirror-selected { background: #d9d9d9; }
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
.CodeMirror-crosshair { cursor: crosshair; }
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
.cm-searching {
background: #ffa;
background: rgba(255, 255, 0, .4);
}
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
.CodeMirror span { *vertical-align: text-bottom; }
/* Used to force a border model for a node */
.cm-force-border { padding-right: .1px; }
@media print {
/* Hide the cursor when printing */
.CodeMirror div.CodeMirror-cursors {
visibility: hidden;
}
}
/* See issue #2901 */
.cm-tab-wrap-hack:after { content: ''; }
/* Help users use markselection to safely style text background */
span.CodeMirror-selectedtext { background: none; }
File diff suppressed because one or more lines are too long
@@ -0,0 +1,120 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
currentMapping = 0;
if (typeof String.prototype.startsWith != 'function') {
String.prototype.startsWith = function (str){
return this.slice(0, str.length) == str;
};
}
function getMappedElement(eltId) {
if (eltId.startsWith("move-src")) {
return eltId.replace("src","dst");
}
else {
return eltId.replace("dst","src");
}
}
function nextMapping() {
if (currentMapping == 0) {
currentMapping = 1;
return "#mapping-" + currentMapping.toString();
} else {
currentMapping++;
if ($("#mapping-" + currentMapping.toString()).length > 0) {
return "#mapping-" + currentMapping.toString();
} else {
currentMapping = 1;
return "#mapping-" + currentMapping.toString();
}
}
}
function isSrc(eltId) {
return eltId.startsWith("move-src");
}
$(function() {
$("#legend").popover();
$("#shortcuts").popover();
// shortcuts
$("body").keypress(function (event) {
switch(event.which) {
case 110:
var mapping = nextMapping();
$('html, body').animate({scrollTop: $(mapping).offset().top - 200}, 100);
break;
case 116:
$('html, body').animate({scrollTop: 0}, 100);
break;
case 98:
$("html, body").animate({ scrollTop: $(document).height() }, 100);
break;
case 113:
window.location = "/quit";
break;
case 108:
window.location = "/list";
break;
}
});
// highlight
$("span.mv.token, span.token.upd").click(function(event) {
if ($(this).hasClass("selected")) {
$("span.mv.token, span.token.upd").removeClass("selected");
} else {
$("span.mv.token, span.token.upd").removeClass("selected");
var eltId = $(this).attr("id");
var refEltId = getMappedElement(eltId);
$("#" + refEltId).addClass("selected");
$(this).addClass("selected");
var sel = "#dst";
if (isSrc(refEltId))
var sel = "#src";
$div = $(sel);
$span = $("#" + refEltId);
}
event.stopPropagation();
});
$("span.add.token, span.token.del").click(function(event) {
$("span.mv.token, span.token.upd").removeClass("selected");
event.stopPropagation();
});
// tooltip
$("span.token").hover(
function (event) {
$(this).tooltip('show');
event.stopPropagation();
},
function (event) {
$(this).tooltip('hide');
event.stopPropagation();
}
);
});
@@ -0,0 +1,93 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
.add {
border: 1px solid black;
background-color: MediumSeaGreen;
}
.del {
border: 1px solid black;
background-color: DarkSalmon;
}
.mv {
border: 1px solid black;
background-color: Lavender;
}
.upd {
border: 1px solid black;
background-color: RosyBrown;
font-weight: bold;
}
.cupd {
font-weight: normal;
color: DimGray;
}
.selected {
background-color: Gold;
}
.marker {
margin: 0;
padding: 0;
}
.container {
margin-right: auto;
margin-left: auto;
width: 100%;
}
.scrollable {
overflow: scroll;
}
.no-overflow {
overflow: hidden;
}
body, html {
height: 100%;
margin: 0px;
padding: 0px;
}
div {
margin: 0px;
padding: 0px;
}
.max-height {
height: 100%;
}
.pre {
margin: 0px;
padding: 0px;
font-size: 10pt;
color: black;
background-color: white;
border-color: black;
font-family: "Inconsolata", "Consolas", "Liberation Sans Regular", "DejaVu Sans Mono", monospace;
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,31 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
$(function() {
// shortcut
$("body").keypress(function (event) {
switch (event.which) {
case 113:
window.location = "/quit";
break;
}
});
});
@@ -0,0 +1,50 @@
/**
* Copyright (c) 2016 by Jamie Peabody, http://www.mergely.com
* All rights reserved.
* Version: 3.4.3 2016-09-07
*/
/* required */
.mergely-column textarea { width: 80px; height: 200px; }
.mergely-column { float: left; }
.mergely-margin { float: left; }
.mergely-canvas { float: left; width: 28px; }
/* resizeable */
.mergely-resizer { width: 100%; height: 100%; }
/* style configuration */
.mergely-column { border: 1px solid #ccc; }
.mergely-active { border: 1px solid #a3d1ff; }
.mergely.a,.mergely.d,.mergely.c { color: #000; }
.mergely.a.rhs.start { border-top: 1px solid #a3d1ff; }
.mergely.a.lhs.start.end,
.mergely.a.rhs.end { border-bottom: 1px solid #a3d1ff; }
.mergely.a.rhs { background-color: #ddeeff; }
.mergely.a.lhs.start.end.first { border-bottom: 0; border-top: 1px solid #a3d1ff; }
.mergely.d.lhs { background-color: #ffe9e9; }
.mergely.d.lhs.end,
.mergely.d.rhs.start.end { border-bottom: 1px solid #f8e8e8; }
.mergely.d.rhs.start.end.first { border-bottom: 0; border-top: 1px solid #f8e8e8; }
.mergely.d.lhs.start { border-top: 1px solid #f8e8e8; }
.mergely.c.lhs,
.mergely.c.rhs { background-color: #fafafa; }
.mergely.c.lhs.start,
.mergely.c.rhs.start { border-top: 1px solid #a3a3a3; }
.mergely.c.lhs.end,
.mergely.c.rhs.end { border-bottom: 1px solid #a3a3a3; }
.mergely.ch.a.rhs { background-color: #ddeeff; }
.mergely.ch.d.lhs { background-color: #ffe9e9; text-decoration: line-through; color: red !important; }
.mergely.current.start { border-top: 1px solid #000 !important; }
.mergely.current.end { border-bottom: 1px solid #000 !important; }
.mergely.current.lhs.a.start.end,
.mergely.current.rhs.d.start.end { border-top: 0 !important; }
.mergely.current.CodeMirror-linenumber { color: #F9F9F9; font-weight: bold; background-color: #777; }
.CodeMirror-linenumber { cursor: pointer; }
.CodeMirror-code { color: #717171; }
File diff suppressed because one or more lines are too long
@@ -0,0 +1,19 @@
$(document).ready(function () {
$('#compare').mergely({
editor_width: 'calc(50% - 25px)',
editor_height: 'calc(100% - 25px)',
cmsettings: {
readOnly: true,
lineNumbers: true,
lineWrapping: true
}
});
$.get(lhs_url, function(data) {
$('#compare').mergely('lhs', data);
});
$.get(rhs_url, function(data) {
$('#compare').mergely('rhs', data);
});
});
@@ -0,0 +1,8 @@
html, body, #compare, .CodeMirror {
height: 100%;
}
.CodeMirror pre {
font-family: "Inconsolata", "Consolas", "Liberation Sans Regular", "DejaVu Sans Mono", monospace;
font-size: 10pt;
}
@@ -0,0 +1,31 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2016 Floréal Morandat <florealm@gmail.com>
*/
$(function(){
$("body").keypress(function (event) {
switch (event.which) {
case 113:
window.location = "/quit";
break;
case 108:
window.location = "/list";
break;
}
});
});
@@ -0,0 +1,40 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
$(function(){
$("#infos").popover();
$("body").keypress(function (event) {
switch (event.which) {
case 116:
$('html, body').animate({scrollTop: 0}, 100);
break;
case 98:
$("html, body").animate({ scrollTop: $(document).height() }, 100);
break;
case 113:
window.location = "/quit";
break;
case 108:
window.location = "/list";
break;
}
});
});
+24
View File
@@ -0,0 +1,24 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.gumtreediff</groupId>
<artifactId>gumtree</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>client</artifactId>
<packaging>jar</packaging>
<name>GumTree Client Module</name>
<dependencies>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.9-RC1</version>
</dependency>
<dependency>
<groupId>com.github.gumtreediff</groupId>
<artifactId>core</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,28 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client;
public abstract class Client {
public Client(String[] args) {}
public abstract void run() throws Exception;
}
@@ -0,0 +1,62 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client;
import com.github.gumtreediff.gen.Registry;
public class Clients extends Registry<String, Client, Register> {
private static Clients registry;
public static Clients getInstance() {
if (registry == null)
registry = new Clients();
return registry;
}
protected String getName(Register annotation, Class<? extends Client> clazz) {
String name = annotation.name();
if (Register.no_value.equals(name))
name = clazz.getSimpleName().toLowerCase();
return name;
}
@Override
protected Entry newEntry(Class<? extends Client> clazz, Register annotation) {
String name = annotation.name().equals(Register.no_value)
? clazz.getSimpleName() : annotation.name();
return new Entry(name.toLowerCase(), clazz, defaultFactory(clazz, String[].class), annotation.priority()) {
@Override
protected boolean handle(String key) {
return id.equalsIgnoreCase(key);
}
final String description;
{
description = annotation.description();
}
@Override
public String toString() {
return String.format("%s: %s", id, description);
}
};
}
}
@@ -0,0 +1,97 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client;
import com.github.gumtreediff.gen.Generators;
import com.github.gumtreediff.matchers.Matchers;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Collection;
@Register(description = "List things (matchers, generators, properties, ...)")
public class List extends Client {
public static final String SYNTAX = "Syntax: list " + Arrays.toString(Listable.values());
private final Listable item;
public List(String[] args) {
super(args);
if (args.length == 0)
throw new Option.OptionException(SYNTAX);
try {
Listable listable = Listable.valueOf(args[0].toUpperCase());
item = listable;
} catch (Exception e) {
throw new Option.OptionException(SYNTAX);
}
}
@Override
public void run() throws IOException {
item.print(System.out);
}
enum Listable {
MATCHERS {
@Override
Collection<?> list() {
return Matchers.getInstance().getEntries();
}
},
GENERATORS {
@Override
Collection<?> list() {
return Generators.getInstance().getEntries();
}
},
PROPERTIES {
@Override
Collection<?> list() {
return Arrays.asList(properties);
}
},
CLIENTS {
@Override
Collection<?> list() {
return Clients.getInstance().getEntries();
}
};
void print(PrintStream out) {
this.list().forEach(item -> out.println(item));
}
abstract Collection<?> list();
}
// This list is generated using (manually) list_properties (it is only an heuristic), some properties may be missing
public static final String[] properties = new String[] {
"gumtree.client.experimental (com.github.gumtreediff.client.Run)",
"gumtree.client.web.port (com.github.gumtreediff.client.diff.WebDiff)",
"gumtree.generator.experimental (com.github.gumtreediff.gen.TreeGeneratorRegistry)",
"line.separator (com.github.gumtreediff.io.IndentingXMLStreamWriter)",
"user.dir (com.github.gumtreediff.client.diff.AbstractDiffClient)"
};
}
@@ -0,0 +1,177 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client;
import java.io.PrintStream;
import java.util.ArrayList;
public abstract class Option {
final String description;
final String key;
final int paramCount;
public interface Context {
Option[] values();
static Option[] addValue(Option[] options, Option... newOptions) {
Option[] nopts = new Option[options.length + newOptions.length];
System.arraycopy(options, 0, nopts, 0, options.length);
System.arraycopy(newOptions, 0, nopts, options.length, newOptions.length);
return nopts;
}
}
@SuppressWarnings("serial")
public static class OptionException extends RuntimeException {
final Context context;
public OptionException(String msg, Context ctx) {
super(msg);
context = ctx;
}
public OptionException(String msg) {
this(msg, null);
}
public Context getContext() {
return context;
}
}
public Option(String key, String text) {
this(key, text, 0);
}
public Option(String key, String text, int params) {
this.key = key;
this.description = text;
this.paramCount = params;
}
public static String[] processCommandLine(String[] args, Context context) {
return processCommandLine(args, context.values(), context);
}
public static String[] processCommandLine(String[] args, Option[] availableOptions, Context ctx) {
ArrayList<String> todo = new ArrayList<>(args.length);
for (int i = 0; i < args.length; i++) {
String arg = args[i];
boolean found = false;
for (int j = 0; j < availableOptions.length && !found; j++) {
if (availableOptions[j].hasOption(arg)) {
int nbParams = availableOptions[j].paramCount;
String[] opts = new String[nbParams];
int currentParam = 0;
while (currentParam < nbParams) {
try {
opts[currentParam++] = args[++i];
} catch (ArrayIndexOutOfBoundsException e) {
throw new OptionException(String.format(
"Option '%s' expects more parameters, using null", arg), ctx);
}
}
availableOptions[j].process(arg, opts);
found = true;
}
}
if (!found) {
todo.add(arg);
}
}
String[] rest = new String[todo.size()];
todo.toArray(rest);
return rest;
}
protected boolean hasOption(String arg) {
return key.equals(arg);
}
protected abstract void process(String name, String[] args);
public String formatHelpText() {
return String.format("%s%s\t%s", key, (paramCount > 0 ? " <" + paramCount + ">" : ""), description);
}
public String toString() {
return key;
}
public static void displayOptions(PrintStream out, Context ctx) {
for (Option opt : ctx.values()) {
out.println(opt.formatHelpText());
}
}
public static class Help extends Option {
protected final Context context;
public Help(final Context ctx) {
super("--help", "Display help (this screen)");
context = ctx;
}
@Override
public void process(String name, String[] args) {
displayOptions(System.out, context);
System.exit(0);
}
}
public static class Text extends Option {
public Text(String text) {
super("", text);
}
@Override
public boolean hasOption(String opt) {
return false;
}
@Override
protected void process(String name, String[] args) {}
@Override
public String formatHelpText() {
return description;
}
}
public static class Verbose extends Option {
public static boolean verbose = false;
public Verbose() {
super("-v", "Verbose mode");
}
@Override
public boolean hasOption(String opt) {
return super.hasOption(opt) || opt.equals("--verbose");
}
@Override
protected void process(String name, String[] opts) {
verbose = true;
}
}
}
@@ -0,0 +1,47 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client;
import com.github.gumtreediff.gen.Registry;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Register {
String name() default no_value;
String description() default "";
int priority() default Registry.Priority.MEDIUM;
// FIXME currently unused, will be useful only for help purpose
Class<? extends Option.Context> options() default NoOption.class;
String no_value = "";
class NoOption implements Option.Context {
@Override
public Option[] values() {
return new Option[]{};
}
}
}
@@ -0,0 +1,141 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client;
import com.github.gumtreediff.gen.Generators;
import com.github.gumtreediff.gen.Registry;
import com.github.gumtreediff.gen.TreeGenerator;
import org.reflections.Reflections;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
public class Run {
public static class Options implements Option.Context {
@Override
public Option[] values() {
return new Option[]{
new Option("-c", "Set global property (-c property value). "
+ "Properties do not need to be prefixed by gumtree.", 2) {
@Override
protected void process(String name, String[] args) {
String key = args[0].startsWith("gumtree.") ? args[0] : "gumtree." + args[0];
System.setProperty(key, args[1]);
}
},
new Option.Verbose(),
new Help(this)
};
}
}
public static void initGenerators() {
Reflections reflections = new Reflections("com.github.gumtreediff.gen");
reflections.getSubTypesOf(TreeGenerator.class).forEach(
gen -> {
com.github.gumtreediff.gen.Register a =
gen.getAnnotation(com.github.gumtreediff.gen.Register.class);
if (a != null)
Generators.getInstance().install(gen, a);
});
}
public static void initClients() {
Reflections reflections = new Reflections("com.github.gumtreediff.client");
reflections.getSubTypesOf(Client.class).forEach(
cli -> {
com.github.gumtreediff.client.Register a =
cli.getAnnotation(com.github.gumtreediff.client.Register.class);
if (a != null)
Clients.getInstance().install(cli, a);
});
}
static {
initGenerators();
}
public static void startClient(String name, Registry.Factory<? extends Client> client, String[] args) {
try {
Client inst = client.newInstance(new Object[]{args});
try {
inst.run();
} catch (Exception e) {
System.err.printf("** Error while running client %s: %s\n", name, e);
}
} catch (InvocationTargetException e) {
System.err.printf("** Error while parsing option for %s:\n%s\n", name, e.getCause());
} catch (InstantiationException | IllegalAccessException e) {
System.err.printf("Can't instantiate client: '%s'\n%s\n", name, e);
e.printStackTrace();
}
}
public static void main(String[] args) {
Options opts = new Options();
args = Option.processCommandLine(args, opts);
initClients();
Registry.Factory<? extends Client> client;
if (args.length == 0) {
System.err.println("** No command given.");
displayHelp(System.err, opts);
} else if ((client = Clients.getInstance().getFactory(args[0])) == null) {
System.err.printf("** Unknown sub-command '%s'.\n", args[0]);
displayHelp(System.err, opts);
} else {
String[] a = new String[args.length - 1];
System.arraycopy(args, 1, a, 0, a.length);
startClient(args[0], client, a);
}
}
public static void displayHelp(PrintStream out, Option.Context ctx) {
out.println("Available Options:");
Option.displayOptions(out, ctx);
out.println("");
listCommand(out);
}
@SuppressWarnings("rawtypes")
public static void listCommand(PrintStream out) {
out.println("Available Commands:");
for (Registry.Entry cmd: Clients.getInstance().getEntries())
out.println("* " + cmd);
}
static class Help extends Option.Help {
public Help(Context ctx) {
super(ctx);
}
@Override
public void process(String name, String[] args) {
displayHelp(System.out, context);
System.exit(0);
}
}
}
@@ -0,0 +1,129 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.client;
import com.github.gumtreediff.io.TreeIoUtils;
import com.github.gumtreediff.gen.Generators;
import com.github.gumtreediff.tree.TreeContext;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.util.Arrays;
@Register(name = "parse", description = "Parse file and dump result")
public class Serializer extends Client {
public static final String SYNTAX = "Syntax: parse [options] file ...";
static class Options implements Option.Context {
protected OutputFormat format = OutputFormat.JSON;
protected String output = null;
protected String[] files;
@Override
public Option[] values() {
return new Option[]{
new Option("-f", "Output format " + Arrays.toString(OutputFormat.values()), 1) {
@Override
protected void process(String name, String[] args) {
OutputFormat o = OutputFormat.valueOf(args[0].toUpperCase());
if (o != null)
format = o;
else
System.err.println("Invalid output type: " + args[0]);
}
},
new Option("-o", "Output filename (or directory if more than one file), defaults to stdout", 1) {
@Override
protected void process(String name, String[] args) {
}
}
};
}
}
enum OutputFormat {
JSON {
@Override
TreeIoUtils.TreeSerializer getSerializer(TreeContext ctx) {
return TreeIoUtils.toJson(ctx);
}
},
XML {
@Override
TreeIoUtils.TreeSerializer getSerializer(TreeContext ctx) {
return TreeIoUtils.toCompactXml(ctx);
}
},
FULLXML {
@Override
TreeIoUtils.TreeSerializer getSerializer(TreeContext ctx) {
return TreeIoUtils.toXml(ctx);
}
},
DOT {
@Override
TreeIoUtils.TreeSerializer getSerializer(TreeContext ctx) {
return TreeIoUtils.toDot(ctx);
}
},
LISP {
@Override
TreeIoUtils.TreeSerializer getSerializer(TreeContext ctx) {
return TreeIoUtils.toLisp(ctx);
}
};
abstract TreeIoUtils.TreeSerializer getSerializer(TreeContext ctx);
}
Options opts = new Options();
public Serializer(String[] args) {
super(args);
args = Option.processCommandLine(args, opts);
if (args.length == 0)
throw new Option.OptionException(SYNTAX);
opts.files = args;
}
@Override
public void run() throws IOException {
final boolean multiple = opts.files.length > 1;
if (multiple && opts.output != null)
Files.createDirectories(FileSystems.getDefault().getPath(opts.output));
for (String file : opts.files) {
try {
TreeContext tc = Generators.getInstance().getTree(file);
opts.format.getSerializer(tc).writeTo(opts.output == null
? System.out
: new FileOutputStream(opts.output));
} catch (Exception e) {
System.err.println(e);
}
}
}
}
@@ -0,0 +1,27 @@
pdf()
files <- dir(pattern="metrics.*csv")
s_script <- vector(mode="integer")
s_ins <- vector(mode="integer")
s_del <- vector(mode="integer")
s_up <- vector(mode="integer")
s_mov <- vector(mode="integer")
t_total <- vector(mode="integer")
for (file in files) {
d <- read.csv(file, header=T, sep=";")
length(d[[3]])
s_script <- cbind(s_script, d[[3]])
s_ins <- cbind(s_ins, d[[3]])
s_del <- cbind(s_del, d[[4]])
s_up <- cbind(s_up, d[[5]])
s_mov <- cbind(s_mov, d[[6]])
t_total <- cbind(t_total, d[[11]])
}
boxplot(s_script, main="Edit script size")
boxplot(s_ins, main="Insert actions")
boxplot(s_del, main="Delete actions")
boxplot(s_up, main="Update actions")
boxplot(s_mov, main="Move actions")
boxplot(t_total, main="Total time")
@@ -0,0 +1,25 @@
#!/bin/sh
#
# This file is part of GumTree.
#
# GumTree is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GumTree is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with GumTree. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
# Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
#
find . -name '*.java' | xargs grep -o 'System.getProperty.*'|
grep -v '^./samples' | grep -o 'fr/labri.gumtree.*'|
sed 's/System.getProperty("\([^"]*\)".*/\1/' | tr / . |
sed 's/\(.*\).java:\(.*\)/"\2 (\1)",/' | sort -u
+27
View File
@@ -0,0 +1,27 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>gumtree</artifactId>
<groupId>com.github.gumtreediff</groupId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>core</artifactId>
<name>GumTree Core Module</name>
<dependencies>
<dependency>
<groupId>com.github.mpkorstanje</groupId>
<artifactId>simmetrics-core</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>net.sf.trove4j</groupId>
<artifactId>trove4j</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3</version>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,263 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.actions;
import com.github.gumtreediff.actions.model.*;
import com.github.gumtreediff.matchers.Mapping;
import com.github.gumtreediff.matchers.MappingStore;
import com.github.gumtreediff.tree.AbstractTree;
import com.github.gumtreediff.tree.ITree;
import com.github.gumtreediff.tree.TreeUtils;
import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class ActionGenerator {
private ITree origSrc;
private ITree newSrc;
private ITree origDst;
private MappingStore origMappings;
private MappingStore newMappings;
private Set<ITree> dstInOrder;
private Set<ITree> srcInOrder;
private int lastId;
private List<Action> actions;
private TIntObjectMap<ITree> origSrcTrees;
private TIntObjectMap<ITree> cpySrcTrees;
public ActionGenerator(ITree src, ITree dst, MappingStore mappings) {
this.origSrc = src;
this.newSrc = this.origSrc.deepCopy();
this.origDst = dst;
origSrcTrees = new TIntObjectHashMap<>();
for (ITree t: origSrc.getTrees())
origSrcTrees.put(t.getId(), t);
cpySrcTrees = new TIntObjectHashMap<>();
for (ITree t: newSrc.getTrees())
cpySrcTrees.put(t.getId(), t);
origMappings = new MappingStore();
for (Mapping m: mappings)
this.origMappings.link(cpySrcTrees.get(m.getFirst().getId()), m.getSecond());
this.newMappings = origMappings.copy();
}
public List<Action> getActions() {
return actions;
}
public List<Action> generate() {
ITree srcFakeRoot = new AbstractTree.FakeTree(newSrc);
ITree dstFakeRoot = new AbstractTree.FakeTree(origDst);
newSrc.setParent(srcFakeRoot);
origDst.setParent(dstFakeRoot);
actions = new ArrayList<>();
dstInOrder = new HashSet<>();
srcInOrder = new HashSet<>();
lastId = newSrc.getSize() + 1;
newMappings.link(srcFakeRoot, dstFakeRoot);
List<ITree> bfsDst = TreeUtils.breadthFirst(origDst);
for (ITree x: bfsDst) {
ITree w = null;
ITree y = x.getParent();
ITree z = newMappings.getSrc(y);
if (!newMappings.hasDst(x)) {
int k = findPos(x);
// Insertion case : insert new node.
w = new AbstractTree.FakeTree();
w.setId(newId());
// In order to use the real nodes from the second tree, we
// furnish x instead of w and fake that x has the newly
// generated ID.
Action ins = new Insert(x, origSrcTrees.get(z.getId()), k);
actions.add(ins);
//System.out.println(ins);
origSrcTrees.put(w.getId(), x);
newMappings.link(w, x);
z.getChildren().add(k, w);
w.setParent(z);
} else {
w = newMappings.getSrc(x);
if (!x.equals(origDst)) { // TODO => x != origDst // Case of the root
ITree v = w.getParent();
if (!w.getLabel().equals(x.getLabel())) {
actions.add(new Update(origSrcTrees.get(w.getId()), x));
w.setLabel(x.getLabel());
}
if (!z.equals(v)) {
int k = findPos(x);
// Action mv = new Move(origSrcTrees.get(w.getId()), origSrcTrees.get(z.getId()), k);
Action mv = new Move(origSrcTrees.get(w.getId()), origSrcTrees.get(z.getId()), x, k);
actions.add(mv);
//System.out.println(mv);
int oldk = w.positionInParent();
z.getChildren().add(k, w);
w.getParent().getChildren().remove(oldk);
w.setParent(z);
}
}
}
//FIXME not sure why :D
srcInOrder.add(w);
dstInOrder.add(x);
alignChildren(w, x);
}
for (ITree w : newSrc.postOrder()) {
if (!newMappings.hasSrc(w)) {
actions.add(new Delete(origSrcTrees.get(w.getId())));
//w.getParent().getChildren().remove(w);
}
}
//FIXME should ensure isomorphism.
return actions;
}
private void alignChildren(ITree w, ITree x) {
srcInOrder.removeAll(w.getChildren());
dstInOrder.removeAll(x.getChildren());
List<ITree> s1 = new ArrayList<>();
for (ITree c: w.getChildren())
if (newMappings.hasSrc(c))
if (x.getChildren().contains(newMappings.getDst(c)))
s1.add(c);
List<ITree> s2 = new ArrayList<>();
for (ITree c: x.getChildren())
if (newMappings.hasDst(c))
if (w.getChildren().contains(newMappings.getSrc(c)))
s2.add(c);
List<Mapping> lcs = lcs(s1, s2);
for (Mapping m : lcs) {
srcInOrder.add(m.getFirst());
dstInOrder.add(m.getSecond());
}
for (ITree a : s1) {
for (ITree b: s2 ) {
if (origMappings.has(a, b)) {
if (!lcs.contains(new Mapping(a, b))) {
int k = findPos(b);
// Action mv = new Move(origSrcTrees.get(a.getId()), origSrcTrees.get(w.getId()), k);
Action mv = new Move(origSrcTrees.get(a.getId()), origSrcTrees.get(w.getId()), b, k);
actions.add(mv);
//System.out.println(mv);
int oldk = a.positionInParent();
w.getChildren().add(k, a);
if (k < oldk ) // FIXME this is an ugly way to patch the index
oldk ++;
a.getParent().getChildren().remove(oldk);
a.setParent(w);
srcInOrder.add(a);
dstInOrder.add(b);
}
}
}
}
}
private int findPos(ITree x) {
ITree y = x.getParent();
List<ITree> siblings = y.getChildren();
for (ITree c : siblings) {
if (dstInOrder.contains(c)) {
if (c.equals(x)) return 0;
else break;
}
}
int xpos = x.positionInParent();
ITree v = null;
for (int i = 0; i < xpos; i++) {
ITree c = siblings.get(i);
if (dstInOrder.contains(c)) v = c;
}
//if (v == null) throw new RuntimeException("No rightmost sibling in order");
if (v == null) return 0;
ITree u = newMappings.getSrc(v);
// siblings = u.getParent().getChildren();
// int upos = siblings.indexOf(u);
int upos = u.positionInParent();
// int r = 0;
// for (int i = 0; i <= upos; i++)
// if (srcInOrder.contains(siblings.get(i))) r++;
return upos + 1;
}
private int newId() {
return ++lastId;
}
private List<Mapping> lcs(List<ITree> x, List<ITree> y) {
int m = x.size();
int n = y.size();
List<Mapping> lcs = new ArrayList<>();
int[][] opt = new int[m + 1][n + 1];
for (int i = m - 1; i >= 0; i--) {
for (int j = n - 1; j >= 0; j--) {
if (newMappings.getSrc(y.get(j)).equals(x.get(i))) opt[i][j] = opt[i + 1][j + 1] + 1;
else opt[i][j] = Math.max(opt[i + 1][j], opt[i][j + 1]);
}
}
int i = 0, j = 0;
while (i < m && j < n) {
if (newMappings.getSrc(y.get(j)).equals(x.get(i))) {
lcs.add(new Mapping(x.get(i), y.get(j)));
i++;
j++;
} else if (opt[i + 1][j] >= opt[i][j + 1]) i++;
else j++;
}
return lcs;
}
}
@@ -0,0 +1,50 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.actions;
import com.github.gumtreediff.actions.model.*;
import com.github.gumtreediff.tree.TreeContext;
import java.util.List;
public class ActionUtil {
private ActionUtil() {}
public static TreeContext apply(TreeContext context, List<Action> actions) {
for (Action a: actions) {
if (a instanceof Insert) {
Insert action = ((Insert) a);
action.getParent().insertChild(action.getNode(), action.getPosition());
} else if (a instanceof Update) {
Update action = ((Update) a);
action.getNode().setLabel(action.getValue());
} else if (a instanceof Move) {
Move action = ((Move) a);
action.getNode().getParent().getChildren().remove(action.getNode());
action.getParent().insertChild(action.getNode(), action.getPosition());
} else if (a instanceof Delete) {
Delete action = ((Delete) a);
action.getNode().getParent().getChildren().remove(action.getNode());
} else throw new RuntimeException("No such action: " + a );
}
return context;
}
}
@@ -0,0 +1,71 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.actions;
import java.util.List;
import java.util.Set;
import com.github.gumtreediff.actions.model.Delete;
import com.github.gumtreediff.actions.model.Update;
import com.github.gumtreediff.actions.model.Action;
import com.github.gumtreediff.actions.model.Insert;
import com.github.gumtreediff.actions.model.Move;
import com.github.gumtreediff.matchers.Mapping;
import com.github.gumtreediff.matchers.Matcher;
import com.github.gumtreediff.tree.ITree;
import com.github.gumtreediff.tree.TreeContext;
public class LeavesClassifier extends TreeClassifier {
public LeavesClassifier(TreeContext src, TreeContext dst, Set<Mapping> rawMappings, List<Action> actions) {
super(src, dst, rawMappings, actions);
}
public LeavesClassifier(TreeContext src, TreeContext dst, Matcher m) {
super(src, dst, m);
}
@Override
public void classify() {
for (Action a: actions) {
if (a instanceof Delete && isLeafAction(a)) {
srcDelTrees.add(a.getNode());
} else if (a instanceof Insert && isLeafAction(a)) {
dstAddTrees.add(a.getNode());
} else if (a instanceof Update && isLeafAction(a)) {
srcUpdTrees.add(a.getNode());
dstUpdTrees.add(mappings.getDst(a.getNode()));
} else if (a instanceof Move && isLeafAction(a)) {
srcMvTrees.add(a.getNode());
dstMvTrees.add(mappings.getDst(a.getNode()));
}
}
}
private boolean isLeafAction(Action a) {
for (ITree d: a.getNode().getDescendants()) {
for (Action c: actions)
if (a != c && d == c.getNode()) return false;
}
return true;
}
}
@@ -0,0 +1,85 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.actions;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.github.gumtreediff.actions.model.Delete;
import com.github.gumtreediff.actions.model.Action;
import com.github.gumtreediff.actions.model.Insert;
import com.github.gumtreediff.actions.model.Move;
import com.github.gumtreediff.actions.model.Update;
import com.github.gumtreediff.matchers.Mapping;
import com.github.gumtreediff.matchers.Matcher;
import com.github.gumtreediff.tree.ITree;
import com.github.gumtreediff.tree.TreeContext;
public class RootAndLeavesClassifier extends TreeClassifier {
public RootAndLeavesClassifier(TreeContext src, TreeContext dst, Set<Mapping> rawMappings, List<Action> actions) {
super(src, dst, rawMappings, actions);
}
public RootAndLeavesClassifier(TreeContext src, TreeContext dst, Matcher m) {
super(src, dst, m);
}
@Override
public void classify() {
for (Action a: actions) {
if (a instanceof Insert) {
dstAddTrees.add(a.getNode());
} else if (a instanceof Delete) {
srcDelTrees.add(a.getNode());
} else if (a instanceof Update) {
srcUpdTrees.add(a.getNode());
dstUpdTrees.add(mappings.getDst(a.getNode()));
} else if (a instanceof Move) {
srcMvTrees.add(a.getNode());
dstMvTrees.add(mappings.getDst(a.getNode()));
}
}
Set<ITree> fDstAddTrees = new HashSet<>();
for (ITree t: dstAddTrees)
if (!dstAddTrees.contains(t.getParent()))
fDstAddTrees.add(t);
dstAddTrees = fDstAddTrees;
Set<ITree> fSrcDelTrees = new HashSet<>();
for (ITree t: srcDelTrees) {
if (!srcDelTrees.contains(t.getParent()))
fSrcDelTrees.add(t);
}
srcDelTrees = fSrcDelTrees;
@SuppressWarnings("unused")
Set<ITree> fSrcMvTrees = new HashSet<>(); // FIXME check why it's unused
for (ITree t: srcDelTrees) {
if (!srcDelTrees.contains(t.getParent()))
fSrcDelTrees.add(t);
}
srcDelTrees = fSrcDelTrees;
}
}
@@ -0,0 +1,59 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.actions;
import java.util.List;
import java.util.Set;
import com.github.gumtreediff.actions.model.Delete;
import com.github.gumtreediff.actions.model.Move;
import com.github.gumtreediff.actions.model.Update;
import com.github.gumtreediff.actions.model.Action;
import com.github.gumtreediff.actions.model.Insert;
import com.github.gumtreediff.matchers.Mapping;
import com.github.gumtreediff.matchers.Matcher;
import com.github.gumtreediff.tree.TreeContext;
public class RootsClassifier extends TreeClassifier {
public RootsClassifier(TreeContext src, TreeContext dst, Set<Mapping> rawMappings, List<Action> script) {
super(src, dst, rawMappings, script);
}
public RootsClassifier(TreeContext src, TreeContext dst, Matcher m) {
super(src, dst, m);
}
public void classify() {
for (Action a: actions) {
if (a instanceof Delete) srcDelTrees.add(a.getNode());
else if (a instanceof Insert)
dstAddTrees.add(a.getNode());
else if (a instanceof Update) {
srcUpdTrees.add(a.getNode());
dstUpdTrees.add(mappings.getDst(a.getNode()));
} else if (a instanceof Move) {
srcMvTrees.add(a.getNode());
dstMvTrees.add(mappings.getDst(a.getNode()));
}
}
}
}
@@ -0,0 +1,108 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.actions;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.github.gumtreediff.actions.model.Action;
import com.github.gumtreediff.matchers.Mapping;
import com.github.gumtreediff.matchers.MappingStore;
import com.github.gumtreediff.matchers.Matcher;
import com.github.gumtreediff.tree.ITree;
import com.github.gumtreediff.tree.TreeContext;
public abstract class TreeClassifier {
protected Set<ITree> srcUpdTrees;
protected Set<ITree> dstUpdTrees;
protected Set<ITree> srcMvTrees;
protected Set<ITree> dstMvTrees;
protected Set<ITree> srcDelTrees;
protected Set<ITree> dstAddTrees;
protected TreeContext src;
protected TreeContext dst;
protected MappingStore mappings;
protected List<Action> actions;
public TreeClassifier(TreeContext src, TreeContext dst, Set<Mapping> rawMappings, List<Action> actions) {
this(src, dst, rawMappings);
this.actions = actions;
classify();
}
public TreeClassifier(TreeContext src, TreeContext dst, Matcher m) {
this(src, dst, m.getMappingSet());
ActionGenerator g = new ActionGenerator(src.getRoot(), dst.getRoot(), m.getMappings());
g.generate();
this.actions = g.getActions();
classify();
}
private TreeClassifier(TreeContext src, TreeContext dst, Set<Mapping> rawMappings) {
this.src = src;
this.dst = dst;
this.mappings = new MappingStore(rawMappings);
this.srcDelTrees = new HashSet<>();
this.srcMvTrees = new HashSet<>();
this.srcUpdTrees = new HashSet<>();
this.dstMvTrees = new HashSet<>();
this.dstAddTrees = new HashSet<>();
this.dstUpdTrees = new HashSet<>();
}
public abstract void classify();
public Set<ITree> getSrcUpdTrees() {
return srcUpdTrees;
}
public Set<ITree> getDstUpdTrees() {
return dstUpdTrees;
}
public Set<ITree> getSrcMvTrees() {
return srcMvTrees;
}
public Set<ITree> getDstMvTrees() {
return dstMvTrees;
}
public Set<ITree> getSrcDelTrees() {
return srcDelTrees;
}
public Set<ITree> getDstAddTrees() {
return dstAddTrees;
}
}
@@ -0,0 +1,70 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.actions.model;
import com.github.gumtreediff.tree.ITree;
import java.io.Serializable;
public abstract class Action implements Comparable<Action>,Serializable {
protected ITree node;
protected Integer position;
protected int length = 0;
public Action(ITree node, int pos, int length) {
this.node = node;
this.length = length;
this.position = pos;
}
public ITree getNode() {
return node;
}
public void setNode(ITree node) {
this.node = node;
}
public int getPosition() {
return position;
}
public int getLength() {
return length;
}
public abstract String getName();
@Override
public abstract String toString();
@Override
public int compareTo(Action o) {
int result = this.position.compareTo(o.position);
if (result == 0) {
result = this.length >= o.length ? -1 : 1;
}
return result;
}
}
@@ -0,0 +1,49 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.actions.model;
import com.github.gumtreediff.tree.ITree;
public abstract class Addition extends Action {
protected ITree parent;
protected int pos;//index position of the new node in the children array list of its corresponding old parent node.
public Addition(ITree node, ITree parent, int pos) {
super(node, node.getPos(), node.getLength());
this.parent = parent;
this.pos = pos;
}
public ITree getParent() {
return parent;
}
public int getPos() {
return pos;
}
@Override
public String toString() {
return getName() + " " + node.toShortString() + " @TO@ " + parent.toShortString() + " @AT@ " + position + " @LENGTH@ " + length;
}
}
@@ -0,0 +1,42 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.actions.model;
import com.github.gumtreediff.tree.ITree;
public class Delete extends Action {
public Delete(ITree node) {
super(node, node.getPos(), node.getLength());
}
@Override
public String getName() {
return "DEL";
}
@Override
public String toString() {
// node.toShortString: getType()@@getLabel()
// return getName() + " " + node.toShortString() + " / "+node.getChildrenLabels() + " at " + node.getPos();
return getName() + " " + node.toShortString() + " @AT@ " + position + " @LENGTH@ " + length;
}
}
@@ -0,0 +1,36 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.actions.model;
import com.github.gumtreediff.tree.ITree;
public class Insert extends Addition {
public Insert(ITree node, ITree parent, int pos) {
super(node, parent, pos);
}
@Override
public String getName() {
return "INS";
}
}
@@ -0,0 +1,54 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.actions.model;
import com.github.gumtreediff.tree.ITree;
public class Move extends Addition {
private ITree newNode;
public Move(ITree node, ITree parent, int pos) {
super(node, parent, pos);
}
/**
*
* @param node, old node.
* @param parent, parent of old node.
* @param newNode, new node.
* @param pos, position of the new node in the children array list of its corresponding old parent node.
*/
public Move(ITree node, ITree parent, ITree newNode, int pos) {
this(node, parent, pos);
this.newNode = newNode;
}
public ITree getNewNode() {
return this.newNode;
}
@Override
public String getName() {
return "MOV";
}
}
@@ -0,0 +1,55 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.actions.model;
import com.github.gumtreediff.tree.ITree;
public class Update extends Action {
private String value;
private ITree newNode;
public Update(ITree node, ITree newNode) {
super(node, node.getPos(), node.getLength());
this.value = newNode.getLabel();
this.newNode = newNode;
}
@Override
public String getName() {
return "UPD";
}
public String getValue() {
return this.value;
}
public ITree getNewNode() {
return this.newNode;
}
@Override
public String toString() {
// node.toShortString: getType()@@getLabel()
return getName() + " " + node.toShortString() + " @TO@ " + value + " @AT@ " + position + " @LENGTH@ " + length;
}
}
@@ -0,0 +1,79 @@
/*
* This file is part of GumTree.
*
* GumTree is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GumTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
* Copyright 2011-2015 Floréal Morandat <florealm@gmail.com>
*/
package com.github.gumtreediff.gen;
import com.github.gumtreediff.tree.TreeContext;
import java.io.IOException;
import java.util.Arrays;
import java.util.regex.Pattern;
public class Generators extends Registry<String, TreeGenerator, Register> {
private static Generators registry;
public static final Generators getInstance() {
if (registry == null)
registry = new Generators();
return registry;
}
public TreeContext getTree(String file) throws UnsupportedOperationException, IOException {
TreeGenerator p = get(file);
if (p == null)
throw new UnsupportedOperationException("No generator found for file: " + file);
return p.generateFromFile(file);
}
public TreeContext getTree(String generator, String file) throws UnsupportedOperationException, IOException {
for (Entry e : entries)
if (e.id.equals(generator))
return e.instantiate(null).generateFromFile(file);
throw new UnsupportedOperationException("No generator \"" + generator + "\" found.");
}
@Override
protected Entry newEntry(Class<? extends TreeGenerator> clazz, Register annotation) {
return new Entry(annotation.id(), clazz, defaultFactory(clazz), annotation.priority()) {
final Pattern[] accept;
{
String[] accept = annotation.accept();
this.accept = new Pattern[accept.length];
for (int i = 0; i < accept.length; i++)
this.accept[i] = Pattern.compile(accept[i]);
}
@Override
protected boolean handle(String key) {
for (Pattern pattern : accept)
if (pattern.matcher(key).find())
return true;
return false;
}
@Override
public String toString() {
return String.format("%s: %s", Arrays.toString(accept), clazz.getCanonicalName());
}
};
}
}

Some files were not shown because too many files have changed in this diff Show More