├── .gitmodules ├── README.md ├── build.gradle ├── deploy.gradle ├── libs ├── ijdk-3.4.3.jar ├── ijdk-3.8.1.jar ├── ijdk-3.9.0.jar ├── jagol-1.1.0.jar ├── java-diff-1.0.0.jar ├── pmd-4.2.5.jar ├── pmdx-2.0.0.jar ├── pmdx-3.0.0.jar ├── qualog-2.2.0.jar └── qualog-3.0.0.jar └── src ├── main ├── jar │ └── launcher.manifest ├── java │ ├── META-INF │ │ └── MANIFEST.MF │ └── org │ │ └── incava │ │ ├── analysis │ │ ├── BriefReport.java │ │ ├── DetailedReport.java │ │ ├── DiffContextHighlightWriter.java │ │ ├── DiffContextWriter.java │ │ ├── DiffNoContextWriter.java │ │ ├── DiffWriter.java │ │ ├── FileDiff.java │ │ ├── FileDiffAdd.java │ │ ├── FileDiffChange.java │ │ ├── FileDiffCodeAdded.java │ │ ├── FileDiffCodeDeleted.java │ │ ├── FileDiffDelete.java │ │ ├── FileDiffs.java │ │ ├── Report.java │ │ └── TokenUtil.java │ │ ├── diffj │ │ ├── app │ │ │ ├── DiffJ.java │ │ │ └── Options.java │ │ ├── code │ │ │ ├── Block.java │ │ │ ├── Code.java │ │ │ ├── CodeLogger.java │ │ │ ├── Statement.java │ │ │ ├── Tkn.java │ │ │ ├── TokenComparator.java │ │ │ ├── TokenDiffer.java │ │ │ ├── TokenDifference.java │ │ │ ├── TokenDifferenceAdd.java │ │ │ ├── TokenDifferenceChange.java │ │ │ ├── TokenDifferenceDelete.java │ │ │ ├── TokenList.java │ │ │ └── stmt │ │ │ │ ├── SLLogger.java │ │ │ │ ├── StatementList.java │ │ │ │ ├── StatementListDiffer.java │ │ │ │ ├── StatementsDiff.java │ │ │ │ ├── StatementsDiffAdd.java │ │ │ │ ├── StatementsDiffChange.java │ │ │ │ ├── StatementsDiffDelete.java │ │ │ │ └── StatementsDiffDelta.java │ │ ├── compunit │ │ │ ├── CompilationUnit.java │ │ │ ├── Import.java │ │ │ ├── Imports.java │ │ │ ├── Package.java │ │ │ └── Parser.java │ │ ├── element │ │ │ ├── Access.java │ │ │ ├── AccessibleElement.java │ │ │ ├── CodedElement.java │ │ │ ├── DiffParameters.java │ │ │ ├── Diffable.java │ │ │ ├── Differences.java │ │ │ ├── Element.java │ │ │ └── Modifiers.java │ │ ├── field │ │ │ ├── Field.java │ │ │ ├── FieldModifiers.java │ │ │ ├── Fields.java │ │ │ ├── Variable.java │ │ │ └── Variables.java │ │ ├── function │ │ │ ├── Ctor.java │ │ │ ├── Ctors.java │ │ │ ├── Function.java │ │ │ ├── Initializer.java │ │ │ ├── Initializers.java │ │ │ ├── Method.java │ │ │ ├── MethodModifiers.java │ │ │ ├── Methods.java │ │ │ └── Throws.java │ │ ├── io │ │ │ ├── JavaDirectory.java │ │ │ ├── JavaElementFactory.java │ │ │ ├── JavaFSElement.java │ │ │ └── JavaFile.java │ │ ├── lang │ │ │ └── DiffJException.java │ │ ├── params │ │ │ ├── Parameter.java │ │ │ ├── ParameterComparator.java │ │ │ ├── ParameterExactMatch.java │ │ │ ├── ParameterExactNameMatch.java │ │ │ ├── ParameterExactTypeMatch.java │ │ │ ├── ParameterMatch.java │ │ │ ├── ParameterNameMatch.java │ │ │ ├── ParameterNoMatch.java │ │ │ ├── ParameterTypeComparison.java │ │ │ ├── ParameterTypeMatch.java │ │ │ ├── ParameterTypes.java │ │ │ └── Parameters.java │ │ ├── type │ │ │ ├── Extends.java │ │ │ ├── Implements.java │ │ │ ├── InnerTypes.java │ │ │ ├── Items.java │ │ │ ├── NameToDecl.java │ │ │ ├── Supers.java │ │ │ ├── Type.java │ │ │ ├── TypeDeclarationList.java │ │ │ ├── TypeMatches.java │ │ │ ├── TypeModifiers.java │ │ │ └── Types.java │ │ └── util │ │ │ ├── DiffPoint.java │ │ │ ├── DiffRange.java │ │ │ ├── ListComparator.java │ │ │ ├── ListComparison.java │ │ │ └── Messages.java │ │ ├── ijdk │ │ └── text │ │ │ ├── Location.java │ │ │ ├── LocationRange.java │ │ │ ├── LocationRanges.java │ │ │ ├── Message.java │ │ │ ├── TextLocation.java │ │ │ └── TextRange.java │ │ └── java │ │ ├── Java.java │ │ └── JavaVersionTypes.java └── sh │ └── diffj ├── site └── resources │ └── img │ └── diffj-codechange-statement.png └── test ├── java └── org │ └── incava │ ├── analysis │ └── FileDiffTest.java │ ├── diffj │ ├── DiffJTest.java │ ├── DiffJTestCase.java │ ├── ItemsTest.java │ ├── OutputContextHighlightTest.java │ ├── OutputContextNoHighlightTest.java │ ├── OutputContextTest.java │ ├── OutputNoContextTest.java │ ├── OutputTest.java │ ├── compunit │ │ ├── ImportsTest.java │ │ └── PackageTest.java │ ├── field │ │ ├── FieldAccessTest.java │ │ ├── FieldInitializerTest.java │ │ ├── FieldModifierTest.java │ │ ├── FieldVariableAddedRemovedTest.java │ │ ├── FieldVariableTest.java │ │ └── FieldsTest.java │ ├── function │ │ ├── CtorAccessTest.java │ │ ├── CtorCodeTest.java │ │ ├── CtorParametersTest.java │ │ ├── CtorTest.java │ │ ├── CtorThrowsTest.java │ │ ├── CtorsTest.java │ │ ├── FunctionTestCase.java │ │ ├── MethodAccessTest.java │ │ ├── MethodCodeByStatementTest.java │ │ ├── MethodCodeTest.java │ │ ├── MethodImplementedTest.java │ │ ├── MethodModifiersTest.java │ │ ├── MethodParametersTest.java │ │ ├── MethodReturnTypeTest.java │ │ ├── MethodThrowsTest.java │ │ ├── MethodsAnnotatedTest.java │ │ ├── MethodsInInnerClassTest.java │ │ ├── MethodsTest.java │ │ └── StaticBlockTest.java │ ├── params │ │ └── ParameterTypesTest.java │ ├── type │ │ ├── InnerClassTest.java │ │ ├── InnerInterfaceTest.java │ │ ├── TypeTest.java │ │ └── TypesTest.java │ └── util │ │ ├── Lines.java │ │ └── ListComparatorTest.java │ ├── ijdk │ └── text │ │ ├── TextLocationTest.java │ │ └── TextRangeTest.java │ └── test │ └── IncavaTestCase.java └── resources └── diffj ├── codecomp ├── d0 │ ├── Changed.java │ └── ChangedCtor.java ├── d1 │ ├── Changed.java │ └── ChangedCtor.java └── output-1.3.x.txt ├── example ├── d0 │ ├── Changed.java │ └── Unchanged.java └── d1 │ ├── Changed.java │ └── Unchanged.java ├── imports ├── section │ ├── d0 │ │ ├── Added.java │ │ └── Removed.java │ └── d1 │ │ ├── Added.java │ │ └── Removed.java └── statement │ ├── d0 │ ├── Added.java │ └── Removed.java │ └── d1 │ ├── Added.java │ └── Removed.java ├── packages ├── d0 │ ├── Added.java │ ├── Changed.java │ ├── NoChange.java │ ├── None.java │ └── Removed.java └── d1 │ ├── Added.java │ ├── Changed.java │ ├── NoChange.java │ ├── None.java │ └── Removed.java ├── type ├── access │ ├── d0 │ │ ├── Added.java │ │ ├── Changed.java │ │ └── Removed.java │ └── d1 │ │ ├── Added.java │ │ ├── Changed.java │ │ └── Removed.java ├── ctor │ ├── access │ │ ├── d0 │ │ │ ├── Added.java │ │ │ ├── Changed.java │ │ │ └── Removed.java │ │ └── d1 │ │ │ ├── Added.java │ │ │ ├── Changed.java │ │ │ └── Removed.java │ ├── body │ │ └── codechange │ │ │ └── varinit │ │ │ ├── d0 │ │ │ ├── Added.java │ │ │ ├── Changed.java │ │ │ ├── Removed.java │ │ │ └── Unchanged.java │ │ │ └── d1 │ │ │ ├── Added.java │ │ │ ├── Changed.java │ │ │ ├── Removed.java │ │ │ └── Unchanged.java │ ├── parameters │ │ ├── namechange │ │ │ ├── d0 │ │ │ │ └── Changed.java │ │ │ └── d1 │ │ │ │ └── Changed.java │ │ └── onetwo │ │ │ ├── d0 │ │ │ ├── Added.java │ │ │ └── Removed.java │ │ │ └── d1 │ │ │ ├── Added.java │ │ │ └── Removed.java │ └── throws │ │ └── zeroone │ │ ├── d0 │ │ ├── Added.java │ │ └── Removed.java │ │ └── d1 │ │ ├── Added.java │ │ └── Removed.java ├── declarations │ ├── ctor │ │ ├── noparams │ │ │ ├── d0 │ │ │ │ ├── Added.java │ │ │ │ ├── Removed.java │ │ │ │ └── Unchanged.java │ │ │ └── d1 │ │ │ │ ├── Added.java │ │ │ │ ├── Removed.java │ │ │ │ └── Unchanged.java │ │ └── withparams │ │ │ ├── d0 │ │ │ ├── Added.java │ │ │ └── Removed.java │ │ │ └── d1 │ │ │ ├── Added.java │ │ │ └── Removed.java │ ├── d0 │ │ ├── Added.java │ │ ├── Changed.java │ │ └── Removed.java │ ├── d1 │ │ ├── Added.java │ │ ├── Changed.java │ │ └── Removed.java │ ├── field │ │ ├── one │ │ │ ├── d0 │ │ │ │ ├── Added.java │ │ │ │ ├── Removed.java │ │ │ │ └── Unchanged.java │ │ │ └── d1 │ │ │ │ ├── Added.java │ │ │ │ ├── Removed.java │ │ │ │ └── Unchanged.java │ │ ├── oneoftwo │ │ │ ├── d0 │ │ │ │ ├── Added.java │ │ │ │ └── Removed.java │ │ │ └── d1 │ │ │ │ ├── Added.java │ │ │ │ └── Removed.java │ │ └── threeofthree │ │ │ ├── d0 │ │ │ ├── Added.java │ │ │ └── Removed.java │ │ │ └── d1 │ │ │ ├── Added.java │ │ │ └── Removed.java │ ├── innertype │ │ ├── cls │ │ │ ├── outercls │ │ │ │ ├── d0 │ │ │ │ │ ├── Added.java │ │ │ │ │ ├── Removed.java │ │ │ │ │ └── Unchanged.java │ │ │ │ └── d1 │ │ │ │ │ ├── Added.java │ │ │ │ │ ├── Removed.java │ │ │ │ │ └── Unchanged.java │ │ │ └── outeriface │ │ │ │ ├── d0 │ │ │ │ ├── Added.java │ │ │ │ ├── Removed.java │ │ │ │ └── Unchanged.java │ │ │ │ └── d1 │ │ │ │ ├── Added.java │ │ │ │ ├── Removed.java │ │ │ │ └── Unchanged.java │ │ └── iface │ │ │ ├── outercls │ │ │ ├── d0 │ │ │ │ ├── Added.java │ │ │ │ ├── Removed.java │ │ │ │ └── Unchanged.java │ │ │ └── d1 │ │ │ │ ├── Added.java │ │ │ │ ├── Removed.java │ │ │ │ └── Unchanged.java │ │ │ └── outeriface │ │ │ ├── d0 │ │ │ ├── Added.java │ │ │ ├── Removed.java │ │ │ └── Unchanged.java │ │ │ └── d1 │ │ │ ├── Added.java │ │ │ ├── Removed.java │ │ │ └── Unchanged.java │ └── method │ │ ├── noparams │ │ ├── d0 │ │ │ ├── Added.java │ │ │ └── Removed.java │ │ └── d1 │ │ │ ├── Added.java │ │ │ └── Removed.java │ │ └── withparams │ │ ├── d0 │ │ ├── Added.java │ │ └── Removed.java │ │ └── d1 │ │ ├── Added.java │ │ └── Removed.java ├── extends │ ├── d0 │ │ ├── Added.java │ │ ├── Changed.java │ │ └── Removed.java │ └── d1 │ │ ├── Added.java │ │ ├── Changed.java │ │ └── Removed.java ├── field │ ├── access │ │ ├── d0 │ │ │ ├── Added.java │ │ │ ├── Changed.java │ │ │ └── Removed.java │ │ └── d1 │ │ │ ├── Added.java │ │ │ ├── Changed.java │ │ │ └── Removed.java │ ├── init │ │ ├── d0 │ │ │ ├── Added.java │ │ │ ├── Changed.java │ │ │ ├── Removed.java │ │ │ └── Unchanged.java │ │ └── d1 │ │ │ ├── Added.java │ │ │ ├── Changed.java │ │ │ ├── Removed.java │ │ │ └── Unchanged.java │ ├── modifier │ │ ├── d0 │ │ │ ├── Added.java │ │ │ └── Removed.java │ │ └── d1 │ │ │ ├── Added.java │ │ │ └── Removed.java │ └── variable │ │ ├── init │ │ ├── d0 │ │ │ ├── Added.java │ │ │ ├── Changed.java │ │ │ ├── Removed.java │ │ │ └── Unchanged.java │ │ └── d1 │ │ │ ├── Added.java │ │ │ ├── Changed.java │ │ │ ├── Removed.java │ │ │ └── Unchanged.java │ │ ├── onetwo │ │ ├── d0 │ │ │ ├── Added.java │ │ │ ├── Changed.java │ │ │ └── Removed.java │ │ └── d1 │ │ │ ├── Added.java │ │ │ ├── Changed.java │ │ │ └── Removed.java │ │ └── renamed │ │ ├── init │ │ ├── codechange │ │ │ ├── d0 │ │ │ │ ├── Changed.java │ │ │ │ └── Unchanged.java │ │ │ └── d1 │ │ │ │ ├── Changed.java │ │ │ │ └── Unchanged.java │ │ └── nocodechange │ │ │ ├── d0 │ │ │ ├── Changed.java │ │ │ └── Unchanged.java │ │ │ └── d1 │ │ │ ├── Changed.java │ │ │ └── Unchanged.java │ │ └── noinit │ │ ├── d0 │ │ ├── Changed.java │ │ └── Unchanged.java │ │ └── d1 │ │ ├── Changed.java │ │ └── Unchanged.java ├── implements │ ├── onetwo │ │ ├── d0 │ │ │ ├── Added.java │ │ │ ├── Changed.java │ │ │ └── Removed.java │ │ └── d1 │ │ │ ├── Added.java │ │ │ ├── Changed.java │ │ │ └── Removed.java │ └── zeroone │ │ ├── d0 │ │ ├── Added.java │ │ ├── Changed.java │ │ └── Removed.java │ │ └── d1 │ │ ├── Added.java │ │ ├── Changed.java │ │ └── Removed.java ├── method │ ├── access │ │ ├── d0 │ │ │ ├── Added.java │ │ │ ├── Changed.java │ │ │ └── Removed.java │ │ └── d1 │ │ │ ├── Added.java │ │ │ ├── Changed.java │ │ │ └── Removed.java │ ├── body │ │ ├── codechange │ │ │ ├── repeatedtokens │ │ │ │ ├── d0 │ │ │ │ │ └── Changed.java │ │ │ │ └── d1 │ │ │ │ │ └── Changed.java │ │ │ ├── returnvalue │ │ │ │ ├── d0 │ │ │ │ │ ├── Changed.java │ │ │ │ │ └── Unchanged.java │ │ │ │ └── d1 │ │ │ │ │ ├── Changed.java │ │ │ │ │ └── Unchanged.java │ │ │ ├── statement │ │ │ │ ├── d0 │ │ │ │ │ ├── Changed.java │ │ │ │ │ └── Unchanged.java │ │ │ │ └── d1 │ │ │ │ │ ├── Changed.java │ │ │ │ │ └── Unchanged.java │ │ │ └── varinit │ │ │ │ ├── d0 │ │ │ │ ├── Added.java │ │ │ │ ├── Changed.java │ │ │ │ ├── Removed.java │ │ │ │ └── Unchanged.java │ │ │ │ └── d1 │ │ │ │ ├── Added.java │ │ │ │ ├── Changed.java │ │ │ │ ├── Removed.java │ │ │ │ └── Unchanged.java │ │ └── zeroone │ │ │ ├── d0 │ │ │ ├── Added.java │ │ │ └── Removed.java │ │ │ └── d1 │ │ │ ├── Added.java │ │ │ └── Removed.java │ ├── modifier │ │ ├── d0 │ │ │ ├── Added.java │ │ │ └── Removed.java │ │ └── d1 │ │ │ ├── Added.java │ │ │ └── Removed.java │ ├── parameters │ │ ├── many │ │ │ ├── d0 │ │ │ │ └── Unchanged.java │ │ │ └── d1 │ │ │ │ └── Unchanged.java │ │ ├── namechange │ │ │ ├── d0 │ │ │ │ └── Changed.java │ │ │ └── d1 │ │ │ │ └── Changed.java │ │ ├── onetwo │ │ │ ├── d0 │ │ │ │ ├── Added.java │ │ │ │ └── Removed.java │ │ │ └── d1 │ │ │ │ ├── Added.java │ │ │ │ └── Removed.java │ │ ├── reorder │ │ │ ├── rename │ │ │ │ ├── d0 │ │ │ │ │ └── Changed.java │ │ │ │ └── d1 │ │ │ │ │ └── Changed.java │ │ │ ├── simple │ │ │ │ ├── d0 │ │ │ │ │ └── Changed.java │ │ │ │ └── d1 │ │ │ │ │ └── Changed.java │ │ │ └── typechange │ │ │ │ ├── d0 │ │ │ │ └── Changed.java │ │ │ │ └── d1 │ │ │ │ └── Changed.java │ │ ├── typechange │ │ │ ├── d0 │ │ │ │ └── Changed.java │ │ │ └── d1 │ │ │ │ └── Changed.java │ │ ├── varargs │ │ │ ├── d0 │ │ │ │ ├── Changed.java │ │ │ │ └── Unchanged.java │ │ │ └── d1 │ │ │ │ ├── Changed.java │ │ │ │ └── Unchanged.java │ │ └── zeroone │ │ │ ├── d0 │ │ │ ├── Added.java │ │ │ └── Removed.java │ │ │ └── d1 │ │ │ ├── Added.java │ │ │ └── Removed.java │ ├── returntype │ │ ├── d0 │ │ │ └── Changed.java │ │ └── d1 │ │ │ └── Changed.java │ └── throws │ │ ├── onetwo │ │ ├── d0 │ │ │ ├── Added.java │ │ │ └── Removed.java │ │ └── d1 │ │ │ ├── Added.java │ │ │ ├── Changed.java │ │ │ └── Removed.java │ │ ├── reorder │ │ ├── d0 │ │ │ └── Changed.java │ │ └── d1 │ │ │ └── Changed.java │ │ └── zeroone │ │ ├── d0 │ │ ├── Added.java │ │ └── Removed.java │ │ └── d1 │ │ ├── Added.java │ │ └── Removed.java ├── modifiers │ ├── d0 │ │ ├── Added.java │ │ └── Removed.java │ └── d1 │ │ ├── Added.java │ │ └── Removed.java ├── semicolon │ ├── d0 │ │ └── None.java │ └── d1 │ │ └── None.java └── typechange │ ├── clstoiface │ ├── d0 │ │ └── Changed.java │ └── d1 │ │ └── Changed.java │ └── ifacetocls │ ├── d0 │ └── Changed.java │ └── d1 │ └── Changed.java └── types ├── d0 ├── Added.java └── Removed.java └── d1 ├── Added.java └── Removed.java /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "src/main/java/org/incava/ijdk"] 2 | path = src/main/java/org/incava/ijdk 3 | url = git@github.com:jpace/ijdk.git 4 | [submodule "src/main/java/org/incava/pmdx"] 5 | path = src/main/java/org/incava/pmdx 6 | url = git@github.com:jpace/pmdx.git 7 | [submodule "src/main/java/org/incava/jagol"] 8 | path = src/main/java/org/incava/jagol 9 | url = git@github.com:jpace/jagol.git 10 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | dependencies { 6 | } 7 | } 8 | 9 | plugins { 10 | id 'com.jfrog.bintray' version '1.3.1' 11 | } 12 | 13 | apply plugin: 'java' 14 | apply plugin: 'application' 15 | apply plugin: 'pmd' 16 | 17 | group = 'org.incava' 18 | version ='1.6.3' 19 | mainClassName = 'org.incava.diffj.app.DiffJ' 20 | ext { 21 | pkgName = 'diffj' 22 | pkgDesc = 'Java code comparison' 23 | githubRepo = 'github.com/jpace/diffj' 24 | pkgLicense = 'Apache-2.0' 25 | pkgLicenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' 26 | devInfo = { 27 | id 'jpace' 28 | name 'Jeff Pace' 29 | url 'https://github.com/jpace' 30 | email 'jeugenepace@gmail' 31 | } 32 | bintrayUser = System.getenv('BINTRAY_USER') 33 | bintrayKey = System.getenv('BINTRAY_API_KEY') 34 | mavenUserToken = System.getenv('MAVEN_USER_TOKEN') 35 | mavenUserPass = System.getenv('MAVEN_USER_PASS') 36 | deployDryRun = false 37 | } 38 | apply from: 'deploy.gradle' 39 | 40 | dependencies { 41 | compile files('libs/pmdx-3.0.0.jar') 42 | 43 | // compile files('libs/ijdk-3.4.3.jar') 44 | // compile files('libs/qualog-2.2.0.jar') 45 | compile files('libs/ijdk-3.9.0.jar') 46 | compile files('libs/qualog-3.0.0.jar') 47 | 48 | compile files('libs/jagol-1.1.0.jar') 49 | compile files('libs/java-diff-1.0.0.jar') 50 | testCompile group: 'junit', name: 'junit', version: '4.10' 51 | testCompile group: 'pl.pragmatists', name: 'JUnitParams', version: '1.0.6' 52 | testCompile 'org.incava:attest:[0.0.4,)' 53 | testCompile 'org.hamcrest:hamcrest-library:[1.3,)' 54 | } 55 | 56 | allprojects { 57 | tasks.withType(JavaCompile).all { JavaCompile compile -> 58 | compile.options.debug = true 59 | compile.options.compilerArgs = ['-Xlint:all'] 60 | } 61 | } 62 | 63 | jar { 64 | from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } 65 | manifest { attributes 'Main-Class' : 'org.incava.diffj.app.DiffJ' } 66 | } 67 | 68 | test { 69 | excludes = [ '**/*TestCase*', '**/.#*', '**/ItemsTest.class', '**/OutputTest.class' ] 70 | includes = [ '**/*Test*' ] 71 | testLogging { 72 | exceptionFormat = "full" 73 | } 74 | } 75 | 76 | logging.captureStandardOutput LogLevel.ERROR 77 | 78 | // -- PMD configuration -- 79 | 80 | configurations { 81 | pmdConf 82 | } 83 | 84 | dependencies { 85 | pmdConf 'pmd:pmd:4.2.5' 86 | } 87 | -------------------------------------------------------------------------------- /libs/ijdk-3.4.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpace/diffj/518a4821bd1227642c41a462c7dc6c023e6450bd/libs/ijdk-3.4.3.jar -------------------------------------------------------------------------------- /libs/ijdk-3.8.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpace/diffj/518a4821bd1227642c41a462c7dc6c023e6450bd/libs/ijdk-3.8.1.jar -------------------------------------------------------------------------------- /libs/ijdk-3.9.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpace/diffj/518a4821bd1227642c41a462c7dc6c023e6450bd/libs/ijdk-3.9.0.jar -------------------------------------------------------------------------------- /libs/jagol-1.1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpace/diffj/518a4821bd1227642c41a462c7dc6c023e6450bd/libs/jagol-1.1.0.jar -------------------------------------------------------------------------------- /libs/java-diff-1.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpace/diffj/518a4821bd1227642c41a462c7dc6c023e6450bd/libs/java-diff-1.0.0.jar -------------------------------------------------------------------------------- /libs/pmd-4.2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpace/diffj/518a4821bd1227642c41a462c7dc6c023e6450bd/libs/pmd-4.2.5.jar -------------------------------------------------------------------------------- /libs/pmdx-2.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpace/diffj/518a4821bd1227642c41a462c7dc6c023e6450bd/libs/pmdx-2.0.0.jar -------------------------------------------------------------------------------- /libs/pmdx-3.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpace/diffj/518a4821bd1227642c41a462c7dc6c023e6450bd/libs/pmdx-3.0.0.jar -------------------------------------------------------------------------------- /libs/qualog-2.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpace/diffj/518a4821bd1227642c41a462c7dc6c023e6450bd/libs/qualog-2.2.0.jar -------------------------------------------------------------------------------- /libs/qualog-3.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpace/diffj/518a4821bd1227642c41a462c7dc6c023e6450bd/libs/qualog-3.0.0.jar -------------------------------------------------------------------------------- /src/main/jar/launcher.manifest: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: . 3 | Main-Class: org.incava.diffj.DiffJLauncher 4 | -------------------------------------------------------------------------------- /src/main/java/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Main-Class: DiffJMain 2 | -------------------------------------------------------------------------------- /src/main/java/org/incava/analysis/BriefReport.java: -------------------------------------------------------------------------------- 1 | package org.incava.analysis; 2 | 3 | import java.io.IOException; 4 | import java.io.Writer; 5 | import java.util.Collection; 6 | 7 | /** 8 | * Reports differences briefly, vaguely a la "diff --brief". 9 | */ 10 | public class BriefReport extends Report { 11 | public BriefReport(Writer writer) { 12 | super(writer); 13 | } 14 | 15 | /** 16 | * Returns the given difference, in brief format. 17 | */ 18 | protected String toString(FileDiff fdiff) { 19 | StringBuilder sb = new StringBuilder(); 20 | sb.append(fdiff.toDiffSummaryString()); 21 | sb.append(": "); 22 | sb.append(fdiff.getMessage()); 23 | sb.append(EOLN); 24 | 25 | return sb.toString(); 26 | } 27 | 28 | /** 29 | * Writes the differences. 30 | */ 31 | public void writeDifferences() { 32 | try { 33 | Collection diffs = getDifferences(); 34 | String lastStr = null; 35 | for (FileDiff fdiff : diffs) { 36 | String str = toString(fdiff); 37 | if (!str.equals(lastStr)) { 38 | writer.write(str); 39 | lastStr = str; 40 | } 41 | } 42 | // we can't close STDOUT 43 | writer.flush(); 44 | } 45 | catch (IOException ioe) { 46 | tr.Ace.log("ioe", ioe); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/incava/analysis/DiffContextHighlightWriter.java: -------------------------------------------------------------------------------- 1 | package org.incava.analysis; 2 | 3 | import java.util.List; 4 | import org.incava.ijdk.util.ANSI; 5 | 6 | /** 7 | * Writes differences with context, and color! 8 | */ 9 | public class DiffContextHighlightWriter extends DiffContextWriter { 10 | /** 11 | * The color for added code. 12 | */ 13 | protected static String COLOR_ADDED = ANSI.YELLOW; 14 | 15 | /** 16 | * The color for deleted code. 17 | */ 18 | protected static String COLOR_DELETED = ANSI.RED; 19 | 20 | public DiffContextHighlightWriter(List fromContents, List toContents) { 21 | super(fromContents, toContents); 22 | } 23 | 24 | protected String getLine(List lines, int lidx, int fromLine, int fromColumn, int toLine, int toColumn, boolean isDelete) { 25 | String line = lines.get(lidx - 1); 26 | 27 | StringBuilder sb = new StringBuilder(); 28 | 29 | // PMD reports columns using tabSize == 8, so we replace tabs with 30 | // spaces here. 31 | // ... I loathe tabs. 32 | 33 | line = line.replace("\t", " "); 34 | 35 | int llen = line.length(); 36 | 37 | // columns are 1-indexed, strings are 0-indexed 38 | // ... half my life is adding or substracting one. 39 | 40 | int fcol = fromLine == lidx ? fromColumn - 1 : 0; 41 | int tcol = toLine == lidx ? toColumn : llen; 42 | 43 | sb.append("! ").append(line.substring(0, fcol)); 44 | 45 | // highlight: 46 | 47 | String highlightColor = isDelete ? COLOR_DELETED : COLOR_ADDED; 48 | 49 | sb.append(highlightColor); 50 | sb.append(line.substring(fcol, tcol)); 51 | sb.append(ANSI.RESET); 52 | 53 | sb.append(line.substring(tcol, llen)); 54 | sb.append(EOLN); 55 | 56 | return sb.toString(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/incava/analysis/DiffContextWriter.java: -------------------------------------------------------------------------------- 1 | package org.incava.analysis; 2 | 3 | import java.util.List; 4 | import org.incava.ijdk.text.LocationRange; 5 | 6 | /** 7 | * Writes differences with context. Actually returns the differences as strings. 8 | * Writing is left to the invoker. 9 | */ 10 | public class DiffContextWriter extends DiffWriter { 11 | public DiffContextWriter(List fromContents, List toContents) { 12 | super(fromContents, toContents); 13 | } 14 | 15 | public void printFrom(StringBuilder sb, FileDiff fdiff) { 16 | printLines(sb, true, fdiff, fdiff.getFirstLocation(), fromContents); 17 | } 18 | 19 | public void printTo(StringBuilder sb, FileDiff fdiff) { 20 | printLines(sb, false, fdiff, fdiff.getSecondLocation(), toContents); 21 | } 22 | 23 | protected String getLine(List lines, int lidx, int fromLine, int fromColumn, int toLine, int toColumn, boolean isDelete) { 24 | StringBuilder sb = new StringBuilder(); 25 | sb.append("! ").append(lines.get(lidx - 1)).append(EOLN); 26 | return sb.toString(); 27 | } 28 | 29 | protected void printLines(StringBuilder sb, boolean isDelete, FileDiff fdiff, LocationRange loc, List lines) { 30 | int fromLine = loc.getStart().getLine(); 31 | int fromColumn = loc.getStart().getColumn(); 32 | int toLine = loc.getEnd().getLine(); 33 | int toColumn = loc.getEnd().getColumn(); 34 | 35 | for (int lnum = Math.max(0, fromLine - 4); lnum < fromLine - 1; ++lnum) { 36 | sb.append(" ").append(lines.get(lnum)); 37 | sb.append(EOLN); 38 | } 39 | 40 | // PMD reports columns using tabSize == 8, so we replace tabs with 41 | // spaces here. 42 | // ... I loathe tabs. 43 | 44 | for (int lidx = fromLine; lidx <= toLine; ++lidx) { 45 | String line = getLine(lines, lidx, fromLine, fromColumn, toLine, toColumn, isDelete); 46 | sb.append(line); 47 | } 48 | 49 | for (int lnum = toLine; lnum < Math.min(toLine + 3, lines.size()); ++lnum) { 50 | sb.append(" ").append(lines.get(lnum)); 51 | sb.append(EOLN); 52 | } 53 | } 54 | 55 | protected void printLines(StringBuilder sb, FileDiff fdiff) { 56 | fdiff.printContext(this, sb); 57 | sb.append(DiffContextWriter.EOLN); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/incava/analysis/DiffNoContextWriter.java: -------------------------------------------------------------------------------- 1 | package org.incava.analysis; 2 | 3 | import java.util.List; 4 | import org.incava.ijdk.text.LocationRange; 5 | 6 | /** 7 | * Writes differences. Actually returns the differences as strings. Writing is 8 | * left to the invoker. 9 | */ 10 | public class DiffNoContextWriter extends DiffWriter { 11 | public DiffNoContextWriter(List fromContents, List toContents) { 12 | super(fromContents, toContents); 13 | } 14 | 15 | public void printFrom(StringBuilder sb, FileDiff fdiff) { 16 | printLines(sb, fdiff.getFirstLocation(), "<", fromContents); 17 | } 18 | 19 | public void printTo(StringBuilder sb, FileDiff fdiff) { 20 | printLines(sb, fdiff.getSecondLocation(), ">", toContents); 21 | } 22 | 23 | protected void printLines(StringBuilder sb, FileDiff fdiff) { 24 | fdiff.printNoContext(this, sb); 25 | sb.append(EOLN); 26 | } 27 | 28 | protected void printLines(StringBuilder sb, LocationRange loc, String ind, List lines) { 29 | int fromLine = loc.getStart().getLine(); 30 | int throughLine = loc.getEnd().getLine(); 31 | for (int lnum = fromLine; lnum <= throughLine; ++lnum) { 32 | sb.append(ind + " " + lines.get(lnum - 1)); 33 | sb.append(EOLN); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/incava/analysis/DiffWriter.java: -------------------------------------------------------------------------------- 1 | package org.incava.analysis; 2 | 3 | import java.util.List; 4 | import org.incava.ijdk.io.IO; 5 | 6 | /** 7 | * Writes differences. Actually returns the differences as strings. Writing is 8 | * left to the invoker. 9 | */ 10 | public abstract class DiffWriter { 11 | /** 12 | * The end-of-line character/sequence for this OS. 13 | */ 14 | protected final static String EOLN = IO.EOLN; 15 | 16 | /** 17 | * The from-contents, separated by new lines, which are included at the end 18 | * of each string. 19 | */ 20 | protected final List fromContents; 21 | 22 | /** 23 | * The to-contents, separated by new lines, which are included at the end 24 | * of each string. 25 | */ 26 | protected final List toContents; 27 | 28 | public DiffWriter(List fromContents, List toContents) { 29 | this.fromContents = fromContents; 30 | this.toContents = toContents; 31 | } 32 | 33 | /** 34 | * Returns a string representing the given reference, consistent with the 35 | * format of the Report subclass. 36 | */ 37 | public String getDifference(FileDiff fdiff) { 38 | StringBuilder sb = new StringBuilder(); 39 | 40 | printDiffSummary(sb, fdiff); 41 | printLines(sb, fdiff); 42 | 43 | return sb.toString(); 44 | } 45 | 46 | protected void printDiffSummary(StringBuilder sb, FileDiff fdiff) { 47 | sb.append(fdiff.toDiffSummaryString()); 48 | sb.append(' '); 49 | sb.append(fdiff.getMessage()); 50 | sb.append(EOLN); 51 | } 52 | 53 | protected abstract void printLines(StringBuilder sb, FileDiff fdiff); 54 | 55 | public void printFrom(StringBuilder sb, FileDiff fdiff) { 56 | } 57 | 58 | public void printTo(StringBuilder sb, FileDiff fdiff) { 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/incava/analysis/FileDiffAdd.java: -------------------------------------------------------------------------------- 1 | package org.incava.analysis; 2 | 3 | import org.incava.ijdk.text.Location; 4 | import org.incava.ijdk.text.LocationRange; 5 | import org.incava.ijdk.text.Message; 6 | 7 | /** 8 | * A reference to code added, associated with a file by a starting and ending 9 | * position. 10 | */ 11 | public class FileDiffAdd extends FileDiff { 12 | public FileDiffAdd(String message, LocationRange fromLoc, LocationRange toLoc) { 13 | super(Type.ADDED, message, fromLoc, toLoc); 14 | } 15 | 16 | public FileDiffAdd(String message, Location fromStart, Location fromEnd, Location toStart, Location toEnd) { 17 | super(Type.ADDED, message, fromStart, fromEnd, toStart, toEnd); 18 | } 19 | 20 | public FileDiffAdd(LocationRange fromLoc, LocationRange toLoc, Message msg, Object ... params) { 21 | super(Type.ADDED, fromLoc, toLoc, msg, params); 22 | } 23 | 24 | public void printContext(DiffWriter dw, StringBuilder sb) { 25 | dw.printTo(sb, this); 26 | } 27 | 28 | public void printNoContext(DiffWriter dw, StringBuilder sb) { 29 | dw.printTo(sb, this); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/incava/analysis/FileDiffChange.java: -------------------------------------------------------------------------------- 1 | package org.incava.analysis; 2 | 3 | import org.incava.ijdk.text.Location; 4 | import org.incava.ijdk.text.LocationRange; 5 | import org.incava.ijdk.text.Message; 6 | 7 | /** 8 | * A reference to code changed, associated with a file by a starting and ending 9 | * position. 10 | */ 11 | public class FileDiffChange extends FileDiff { 12 | public FileDiffChange(String message, LocationRange fromLoc, LocationRange toLoc) { 13 | super(Type.CHANGED, message, fromLoc, toLoc); 14 | } 15 | 16 | public FileDiffChange(String message, Location fromStart, Location fromEnd, Location toStart, Location toEnd) { 17 | super(Type.CHANGED, message, fromStart, fromEnd, toStart, toEnd); 18 | } 19 | 20 | public FileDiffChange(LocationRange fromLoc, LocationRange toLoc, Message msg, Object ... params) { 21 | super(Type.CHANGED, fromLoc, toLoc, msg, params); 22 | } 23 | 24 | /** 25 | * Expands a file diff for the given ranges. 26 | */ 27 | public FileDiffChange(String message, FileDiff fileDiff, LocationRange fromLocRg, LocationRange toLocRg) { 28 | this(message, fileDiff.getFirstLocation().getStart(), fromLocRg.getEnd(), fileDiff.getSecondLocation().getStart(), toLocRg.getEnd()); 29 | } 30 | 31 | public void printContext(DiffWriter dw, StringBuilder sb) { 32 | dw.printFrom(sb, this); 33 | sb.append(DiffWriter.EOLN); 34 | dw.printTo(sb, this); 35 | } 36 | 37 | public void printNoContext(DiffWriter dw, StringBuilder sb) { 38 | dw.printFrom(sb, this); 39 | sb.append("---"); 40 | sb.append(DiffWriter.EOLN); 41 | dw.printTo(sb, this); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/incava/analysis/FileDiffCodeAdded.java: -------------------------------------------------------------------------------- 1 | package org.incava.analysis; 2 | 3 | import org.incava.ijdk.text.LocationRange; 4 | 5 | /** 6 | * Code added. 7 | */ 8 | public class FileDiffCodeAdded extends FileDiffAdd { 9 | public FileDiffCodeAdded(String message, LocationRange fromLoc, LocationRange toLoc) { 10 | super(message, fromLoc, toLoc); 11 | } 12 | 13 | public void printNoContext(DiffWriter dw, StringBuilder sb) { 14 | dw.printFrom(sb, this); 15 | sb.append("---"); 16 | sb.append(DiffWriter.EOLN); 17 | dw.printTo(sb, this); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/incava/analysis/FileDiffCodeDeleted.java: -------------------------------------------------------------------------------- 1 | package org.incava.analysis; 2 | 3 | import org.incava.ijdk.text.LocationRange; 4 | 5 | /** 6 | * Code deleted. 7 | */ 8 | public class FileDiffCodeDeleted extends FileDiffDelete { 9 | public FileDiffCodeDeleted(String message, LocationRange fromLoc, LocationRange toLoc) { 10 | super(message, fromLoc, toLoc); 11 | } 12 | 13 | public void printNoContext(DiffWriter dw, StringBuilder sb) { 14 | dw.printFrom(sb, this); 15 | sb.append("---"); 16 | sb.append(DiffWriter.EOLN); 17 | dw.printTo(sb, this); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/incava/analysis/FileDiffDelete.java: -------------------------------------------------------------------------------- 1 | package org.incava.analysis; 2 | 3 | import org.incava.ijdk.text.Location; 4 | import org.incava.ijdk.text.LocationRange; 5 | import org.incava.ijdk.text.Message; 6 | 7 | /** 8 | * A reference to code deleted, associated with a file by a starting and ending 9 | * position. Note that code deleted is not the same as a section of code deleted. 10 | */ 11 | public class FileDiffDelete extends FileDiff { 12 | public FileDiffDelete(String message, LocationRange fromLoc, LocationRange toLoc) { 13 | super(Type.DELETED, message, fromLoc, toLoc); 14 | } 15 | 16 | public FileDiffDelete(LocationRange fromLoc, LocationRange toLoc, Message msg, Object ... params) { 17 | super(Type.DELETED, fromLoc, toLoc, msg, params); 18 | } 19 | 20 | public void printContext(DiffWriter dw, StringBuilder sb) { 21 | dw.printFrom(sb, this); 22 | } 23 | 24 | public void printNoContext(DiffWriter dw, StringBuilder sb) { 25 | dw.printFrom(sb, this); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/incava/analysis/FileDiffs.java: -------------------------------------------------------------------------------- 1 | package org.incava.analysis; 2 | 3 | import java.util.TreeSet; 4 | 5 | /** 6 | * A list/set/collection of FileDiffs, which knows that it was added to, even 7 | * after the set is cleared. 8 | */ 9 | public class FileDiffs extends TreeSet { 10 | public static final long serialVersionUID = 1L; 11 | 12 | private boolean added; 13 | 14 | public FileDiffs() { 15 | added = false; 16 | } 17 | 18 | public boolean add(FileDiff fd) { 19 | added = true; 20 | return super.add(fd); 21 | } 22 | 23 | public boolean wasAdded() { 24 | return added; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/incava/analysis/TokenUtil.java: -------------------------------------------------------------------------------- 1 | package org.incava.analysis; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.Token; 4 | import org.incava.ijdk.text.Location; 5 | import org.incava.ijdk.text.LocationRange; 6 | 7 | public class TokenUtil { 8 | public static Location toBeginLocation(Token t) { 9 | return t == null ? null : new Location(t.beginLine, t.beginColumn); 10 | } 11 | 12 | public static LocationRange toLocationRange(Token from, Token to) { 13 | return new LocationRange(toBeginLocation(from), toEndLocation(to)); 14 | } 15 | 16 | public static Location toEndLocation(Token t) { 17 | return t == null ? null : new Location(t.endLine, t.endColumn); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/code/Block.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.code; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import net.sourceforge.pmd.lang.java.ast.ASTBlockStatement; 6 | import net.sourceforge.pmd.lang.java.ast.AbstractJavaNode; 7 | import net.sourceforge.pmd.lang.java.ast.Token; 8 | import org.incava.diffj.code.stmt.StatementListDiffer; 9 | import org.incava.diffj.code.stmt.StatementsDiff; 10 | import org.incava.diffj.element.Differences; 11 | import org.incava.pmdx.Node; 12 | 13 | public class Block { 14 | private final String name; 15 | private final List statements; 16 | private final AbstractJavaNode blk; 17 | 18 | public Block(String name, AbstractJavaNode blk) { 19 | this(name, blk, Node.of(blk).findChildren(ASTBlockStatement.class)); 20 | } 21 | 22 | public Block(String name, AbstractJavaNode blk, List blkStatements) { 23 | this.name = name; 24 | this.statements = new ArrayList(); 25 | this.blk = blk; 26 | for (ASTBlockStatement blkStmt : blkStatements) { 27 | Statement stmt = new Statement(blkStmt); 28 | statements.add(stmt); 29 | } 30 | } 31 | 32 | public List getStatements() { 33 | return statements; 34 | } 35 | 36 | public Token getLastToken() { 37 | return Node.of(blk).getLastToken(); 38 | } 39 | 40 | public TokenList getTokens() { 41 | List allTokens = new ArrayList(); 42 | for (Statement stmt : statements) { 43 | allTokens.addAll(stmt.getTokens()); 44 | } 45 | return new TokenList(allTokens); 46 | } 47 | 48 | public void compareCode(Block toBlock, Differences differences) { 49 | compareCodeNew(toBlock, differences); 50 | } 51 | 52 | public void compareCodeOld(Block toBlock, Differences differences) { 53 | Code fromCode = new Code(name, getTokens()); 54 | Code toCode = new Code(name, toBlock.getTokens()); 55 | fromCode.diff(toCode, differences); 56 | } 57 | 58 | public void compareCodeNew(Block toBlock, Differences differences) { 59 | StatementListDiffer diff = new StatementListDiffer(this, toBlock); 60 | List diffs = diff.execute(); 61 | for (StatementsDiff df : diffs) { 62 | df.execute(name, differences); 63 | } 64 | } 65 | 66 | public String toString() { 67 | return "" + name; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/code/CodeLogger.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.code; 2 | 3 | public class CodeLogger { 4 | protected static final boolean debug = Boolean.getBoolean("diffj.debug.code"); 5 | 6 | public static void log(String msg, Object obj) { 7 | if (debug) { 8 | tr.Ace.log(String.format("%-30s", msg), obj); 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/code/Statement.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.code; 2 | 3 | import java.util.List; 4 | import net.sourceforge.pmd.lang.java.ast.ASTBlockStatement; 5 | import net.sourceforge.pmd.lang.java.ast.Token; 6 | import org.incava.pmdx.Node; 7 | import org.incava.pmdx.SimpleNodeUtil; 8 | 9 | public class Statement implements Comparable { 10 | private final ASTBlockStatement stmt; 11 | private final List tokens; 12 | private final TokenList tokenList; 13 | 14 | public Statement(ASTBlockStatement stmt) { 15 | this.stmt = stmt; 16 | this.tokens = SimpleNodeUtil.getChildTokens(stmt); 17 | this.tokenList = new TokenList(tokens); 18 | } 19 | 20 | public List getTokens() { 21 | return tokens; 22 | } 23 | 24 | public TokenList getTokenList() { 25 | return tokenList; 26 | } 27 | 28 | public ASTBlockStatement getBlockStatement() { 29 | return stmt; 30 | } 31 | 32 | public int compareTo(Statement other) { 33 | return tokenList.compareTo(other.tokenList); 34 | } 35 | 36 | public String toString() { 37 | return tokenList.toString(); 38 | } 39 | 40 | public Tkn getTkn(int idx) { 41 | return new Tkn(tokenList.get(idx)); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/code/Tkn.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.code; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.Token; 4 | import org.incava.ijdk.text.Location; 5 | import org.incava.ijdk.text.LocationRange; 6 | 7 | /** 8 | * Wraps a PMD Token 9 | */ 10 | public class Tkn { 11 | private final Token token; 12 | 13 | public Tkn(Token token) { 14 | this.token = token; 15 | } 16 | 17 | public Token getToken() { 18 | return token; 19 | } 20 | 21 | public Location getBeginLocation() { 22 | return token == null ? null : new Location(token.beginLine, token.beginColumn); 23 | } 24 | 25 | public LocationRange getLocationRange(Tkn to) { 26 | return new LocationRange(getBeginLocation(), to.getEndLocation()); 27 | } 28 | 29 | public Location getEndLocation() { 30 | return token == null ? null : new Location(token.endLine, token.endColumn); 31 | } 32 | 33 | public int compareTo(Tkn other) { 34 | if (token == null) { 35 | return other.token == null ? 0 : -1; 36 | } 37 | else if (other.token == null) { 38 | return 1; 39 | } 40 | 41 | int cmp = new Integer(token.kind).compareTo(new Integer(other.token.kind)); 42 | if (cmp == 0) { 43 | cmp = token.image.compareTo(other.token.image); 44 | } 45 | return cmp; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/code/TokenComparator.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.code; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.Token; 4 | import org.incava.ijdk.util.DefaultComparator; 5 | 6 | public class TokenComparator extends DefaultComparator { 7 | public int doCompare(Token xt, Token yt) { 8 | Tkn x = new Tkn(xt); 9 | Tkn y = new Tkn(yt); 10 | return x.compareTo(y); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/code/TokenDiffer.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.code; 2 | 3 | import java.util.List; 4 | import net.sourceforge.pmd.lang.java.ast.Token; 5 | import org.incava.diff.Differ; 6 | import org.incava.diff.Difference; 7 | 8 | public class TokenDiffer extends Differ { 9 | public TokenDiffer(List fromTokens, List toTokens) { 10 | super(fromTokens, toTokens, new TokenComparator()); 11 | } 12 | 13 | public TokenDifference createDifference(Integer delStart, Integer delEnd, Integer addStart, Integer addEnd) { 14 | if (delEnd == Difference.NONE) { 15 | return new TokenDifferenceAdd(delStart, delEnd, addStart, addEnd); 16 | } 17 | else if (addEnd == Difference.NONE) { 18 | return new TokenDifferenceDelete(delStart, delEnd, addStart, addEnd); 19 | } 20 | else { 21 | return new TokenDifferenceChange(delStart, delEnd, addStart, addEnd); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/code/TokenDifference.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.code; 2 | 3 | import org.incava.analysis.FileDiff; 4 | import org.incava.diff.Difference; 5 | import org.incava.diffj.element.Differences; 6 | import org.incava.ijdk.text.LocationRange; 7 | import org.incava.ijdk.text.Message; 8 | 9 | public abstract class TokenDifference extends Difference { 10 | public TokenDifference(Integer delStart, Integer delEnd, Integer addStart, Integer addEnd) { 11 | super(delStart, delEnd, addStart, addEnd); 12 | } 13 | 14 | public abstract FileDiff getFileDiff(String str, LocationRange fromLocRg, LocationRange toLocRg); 15 | 16 | public abstract Message getMessage(); 17 | 18 | public FileDiff execute(String name, LocationRange fromLocRg, LocationRange toLocRg, Differences differences) { 19 | Message msg = getMessage(); 20 | String str = msg.format(name); 21 | FileDiff fileDiff = getFileDiff(str, fromLocRg, toLocRg); 22 | differences.add(fileDiff); 23 | return fileDiff; 24 | } 25 | 26 | protected FileDiff addFileDiff(FileDiff fileDiff, Differences differences) { 27 | differences.add(fileDiff); 28 | return fileDiff; 29 | } 30 | 31 | public LocationRange getDeletedRange(TokenList tokenList) { 32 | return tokenList.getLocationRange(getDeletedStart(), getDeletedEnd()); 33 | } 34 | 35 | public LocationRange getAddedRange(TokenList tokenList) { 36 | return tokenList.getLocationRange(getAddedStart(), getAddedEnd()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/code/TokenDifferenceAdd.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.code; 2 | 3 | import org.incava.analysis.FileDiff; 4 | import org.incava.analysis.FileDiffCodeAdded; 5 | import org.incava.ijdk.text.LocationRange; 6 | import org.incava.ijdk.text.Message; 7 | 8 | public class TokenDifferenceAdd extends TokenDifference { 9 | public TokenDifferenceAdd(Integer delStart, Integer delEnd, Integer addStart, Integer addEnd) { 10 | super(delStart, delEnd, addStart, addEnd); 11 | } 12 | 13 | public Message getMessage() { 14 | return Code.CODE_ADDED; 15 | } 16 | 17 | public FileDiff getFileDiff(String str, LocationRange fromLocRg, LocationRange toLocRg) { 18 | // this will show as add when highlighted, as change when not. 19 | return new FileDiffCodeAdded(str, fromLocRg, toLocRg); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/code/TokenDifferenceChange.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.code; 2 | 3 | import org.incava.analysis.FileDiff; 4 | import org.incava.analysis.FileDiffChange; 5 | import org.incava.ijdk.text.LocationRange; 6 | import org.incava.ijdk.text.Message; 7 | 8 | public class TokenDifferenceChange extends TokenDifference { 9 | public TokenDifferenceChange(Integer delStart, Integer delEnd, Integer addStart, Integer addEnd) { 10 | super(delStart, delEnd, addStart, addEnd); 11 | } 12 | 13 | public Message getMessage() { 14 | return Code.CODE_CHANGED; 15 | } 16 | 17 | public FileDiff getFileDiff(String str, LocationRange fromLocRg, LocationRange toLocRg) { 18 | return new FileDiffChange(str, fromLocRg, toLocRg); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/code/TokenDifferenceDelete.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.code; 2 | 3 | import org.incava.analysis.FileDiff; 4 | import org.incava.analysis.FileDiffCodeDeleted; 5 | import org.incava.ijdk.text.LocationRange; 6 | import org.incava.ijdk.text.Message; 7 | 8 | public class TokenDifferenceDelete extends TokenDifference { 9 | public TokenDifferenceDelete(Integer delStart, Integer delEnd, Integer addStart, Integer addEnd) { 10 | super(delStart, delEnd, addStart, addEnd); 11 | } 12 | 13 | public Message getMessage() { 14 | return Code.CODE_REMOVED; 15 | } 16 | 17 | public FileDiff getFileDiff(String str, LocationRange fromLocRg, LocationRange toLocRg) { 18 | return new FileDiffCodeDeleted(str, fromLocRg, toLocRg); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/code/stmt/SLLogger.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.code.stmt; 2 | 3 | public class SLLogger { 4 | protected static final boolean debug = Boolean.getBoolean("diffj.debug.statementlist"); 5 | 6 | public static void log(String msg, Object obj) { 7 | if (debug) { 8 | tr.Ace.log(msg, obj); 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/code/stmt/StatementListDiffer.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.code.stmt; 2 | 3 | import org.incava.diff.Differ; 4 | import org.incava.diff.Difference; 5 | import org.incava.diffj.code.Block; 6 | import org.incava.diffj.code.Statement; 7 | import org.incava.diffj.util.DiffPoint; 8 | 9 | public class StatementListDiffer extends Differ { 10 | private final StatementList fromStatements; 11 | private final StatementList toStatements; 12 | 13 | public StatementListDiffer(Block fromBlock, Block toBlock) { 14 | super(fromBlock.getStatements(), toBlock.getStatements()); 15 | 16 | this.fromStatements = new StatementList(fromBlock); 17 | this.toStatements = new StatementList(toBlock); 18 | } 19 | 20 | public StatementsDiff createDifference(Integer delStart, Integer delEnd, Integer addStart, Integer addEnd) { 21 | DiffPoint delPoint = new DiffPoint(delStart, delEnd); 22 | DiffPoint addPoint = new DiffPoint(addStart, addEnd); 23 | 24 | if (delEnd == Difference.NONE) { 25 | return new StatementsDiffAdd(fromStatements, toStatements, delPoint, addPoint); 26 | } 27 | else if (addEnd == Difference.NONE) { 28 | return new StatementsDiffDelete(fromStatements, toStatements, delPoint, addPoint); 29 | } 30 | else { 31 | return new StatementsDiffChange(fromStatements, toStatements, delPoint, addPoint); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/code/stmt/StatementsDiff.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.code.stmt; 2 | 3 | import org.incava.diff.Difference; 4 | import org.incava.diffj.element.Differences; 5 | import org.incava.diffj.util.DiffPoint; 6 | 7 | public abstract class StatementsDiff extends Difference { 8 | protected final StatementList fromStatements; 9 | protected final StatementList toStatements; 10 | private final DiffPoint delPoint; 11 | private final DiffPoint addPoint; 12 | 13 | public StatementsDiff(StatementList fromStatements, StatementList toStatements, 14 | DiffPoint delPoint, DiffPoint addPoint) { 15 | super(delPoint.getStart(), delPoint.getEnd(), addPoint.getStart(), addPoint.getEnd()); 16 | this.fromStatements = fromStatements; 17 | this.toStatements = toStatements; 18 | this.delPoint = delPoint; 19 | this.addPoint = addPoint; 20 | } 21 | 22 | public void execute(String name, Differences differences) { 23 | process(name, fromStatements, toStatements, differences); 24 | } 25 | 26 | public abstract void process(String name, StatementList fromStatements, StatementList toStatements, Differences differences); 27 | 28 | public DiffPoint getDeletedPoint() { 29 | return delPoint; 30 | } 31 | 32 | public DiffPoint getAddedPoint() { 33 | return addPoint; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/code/stmt/StatementsDiffAdd.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.code.stmt; 2 | 3 | import org.incava.analysis.FileDiff; 4 | import org.incava.analysis.FileDiffCodeAdded; 5 | import org.incava.diffj.code.Code; 6 | import org.incava.diffj.util.DiffPoint; 7 | import org.incava.ijdk.text.LocationRange; 8 | 9 | public class StatementsDiffAdd extends StatementsDiffDelta { 10 | public StatementsDiffAdd(StatementList fromStatements, StatementList toStatements, 11 | DiffPoint delPoint, DiffPoint addPoint) { 12 | super(fromStatements, toStatements, delPoint, addPoint); 13 | } 14 | 15 | public String getMessage(String name) { 16 | return Code.CODE_ADDED.format(name); 17 | } 18 | 19 | public FileDiff getFileDiff(String msg, LocationRange fromLocRg, LocationRange toLocRg) { 20 | return new FileDiffCodeAdded(msg, fromLocRg, toLocRg); 21 | } 22 | 23 | public LocationRange getFromRange(StatementList fromStatements) { 24 | return fromStatements.getRangeAt(getDeletedStart()); 25 | } 26 | 27 | public LocationRange getToRange(StatementList toStatements) { 28 | return toStatements.getRangeOf(getAddedPoint()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/code/stmt/StatementsDiffChange.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.code.stmt; 2 | 3 | import org.incava.diffj.code.Code; 4 | import org.incava.diffj.element.Differences; 5 | import org.incava.diffj.util.DiffPoint; 6 | 7 | public class StatementsDiffChange extends StatementsDiff { 8 | public StatementsDiffChange(StatementList fromStatements, StatementList toStatements, 9 | DiffPoint delPoint, DiffPoint addPoint) { 10 | super(fromStatements, toStatements, delPoint, addPoint); 11 | } 12 | 13 | public void process(String name, StatementList fromStatements, StatementList toStatements, Differences differences) { 14 | Code fromCode = fromStatements.getAsCode(name, getDeletedPoint()); 15 | Code toCode = toStatements.getAsCode(name, getAddedPoint()); 16 | fromCode.diff(toCode, differences); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/code/stmt/StatementsDiffDelete.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.code.stmt; 2 | 3 | import org.incava.analysis.FileDiff; 4 | import org.incava.analysis.FileDiffCodeDeleted; 5 | import org.incava.diffj.code.Code; 6 | import org.incava.diffj.util.DiffPoint; 7 | import org.incava.ijdk.text.LocationRange; 8 | 9 | public class StatementsDiffDelete extends StatementsDiffDelta { 10 | public StatementsDiffDelete(StatementList fromStatements, StatementList toStatements, 11 | DiffPoint delPoint, DiffPoint addPoint) { 12 | super(fromStatements, toStatements, delPoint, addPoint); 13 | } 14 | 15 | public String getMessage(String name) { 16 | return Code.CODE_REMOVED.format(name); 17 | } 18 | 19 | public FileDiff getFileDiff(String msg, LocationRange fromLocRg, LocationRange toLocRg) { 20 | return new FileDiffCodeDeleted(msg, fromLocRg, toLocRg); 21 | } 22 | 23 | public LocationRange getFromRange(StatementList fromStatements) { 24 | SLLogger.log("fromStatements", fromStatements); 25 | return fromStatements.getRangeOf(getDeletedPoint()); 26 | } 27 | 28 | public LocationRange getToRange(StatementList toStatements) { 29 | SLLogger.log("toStatements", toStatements); 30 | return toStatements.getRangeAt(getAddedStart()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/code/stmt/StatementsDiffDelta.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.code.stmt; 2 | 3 | import org.incava.analysis.FileDiff; 4 | import org.incava.diffj.element.Differences; 5 | import org.incava.diffj.util.DiffPoint; 6 | import org.incava.ijdk.text.LocationRange; 7 | 8 | public abstract class StatementsDiffDelta extends StatementsDiff { 9 | public StatementsDiffDelta(StatementList fromStatements, StatementList toStatements, 10 | DiffPoint delPoint, DiffPoint addPoint) { 11 | super(fromStatements, toStatements, delPoint, addPoint); 12 | } 13 | 14 | public abstract String getMessage(String name); 15 | 16 | public abstract FileDiff getFileDiff(String msg, LocationRange fromLocRg, LocationRange toLocRg); 17 | 18 | public abstract LocationRange getFromRange(StatementList fromStatements); 19 | 20 | public abstract LocationRange getToRange(StatementList toStatements); 21 | 22 | public void process(String name, StatementList fromStatements, StatementList toStatements, Differences differences) { 23 | LocationRange fromLocRg = getFromRange(fromStatements); 24 | LocationRange toLocRg = getToRange(toStatements); 25 | 26 | String msg = getMessage(name); 27 | FileDiff fileDiff = getFileDiff(msg, fromLocRg, toLocRg); 28 | differences.add(fileDiff); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/compunit/CompilationUnit.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.compunit; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; 4 | import org.incava.analysis.Report; 5 | import org.incava.diffj.element.Differences; 6 | import org.incava.diffj.type.Types; 7 | 8 | public class CompilationUnit { 9 | private final ASTCompilationUnit compUnit; 10 | 11 | public CompilationUnit(ASTCompilationUnit compUnit) { 12 | this.compUnit = compUnit; 13 | } 14 | 15 | public Package getPackage() { 16 | return new Package(compUnit); 17 | } 18 | 19 | public Imports getImports() { 20 | return new Imports(compUnit); 21 | } 22 | 23 | public Types getTypes() { 24 | return new Types(compUnit); 25 | } 26 | 27 | public ASTCompilationUnit getAstCompUnit() { 28 | return compUnit; 29 | } 30 | 31 | public void diff(CompilationUnit toCompUnit, Report report) { 32 | if (toCompUnit == null) { 33 | return; 34 | } 35 | 36 | Differences differences = new Differences(report); 37 | 38 | Package fromPackage = getPackage(); 39 | Package toPackage = toCompUnit.getPackage(); 40 | fromPackage.diff(toPackage, differences); 41 | 42 | Imports fromImports = getImports(); 43 | Imports toImports = toCompUnit.getImports(); 44 | fromImports.diff(toImports, differences); 45 | 46 | Types fromTypes = getTypes(); 47 | Types toTypes = toCompUnit.getTypes(); 48 | fromTypes.diff(toTypes, differences); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/compunit/Import.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.compunit; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration; 4 | import net.sourceforge.pmd.lang.java.ast.Token; 5 | import org.incava.diffj.element.Differences; 6 | import org.incava.pmdx.Node; 7 | 8 | public class Import { 9 | private final ASTImportDeclaration imp; 10 | 11 | public Import(ASTImportDeclaration imp) { 12 | this.imp = imp; 13 | } 14 | 15 | public ASTImportDeclaration getNode() { 16 | return imp; 17 | } 18 | 19 | public Token getFirstToken() { 20 | return Node.of(imp).getFirstToken(); 21 | } 22 | 23 | public Token getLastToken() { 24 | return Node.of(imp).getLastToken(); 25 | } 26 | 27 | public String getAsString() { 28 | StringBuilder sb = new StringBuilder(); 29 | Token tk = Node.of(imp).getFirstToken().next; 30 | 31 | while (tk != null) { 32 | if (tk == Node.of(imp).getLastToken()) { 33 | break; 34 | } 35 | else { 36 | sb.append(tk.image); 37 | tk = tk.next; 38 | } 39 | } 40 | 41 | return sb.toString(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/compunit/Parser.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.compunit; 2 | 3 | import java.io.File; 4 | import java.io.Reader; 5 | import java.io.StringReader; 6 | import net.sourceforge.pmd.lang.ParserOptions; 7 | import net.sourceforge.pmd.lang.ast.JavaCharStream; 8 | import net.sourceforge.pmd.lang.ast.ParseException; 9 | import net.sourceforge.pmd.lang.ast.TokenMgrError; 10 | import net.sourceforge.pmd.lang.java.Java13Parser; 11 | import net.sourceforge.pmd.lang.java.Java14Parser; 12 | import net.sourceforge.pmd.lang.java.Java15Parser; 13 | import net.sourceforge.pmd.lang.java.Java18Parser; 14 | import net.sourceforge.pmd.lang.java.Java16Parser; 15 | import net.sourceforge.pmd.lang.java.Java17Parser; 16 | import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; 17 | import net.sourceforge.pmd.lang.java.ast.JavaParser; 18 | import org.incava.analysis.Report; 19 | import org.incava.diffj.compunit.CompilationUnit; 20 | import org.incava.java.Java; 21 | 22 | public class Parser { 23 | public ASTCompilationUnit parse(String label, String contents, String version) throws Exception { 24 | net.sourceforge.pmd.lang.Parser p = getParser(version); 25 | Reader reader = new StringReader(contents); 26 | return (ASTCompilationUnit)p.parse(label, reader); 27 | } 28 | 29 | public net.sourceforge.pmd.lang.Parser getParser(String version) { 30 | ParserOptions opts = new ParserOptions(); 31 | switch (version) { 32 | case Java.SOURCE_1_3: return new Java13Parser(opts); 33 | case Java.SOURCE_1_4: return new Java14Parser(opts); 34 | case Java.SOURCE_1_5: return new Java15Parser(opts); 35 | case Java.SOURCE_1_6: return new Java16Parser(opts); 36 | case Java.SOURCE_1_7: return new Java17Parser(opts); 37 | case Java.SOURCE_1_8: return new Java18Parser(opts); 38 | default: throw new RuntimeException("version '" + version + "' is not 1.3 through 1.8"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/element/Access.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.element; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.AbstractJavaNode; 4 | import net.sourceforge.pmd.lang.java.ast.Token; 5 | import org.incava.diffj.element.Differences; 6 | import org.incava.ijdk.text.Message; 7 | import org.incava.pmdx.ItemUtil; 8 | import org.incava.pmdx.Node; 9 | 10 | public class Access { 11 | public static final Message ACCESS_REMOVED = new Message("access removed: {0}"); 12 | public static final Message ACCESS_ADDED = new Message("access added: {0}"); 13 | public static final Message ACCESS_CHANGED = new Message("access changed from {0} to {1}"); 14 | 15 | private final AbstractJavaNode node; 16 | 17 | public Access(AbstractJavaNode node) { 18 | this.node = node; 19 | } 20 | 21 | public void diff(AbstractJavaNode other, Differences differences) { 22 | Token fromAccess = ItemUtil.getAccess(node); 23 | Token toAccess = ItemUtil.getAccess(other); 24 | 25 | if (fromAccess == null) { 26 | if (toAccess != null) { 27 | differences.changed(Node.of(node).getFirstToken(), toAccess, ACCESS_ADDED, toAccess.image); 28 | } 29 | } 30 | else if (toAccess == null) { 31 | differences.changed(fromAccess, Node.of(other).getFirstToken(), ACCESS_REMOVED, fromAccess.image); 32 | } 33 | else if (!fromAccess.image.equals(toAccess.image)) { 34 | differences.changed(fromAccess, toAccess, ACCESS_CHANGED, fromAccess.image, toAccess.image); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/element/AccessibleElement.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.element; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.AbstractJavaNode; 4 | import org.incava.pmdx.Node; 5 | 6 | public class AccessibleElement extends Element { 7 | public AccessibleElement(AbstractJavaNode node) { 8 | super(node); 9 | } 10 | 11 | public void compareAccess(AccessibleElement toElement, Differences differences) { 12 | Access acc = new Access(getParent()); 13 | acc.diff(toElement.getParent(), differences); 14 | } 15 | 16 | public AbstractJavaNode getParent() { 17 | Node node = Node.of(getNode()); 18 | return node.getParent(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/element/CodedElement.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.element; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.AbstractJavaNode; 4 | 5 | public abstract class CodedElement extends AccessibleElement { 6 | public CodedElement(AbstractJavaNode node) { 7 | super(node); 8 | } 9 | 10 | abstract protected String getName(); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/element/DiffParameters.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.element; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import net.sourceforge.pmd.lang.java.ast.AbstractJavaNode; 6 | import net.sourceforge.pmd.lang.java.ast.Token; 7 | import org.incava.pmdx.Node; 8 | 9 | public class DiffParameters { 10 | public static Object[] toParameters(Token a, Token b) { 11 | List params = new ArrayList(); 12 | if (a != null) { 13 | params.add(a.image); 14 | } 15 | if (b != null) { 16 | params.add(b.image); 17 | } 18 | return params.toArray(new Object[params.size()]); 19 | } 20 | 21 | public static Object[] toParameters(AbstractJavaNode a, AbstractJavaNode b) { 22 | List params = new ArrayList(); 23 | if (a != null) { 24 | params.add(Node.of(a).toString()); 25 | } 26 | if (b != null) { 27 | params.add(Node.of(b).toString()); 28 | } 29 | return params.toArray(new Object[params.size()]); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/element/Diffable.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.element; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.AbstractJavaNode; 4 | import org.incava.ijdk.text.Message; 5 | 6 | /** 7 | * Something that can be compared against another. 8 | */ 9 | public interface Diffable> { 10 | public double getMatchScore(DiffType toDiffable); 11 | 12 | public void diff(DiffType toDiffable, Differences differences); 13 | 14 | public String getName(); 15 | 16 | public Message getAddedMessage(); 17 | 18 | public Message getRemovedMessage(); 19 | 20 | public AbstractJavaNode getNode(); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/element/Element.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.element; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.AbstractJavaNode; 4 | import org.incava.pmdx.SimpleNodeUtil; 5 | import org.incava.pmdx.Node; 6 | 7 | public class Element { 8 | private final AbstractJavaNode node; 9 | 10 | public Element(AbstractJavaNode node) { 11 | this.node = node; 12 | } 13 | 14 | public AbstractJavaNode getNode() { 15 | return node; 16 | } 17 | 18 | public void dump() { 19 | Node.of(node).dump(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/element/Modifiers.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.element; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import java.util.TreeMap; 6 | import net.sourceforge.pmd.lang.java.ast.AbstractJavaNode; 7 | import net.sourceforge.pmd.lang.java.ast.Token; 8 | import org.incava.diffj.element.Differences; 9 | import org.incava.ijdk.text.Message; 10 | import org.incava.pmdx.Node; 11 | 12 | public abstract class Modifiers { 13 | public static final Message MODIFIER_REMOVED = new Message("modifier removed: {0}"); 14 | public static final Message MODIFIER_ADDED = new Message("modifier added: {0}"); 15 | public static final Message MODIFIER_CHANGED = new Message("modifier changed from {0} to {1}"); 16 | 17 | private final AbstractJavaNode node; 18 | 19 | public Modifiers(AbstractJavaNode node) { 20 | this.node = node; 21 | } 22 | 23 | public abstract int[] getModifierTypes(); 24 | 25 | public void diff(Modifiers toModifiers, Differences differences) { 26 | int[] modifierTypes = getModifierTypes(); 27 | 28 | Map fromByKind = getModifierMap(); 29 | Map toByKind = toModifiers.getModifierMap(); 30 | 31 | for (int modType : modifierTypes) { 32 | Token fromMod = fromByKind.get(modType); 33 | Token toMod = toByKind.get(modType); 34 | 35 | if (fromMod == null) { 36 | if (toMod != null) { 37 | differences.changed(Node.of(node).getFirstToken(), toMod, MODIFIER_ADDED, toMod.image); 38 | } 39 | } 40 | else if (toMod == null) { 41 | differences.changed(fromMod, Node.of(toModifiers.node).getFirstToken(), MODIFIER_REMOVED, fromMod.image); 42 | } 43 | } 44 | } 45 | 46 | /** 47 | * Returns a map from token types ("kinds", as integers), to the token. This 48 | * assumes that there are no leading tokens of the same type for the given 49 | * node. 50 | */ 51 | protected Map getModifierMap() { 52 | List mods = Node.of(node).getLeadingTokens(); 53 | Map byKind = new TreeMap(); 54 | 55 | for (Token tk : mods) { 56 | byKind.put(tk.kind, tk); 57 | } 58 | 59 | return byKind; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/field/FieldModifiers.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.field; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.AbstractJavaNode; 4 | import net.sourceforge.pmd.lang.java.ast.JavaParserConstants; 5 | import org.incava.diffj.element.Modifiers; 6 | import org.incava.pmdx.Node; 7 | 8 | public class FieldModifiers extends Modifiers { 9 | public static final int[] MODIFIERS = new int[] { 10 | JavaParserConstants.FINAL, 11 | JavaParserConstants.STATIC, 12 | }; 13 | 14 | public FieldModifiers(AbstractJavaNode node) { 15 | super(node); 16 | } 17 | 18 | public int[] getModifierTypes() { 19 | return MODIFIERS; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/field/Fields.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.field; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; 4 | import net.sourceforge.pmd.lang.java.ast.ASTFieldDeclaration; 5 | import org.incava.diffj.type.Items; 6 | 7 | public class Fields extends Items { 8 | public Fields(ASTClassOrInterfaceDeclaration typeDecl) { 9 | super(typeDecl, ASTFieldDeclaration.class); 10 | } 11 | 12 | public Field getAstType(ASTFieldDeclaration fieldDecl) { 13 | return new Field(fieldDecl); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/function/Ctor.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.function; 2 | 3 | import java.util.List; 4 | import net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration; 5 | import net.sourceforge.pmd.lang.java.ast.ASTFormalParameters; 6 | import net.sourceforge.pmd.lang.java.ast.ASTNameList; 7 | import org.incava.diffj.code.Block; 8 | import org.incava.diffj.element.Diffable; 9 | import org.incava.diffj.element.Differences; 10 | import org.incava.diffj.params.Parameters; 11 | import org.incava.diffj.util.Messages; 12 | import org.incava.ijdk.text.Message; 13 | import org.incava.pmdx.CtorUtil; 14 | 15 | public class Ctor extends Function implements Diffable { 16 | public final static Message CONSTRUCTOR_REMOVED = new Message("constructor removed: {0}"); 17 | public final static Message CONSTRUCTOR_ADDED = new Message("constructor added: {0}"); 18 | public final static Messages CTOR_MESSAGES = new Messages(CONSTRUCTOR_ADDED, null, CONSTRUCTOR_REMOVED); 19 | 20 | private final ASTConstructorDeclaration ctor; 21 | 22 | public Ctor(ASTConstructorDeclaration ctor) { 23 | super(ctor); 24 | this.ctor = ctor; 25 | } 26 | 27 | public void diff(Ctor toCtor, Differences differences) { 28 | compareAccess(toCtor, differences); 29 | compareParameters(toCtor, differences); 30 | compareThrows(toCtor, differences); 31 | compareCode(toCtor, differences); 32 | } 33 | 34 | protected ASTFormalParameters getFormalParameters() { 35 | return CtorUtil.getParameters(ctor); 36 | } 37 | 38 | public String getName() { 39 | return CtorUtil.getFullName(ctor); 40 | } 41 | 42 | public void compareCode(Ctor toCtor, Differences differences) { 43 | Block fromBlock = new Block(getName(), ctor); 44 | Block toBlock = new Block(toCtor.getName(), toCtor.ctor); 45 | fromBlock.compareCode(toBlock, differences); 46 | } 47 | 48 | public double getMatchScore(Ctor toCtor) { 49 | Parameters fromParams = getParameters(); 50 | Parameters toParams = toCtor.getParameters(); 51 | return fromParams.getMatchScore(toParams); 52 | } 53 | 54 | public Message getAddedMessage() { 55 | return CTOR_MESSAGES.getAdded(); 56 | } 57 | 58 | public Message getRemovedMessage() { 59 | return CTOR_MESSAGES.getDeleted(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/function/Ctors.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.function; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; 4 | import net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration; 5 | import org.incava.diffj.type.Items; 6 | 7 | public class Ctors extends Items { 8 | public Ctors(ASTClassOrInterfaceDeclaration typeDecl) { 9 | super(typeDecl, ASTConstructorDeclaration.class); 10 | } 11 | 12 | public Ctor getAstType(ASTConstructorDeclaration ctorDecl) { 13 | return new Ctor(ctorDecl); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/function/Function.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.function; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.ASTFormalParameters; 4 | import net.sourceforge.pmd.lang.java.ast.ASTNameList; 5 | import net.sourceforge.pmd.lang.java.ast.AbstractJavaNode; 6 | import org.incava.diffj.code.Code; 7 | import org.incava.diffj.element.CodedElement; 8 | import org.incava.diffj.element.Differences; 9 | import org.incava.diffj.params.Parameters; 10 | import org.incava.pmdx.FunctionUtil; 11 | 12 | public abstract class Function extends CodedElement { 13 | private final AbstractJavaNode node; 14 | 15 | public Function(AbstractJavaNode node) { 16 | super(node); 17 | this.node = node; 18 | } 19 | 20 | protected ASTNameList getThrowsList() { 21 | return FunctionUtil.getThrowsList(node); 22 | } 23 | 24 | abstract protected ASTFormalParameters getFormalParameters(); 25 | 26 | protected Parameters getParameters() { 27 | return new Parameters(getFormalParameters()); 28 | } 29 | 30 | protected void compareParameters(Function toFunction, Differences differences) { 31 | Parameters fromParams = getParameters(); 32 | Parameters toParams = toFunction.getParameters(); 33 | fromParams.diff(toParams, differences); 34 | } 35 | 36 | protected void compareThrows(Function toFunction, Differences differences) { 37 | Throws fromThrows = getThrows(); 38 | Throws toThrows = toFunction.getThrows(); 39 | fromThrows.diff(toThrows, differences); 40 | } 41 | 42 | protected Throws getThrows() { 43 | return new Throws(node, getThrowsList()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/function/Initializer.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.function; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.ASTBlock; 4 | import net.sourceforge.pmd.lang.java.ast.ASTInitializer; 5 | import net.sourceforge.pmd.lang.java.ast.AbstractJavaNode; 6 | import org.incava.diffj.code.Block; 7 | import org.incava.diffj.element.Diffable; 8 | import org.incava.diffj.element.Differences; 9 | import org.incava.diffj.util.Messages; 10 | import org.incava.ijdk.text.Message; 11 | import org.incava.pmdx.Node; 12 | 13 | public class Initializer implements Diffable { 14 | public static final Message STATIC_BLOCK_REMOVED = new Message("static block removed"); 15 | public static final Message STATIC_BLOCK_ADDED = new Message("static block added"); 16 | public final static Messages STATIC_BLOCK_MSGS = new Messages(STATIC_BLOCK_ADDED, null, STATIC_BLOCK_REMOVED); 17 | 18 | private final ASTInitializer init; 19 | private final Block block; 20 | 21 | public Initializer(ASTInitializer init) { 22 | this.init = init; 23 | ASTBlock astBlk = Node.of(init).findChild(ASTBlock.class); 24 | this.block = astBlk == null ? null : new Block("static block", astBlk); 25 | } 26 | 27 | public double getMatchScore(Initializer toDiffable) { 28 | return 1.0; 29 | } 30 | 31 | public void diff(Initializer toInit, Differences differences) { 32 | block.compareCode(toInit.block, differences); 33 | } 34 | 35 | public String getName() { 36 | return null; 37 | } 38 | 39 | public Message getAddedMessage() { 40 | return STATIC_BLOCK_MSGS.getAdded(); 41 | } 42 | 43 | public Message getRemovedMessage() { 44 | return STATIC_BLOCK_MSGS.getDeleted(); 45 | } 46 | 47 | public AbstractJavaNode getNode() { 48 | return init; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/function/Initializers.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.function; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; 4 | import net.sourceforge.pmd.lang.java.ast.ASTInitializer; 5 | import org.incava.diffj.type.Items; 6 | 7 | public class Initializers extends Items { 8 | public Initializers(ASTClassOrInterfaceDeclaration typeDecl) { 9 | super(typeDecl, ASTInitializer.class); 10 | } 11 | 12 | public Initializer getAstType(ASTInitializer initDecl) { 13 | return new Initializer(initDecl); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/function/MethodModifiers.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.function; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.AbstractJavaNode; 4 | import net.sourceforge.pmd.lang.java.ast.JavaParserConstants; 5 | import org.incava.diffj.element.Modifiers; 6 | 7 | public class MethodModifiers extends Modifiers { 8 | public static final int[] MODIFIERS = new int[] { 9 | JavaParserConstants.ABSTRACT, 10 | JavaParserConstants.FINAL, 11 | JavaParserConstants.NATIVE, 12 | JavaParserConstants.STATIC, 13 | JavaParserConstants.STRICTFP 14 | }; 15 | 16 | public MethodModifiers(AbstractJavaNode node) { 17 | super(node); 18 | } 19 | 20 | public int[] getModifierTypes() { 21 | return MODIFIERS; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/function/Methods.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.function; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; 4 | import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration; 5 | import org.incava.diffj.type.Items; 6 | 7 | public class Methods extends Items { 8 | public Methods(ASTClassOrInterfaceDeclaration typeDecl) { 9 | super(typeDecl, ASTMethodDeclaration.class); 10 | } 11 | 12 | public Method getAstType(ASTMethodDeclaration methodDecl) { 13 | return new Method(methodDecl); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/io/JavaElementFactory.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.io; 2 | 3 | import java.io.File; 4 | import org.incava.analysis.Report; 5 | import org.incava.diffj.lang.DiffJException; 6 | 7 | /** 8 | * Creates Java filesystem elements (files and directories). 9 | */ 10 | public class JavaElementFactory { 11 | public JavaFSElement createElement(File file, String label, String source, boolean recurseDirectories) throws DiffJException { 12 | JavaFile javaFile = createFile(file, label, source); 13 | if (javaFile != null) { 14 | return javaFile; 15 | } 16 | else if (file.isDirectory()) { 17 | return new JavaDirectory(file, source, recurseDirectories); 18 | } 19 | else { 20 | noSuchFile(file, label); 21 | return null; 22 | } 23 | } 24 | 25 | public JavaFile createFile(File file, String label, String source) throws DiffJException { 26 | if (file == null || file.getName().equals("-") || file.isFile() && verifyExists(file, label)) { 27 | return new JavaFile(file, label, source); 28 | } 29 | else { 30 | return null; 31 | } 32 | } 33 | 34 | public boolean verifyExists(File file, String label) throws DiffJException { 35 | if (file != null && file.exists()) { 36 | return true; 37 | } 38 | else { 39 | noSuchFile(file, label); 40 | return false; 41 | } 42 | } 43 | 44 | public void noSuchFile(File file, String label) throws DiffJException { 45 | throw new DiffJException(getName(file, label) + " does not exist"); 46 | } 47 | 48 | public String getName(File file, String label) { 49 | return label == null ? file.getAbsolutePath() : label; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/io/JavaFSElement.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.io; 2 | 3 | import java.io.File; 4 | import org.incava.analysis.Report; 5 | import org.incava.diffj.lang.DiffJException; 6 | 7 | /** 8 | * A filesystem element, such as a directory or a file. 9 | */ 10 | public abstract class JavaFSElement extends File { 11 | public static final long serialVersionUID = 1L; 12 | 13 | private final String sourceVersion; 14 | 15 | public JavaFSElement(String name, String sourceVersion) { 16 | super(name); 17 | this.sourceVersion = sourceVersion; 18 | } 19 | 20 | protected String getSourceVersion() { 21 | return sourceVersion; 22 | } 23 | 24 | public abstract int compareTo(Report report, JavaFSElement elmt) throws DiffJException; 25 | 26 | public abstract int compareFrom(Report report, JavaFile file) throws DiffJException; 27 | 28 | public abstract int compareFrom(Report report, JavaDirectory dir) throws DiffJException; 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/lang/DiffJException.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.lang; 2 | 3 | public class DiffJException extends Exception { 4 | private static final long serialVersionUID = 1L; 5 | 6 | public DiffJException(Exception e) { 7 | super(e); 8 | } 9 | 10 | public DiffJException(String msg, Exception e) { 11 | super(msg, e); 12 | } 13 | 14 | public DiffJException(String msg) { 15 | super(msg); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/params/Parameter.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.params; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.ASTFormalParameter; 4 | import net.sourceforge.pmd.lang.java.ast.Token; 5 | import org.incava.pmdx.ParameterUtil; 6 | 7 | public class Parameter { 8 | private final ASTFormalParameter param; 9 | 10 | public Parameter(ASTFormalParameter param) { 11 | this.param = param; 12 | } 13 | 14 | protected Token getParameterName() { 15 | return ParameterUtil.getParameterName(param); 16 | } 17 | 18 | protected String getParameterType() { 19 | return ParameterUtil.getParameterType(param); 20 | } 21 | 22 | public boolean isTypeEqual(Parameter toParam) { 23 | return getParameterType().equals(toParam.getParameterType()); 24 | } 25 | 26 | public boolean isNameEqual(Parameter toParam) { 27 | return getParameterName().image.equals(toParam.getParameterName().image); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/params/ParameterExactMatch.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.params; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.ASTFormalParameter; 4 | import org.incava.diffj.element.Differences; 5 | 6 | public class ParameterExactMatch extends ParameterMatch { 7 | public ParameterExactMatch(ASTFormalParameter fromFormalParam, int index, int typeMatch, int nameMatch, Parameters toParams) { 8 | super(fromFormalParam, index, typeMatch, nameMatch, toParams); 9 | } 10 | 11 | public void diff(Differences differences) { 12 | // no difference. 13 | } 14 | } -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/params/ParameterExactNameMatch.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.params; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.ASTFormalParameter; 4 | import org.incava.diffj.element.Differences; 5 | 6 | public class ParameterExactNameMatch extends ParameterMatch { 7 | public ParameterExactNameMatch(ASTFormalParameter fromFormalParam, int index, int typeMatch, int nameMatch, Parameters toParams) { 8 | super(fromFormalParam, index, typeMatch, nameMatch, toParams); 9 | } 10 | 11 | public void diff(Differences differences) { 12 | ASTFormalParameter toFormalParam = toParams.getParameter(index); 13 | Parameter toParam = new Parameter(toFormalParam); 14 | String fromType = fromParam.getParameterType(); 15 | String toType = toParam.getParameterType(); 16 | differences.changed(fromFormalParam, toFormalParam, Parameters.PARAMETER_TYPE_CHANGED, fromType, toType); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/params/ParameterExactTypeMatch.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.params; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.ASTFormalParameter; 4 | import net.sourceforge.pmd.lang.java.ast.Token; 5 | import org.incava.diffj.element.Differences; 6 | 7 | public class ParameterExactTypeMatch extends ParameterMatch { 8 | public ParameterExactTypeMatch(ASTFormalParameter fromFormalParam, int index, int typeMatch, int nameMatch, Parameters toParams) { 9 | super(fromFormalParam, index, typeMatch, nameMatch, toParams); 10 | } 11 | 12 | public void diff(Differences differences) { 13 | Token fromNameTk = getParameterName(); 14 | Token toNameTk = toParams.getParameterName(index); 15 | differences.changed(fromNameTk, toNameTk, Parameters.PARAMETER_NAME_CHANGED, fromNameTk.image, toNameTk.image); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/params/ParameterNameMatch.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.params; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.ASTFormalParameter; 4 | import net.sourceforge.pmd.lang.java.ast.Token; 5 | import org.incava.diffj.element.Differences; 6 | 7 | public class ParameterNameMatch extends ParameterMatch { 8 | public ParameterNameMatch(ASTFormalParameter fromFormalParam, int index, int typeMatch, int nameMatch, Parameters toParams) { 9 | super(fromFormalParam, index, typeMatch, nameMatch, toParams); 10 | } 11 | 12 | public void diff(Differences differences) { 13 | int toIdx = getNameMatch(); 14 | Token fromNameTk = fromParam.getParameterName(); 15 | ASTFormalParameter toParam = toParams.getParameter(toIdx); 16 | differences.changed(fromFormalParam, toParam, Parameters.PARAMETER_REORDERED, fromNameTk.image, index, toIdx); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/params/ParameterNoMatch.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.params; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.ASTFormalParameter; 4 | import net.sourceforge.pmd.lang.java.ast.Token; 5 | import org.incava.diffj.element.Differences; 6 | 7 | public class ParameterNoMatch extends ParameterMatch { 8 | public ParameterNoMatch(ASTFormalParameter fromFormalParam, int index, int typeMatch, int nameMatch, Parameters toParams) { 9 | super(fromFormalParam, index, typeMatch, nameMatch, toParams); 10 | } 11 | 12 | public void diff(Differences differences) { 13 | Token fromNameTk = getParameterName(); 14 | differences.changed(fromFormalParam, toParams.getFormalParameters(), Parameters.PARAMETER_REMOVED, fromNameTk.image); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/params/ParameterTypeComparison.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.params; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | public class ParameterTypeComparison { 9 | private final List exactMatches; 10 | private final Map misorderedMatches; 11 | 12 | public ParameterTypeComparison() { 13 | exactMatches = new ArrayList(); 14 | misorderedMatches = new HashMap(); 15 | } 16 | 17 | public void addExactMatch(Integer idx) { 18 | exactMatches.add(idx); 19 | } 20 | 21 | public void addMisorderedMatch(Integer fromIdx, Integer toIdx) { 22 | misorderedMatches.put(fromIdx, toIdx); 23 | } 24 | 25 | public List getExactMatches() { 26 | return exactMatches; 27 | } 28 | 29 | public Map getMisorderedMatches() { 30 | return misorderedMatches; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/params/ParameterTypeMatch.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.params; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.ASTFormalParameter; 4 | import net.sourceforge.pmd.lang.java.ast.Token; 5 | import org.incava.diffj.element.Differences; 6 | 7 | public class ParameterTypeMatch extends ParameterMatch { 8 | public ParameterTypeMatch(ASTFormalParameter fromFormalParam, int index, int typeMatch, int nameMatch, Parameters toParams) { 9 | super(fromFormalParam, index, typeMatch, nameMatch, toParams); 10 | } 11 | 12 | public void diff(Differences differences) { 13 | int toIdx = getTypeMatch(); 14 | Token fromNameTk = fromParam.getParameterName(); 15 | Token toNameTk = toParams.getParameterName(toIdx); 16 | if (fromNameTk.image.equals(toNameTk.image)) { 17 | differences.changed(fromNameTk, toNameTk, Parameters.PARAMETER_REORDERED, fromNameTk.image, index, toIdx); 18 | } 19 | else { 20 | differences.changed(fromNameTk, toNameTk, Parameters.PARAMETER_REORDERED_AND_RENAMED, fromNameTk.image, index, toIdx, toNameTk.image); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/params/ParameterTypes.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.params; 2 | 3 | import java.util.List; 4 | import org.incava.ijdk.util.ListComparator; 5 | import org.incava.ijdk.util.ListComparison; 6 | 7 | public class ParameterTypes { 8 | private final List paramTypes; 9 | 10 | public ParameterTypes(List paramTypes) { 11 | this.paramTypes = paramTypes; 12 | } 13 | 14 | public double getMatchScore(ParameterTypes toParmTyp) { 15 | return getMatchScore(toParmTyp.paramTypes); 16 | } 17 | 18 | public double getMatchScore(List toParamTypes) { 19 | if (paramTypes.isEmpty() && toParamTypes.isEmpty()) { 20 | return 3; 21 | } 22 | 23 | // (int[], double, String) <=> (int[], double, String) ==> 100% (3 of 3) 24 | // (int[], double, String) <=> (double, int[], String) ==> 80% (3 of 3 - 10% * misordered) 25 | // (int[], double) <=> (double, int[], String) ==> 46% (2 of 3 - 10% * misordered) 26 | // (int[], double, String) <=> (String) ==> 33% (1 of 3 params) 27 | // (int[], double) <=> (String) ==> 0 (0 of 3) 28 | 29 | ListComparator lc = new ListComparator(paramTypes, toParamTypes); 30 | 31 | ListComparison comp = lc.getComparison(); 32 | 33 | // I used to diff both ways ((paramTypes, toParamTypes) and 34 | // (toParamTypes, paramTypes)), but that doesn't appear to be necessary. 35 | 36 | int numParams = Math.max(paramTypes.size(), toParamTypes.size()); 37 | return 1 + (comp.getExactMatches().size() * 2 + comp.getMisorderedMatches().keySet().size()) / numParams; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/type/Extends.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.type; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; 4 | import net.sourceforge.pmd.lang.java.ast.AbstractJavaNode; 5 | import org.incava.diffj.util.Messages; 6 | import org.incava.ijdk.text.Message; 7 | 8 | /** 9 | * Compares extends. 10 | */ 11 | public class Extends extends Supers { 12 | public static final Message EXTENDED_TYPE_REMOVED = new Message("extended type removed: {0}"); 13 | public static final Message EXTENDED_TYPE_ADDED = new Message("extended type added: {0}"); 14 | public static final Message EXTENDED_TYPE_CHANGED = new Message("extended type changed from {0} to {1}"); 15 | public static final Messages EXTENDED_TYPE_MSGS = new Messages(EXTENDED_TYPE_ADDED, EXTENDED_TYPE_CHANGED, EXTENDED_TYPE_REMOVED); 16 | 17 | public Extends(ASTClassOrInterfaceDeclaration decl) { 18 | super(decl); 19 | } 20 | 21 | protected Class getPmdClass() { 22 | return net.sourceforge.pmd.lang.java.ast.ASTExtendsList.class; 23 | } 24 | 25 | protected Message getAddedMessage() { 26 | return EXTENDED_TYPE_MSGS.getAdded(); 27 | } 28 | 29 | protected Message getChangedMessage() { 30 | return EXTENDED_TYPE_MSGS.getChanged(); 31 | } 32 | 33 | protected Message getRemovedMessage() { 34 | return EXTENDED_TYPE_MSGS.getDeleted(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/type/Implements.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.type; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; 4 | import net.sourceforge.pmd.lang.java.ast.AbstractJavaNode; 5 | import org.incava.ijdk.text.Message; 6 | import org.incava.diffj.util.Messages; 7 | 8 | /** 9 | * Compares implements. 10 | */ 11 | public class Implements extends Supers { 12 | public static final Message IMPLEMENTED_TYPE_REMOVED = new Message("implemented type removed: {0}"); 13 | public static final Message IMPLEMENTED_TYPE_ADDED = new Message("implemented type added: {0}"); 14 | public static final Message IMPLEMENTED_TYPE_CHANGED = new Message("implemented type changed from {0} to {1}"); 15 | public static final Messages IMPLEMENTED_TYPE_MSGS = new Messages(IMPLEMENTED_TYPE_ADDED, IMPLEMENTED_TYPE_CHANGED, IMPLEMENTED_TYPE_REMOVED); 16 | 17 | public Implements(ASTClassOrInterfaceDeclaration decl) { 18 | super(decl); 19 | } 20 | 21 | protected Class getPmdClass() { 22 | return net.sourceforge.pmd.lang.java.ast.ASTImplementsList.class; 23 | } 24 | 25 | protected Message getAddedMessage() { 26 | return IMPLEMENTED_TYPE_MSGS.getAdded(); 27 | } 28 | 29 | protected Message getChangedMessage() { 30 | return IMPLEMENTED_TYPE_MSGS.getChanged(); 31 | } 32 | 33 | protected Message getRemovedMessage() { 34 | return IMPLEMENTED_TYPE_MSGS.getDeleted(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/type/InnerTypes.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.type; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; 4 | 5 | public class InnerTypes extends Items { 6 | public InnerTypes(ASTClassOrInterfaceDeclaration typeDecl) { 7 | super(typeDecl, ASTClassOrInterfaceDeclaration.class); 8 | } 9 | 10 | public Type getAstType(ASTClassOrInterfaceDeclaration typeDecl) { 11 | return new Type(typeDecl); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/type/NameToDecl.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.type; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import java.util.HashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | import java.util.TreeSet; 9 | import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; 10 | import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceType; 11 | import net.sourceforge.pmd.lang.java.ast.AbstractJavaNode; 12 | import org.incava.pmdx.Node; 13 | import org.incava.pmdx.SimpleNodeUtil; 14 | 15 | /** 16 | * The list of supertypes for 'extends' and 'implements'. 17 | */ 18 | public class NameToDecl { 19 | private final Map map; 20 | 21 | public NameToDecl(ASTClassOrInterfaceDeclaration decl, Class extImpClass) { 22 | this.map = new HashMap(); 23 | AbstractJavaNode list = Node.of(decl).findChild(extImpClass); 24 | 25 | if (list == null) { 26 | return; 27 | } 28 | 29 | Collection types = Node.of(list).findChildren(ASTClassOrInterfaceType.class); 30 | for (ASTClassOrInterfaceType type : types) { 31 | map.put(Node.of(type).toString(), type); 32 | } 33 | } 34 | 35 | public boolean hasOne() { 36 | return map.size() == 1; 37 | } 38 | 39 | public ASTClassOrInterfaceType get(String name) { 40 | return map.get(name); 41 | } 42 | 43 | public Collection getNames() { 44 | return new TreeSet(map.keySet()); 45 | } 46 | 47 | protected String getFirstName() { 48 | return map.keySet().iterator().next(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/type/TypeDeclarationList.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.type; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceBody; 6 | import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceBodyDeclaration; 7 | import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; 8 | import net.sourceforge.pmd.lang.java.ast.AbstractJavaNode; 9 | import org.incava.pmdx.TypeDeclarationUtil; 10 | import org.incava.pmdx.Node; 11 | 12 | public class TypeDeclarationList extends ArrayList { 13 | private static final long serialVersionUID = 1L; 14 | 15 | /** 16 | * Initializes a list of all methods, fields, constructors, and inner 17 | * classes and interfaces for the class/interface declaration. 18 | */ 19 | public TypeDeclarationList(ASTClassOrInterfaceDeclaration coid) { 20 | ASTClassOrInterfaceBody body = Node.of(coid).findChild(ASTClassOrInterfaceBody.class); 21 | List decls = Node.of(body).findChildren(ASTClassOrInterfaceBodyDeclaration.class); 22 | addAll(decls); 23 | } 24 | 25 | public List getDeclarationsOfClass(Class cls) { 26 | List declList = new ArrayList(); 27 | 28 | for (ASTClassOrInterfaceBodyDeclaration decl : this) { 29 | ItemType dec = Node.of(decl).hasChildren() ? Node.of(decl).findChild(cls) : null; 30 | if (dec != null) { 31 | declList.add(dec); 32 | } 33 | } 34 | 35 | return declList; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/type/TypeModifiers.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.type; 2 | 3 | import net.sourceforge.pmd.lang.java.ast.JavaParserConstants; 4 | import net.sourceforge.pmd.lang.java.ast.AbstractJavaNode; 5 | import org.incava.diffj.element.Modifiers; 6 | 7 | public class TypeModifiers extends Modifiers { 8 | public static final int[] MODIFIERS = new int[] { 9 | JavaParserConstants.ABSTRACT, 10 | JavaParserConstants.FINAL, 11 | JavaParserConstants.STATIC, // valid only for inner types 12 | JavaParserConstants.STRICTFP 13 | }; 14 | 15 | public TypeModifiers(AbstractJavaNode node) { 16 | super(node); 17 | } 18 | 19 | public int[] getModifierTypes() { 20 | return MODIFIERS; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/util/DiffPoint.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.util; 2 | 3 | public class DiffPoint { 4 | private final Integer startPoint; 5 | private final Integer endPoint; 6 | 7 | public DiffPoint(Integer startPoint, Integer endPoint) { 8 | this.startPoint = startPoint; 9 | this.endPoint = endPoint; 10 | } 11 | 12 | public Integer getStart() { 13 | return startPoint; 14 | } 15 | 16 | public Integer getEnd() { 17 | return endPoint; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/util/DiffRange.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.util; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * Two diff points, delete and add. 7 | */ 8 | public class DiffRange { 9 | private final DiffPoint deleted; 10 | private final DiffPoint added; 11 | 12 | public DiffRange(DiffPoint deleted, DiffPoint added) { 13 | this.deleted = deleted; 14 | this.added = added; 15 | } 16 | 17 | public DiffPoint getDeletedPoint() { 18 | return deleted; 19 | } 20 | 21 | public DiffPoint getAddedPoint() { 22 | return added; 23 | } 24 | 25 | public Integer getDeletedStart() { 26 | return deleted.getStart(); 27 | } 28 | 29 | public Integer getDeletedEnd() { 30 | return deleted.getEnd(); 31 | } 32 | 33 | public Integer getAddedStart() { 34 | return added.getStart(); 35 | } 36 | 37 | public Integer getAddedEnd() { 38 | return added.getEnd(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/util/ListComparator.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.util; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class ListComparator { 7 | private final List from; 8 | private final List to; 9 | 10 | public ListComparator(List from, List to) { 11 | this.from = new ArrayList(from); 12 | this.to = new ArrayList(to); 13 | } 14 | 15 | public ListComparison getComparison() { 16 | ListComparison comp = new ListComparison(); 17 | for (int idx = 0; idx < from.size(); ++idx) { 18 | Integer paramMatch = getListMatch(idx); 19 | if (paramMatch == null) { 20 | continue; 21 | } 22 | else if (paramMatch == idx) { 23 | comp.addExactMatch(idx); 24 | } 25 | else { 26 | comp.addMisorderedMatch(idx, paramMatch); 27 | } 28 | } 29 | return comp; 30 | } 31 | 32 | public void clearMatchList(int fromIndex, int toIndex) { 33 | from.set(fromIndex, null); 34 | to.set(toIndex, null); 35 | } 36 | 37 | public Integer getListMatch(int fromIndex) { 38 | int fromSize = from.size(); 39 | Type fromVal = fromIndex < fromSize ? from.get(fromIndex) : null; 40 | 41 | if (fromVal == null) { 42 | return null; 43 | } 44 | 45 | int toSize = to.size(); 46 | Type toVal = fromIndex < toSize ? to.get(fromIndex) : null; 47 | 48 | if (fromVal.equals(toVal)) { 49 | clearMatchList(fromIndex, fromIndex); 50 | return fromIndex; 51 | } 52 | 53 | for (int toIdx = 0; toIdx < toSize; ++toIdx) { 54 | toVal = to.get(toIdx); 55 | if (fromVal.equals(toVal)) { 56 | clearMatchList(fromIndex, toIdx); 57 | return toIdx; 58 | } 59 | } 60 | return null; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/util/ListComparison.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.util; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | public class ListComparison { 9 | private final List exactMatches; 10 | private final Map misorderedMatches; 11 | 12 | public ListComparison() { 13 | exactMatches = new ArrayList(); 14 | misorderedMatches = new HashMap(); 15 | } 16 | 17 | public void addExactMatch(Integer idx) { 18 | exactMatches.add(idx); 19 | } 20 | 21 | public void addMisorderedMatch(Integer fromIdx, Integer toIdx) { 22 | misorderedMatches.put(fromIdx, toIdx); 23 | } 24 | 25 | public List getExactMatches() { 26 | return exactMatches; 27 | } 28 | 29 | public Map getMisorderedMatches() { 30 | return misorderedMatches; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/incava/diffj/util/Messages.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.util; 2 | 3 | import org.incava.ijdk.text.Message; 4 | 5 | public class Messages { 6 | private final Message addedMsg; 7 | private final Message changedMsg; 8 | private final Message deletedMsg; 9 | 10 | public Messages(Message addedMsg, Message changedMsg, Message deletedMsg) { 11 | this.addedMsg = addedMsg; 12 | this.changedMsg = changedMsg; 13 | this.deletedMsg = deletedMsg; 14 | } 15 | 16 | public Message getAdded() { 17 | return addedMsg; 18 | } 19 | 20 | public Message getChanged() { 21 | return changedMsg; 22 | } 23 | 24 | public Message getDeleted() { 25 | return deletedMsg; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/incava/ijdk/text/Location.java: -------------------------------------------------------------------------------- 1 | package org.incava.ijdk.text; 2 | 3 | /** 4 | * Code location. 5 | */ 6 | public class Location implements Comparable { 7 | public final int line; 8 | public final int column; 9 | 10 | public Location(int line, int column) { 11 | this.line = line; 12 | this.column = column; 13 | } 14 | 15 | public int getLine() { 16 | return this.line; 17 | } 18 | 19 | public int getColumn() { 20 | return this.column; 21 | } 22 | 23 | public String toString() { 24 | return "" + line + ":" + column; 25 | } 26 | 27 | public boolean equals(Object obj) { 28 | return obj instanceof Location && equals((Location)obj); 29 | } 30 | 31 | public boolean equals(Location other) { 32 | return compareTo(other) == 0; 33 | } 34 | 35 | public int compareTo(Location other) { 36 | int cmp = new Integer(this.line).compareTo(other.getLine()); 37 | if (cmp == 0) { 38 | cmp = new Integer(this.column).compareTo(other.getColumn()); 39 | } 40 | return cmp; 41 | } 42 | 43 | public int hashCode() { 44 | return line * 31 + column; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/incava/ijdk/text/LocationRange.java: -------------------------------------------------------------------------------- 1 | package org.incava.ijdk.text; 2 | 3 | import org.incava.ijdk.lang.ObjectExt; 4 | 5 | /** 6 | * A starting and ending location. 7 | */ 8 | public class LocationRange implements Comparable { 9 | private final Location start; 10 | private final Location end; 11 | 12 | public LocationRange(Location start, Location end) { 13 | this.start = start; 14 | this.end = end; 15 | } 16 | 17 | public Location getStart() { 18 | return this.start; 19 | } 20 | 21 | public Location getEnd() { 22 | return this.end; 23 | } 24 | 25 | public String toString() { 26 | return "[" + start + " .. " + end + "]"; 27 | } 28 | 29 | public boolean equals(Object obj) { 30 | return obj instanceof LocationRange && equals((LocationRange)obj); 31 | } 32 | 33 | public boolean equals(LocationRange other) { 34 | return ObjectExt.equal(other.getStart(), start) && ObjectExt.equal(other.getEnd(), end); 35 | } 36 | 37 | public int compareTo(LocationRange other) { 38 | int cmp = ObjectExt.compare(start, other.start); 39 | if (cmp == 0) { 40 | cmp = ObjectExt.compare(end, other.end); 41 | } 42 | return cmp; 43 | } 44 | 45 | public int hashCode() { 46 | return this.start.hashCode() * 17 + this.end.hashCode(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/incava/ijdk/text/LocationRanges.java: -------------------------------------------------------------------------------- 1 | package org.incava.ijdk.text; 2 | 3 | import org.incava.ijdk.lang.Pair; 4 | 5 | /** 6 | * A pair of location ranges 7 | */ 8 | public class LocationRanges extends Pair { 9 | public LocationRanges(LocationRange from, LocationRange to) { 10 | super(from, to); 11 | } 12 | 13 | public LocationRange from() { 14 | return first(); 15 | } 16 | 17 | public LocationRange to() { 18 | return second(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/incava/ijdk/text/Message.java: -------------------------------------------------------------------------------- 1 | package org.incava.ijdk.text; 2 | 3 | import java.text.MessageFormat; 4 | 5 | public class Message { 6 | private final String pattern; 7 | 8 | public Message(String pattern) { 9 | this.pattern = pattern; 10 | } 11 | 12 | public String format(Object ... args) { 13 | return MessageFormat.format(pattern, args); 14 | } 15 | 16 | public String getPattern() { 17 | return pattern; 18 | } 19 | 20 | public boolean equals(Message other) { 21 | return pattern.equals(other.pattern); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/incava/ijdk/text/TextLocation.java: -------------------------------------------------------------------------------- 1 | package org.incava.ijdk.text; 2 | 3 | /** 4 | * Location of text in a string (or file), denoted by both relative position 5 | * (0-indexed point in a stream) and a line and column number (both of which are 6 | * 1-indexed). 7 | */ 8 | public class TextLocation extends Location { 9 | public final static int UNDEFINED = -317; 10 | 11 | private final int position; 12 | 13 | public TextLocation(int position, int line, int column) { 14 | super(line, column); 15 | this.position = position; 16 | } 17 | 18 | public int getPosition() { 19 | return this.position; 20 | } 21 | 22 | public String toString() { 23 | return "[position: " + this.position + ", line: " + getLine() + ", column: " + getColumn() + "]"; 24 | } 25 | 26 | public boolean equals(Object obj) { 27 | return obj instanceof TextLocation && equals((TextLocation)obj); 28 | } 29 | 30 | public boolean equals(TextLocation other) { 31 | return compareTo(other) == 0; 32 | } 33 | 34 | public int compareTo(TextLocation other) { 35 | int cmp = new Integer(this.position).compareTo(other.getPosition()); 36 | if (cmp == 0) { 37 | cmp = super.compareTo(other); 38 | } 39 | 40 | return cmp; 41 | } 42 | 43 | public int hashCode() { 44 | int hash = super.hashCode(); 45 | return hash * 31 + position; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/incava/ijdk/text/TextRange.java: -------------------------------------------------------------------------------- 1 | package org.incava.ijdk.text; 2 | 3 | import org.incava.ijdk.lang.ObjectExt; 4 | 5 | /** 6 | * A range of text, denoted by starting and ending locations. 7 | */ 8 | public class TextRange { 9 | private final TextLocation start; 10 | private final TextLocation end; 11 | 12 | public TextRange(TextLocation start, TextLocation end) { 13 | this.start = start; 14 | this.end = end; 15 | } 16 | 17 | public TextLocation getStart() { 18 | return this.start; 19 | } 20 | 21 | public TextLocation getEnd() { 22 | return this.end; 23 | } 24 | 25 | public String toString() { 26 | return "[start: " + start + ", end: " + end + "]"; 27 | } 28 | 29 | public boolean equals(Object obj) { 30 | return obj instanceof TextRange && equals((TextRange)obj); 31 | } 32 | 33 | public boolean equals(TextRange other) { 34 | return ObjectExt.equal(other.start, start) && ObjectExt.equal(other.end, end); 35 | } 36 | 37 | public int hashCode() { 38 | return start.hashCode() * 31 + end.hashCode(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/incava/java/Java.java: -------------------------------------------------------------------------------- 1 | package org.incava.java; 2 | 3 | public interface Java { 4 | public final static String SOURCE_1_3 = "1.3"; 5 | public final static String SOURCE_1_4 = "1.4"; 6 | public final static String SOURCE_1_5 = "1.5"; 7 | public final static String SOURCE_1_6 = "1.6"; 8 | public final static String SOURCE_1_7 = "1.7"; 9 | public final static String SOURCE_1_8 = "1.8"; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/org/incava/java/JavaVersionTypes.java: -------------------------------------------------------------------------------- 1 | package org.incava.java; 2 | 3 | public enum JavaVersionTypes { 4 | Version_1_3("1.3"), 5 | Version_1_4("1.4"), 6 | Version_1_5("1.5"), 7 | Version_1_6("1.6"); 8 | 9 | private final String version; 10 | 11 | JavaVersionTypes(String ver) { 12 | version = ver; 13 | } 14 | 15 | public String toString() { 16 | return version; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/site/resources/img/diffj-codechange-statement.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpace/diffj/518a4821bd1227642c41a462c7dc6c023e6450bd/src/site/resources/img/diffj-codechange-statement.png -------------------------------------------------------------------------------- /src/test/java/org/incava/diffj/OutputContextHighlightTest.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj; 2 | 3 | import org.incava.analysis.DetailedReport; 4 | import org.incava.analysis.Report; 5 | import org.incava.ijdk.util.ANSI; 6 | 7 | public class OutputContextHighlightTest extends OutputContextTest { 8 | public OutputContextHighlightTest(String name) { 9 | super(name); 10 | tr.Ace.setVerbose(true); 11 | } 12 | 13 | public boolean highlight() { 14 | return true; 15 | } 16 | 17 | public String adorn(String str, boolean isDelete) { 18 | StringBuilder sb = new StringBuilder(); 19 | sb.append(isDelete ? ANSI.RED : ANSI.YELLOW); 20 | sb.append(str); 21 | sb.append(ANSI.RESET); 22 | 23 | return sb.toString(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/org/incava/diffj/OutputContextNoHighlightTest.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj; 2 | 3 | import org.incava.analysis.DetailedReport; 4 | import org.incava.analysis.Report; 5 | 6 | public class OutputContextNoHighlightTest extends OutputContextTest { 7 | public OutputContextNoHighlightTest(String name) { 8 | super(name); 9 | } 10 | 11 | public boolean highlight() { 12 | return false; 13 | } 14 | 15 | public String adorn(String str, boolean isDelete) { 16 | return str; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/test/java/org/incava/diffj/OutputNoContextTest.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | import org.incava.ijdk.util.ANSI; 7 | 8 | public class OutputNoContextTest extends OutputTest { 9 | public OutputNoContextTest(String name) { 10 | super(name); 11 | } 12 | 13 | public boolean showContext() { 14 | return false; 15 | } 16 | 17 | public void testImportAdded() { 18 | String[] output = doImportAddedTest(); 19 | tr.Ace.log("output", output); 20 | } 21 | 22 | public void testCodeChangedSingleLine() { 23 | String[] output = doCodeChangedSingleLineTest(); 24 | tr.Ace.log("output", output); 25 | } 26 | 27 | public void testCodeChangedMultipleLines() { 28 | String[] output = doCodeChangedMultipleLinesTest(); 29 | 30 | // output doesn't have end-of-lines 31 | List expected = new ArrayList(); 32 | 33 | expected.add("- <=> -"); 34 | expected.add("2c2,3 code changed in Test(int)"); 35 | expected.add("< Test(int i) { i = 1; }"); 36 | expected.add("---"); 37 | expected.add("> int j = 0;"); 38 | expected.add("> i = 2; "); 39 | 40 | assertEquals(expected, Arrays.asList(output)); 41 | } 42 | 43 | public void testCodeDeleted() { 44 | String[] output = doCodeDeletedTest(); 45 | 46 | List expected = new ArrayList(); 47 | 48 | // @todo change so that the non-context output shows the previous block. 49 | expected.add("- <=> -"); 50 | expected.add("3d3 code removed in Test()"); 51 | expected.add("< int j = 0;"); 52 | expected.add("---"); 53 | expected.add("> Test() { int i = -1; }"); 54 | 55 | assertEquals(expected, Arrays.asList(output)); 56 | } 57 | 58 | public void testCodeAdded() { 59 | String[] output = doCodeAddedTest(); 60 | 61 | List expected = new ArrayList(); 62 | 63 | // @todo change so that the non-context output shows the previous block. 64 | expected.add("- <=> -"); 65 | expected.add("4a5 code added in Test()"); 66 | expected.add("< int i = -1;"); 67 | expected.add("---"); 68 | expected.add("> int i = -1, k = 666;"); 69 | 70 | assertEquals(expected, Arrays.asList(output)); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/test/java/org/incava/diffj/field/FieldAccessTest.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.field; 2 | 3 | import org.incava.diffj.ItemsTest; 4 | import org.incava.diffj.util.Lines; 5 | 6 | public class FieldAccessTest extends ItemsTest { 7 | public FieldAccessTest(String name) { 8 | super(name); 9 | } 10 | 11 | public void testAccessAdded() { 12 | evaluate(new Lines("class Test {", 13 | " int i;", 14 | "", 15 | "}"), 16 | 17 | new Lines("class Test {", 18 | "", 19 | " private int i;", 20 | "}"), 21 | 22 | makeAccessAddedRef(locrg(2, 5, 7), locrg(3, 5, 11), "private")); 23 | } 24 | 25 | public void testAccessRemoved() { 26 | evaluate(new Lines("class Test {", 27 | " public int i;", 28 | "", 29 | "}"), 30 | 31 | new Lines("class Test {", 32 | "", 33 | " int i;", 34 | "}"), 35 | 36 | makeAccessRemovedRef(locrg(2, 5, 10), locrg(3, 5, 7), "public")); 37 | } 38 | 39 | public void testAccessChanged() { 40 | evaluate(new Lines("class Test {", 41 | " private int i;", 42 | "", 43 | "}"), 44 | 45 | new Lines("class Test {", 46 | "", 47 | " public int i;", 48 | "}"), 49 | 50 | makeAccessChangedRef(loc(2, 5), loc(3, 5), "private", "public")); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/org/incava/diffj/field/FieldModifierTest.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.field; 2 | 3 | import org.incava.diffj.ItemsTest; 4 | import org.incava.diffj.util.Lines; 5 | 6 | public class FieldModifierTest extends ItemsTest { 7 | public FieldModifierTest(String name) { 8 | super(name); 9 | tr.Ace.setVerbose(true); 10 | } 11 | 12 | public void testModifierAdded() { 13 | evaluate(new Lines("class Test {", 14 | " int i;", 15 | "", 16 | "}"), 17 | 18 | new Lines("class Test {", 19 | "", 20 | " static int i;", 21 | "}"), 22 | 23 | makeModifierRef(locrg(2, 5, 7), locrg(3, 5, 10), null, "static")); 24 | } 25 | 26 | public void testModifierRemoved() { 27 | evaluate(new Lines("class Test {", 28 | " final int i;", 29 | "", 30 | "}"), 31 | 32 | new Lines("class Test {", 33 | "", 34 | " int i;", 35 | "}"), 36 | 37 | makeModifierRef(locrg(2, 5, 9), locrg(3, 5, 7), "final", null)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/org/incava/diffj/field/FieldsTest.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.field; 2 | 3 | import org.incava.analysis.FileDiffAdd; 4 | import org.incava.analysis.FileDiffDelete; 5 | import org.incava.diffj.ItemsTest; 6 | import org.incava.diffj.util.Lines; 7 | import org.incava.ijdk.text.LocationRange; 8 | import org.incava.ijdk.text.Message; 9 | 10 | public class FieldsTest extends ItemsTest { 11 | public FieldsTest(String name) { 12 | super(name); 13 | } 14 | 15 | public void testClassOneFieldAdded() { 16 | evaluate(new Lines("class Test {", 17 | "", 18 | "}"), 19 | 20 | new Lines("class Test {", 21 | "", 22 | " int i;", 23 | "}"), 24 | 25 | new FileDiffAdd(locrg(1, 1, 3, 1), locrg(3, 5, 3, 10), Field.FIELD_ADDED, "i")); 26 | } 27 | 28 | public void testClassOneFieldRemoved() { 29 | evaluate(new Lines("class Test {", 30 | " int i;", 31 | "", 32 | "}"), 33 | 34 | new Lines("class Test {", 35 | "", 36 | "}"), 37 | 38 | new FileDiffDelete(locrg(2, 5, 2, 10), locrg(1, 1, 3, 1), Field.FIELD_REMOVED, "i")); 39 | } 40 | 41 | public void testClassOneFieldRemovedOneFieldAdded() { 42 | evaluate(new Lines("class Test {", 43 | " int i;", 44 | "", 45 | "}"), 46 | 47 | new Lines("class Test {", 48 | " String j;", 49 | "", 50 | "}"), 51 | 52 | new FileDiffAdd(locrg(1, 1, 4, 1), locrg(2, 5, 2, 13), Field.FIELD_ADDED, "j"), 53 | new FileDiffDelete(locrg(2, 5, 2, 10), locrg(1, 1, 4, 1), Field.FIELD_REMOVED, "i")); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/org/incava/diffj/function/CtorAccessTest.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.function; 2 | 3 | import org.incava.diffj.ItemsTest; 4 | import org.incava.diffj.util.Lines; 5 | 6 | public class CtorAccessTest extends ItemsTest { 7 | public CtorAccessTest(String name) { 8 | super(name); 9 | } 10 | 11 | public void testAccessAdded() { 12 | evaluate(new Lines("class Test {", 13 | " Test() {}", 14 | "}"), 15 | 16 | new Lines("class Test {", 17 | " public Test() {}", 18 | "}"), 19 | 20 | makeAccessAddedRef(locrg(2, 5, 8), locrg(2, 5, 10), "public")); 21 | } 22 | 23 | public void testAccessRemoved() { 24 | evaluate(new Lines("class Test {", 25 | " public Test() {}", 26 | "}"), 27 | 28 | new Lines("class Test {", 29 | " Test() {}", 30 | "}"), 31 | 32 | makeAccessRemovedRef(locrg(2, 5, 10), locrg(2, 5, 8), "public")); 33 | } 34 | 35 | public void testAccessChanged() { 36 | evaluate(new Lines("class Test {", 37 | " private Test() {}", 38 | "}"), 39 | 40 | new Lines("class Test {", 41 | " public Test() {}", 42 | "}"), 43 | 44 | makeAccessChangedRef(loc(2, 5), loc(2, 5), "private", "public")); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/org/incava/diffj/function/CtorTest.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.function; 2 | 3 | import org.incava.diffj.ItemsTest; 4 | import org.incava.diffj.io.JavaFile; 5 | import org.incava.diffj.util.Lines; 6 | import org.incava.java.Java; 7 | 8 | public class CtorTest extends ItemsTest { 9 | public CtorTest(String name) { 10 | super(name); 11 | } 12 | 13 | public void testCtorWithParameterizedType() { 14 | //$$$ todo: fix this diff to show the type parameter removed: 15 | evaluate(new Lines("public class LogIterator {", 16 | " public LogIterator() {", 17 | " }", 18 | "}"), 19 | new Lines("public class LogIterator {", 20 | " public LogIterator() {", 21 | " }", 22 | "}"), 23 | Java.SOURCE_1_6, 24 | NO_CHANGES); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/org/incava/diffj/function/CtorsTest.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.function; 2 | 3 | import org.incava.analysis.FileDiffAdd; 4 | import org.incava.analysis.FileDiffDelete; 5 | import org.incava.diffj.ItemsTest; 6 | import org.incava.diffj.util.Lines; 7 | 8 | public class CtorsTest extends ItemsTest { 9 | public CtorsTest(String name) { 10 | super(name); 11 | } 12 | 13 | public void testClassConstructorAdded() { 14 | evaluate(new Lines("class Test {", 15 | "", 16 | "}"), 17 | 18 | new Lines("class Test {", 19 | "", 20 | " Test(String s) {}", 21 | "}"), 22 | 23 | new FileDiffAdd(locrg(1, 1, 3, 1), locrg(3, 5, 21), Ctor.CONSTRUCTOR_ADDED, "Test(String)")); 24 | } 25 | 26 | public void testClassConstructorRemoved() { 27 | evaluate(new Lines("class Test {", 28 | "", 29 | " public Test(int i, double d, float f) {}", 30 | "}"), 31 | 32 | new Lines("class Test {", 33 | "", 34 | "}"), 35 | 36 | new FileDiffDelete(locrg(3, 12, 44), locrg(1, 1, 3, 1), Ctor.CONSTRUCTOR_REMOVED, "Test(int, double, float)")); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/org/incava/diffj/function/MethodAccessTest.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.function; 2 | 3 | import org.incava.diffj.ItemsTest; 4 | import org.incava.diffj.util.Lines; 5 | 6 | public class MethodAccessTest extends ItemsTest { 7 | public MethodAccessTest(String name) { 8 | super(name); 9 | } 10 | 11 | public void testAccessAdded() { 12 | evaluate(new Lines("class Test {", 13 | " void foo() {}", 14 | "", 15 | "}"), 16 | 17 | new Lines("class Test {", 18 | "", 19 | " public void foo() {}", 20 | "}"), 21 | 22 | makeAccessAddedRef(locrg(2, 5, 8), locrg(3, 5, 10), "public")); 23 | } 24 | 25 | public void testAccessRemoved() { 26 | evaluate(new Lines("class Test {", 27 | " public void foo() {}", 28 | "", 29 | "}"), 30 | 31 | new Lines("class Test {", 32 | "", 33 | " void foo() {}", 34 | "}"), 35 | 36 | makeAccessRemovedRef(locrg(2, 5, 10), locrg(3, 5, 8), "public")); 37 | } 38 | 39 | public void testAccessChanged() { 40 | evaluate(new Lines("class Test {", 41 | " private void foo() {}", 42 | "", 43 | "}"), 44 | 45 | new Lines("class Test {", 46 | "", 47 | " public void foo() {}", 48 | "}"), 49 | 50 | makeAccessChangedRef(loc(2, 5), loc(3, 5), "private", "public")); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/org/incava/diffj/function/MethodModifiersTest.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.function; 2 | 3 | import org.incava.diffj.ItemsTest; 4 | import org.incava.diffj.util.Lines; 5 | 6 | public class MethodModifiersTest extends ItemsTest { 7 | public MethodModifiersTest(String name) { 8 | super(name); 9 | } 10 | 11 | public void testModifierAdded() { 12 | evaluate(new Lines("class Test {", 13 | " void foo() {}", 14 | "", 15 | "}"), 16 | 17 | new Lines("class Test {", 18 | "", 19 | " static void foo() {}", 20 | "}"), 21 | 22 | makeModifierRef(locrg(2, 5, 8), locrg(3, 5, 10), null, "static")); 23 | } 24 | 25 | public void testModifierAddedToExisting() { 26 | evaluate(new Lines("class Test {", 27 | " public void foo() {}", 28 | "", 29 | "}"), 30 | 31 | new Lines("class Test {", 32 | "", 33 | " static public void foo() {}", 34 | "}"), 35 | 36 | makeModifierRef(locrg(2, 5, 10), locrg(3, 5, 10), null, "static")); 37 | } 38 | 39 | public void testModifierRemoved() { 40 | evaluate(new Lines("class Test {", 41 | " final void foo() {}", 42 | "", 43 | "}"), 44 | 45 | new Lines("class Test {", 46 | "", 47 | " void foo() {}", 48 | "}"), 49 | 50 | makeModifierRef(locrg(2, 5, 9), locrg(3, 5, 8), "final", null)); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/org/incava/diffj/function/MethodReturnTypeTest.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.function; 2 | 3 | import org.incava.analysis.FileDiffChange; 4 | import org.incava.diffj.ItemsTest; 5 | import org.incava.diffj.util.Lines; 6 | import static org.incava.diffj.function.Method.*; 7 | 8 | public class MethodReturnTypeTest extends ItemsTest { 9 | public MethodReturnTypeTest(String name) { 10 | super(name); 11 | } 12 | 13 | public void testReturnTypeChanged() { 14 | evaluate(new Lines("class Test {", 15 | " Object foo() { return null; }", 16 | "", 17 | "}"), 18 | 19 | new Lines("class Test {", 20 | "", 21 | " Integer foo() { return null; }", 22 | "}"), 23 | 24 | new FileDiffChange(locrg(2, 5, 10), locrg(3, 5, 11), RETURN_TYPE_CHANGED, "Object", "Integer")); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/org/incava/diffj/function/MethodsAnnotatedTest.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.function; 2 | 3 | import org.incava.diffj.ItemsTest; 4 | import org.incava.diffj.util.Lines; 5 | import org.incava.java.Java; 6 | 7 | public class MethodsAnnotatedTest extends ItemsTest { 8 | public MethodsAnnotatedTest(String name) { 9 | super(name); 10 | } 11 | 12 | public void testNoChange() { 13 | evaluate(new Lines("public interface AS {", 14 | " @Foo(name = \"Fred\")", 15 | " Integer getFred();", 16 | "}"), 17 | new Lines("public interface AS {", 18 | " @Foo(name = \"Fred\")", 19 | " Integer getFred();", 20 | "}"), 21 | Java.SOURCE_1_6); 22 | } 23 | 24 | public void testAnnotatedToUnannotated() { 25 | evaluate(new Lines("public interface AS {", 26 | " @Foo(name = \"Fred\")", 27 | " Integer getFred();", 28 | "}"), 29 | new Lines("public interface AS {", 30 | " Integer getFred();", 31 | "}"), 32 | Java.SOURCE_1_6); 33 | } 34 | 35 | public void testUnannotatedToAnnotated() { 36 | evaluate(new Lines("public interface AS {", 37 | " Integer getFred();", 38 | "}"), 39 | new Lines("public interface AS {", 40 | " @Foo(name = \"Fred\")", 41 | " Integer getFred();", 42 | "}"), 43 | Java.SOURCE_1_6); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/org/incava/diffj/function/StaticBlockTest.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.function; 2 | 3 | import org.incava.analysis.FileDiffAdd; 4 | import org.incava.analysis.FileDiffChange; 5 | import org.incava.analysis.FileDiffDelete; 6 | import org.incava.diffj.ItemsTest; 7 | import org.incava.diffj.code.Code; 8 | import org.incava.diffj.util.Lines; 9 | 10 | public class StaticBlockTest extends ItemsTest { 11 | public StaticBlockTest(String name) { 12 | super(name); 13 | } 14 | 15 | public void testStaticBlockRemoved() { 16 | evaluate(new Lines("class Test {", 17 | " { int i; }", 18 | "}"), 19 | 20 | new Lines("class Test {", 21 | "}"), 22 | 23 | new FileDiffDelete(locrg(2, 5, 14), locrg(1, 1, 2, 1), Initializer.STATIC_BLOCK_REMOVED)); 24 | } 25 | 26 | public void testStaticBlockAdded() { 27 | evaluate(new Lines("class Test {", 28 | "}"), 29 | 30 | new Lines("class Test {", 31 | " { int i; }", 32 | "}"), 33 | 34 | new FileDiffAdd(locrg(1, 1, 2, 1), locrg(2, 5, 14), Initializer.STATIC_BLOCK_ADDED)); 35 | } 36 | 37 | public void testStaticBlockChanged() { 38 | evaluate(new Lines("class Test {", 39 | " { int i; }", 40 | "}"), 41 | 42 | new Lines("class Test {", 43 | " { double d; }", 44 | "}"), 45 | 46 | new FileDiffChange(locrg(2, 7, 11), locrg(2, 7, 14), Code.CODE_CHANGED, "static block")); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/org/incava/diffj/type/InnerClassTest.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.type; 2 | 3 | import org.incava.analysis.FileDiffAdd; 4 | import org.incava.analysis.FileDiffDelete; 5 | import org.incava.diffj.ItemsTest; 6 | import org.incava.diffj.util.Lines; 7 | 8 | public class InnerClassTest extends ItemsTest { 9 | public InnerClassTest(String name) { 10 | super(name); 11 | } 12 | 13 | public void testInnerClassAdded() { 14 | evaluate(new Lines("class Test {", 15 | " class ITest {", 16 | " }", 17 | "", 18 | "}"), 19 | 20 | new Lines("class Test {", 21 | "", 22 | " class ITest {", 23 | " class I2Test {", 24 | " }", 25 | " }", 26 | "}"), 27 | 28 | new FileDiffAdd(locrg(2, 5, 3, 5), locrg(4, 9, 5, 9), Type.INNER_CLASS_ADDED, "I2Test")); 29 | } 30 | 31 | public void testInnerClassRemoved() { 32 | evaluate(new Lines("class Test {", 33 | " class ITest {", 34 | " class I2Test {", 35 | " }", 36 | " }", 37 | "", 38 | "}"), 39 | 40 | new Lines("class Test {", 41 | " class ITest {", 42 | " }", 43 | "}"), 44 | 45 | new FileDiffDelete(locrg(3, 9, 4, 9), locrg(2, 5, 3, 5), Type.INNER_CLASS_REMOVED, "I2Test")); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/org/incava/diffj/util/Lines.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.util; 2 | 3 | import org.incava.ijdk.lang.StringExt; 4 | 5 | public class Lines { 6 | private String[] lines; 7 | 8 | public Lines(String ... lines) { 9 | this.lines = new String[lines.length]; 10 | 11 | for (int idx = 0; idx < lines.length; ++idx) { 12 | this.lines[idx] = lines[idx] + "\n"; 13 | } 14 | } 15 | 16 | public String[] get() { 17 | return lines; 18 | } 19 | 20 | public String toString() { 21 | return StringExt.join(lines, ""); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/org/incava/ijdk/text/TextLocationTest.java: -------------------------------------------------------------------------------- 1 | package org.incava.ijdk.text; 2 | 3 | import java.util.*; 4 | import junit.framework.TestCase; 5 | 6 | public class TextLocationTest extends TestCase { 7 | public TextLocationTest(String name) { 8 | super(name); 9 | } 10 | 11 | public void testCtor() { 12 | TextLocation tl = new TextLocation(4, 1, 3); 13 | assertEquals(4, tl.getPosition()); 14 | assertEquals(1, tl.getLine()); 15 | assertEquals(3, tl.getColumn()); 16 | } 17 | 18 | public void testToString() { 19 | TextLocation tl = new TextLocation(4, 1, 3); 20 | assertEquals("[position: 4, line: 1, column: 3]", tl.toString()); 21 | } 22 | 23 | public void testEquals() { 24 | TextLocation a = new TextLocation(4, 1, 3); 25 | TextLocation b = new TextLocation(4, 1, 3); 26 | TextLocation c = new TextLocation(8, 1, 3); 27 | 28 | assertTrue(new TextLocation(4, 1, 3).equals(new TextLocation(4, 1, 3))); 29 | assertTrue(new TextLocation(1, 3, 4).equals(new TextLocation(1, 3, 4))); 30 | 31 | assertFalse(new TextLocation(4, 1, 3).equals(new TextLocation(4, 1, 2))); 32 | assertFalse(new TextLocation(4, 1, 3).equals(new TextLocation(4, 2, 3))); 33 | assertFalse(new TextLocation(4, 1, 3).equals(new TextLocation(5, 1, 3))); 34 | 35 | assertFalse(new TextLocation(4, 1, 3).equals(new Integer(4))); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/org/incava/ijdk/text/TextRangeTest.java: -------------------------------------------------------------------------------- 1 | package org.incava.ijdk.text; 2 | 3 | import java.io.*; 4 | import java.util.*; 5 | import junit.framework.TestCase; 6 | 7 | public class TextRangeTest extends TestCase { 8 | public TextRangeTest(String name) { 9 | super(name); 10 | } 11 | 12 | public void testCtor() { 13 | // TextRange tl = new TextRange(4, 1, 3); 14 | // assertEquals(4, tl.getPosition()); 15 | // assertEquals(1, tl.getLine()); 16 | // assertEquals(3, tl.getColumn()); 17 | } 18 | 19 | public void testToString() { 20 | // TextRange tl = new TextRange(4, 1, 3); 21 | // assertEquals("[position: 4, line: 1, column: 3]", tl.toString()); 22 | } 23 | 24 | public void testEquals() { 25 | // TextRange a = new TextRange(4, 1, 3); 26 | // TextRange b = new TextRange(4, 1, 3); 27 | // TextRange c = new TextRange(8, 1, 3); 28 | 29 | // assertTrue(new TextRange(4, 1, 3).equals(new TextRange(4, 1, 3))); 30 | // assertTrue(new TextRange(1, 3, 4).equals(new TextRange(1, 3, 4))); 31 | 32 | // assertFalse(new TextRange(4, 1, 3).equals(new TextRange(4, 1, 2))); 33 | // assertFalse(new TextRange(4, 1, 3).equals(new TextRange(4, 2, 3))); 34 | // assertFalse(new TextRange(4, 1, 3).equals(new TextRange(5, 1, 3))); 35 | 36 | // assertFalse(new TextRange(4, 1, 3).equals(new Integer(4))); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/org/incava/test/IncavaTestCase.java: -------------------------------------------------------------------------------- 1 | package org.incava.test; 2 | 3 | import junit.framework.TestCase; 4 | import java.util.Arrays; 5 | import java.util.Collection; 6 | import java.util.Iterator; 7 | 8 | public class IncavaTestCase extends TestCase { 9 | public IncavaTestCase(String name) { 10 | super(name); 11 | } 12 | 13 | public IncavaTestCase() { 14 | } 15 | 16 | static protected String toMessage(String msg) { 17 | return msg == null ? "" : msg + "; "; 18 | } 19 | 20 | static public void assertEquals(String msg, Collection expected, Collection actual) { 21 | String m = toMessage(msg); 22 | 23 | // assertEquals(expected.size(), actual.size()); 24 | 25 | int count = Math.max(expected.size(), actual.size()); 26 | Iterator eit = expected.iterator(); 27 | Iterator ait = actual.iterator(); 28 | 29 | for (int ni = 0; ni < count; ++ni) { 30 | Object e = eit.next(); 31 | Object a = ait.next(); 32 | 33 | assertEquals(m + "collection[" + ni + "]", e, a); 34 | } 35 | } 36 | 37 | static public void assertEquals(Collection expected, Collection actual) { 38 | assertEquals(null, expected, actual); 39 | } 40 | 41 | static public void assertEquals(String msg, Object[] expected, Object[] actual) { 42 | assertEquals(msg, Arrays.asList(expected), Arrays.asList(actual)); 43 | } 44 | 45 | static public void assertEquals(Object[] expected, Object[] actual) { 46 | assertEquals(null, expected, actual); 47 | } 48 | 49 | static public void assertEquals(int[] expected, int[] actual) { 50 | assertEquals(null, expected, actual); 51 | } 52 | 53 | static public void assertEquals(String msg, int[] expected, int[] actual) { 54 | String m = toMessage(msg); 55 | for (int ni = 0; ni < Math.max(expected.length, actual.length); ++ni) { 56 | assertEquals(m + "array[" + ni + "]", expected[ni], actual[ni]); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/test/resources/diffj/codecomp/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void f(String s) { 3 | boolean debug = true; 4 | if (debug) System.out.println("foo"); 5 | if (s instanceof String) System.out.println("s: " + s); 6 | 7 | if (true) { bar(); } 8 | 9 | String x = null; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/resources/diffj/codecomp/d0/ChangedCtor.java: -------------------------------------------------------------------------------- 1 | class ChangedCtor { 2 | ChangedCtor() { 3 | boolean debug = true; 4 | if (debug) System.out.println("foo"); 5 | if (s instanceof String) System.out.println("s: " + s); 6 | 7 | if (true) { bar(); } 8 | 9 | String x = null; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/resources/diffj/codecomp/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void f(String s) { 3 | boolean debug = true; 4 | if (s instanceof String) System.out.println("s: " + s); 5 | 6 | if (true) { foo(); } 7 | 8 | String x = null; 9 | String y = null; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/resources/diffj/codecomp/d1/ChangedCtor.java: -------------------------------------------------------------------------------- 1 | class ChangedCtor { 2 | ChangedCtor() { 3 | boolean debug = true; 4 | if (s instanceof String) System.out.println("s: " + s); 5 | 6 | if (true) { foo(); } 7 | 8 | String x = null; 9 | String y = null; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/resources/diffj/codecomp/output-1.3.x.txt: -------------------------------------------------------------------------------- 1 | src/test/resources/diffj/codecomp/d0/Changed.java <=> src/test/resources/diffj/codecomp/d1/Changed.java 2 | 4,5d4 code removed in f(String) 3 | class Changed { 4 | void f(String s) { 5 | boolean debug = true; 6 | ! if (debug) System.out.println("foo"); 7 | !  if (s instanceof String) System.out.println("s: " + s); 8 | 9 | String x = null; 10 | String y = null; 11 | 12 | 7,8d6 code removed in f(String) 13 | if (debug) System.out.println("foo"); 14 | if (s instanceof String) System.out.println("s: " + s); 15 | 16 | ! String x = null; 17 | !  String y = null; 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/test/resources/diffj/example/d0/Changed.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.example; 2 | 3 | import java.util.List; 4 | import java.util.ArrayList; 5 | import java.util.Map; 6 | // import java.text.MessageFormat; 7 | import java.io.File; 8 | 9 | abstract public class Changed 10 | implements Map 11 | { 12 | 13 | public void obsoleteMethod() { 14 | } 15 | 16 | public Changed( int s ) 17 | { 18 | size = s; 19 | } 20 | 21 | private int size; 22 | 23 | // @todo - comment this field 24 | static final public int MAX_SIZE = 317; 25 | 26 | private int idx; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/test/resources/diffj/example/d0/Unchanged.java: -------------------------------------------------------------------------------- 1 | package org.incava.bar; 2 | 3 | import java.util.List; 4 | 5 | import java.io.*; 6 | import java.lang.reflect.*; 7 | 8 | abstract public class Unchanged extends java.util.ArrayList 9 | { 10 | 11 | final static public int MAXIMUM_SIZE = 317; 12 | 13 | abstract double calculate(String str); 14 | 15 | double recalculate(int val, String str) 16 | { 17 | while (val < str.length()) { 18 | val += calculate(str); 19 | } 20 | return val; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/resources/diffj/example/d1/Changed.java: -------------------------------------------------------------------------------- 1 | package org.incava.diffj.example; 2 | 3 | import java.io.File; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | public abstract class Changed implements List { 9 | /** 10 | * The maximum size of this object. 11 | */ 12 | public final static int MAX_SIZE = 317; 13 | 14 | private final int size; 15 | private int index; 16 | 17 | public Changed(int size) { 18 | this.size = size; 19 | } 20 | 21 | public void newMethod() { 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/diffj/example/d1/Unchanged.java: -------------------------------------------------------------------------------- 1 | package org.incava.bar; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.List; 6 | 7 | /** 8 | * This calculates a value from a string. 9 | */ 10 | public abstract class Unchanged extends java.util.ArrayList { 11 | /** 12 | * The maximum length of the string, beyond which processing does not occur. 13 | */ 14 | public static final int MAXIMUM_SIZE = 317; 15 | 16 | /** 17 | * Returns the value calculated for the string. 18 | */ 19 | abstract double calculate(String str); 20 | 21 | /** 22 | * Does some type of calculation. 23 | */ 24 | public double recalculate(int val, String str) { 25 | while (val < str.length()) { 26 | val += calculate(str); 27 | } 28 | return val; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/resources/diffj/imports/section/d0/Added.java: -------------------------------------------------------------------------------- 1 | class SctnAdded { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/imports/section/d0/Removed.java: -------------------------------------------------------------------------------- 1 | import org.incava.sect0.*; 2 | import org.incava.sect1.Removed; 3 | 4 | class SctnRemoved { 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/imports/section/d1/Added.java: -------------------------------------------------------------------------------- 1 | import org.incava.sect0.*; 2 | import org.incava.sect1.Added; 3 | 4 | class SctnAdded { 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/imports/section/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class SctnRemoved { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/imports/statement/d0/Added.java: -------------------------------------------------------------------------------- 1 | import org.incava.NoChange; 2 | 3 | class Added { 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/imports/statement/d0/Removed.java: -------------------------------------------------------------------------------- 1 | import org.incava.NoChange; 2 | import org.incava.Removed; 3 | 4 | class Removed { 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/imports/statement/d1/Added.java: -------------------------------------------------------------------------------- 1 | import org.incava.NoChange; 2 | import org.incava.Added; 3 | 4 | class Added { 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/imports/statement/d1/Removed.java: -------------------------------------------------------------------------------- 1 | import org.incava.NoChange; 2 | 3 | class Removed { 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/packages/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/packages/d0/Changed.java: -------------------------------------------------------------------------------- 1 | package org.incava.fromname; 2 | 3 | class Changed { 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/packages/d0/NoChange.java: -------------------------------------------------------------------------------- 1 | package org.incava.unchanged; 2 | 3 | class NoChange { 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/packages/d0/None.java: -------------------------------------------------------------------------------- 1 | class None { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/packages/d0/Removed.java: -------------------------------------------------------------------------------- 1 | package org.incava.removed; 2 | 3 | class Removed { 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/packages/d1/Added.java: -------------------------------------------------------------------------------- 1 | package org.incava.added; 2 | 3 | class Added { 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/packages/d1/Changed.java: -------------------------------------------------------------------------------- 1 | package org.incava.toname; 2 | 3 | class Changed { 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/packages/d1/NoChange.java: -------------------------------------------------------------------------------- 1 | package org.incava.unchanged; 2 | 3 | class NoChange { 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/packages/d1/None.java: -------------------------------------------------------------------------------- 1 | class None { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/packages/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/access/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/access/d0/Changed.java: -------------------------------------------------------------------------------- 1 | public class Changed { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/access/d0/Removed.java: -------------------------------------------------------------------------------- 1 | public class Removed { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/access/d1/Added.java: -------------------------------------------------------------------------------- 1 | public class Added { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/access/d1/Changed.java: -------------------------------------------------------------------------------- 1 | protected class Changed { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/access/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/access/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | Added() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/access/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | protected Changed() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/access/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | public Removed() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/access/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | protected Added() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/access/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | private Changed() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/access/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | Removed() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/body/codechange/varinit/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added{Added(){int i;}} 2 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/body/codechange/varinit/d0/Changed.java: -------------------------------------------------------------------------------- 1 | /* There was also a Nun, a PRIORESS, */ class 2 | /* That of her smiling was full simple and coy; */ Changed 3 | /* Her greatest oathe was but by Saint Loy; */ { 4 | /* And she was cleped Madame Eglentine. */ Changed 5 | /* Full well she sang the service divine, */ ( 6 | /* Entuned in her nose full seemly; */ ) 7 | /* And French she spake full fair and fetisly */ { 8 | /* After the school of Stratford atte Bow, */ double 9 | /* For French of Paris was to her unknow. */ d 10 | /* At meate was she well y-taught withal; */ = 11 | /* She let no morsel from her lippes fall, */ 3 12 | /* Nor wet her fingers in her sauce deep. */ ; 13 | /* Well could she carry a morsel, and well keep, */ } 14 | /* That no droppe ne fell upon her breast. */ } 15 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/body/codechange/varinit/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | 3 | 4 | 5 | Removed() { String 6 | str = "ess" 7 | ; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/body/codechange/varinit/d0/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged{Unchanged(){char c='A';}} 2 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/body/codechange/varinit/d1/Added.java: -------------------------------------------------------------------------------- 1 | class 2 | Added 3 | { 4 | Added 5 | ( 6 | ) 7 | { 8 | int 9 | i 10 | = 11 | 17 12 | ; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/body/codechange/varinit/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class /* In courtesy was set full much her lest. */ Changed 2 | { /* Her over-lippe wiped she so clean, */ Changed 3 | ( /* That in her cup there was no farthing seen */ ) 4 | { /* Of grease, when she drunken had her draught; */ double 5 | d/* Full seemely after her meat she raught: */= 6 | 42 /* And sickerly she was of great disport, */; 7 | }/* And full pleasant, and amiable of port, */} 8 | /* And pained her to counterfeite cheer */ 9 | /* Of court, and be estately of mannere, */ 10 | /* And to be holden digne of reverence. */ 11 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/body/codechange/varinit/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class 2 | Removed 3 | { 4 | Removed 5 | ( 6 | ) 7 | { 8 | String 9 | s 10 | ; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/body/codechange/varinit/d1/Unchanged.java: -------------------------------------------------------------------------------- 1 | /* But for to speaken of her conscience, */ 2 | /* She was so charitable and so pitous, */ 3 | /* She woulde weep if that she saw a mouse */ 4 | /* Caught in a trap, if it were dead or bled. */ 5 | /* Of smalle houndes had she, that she fed */ 6 | /* With roasted flesh, */ class /* and milk, and wastel bread. */ 7 | /* But sore she wept if one of them were dead, */ 8 | /* Or if men smote it with a yarde smart: */ 9 | /* And all was conscience and tender heart. */ 10 | /* Full seemly her */ Unchanged /* wimple y-pinched was; */ 11 | /* Her nose tretis; her eyen gray as glass; */ 12 | /* Her mouth full small, and thereto soft and red*/ { /*; */ 13 | /* But sickerly she had a fair */ Unchanged /* forehead. */ ( 14 | /* It was almost a spanne broad I trow; */ 15 | /* For hardily she was not undergrow. */ 16 | /* Full fetis was her cloak, as I was ware. */ 17 | /* Of small coral about her arm she bare */ ) 18 | /* A pair of beades,*/ { /* gauded all with green; */ 19 | /* And thereon hung a brooch of gold */ char /* full sheen, */ 20 | /* On which */ c /* was first y-written*/=/* a crown'd A*/'A'/*, */ 21 | /* And*/;/* after, Amor vincit omnia. */ } 22 | /* Another Nun also with her had she, */ 23 | /* [That was her chapelleine, and PRIESTES three.] */ } 24 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/parameters/namechange/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void changed(int size) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/parameters/namechange/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void changed(int sz) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/parameters/onetwo/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | Added(int thickness) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/parameters/onetwo/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | Removed(int size, java.io.InputStream stream) {} 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/parameters/onetwo/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | added(int thickness, int width) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/parameters/onetwo/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | Removed(int size) {} 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/throws/zeroone/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | Added() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/throws/zeroone/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | Removed() throws org.xml.sax.SAXParseException { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/throws/zeroone/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | Added() throws Exception { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/ctor/throws/zeroone/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | Removed() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/ctor/noparams/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | 3 | 4 | public Added(int x) { 5 | } 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/ctor/noparams/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | public Removed(String s) { 3 | } 4 | 5 | public Removed() { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/ctor/noparams/d0/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { 2 | // WHEN that Aprilis, with his showers swoot, 3 | // The drought of March hath pierced to the root, 4 | // And bathed every vein in such licour, 5 | // Of which virtue engender'd is the flower; 6 | // When Zephyrus eke with his swoote breath 7 | // Inspired hath in every holt and heath 8 | // The tender croppes and the younge sun 9 | // Hath in the Ram his halfe course y-run, 10 | // And smalle fowles make melody, 11 | // That sleepen all the night with open eye, 12 | // (So pricketh them nature in their corages); 13 | // Then longe folk to go on pilgrimages, 14 | // And palmers for to seeke strange strands, 15 | // To ferne hallows couth in sundry lands; 16 | // And specially, from every shire's end 17 | // Of Engleland, to Canterbury they wend, 18 | // The holy blissful Martyr for to seek, 19 | // That them hath holpen, when that they were sick. 20 | public Unchanged() { 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/ctor/noparams/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | public Added(int x) { 3 | } 4 | 5 | Added() { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/ctor/noparams/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | 3 | public Removed(String s) { } 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/ctor/noparams/d1/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { 2 | /** Befell that, in that season on a day, 3 | * In Southwark at the Tabard as I lay, 4 | * Ready to wenden on my pilgrimage 5 | * To Canterbury with devout corage, 6 | * At night was come into that hostelry 7 | * Well nine and twenty in a company 8 | * Of sundry folk, by aventure y-fall 9 | * In fellowship*, and pilgrims were they all, 10 | * That toward Canterbury woulde ride. 11 | * The chamber, and the stables were wide, 12 | * And well we weren eased at the best. 13 | * And shortly, when the sunne was to rest, 14 | * So had I spoken with them every one, 15 | * That I was of their fellowship anon, 16 | * And made forword* early for to rise, 17 | * To take our way there as I you devise. 18 | */ 19 | public Unchanged() { 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/ctor/withparams/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | public Added(String str, Double d, int x) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/ctor/withparams/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | public Removed(java.util.List list) { 3 | } 4 | 5 | public Removed(java.util.List list, int idx) { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/ctor/withparams/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | public Added(String str, Double d) { 3 | } 4 | 5 | public Added(String str, Double d, int x) { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/ctor/withparams/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | public Removed(java.util.List list, int idx) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/d0/Added.java: -------------------------------------------------------------------------------- 1 | public class Added { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/d0/Changed.java: -------------------------------------------------------------------------------- 1 | public class Changed implements java.io.DataOutput { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/d0/Removed.java: -------------------------------------------------------------------------------- 1 | public class Removed implements Runnable { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/d1/Added.java: -------------------------------------------------------------------------------- 1 | public class Added { 2 | public void added() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/d1/Changed.java: -------------------------------------------------------------------------------- 1 | public class Changed implements java.io.DataInput { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/d1/Removed.java: -------------------------------------------------------------------------------- 1 | public class Removed { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/field/one/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/field/one/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | protected static String str; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/field/one/d0/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { 2 | 3 | public static final Integer fieldOne; 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/field/one/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | private int i; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/field/one/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/field/one/d1/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { 2 | 3 | final static public Integer fieldOne; 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/field/oneoftwo/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | private static final StringBuilder notadded; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/field/oneoftwo/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | private java.util.List notremoved; 3 | private java.io.File removed; 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/field/oneoftwo/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | private static final StringBuilder notadded; 3 | protected StringBuffer added; 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/field/oneoftwo/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | 3 | private java.util.List notremoved; 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/field/threeofthree/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/field/threeofthree/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | public static int fieldOne; 3 | 4 | public static java.util.List fieldTwo; 5 | 6 | public static java.io.IOException fieldThree; 7 | } 8 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/field/threeofthree/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | 3 | public static java.util.HashMap alpha; 4 | 5 | public static java.text.MessageFormat bravo; 6 | 7 | public static Long charlie; 8 | } 9 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/field/threeofthree/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/cls/outercls/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | 3 | Added() { 4 | } 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/cls/outercls/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | // But natheless, while I have time and space, 3 | // Ere that I farther in this tale pace, 4 | // Me thinketh it accordant to reason, 5 | // To tell you alle the condition 6 | // Of each of them, so as it seemed me, 7 | // And which they weren, and of what degree; 8 | // And eke in what array that they were in: 9 | // And at a Knight then will I first begin. 10 | 11 | public Removed() { 12 | } 13 | 14 | class InnerRemoved { 15 | public int meth() { return -1; } 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/cls/outercls/d0/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { 2 | // WHEN that Aprilis, with his showers swoot, 3 | // The drought of March hath pierced to the root, 4 | // And bathed every vein in such licour, 5 | // Of which virtue engender'd is the flower; 6 | // When Zephyrus eke with his swoote breath 7 | // Inspired hath in every holt and heath 8 | // The tender croppes and the younge sun 9 | // Hath in the Ram his halfe course y-run, 10 | // And smalle fowles make melody, 11 | // That sleepen all the night with open eye, 12 | // (So pricketh them nature in their corages); 13 | // Then longe folk to go on pilgrimages, 14 | // And palmers for to seeke strange strands, 15 | // To ferne hallows couth in sundry lands; 16 | // And specially, from every shire's end 17 | // Of Engleland, to Canterbury they wend, 18 | // The holy blissful Martyr for to seek, 19 | // That them hath holpen, when that they were sick. 20 | public class InnerUnchanged { 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/cls/outercls/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | 3 | class InnerAdded { 4 | public void meth() { 5 | } 6 | } 7 | 8 | Added() { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/cls/outercls/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | 3 | /** A KNIGHT there was, and that a worthy man, 4 | * That from the time that he first began 5 | * To riden out, he loved chivalry, 6 | * Truth and honour, freedom and courtesy. 7 | */ 8 | 9 | // Full worthy was he in his Lorde's war, 10 | // And thereto had he ridden, no man farre, 11 | // As well in Christendom as in Heatheness, 12 | // And ever honour'd for his worthiness 13 | // At Alisandre he was when it was won. 14 | 15 | /* Full often time he had the board begun 16 | Above alle nations in Prusse. */ 17 | 18 | // In Lettowe had he reysed, and in Russe, 19 | // No Christian man so oft of his degree. 20 | // In Grenade at the siege eke had he be 21 | // Of Algesir, and ridden in Belmarie. 22 | 23 | /* 24 | At Leyes was he, and at Satalie, 25 | When they were won; and in the Greate Sea 26 | At many a noble army had he be. 27 | 28 | At mortal battles had he been fifteen, 29 | And foughten for our faith at Tramissene. 30 | In listes thries, and aye slain his foe. 31 | 32 | This ilke worthy knight had been also 33 | Some time with the lord of Palatie, 34 | Against another heathen in Turkie: 35 | And evermore he had a sovereign price. 36 | */ 37 | 38 | public Removed() { 39 | // And though that he was worthy he was wise, 40 | // And of his port as meek as is a maid. 41 | 42 | // He never yet no villainy ne said 43 | // In all his life, unto no manner wight. 44 | 45 | } 46 | 47 | // He was a very perfect gentle knight. 48 | 49 | // But for to telle you of his array, 50 | // His horse was good, but yet he was not gay. 51 | 52 | // Of fustian he weared a gipon, 53 | // Alle besmotter'd with his habergeon, 54 | // For he was late y-come from his voyage, 55 | // And wente for to do his pilgrimage. 56 | } 57 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/cls/outercls/d1/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { 2 | public class InnerUnchanged {} 3 | 4 | /** Befell that, in that season on a day, 5 | * In Southwark at the Tabard as I lay, 6 | * Ready to wenden on my pilgrimage 7 | * To Canterbury with devout corage, 8 | * At night was come into that hostelry 9 | * Well nine and twenty in a company 10 | * Of sundry folk, by aventure y-fall 11 | * In fellowship*, and pilgrims were they all, 12 | * That toward Canterbury woulde ride. 13 | * The chamber, and the stables were wide, 14 | * And well we weren eased at the best. 15 | * And shortly, when the sunne was to rest, 16 | * So had I spoken with them every one, 17 | * That I was of their fellowship anon, 18 | * And made forword* early for to rise, 19 | * To take our way there as I you devise. 20 | */ 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/cls/outeriface/d0/Added.java: -------------------------------------------------------------------------------- 1 | interface Added { 2 | 3 | // With him there was his son, a younge SQUIRE, 4 | // A lover, and a lusty bacheler, 5 | // With lockes crulle as they were laid in press. 6 | // Of twenty year of age he was I guess. 7 | public int methName(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/cls/outeriface/d0/Removed.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Embroider'd was he, as it were a mead 3 | * All full of freshe flowers, white and red. 4 | */ 5 | public interface Removed { 6 | 7 | // Singing he was, or fluting all the day; 8 | // He was as fresh as is the month of May. 9 | public static int num = 2; 10 | 11 | class InnerRemoved { 12 | /** Short was his gown, with sleeves long and wide. 13 | * Well could he sit on horse, and faire ride. */ 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/cls/outeriface/d0/Unchanged.java: -------------------------------------------------------------------------------- 1 | public interface Unchanged { 2 | 3 | // Courteous he was, lowly, and serviceable, 4 | // And carv'd before his father at the table. 5 | 6 | public static final String s = "yeoman"; 7 | 8 | public void method(); 9 | 10 | public class InnerUnchanged { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/cls/outeriface/d1/Added.java: -------------------------------------------------------------------------------- 1 | interface Added { 2 | 3 | public int methName(); 4 | 5 | /** 6 | Of his stature he was of even length, 7 | And wonderly deliver, and great of strength. 8 | And he had been some time in chevachie, 9 | In Flanders, in Artois, and Picardie, 10 | And borne him well, as of so little space, 11 | In hope to standen in his lady's grace. 12 | */ 13 | class InnerAdded { 14 | void meth() {} 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/cls/outeriface/d1/Removed.java: -------------------------------------------------------------------------------- 1 | // He coulde songes make, and well indite, 2 | // Joust, and eke dance, and well pourtray and write. 3 | public interface Removed { 4 | 5 | /* So hot he loved, that by nightertale 6 | * He slept no more than doth the nightingale. 7 | */ 8 | public static int num = 2; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/cls/outeriface/d1/Unchanged.java: -------------------------------------------------------------------------------- 1 | public interface Unchanged { 2 | 3 | 4 | // A YEOMAN had he, and servants no mo' 5 | // At that time, for him list ride so 6 | // And he was clad in coat and hood of green. 7 | public class InnerUnchanged {} 8 | 9 | 10 | public final static String s = "yeoman"; 11 | 12 | public void method(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/iface/outercls/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/iface/outercls/d0/Removed.java: -------------------------------------------------------------------------------- 1 | public class Removed { 2 | 3 | interface InnerRemoved { 4 | } 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/iface/outercls/d0/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { 2 | public interface InnerUnchanged { 3 | } 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/iface/outercls/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | public interface InnerAdded { 3 | public void method(); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/iface/outercls/d1/Removed.java: -------------------------------------------------------------------------------- 1 | public class Removed { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/iface/outercls/d1/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { 2 | public interface InnerUnchanged { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/iface/outeriface/d0/Added.java: -------------------------------------------------------------------------------- 1 | interface Added { 2 | 3 | // With him there was his son, a younge SQUIRE, 4 | // A lover, and a lusty bacheler, 5 | // With lockes crulle as they were laid in press. 6 | // Of twenty year of age he was I guess. 7 | public int methName(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/iface/outeriface/d0/Removed.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Embroider'd was he, as it were a mead 3 | * All full of freshe flowers, white and red. 4 | */ 5 | public interface Removed { 6 | 7 | // Singing he was, or fluting all the day; 8 | // He was as fresh as is the month of May. 9 | public static int num = 2; 10 | 11 | class InnerRemoved { 12 | /** Short was his gown, with sleeves long and wide. 13 | * Well could he sit on horse, and faire ride. */ 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/iface/outeriface/d0/Unchanged.java: -------------------------------------------------------------------------------- 1 | public interface Unchanged { 2 | 3 | // Courteous he was, lowly, and serviceable, 4 | // And carv'd before his father at the table. 5 | 6 | public static final String s = "yeoman"; 7 | 8 | public void method(); 9 | 10 | public class InnerUnchanged { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/iface/outeriface/d1/Added.java: -------------------------------------------------------------------------------- 1 | interface Added { 2 | 3 | public int methName(); 4 | 5 | /** 6 | Of his stature he was of even length, 7 | And wonderly deliver, and great of strength. 8 | And he had been some time in chevachie, 9 | In Flanders, in Artois, and Picardie, 10 | And borne him well, as of so little space, 11 | In hope to standen in his lady's grace. 12 | */ 13 | class InnerAdded { 14 | void meth() {} 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/iface/outeriface/d1/Removed.java: -------------------------------------------------------------------------------- 1 | // He coulde songes make, and well indite, 2 | // Joust, and eke dance, and well pourtray and write. 3 | public interface Removed { 4 | 5 | /* So hot he loved, that by nightertale 6 | * He slept no more than doth the nightingale. 7 | */ 8 | public static int num = 2; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/innertype/iface/outeriface/d1/Unchanged.java: -------------------------------------------------------------------------------- 1 | public interface Unchanged { 2 | 3 | 4 | // A YEOMAN had he, and servants no mo' 5 | // At that time, for him list ride so 6 | // And he was clad in coat and hood of green. 7 | public class InnerUnchanged {} 8 | 9 | 10 | public final static String s = "yeoman"; 11 | 12 | public void method(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/method/noparams/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/method/noparams/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | public void removed() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/method/noparams/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | public void added() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/method/noparams/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/method/withparams/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | public void contender(int x) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/method/withparams/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | public void contender(Double[] dary, StringBuilder sb) { 3 | } 4 | 5 | public void contender() { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/method/withparams/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | public void contender(int x) { 3 | } 4 | 5 | public void contender(String s) { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/declarations/method/withparams/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | public void contender() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/extends/d0/Added.java: -------------------------------------------------------------------------------- 1 | public class Added { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/extends/d0/Changed.java: -------------------------------------------------------------------------------- 1 | public class Changed extends java.text.DateFormat { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/extends/d0/Removed.java: -------------------------------------------------------------------------------- 1 | public class Removed extends java.lang.StringBuilder { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/extends/d1/Added.java: -------------------------------------------------------------------------------- 1 | public class Added extends java.io.File { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/extends/d1/Changed.java: -------------------------------------------------------------------------------- 1 | public class Changed extends java.text.MessageFormat { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/extends/d1/Removed.java: -------------------------------------------------------------------------------- 1 | public class Removed { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/access/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | int added; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/access/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | protected int changed; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/access/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | public int removed; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/access/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | protected int added; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/access/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | private int changed; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/access/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | int removed; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/init/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added{int i;} 2 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/init/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | int i = 2 * 2; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/init/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | String str = "ess"; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/init/d0/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { // blah 2 | int // blah 3 | i // blah 4 | = // blah 5 | 317 // blah 6 | ; // blah 7 | } // blah 8 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/init/d1/Added.java: -------------------------------------------------------------------------------- 1 | class 2 | Added 3 | { 4 | int 5 | i 6 | = 7 | 17 8 | ; 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/init/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | int i = 4; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/init/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | String str; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/init/d1/Unchanged.java: -------------------------------------------------------------------------------- 1 | class 2 | Unchanged{int 3 | i=317;} 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/modifier/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | int index; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/modifier/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | final String str; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/modifier/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | static final int index; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/modifier/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed {String str;} 2 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/init/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | int value; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/init/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | double changed = 3.14; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/init/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | char ch = 'j'; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/init/d0/Unchanged.java: -------------------------------------------------------------------------------- 1 | class 2 | 3 | Unchanged 4 | { 5 | long 6 | length = 7 | 14 /* blah blah blah */; 8 | } 9 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/init/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | int value = 666; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/init/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | double changed = 2.818; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/init/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | char ch; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/init/d1/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { 2 | long length = 14; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/onetwo/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | int index; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/onetwo/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | int index; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/onetwo/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | String firstName, lastName; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/onetwo/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | int index, length; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/onetwo/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | int idx; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/onetwo/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | String firstName; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/renamed/init/codechange/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | double d = 317; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/renamed/init/codechange/d0/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged{String str = "something";} 2 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/renamed/init/codechange/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | double dbl = 3.14; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/renamed/init/codechange/d1/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { 2 | String str = "something"; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/renamed/init/nocodechange/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | double d = 317; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/renamed/init/nocodechange/d0/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged{String str;} 2 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/renamed/init/nocodechange/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | // 3 | double dbl=317; 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/renamed/init/nocodechange/d1/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { 2 | String str; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/renamed/noinit/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | float fl; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/renamed/noinit/d0/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged{String str;} 2 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/renamed/noinit/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | float flotilla; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/field/variable/renamed/noinit/d1/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { 2 | String str; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/implements/onetwo/d0/Added.java: -------------------------------------------------------------------------------- 1 | public class Added implements java.io.Serializable { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/implements/onetwo/d0/Changed.java: -------------------------------------------------------------------------------- 1 | public class Changed implements java.io.DataOutput, java.lang.Comparable { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/implements/onetwo/d0/Removed.java: -------------------------------------------------------------------------------- 1 | public class Removed implements Runnable, java.util.Map { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/implements/onetwo/d1/Added.java: -------------------------------------------------------------------------------- 1 | public class Added implements java.util.List, java.io.Serializable { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/implements/onetwo/d1/Changed.java: -------------------------------------------------------------------------------- 1 | public class Changed implements java.io.DataInput, java.lang.Comparable { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/implements/onetwo/d1/Removed.java: -------------------------------------------------------------------------------- 1 | public class Removed implements java.util.Map { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/implements/zeroone/d0/Added.java: -------------------------------------------------------------------------------- 1 | public class Added { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/implements/zeroone/d0/Changed.java: -------------------------------------------------------------------------------- 1 | public class Changed implements java.io.DataOutput { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/implements/zeroone/d0/Removed.java: -------------------------------------------------------------------------------- 1 | public class Removed implements java.util.Map { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/implements/zeroone/d1/Added.java: -------------------------------------------------------------------------------- 1 | public class Added implements java.lang.Comparable { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/implements/zeroone/d1/Changed.java: -------------------------------------------------------------------------------- 1 | public class Changed implements java.io.DataInput { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/implements/zeroone/d1/Removed.java: -------------------------------------------------------------------------------- 1 | public class Removed { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/access/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | void added() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/access/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | protected void changed() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/access/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | public void removed() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/access/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | protected void added() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/access/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | private void changed() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/access/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | void removed() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/codechange/repeatedtokens/d0/Changed.java: -------------------------------------------------------------------------------- 1 | public class Changed { 2 | 3 | public void methodName(String[] ary) { 4 | String str = null; 5 | for (int index = 0; index < ary.length; index++) { 6 | if (str == null || str.length() < 1) 7 | str = new String(otherMethod(ary[index])); 8 | else 9 | str += SEP + otherMethod(ary[index]); 10 | } 11 | 12 | methodName(str); 13 | } 14 | 15 | public String otherMethod(String str) { 16 | return str; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/codechange/repeatedtokens/d1/Changed.java: -------------------------------------------------------------------------------- 1 | public class Changed { 2 | 3 | public void methodName(String[] ary) { 4 | StringBuilder as = null; 5 | 6 | for (int index = 0; index < ary.length; index++) { 7 | if (index == 0) { 8 | as = new StringBuilder(otherMethod(ary[index])); 9 | } 10 | else { 11 | as.append(SEP).append(otherMethod(ary[index])); 12 | } 13 | } 14 | methodName(as.toString()); 15 | } 16 | 17 | public String otherMethod(String str) { 18 | return str; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/codechange/returnvalue/d0/Changed.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | // 5 | class Changed /* */ { int changed( 6 | 7 | 8 | /** this is 9 | almost as bad as 10 | some formatting 11 | I've seen. */ 12 | 13 | 14 | 15 | 16 | 17 | 18 | ) { 19 | return /** more ignored commentary */ - 20 | 1; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/codechange/returnvalue/d0/Unchanged.java: -------------------------------------------------------------------------------- 1 | class 2 | Unchanged { int 3 | unchanged() { return -1 ; 4 | /** This is an ignored comment. */ 5 | }} 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/codechange/returnvalue/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | int 3 | 4 | 5 | 6 | /** 7 | A YEOMAN had he, and servants no mo' 8 | At that time, for him list ride so 9 | And he was clad in coat and hood of green. 10 | A sheaf of peacock arrows bright and keen 11 | Under his belt he bare full thriftily. 12 | */ 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | changed( ) { return 22 | 23 | 24 | - 2; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/codechange/returnvalue/d1/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { 2 | int unchanged() { 3 | // this comment doesn't matter 4 | return - 5 | 6 | 7 | 8 | 1 9 | 10 | 11 | 12 | 13 | ; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/codechange/statement/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void meth(String str, char ch) { 3 | Integer[ ] ary = new Integer[ str.indexOf ( ch, 317 ) + str.length ( ) ]; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/codechange/statement/d0/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { 2 | void meth(String str, char ch) { 3 | Integer[ ] ary = new Integer[ str.indexOf ( ch, 317 ) + str.length ( ) ]; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/codechange/statement/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void meth(String str, char ch) { 3 | Integer[] ary = new Integer[10 + str.length() + ch]; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/codechange/statement/d1/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { 2 | void meth(String str, char ch) { 3 | Integer[] ary = new Integer[str.indexOf(ch, 317) + str.length()]; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/codechange/varinit/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added{void added(){int i;}} 2 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/codechange/varinit/d0/Changed.java: -------------------------------------------------------------------------------- 1 | /* */ class/* */ 2 | Changed/* */{ /* */void/* */ changed/* */ (/* */ )/* */ {/* */double/* */d/* */=/* */3/* */;/* */}/* */ 3 | /* */ }/* */ 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/codechange/varinit/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | void removed() { 3 | String s = "ess"; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/codechange/varinit/d0/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | void 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | unchanged( 36 | 37 | // no arguments here. 38 | 39 | ){int i=317;}} 40 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/codechange/varinit/d1/Added.java: -------------------------------------------------------------------------------- 1 | class 2 | Added 3 | { 4 | void 5 | added 6 | ( 7 | ) 8 | { 9 | int 10 | i 11 | = 12 | 17 13 | ; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/codechange/varinit/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed 2 | { 3 | void changed (){double d = -17;}// 4 | } 5 | 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/codechange/varinit/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class 2 | Removed 3 | { 4 | void 5 | removed 6 | ( 7 | ) 8 | { 9 | String 10 | s 11 | ; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/codechange/varinit/d1/Unchanged.java: -------------------------------------------------------------------------------- 1 | class 2 | // 3 | Unchanged { void 4 | unchanged() { int 5 | 6 | 7 | 8 | i = 317 9 | ; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/zeroone/d0/Added.java: -------------------------------------------------------------------------------- 1 | abstract class Added { 2 | abstract void added(); 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/zeroone/d0/Removed.java: -------------------------------------------------------------------------------- 1 | abstract class Removed { 2 | void removed() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/zeroone/d1/Added.java: -------------------------------------------------------------------------------- 1 | abstract class Added { 2 | void added() {} 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/body/zeroone/d1/Removed.java: -------------------------------------------------------------------------------- 1 | abstract class Removed { 2 | abstract void removed(); 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/modifier/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | void added() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/modifier/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | final void removed() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/modifier/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | static void added() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/modifier/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | void removed() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/namechange/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void changed(int idx) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/namechange/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void changed(int index) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/onetwo/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | void added(int i) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/onetwo/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | void removed(java.util.List list, java.io.File file) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/onetwo/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | void added(int i, String str) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/onetwo/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | void removed(java.util.List list) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/reorder/rename/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void changed(int idx, double d) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/reorder/rename/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void changed(double dbl, int index) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/reorder/simple/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void changed(int idx, double down) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/reorder/simple/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void changed(double down, int idx) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/reorder/typechange/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void changed(Integer idx, double down) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/reorder/typechange/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void changed(Double down, int idx) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/typechange/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void changed(int i) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/typechange/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void changed(java.util.List i) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/varargs/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void changed(int idx) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/varargs/d0/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { 2 | public Collection put(K key, V value) { 3 | Collection coll = get(key); 4 | 5 | if (coll == null) { 6 | coll = getCollection(); 7 | put(key, coll); 8 | } 9 | 10 | coll.add(value); 11 | 12 | return coll; 13 | } 14 | 15 | public Collection put(K key, V ... values) { 16 | Collection coll = null; 17 | for (V val : values) { 18 | coll = put(key, val); 19 | } 20 | 21 | return coll; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/varargs/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void changed(int index) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/varargs/d1/Unchanged.java: -------------------------------------------------------------------------------- 1 | class Unchanged { 2 | public Collection put(K key, V value) { 3 | Collection coll = get(key); 4 | 5 | if (coll == null) { 6 | coll = getCollection(); 7 | put(key, coll); 8 | } 9 | 10 | coll.add(value); 11 | 12 | return coll; 13 | } 14 | 15 | public Collection put(K key, V ... values) { 16 | Collection coll = null; 17 | for (V val : values) { 18 | coll = put(key, val); 19 | } 20 | 21 | return coll; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/zeroone/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | void added() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/zeroone/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | void removed(Double[] ary) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/zeroone/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | void added(int i) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/parameters/zeroone/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | void removed() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/returntype/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | int changed() { 3 | return -1; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/returntype/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | double changed() { 3 | return -1; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/throws/onetwo/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | void added() throws java.io.EOFException { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/throws/onetwo/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | void removed() throws javax.naming.LimitExceededException, java.rim.ServerRuntimeException { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/throws/onetwo/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | void added() throws java.io.EOFException, java.beans.InstrospectionException { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/throws/onetwo/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void changed(int index) { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/throws/onetwo/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | void removed() throws javax.naming.LimitExceededException { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/throws/reorder/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void changed() throws java.security.PrivilegedActionException, java.awt.HeadlessException { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/throws/reorder/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | void changed() throws java.awt.HeadlessException, java.security.PrivilegedActionException { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/throws/zeroone/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | void added() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/throws/zeroone/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | void removed() throws Exception { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/throws/zeroone/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | void added() throws java.io.IOException { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/method/throws/zeroone/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | void removed() { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/modifiers/d0/Added.java: -------------------------------------------------------------------------------- 1 | public class Added { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/modifiers/d0/Removed.java: -------------------------------------------------------------------------------- 1 | public strictfp class Removed { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/modifiers/d1/Added.java: -------------------------------------------------------------------------------- 1 | public abstract class Added { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/modifiers/d1/Removed.java: -------------------------------------------------------------------------------- 1 | public class Removed { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/semicolon/d0/None.java: -------------------------------------------------------------------------------- 1 | ; 2 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/semicolon/d1/None.java: -------------------------------------------------------------------------------- 1 | ; 2 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/typechange/clstoiface/d0/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/typechange/clstoiface/d1/Changed.java: -------------------------------------------------------------------------------- 1 | interface Changed { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/typechange/ifacetocls/d0/Changed.java: -------------------------------------------------------------------------------- 1 | interface Changed { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/type/typechange/ifacetocls/d1/Changed.java: -------------------------------------------------------------------------------- 1 | class Changed { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/types/d0/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | } 3 | -------------------------------------------------------------------------------- /src/test/resources/diffj/types/d0/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | } 3 | 4 | class TheTypeRemoved { 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/types/d1/Added.java: -------------------------------------------------------------------------------- 1 | class Added { 2 | } 3 | 4 | class TheTypeAdded { 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/diffj/types/d1/Removed.java: -------------------------------------------------------------------------------- 1 | class Removed { 2 | } 3 | --------------------------------------------------------------------------------