pouryafard75 / RM-ASTDiff

MIT License
2 stars 1 forks source link

Support for composite replacements #3

Open tsantalis opened 2 years ago

tsantalis commented 2 years ago

Composite replacement: the resource expressions correspond to extra statements https://github.com/NLPchina/ansj_seg/commit/913704e835169255530c7408cad11ce9a714d4ec#diff-37efb71e313d229310c23302fb8788212cafe759abfdcca86e60fbde9deb7c7cR105

https://github.com/neo4j/neo4j/commit/d3533c1a0716ca114d294b3ea183504c9725698f#diff-b32651bf4edb0ff7028d860d1deed635ff9a5ab38b7e422d4bcca2eeccb36124R144

DataInputStream dis = null;
        try
        {
            FileInputStream fis = new FileInputStream(privateKeyFile);
            dis = new DataInputStream(fis);

becomes

try(DataInputStream in = new DataInputStream(new FileInputStream(privateKeyFile)))

http://refactoring.encs.concordia.ca/oracle/tool-refactorings/RefactoringMiner/TP/Replace%20Loop%20With%20Pipeline

https://github.com/junit-team/junit5/commit/62c433c14ce9d70fa5b82ef385a6e15c22cc0003#diff-3679a3039f048d756df1feebd214cc17df7b0a686dc3be77f24bff5bc61bbf4cR203-R222

https://github.com/kiegroup/drools/commit/1bf2875e9d73e2d1cd3b58200d5300485f890ff5#diff-1e1bf3853477703f78c734cfb42a7cb2a2a0e55e5ac89265a9a9e73982d5438bL231-L233

https://github.com/nutzam/nutz/commit/6599c748ef35d38085703cf3bd41b9b5b6af5f32#diff-d47d95ef90d7f70d88b06a02d8505b58a81c7c1174c2494e56c9b09d090bc6edL307

https://github.com/graphhopper/graphhopper/commit/7f80425b6a0af9bdfef12c8a873676e39e0a04a6#diff-619f379c7f10d178fba87944b27d543e3f36a9d34803fbdd5ab964a8c9f60a86L943

https://github.com/BuildCraft/BuildCraft/commit/6abc40ed4850d74ee6c155f5a28f8b34881a0284#diff-0850b8a596d522bb87b55e5a3799a56612654c4c2b7d86a8157bf2d6bb8e5e0cL353-L356

https://github.com/JetBrains/intellij-community/commit/1b70adbfd49e00194c4c1170ef65e8114d7a2e46#diff-618af48f6b6713ae4367692615f2309a93d3ac39eb4453167d89ed33d0f8e35aL160

https://github.com/apache/giraph/commit/03ade425dd5a65d3a713d5e7d85aa7605956fbd2 if(!conf.isStaticGraph() && !file.delete()) to [if(!conf.isStaticGraph() || serviceWorker.getSuperstep() == BspServiceWorker.INPUT_SUPERSTEP), if(!file.delete())]

While Split to While + If https://github.com/thymeleaf/thymeleaf/commit/378ba37750a9cb1b19a6db434dfa59308f721ea6#diff-fe47a14afb3317314d81d6f5278d04b52ae3ce0d65dedc1d84cb6c40aa3908ceR270-R278

While Split to If + While https://github.com/apache/drill/commit/711992f22ae6d6dfc43bdb4c01bf8f921d175b38#diff-6c459fac9e29d1448e6a4a08041df7c7250f6aed611eaa036a24a529196b490dR148-R151

https://github.com/JetBrains/intellij-community/commit/9f7de200c9aef900596b09327a52d33241a68d9c#diff-ed6bc52ae4591f4de13f2398154358599d6380ef4f524b4442c3176d82fb037cR105-R107

https://github.com/checkstyle/checkstyle/commit/f1afaf83f39b83cc3bd07a2388448b262652a76b#diff-b48cc2ff38026f94180847550cd260a0ebefb4a9cb9635e39f5fa2046311d72bR474

https://github.com/netty/netty/commit/d31fa31cdcc5ea2fa96116e3b1265baa180df58a#diff-ac1404c2792cc01bf80c28d4a352a533a9e8d2937e7b97d65d16842e2b7f1ad4L80-L84

https://github.com/JetBrains/intellij-community/commit/ff46945822eb06b5df7e9c2cee809ca39fcaaf26#diff-195db6e789b2625726917559b766417af74e54362fa8580ca7d4681c8eb3a435R107

https://github.com/open-keychain/open-keychain/commit/c11fef6e7c80681ce69e5fdc7f4796b0b7a18e2b#diff-4d4436d415b26cfa599819885f9510c2da0cd152fcd5e1898a135b29ca90bce8R136-R146

https://github.com/linkedin/rest.li/commit/54fa890a6af4ccf564fb481d3e1b6ad4d084de9e#diff-ad956a39fb8d6f1ba66cc531080cbc28877e2f10781c2633b0ccc321b69d1c00R231-R234 public onRestRequest(req RestRequest, requestContext RequestContext, wireAttrs Map<String,String>, nextFilter NextFilter<RestRequest,RestResponse>) : void req.builder().addHeaderValue(HttpConstants.ACCEPT_ENCODING, _acceptEncodingHeader).build(); is extracted to public addResponseCompressionHeaders(responseCompressionOverride CompressionOption, req RestRequest) : RestRequest

https://github.com/CyanogenMod/android_frameworks_base/commit/910397f2390d6821a006991ed6035c76cbc74897#diff-3915a87990e3c24a5f92c176d5f80db4fcc23d08ed9b59cc3ec048e262ac4491R114-R116

https://github.com/linkedin/rest.li/commit/ec5ea36faa3dd74585bb339beabdba6149ed63be#diff-fdf9da24acd0f3b1439a8ce6c9fd04484e15222cc08f615e837fec6a69426081L55-L57

https://github.com/jfinal/jfinal/commit/881baed894540031bd55e402933bcad28b74ca88#diff-e19efa6dd99d3caacc529cb4b7d1038422f5f791ce618b4c6c48cbf9d2ef68e3R112

https://github.com/iluwatar/java-design-patterns/commit/dd971d8c19bcf3ae8b25956ea6daed0362488cef

jersey/fab1516773d50bf86d9cc37e2f6db13496f0ecae core-server/src/main/java/org/glassfish/jersey/server/internal/scanning/JarFileScanner.java

} catch (final IOException e) {
    LOGGER.log(Level.CONFIG, "Unable to read the next jar entry.", e);
    return false;
} catch (final SecurityException e) {
    LOGGER.log(Level.CONFIG, "Unable to read the next jar entry.", e);
    return false;
}

becomes

} catch (final IOException | SecurityException e) {
    LOGGER.log(Level.CONFIG, LocalizationMessages.JAR_SCANNER_UNABLE_TO_READ_ENTRY(), e);
    return false;
}

https://github.com/Graylog2/graylog2-server/commit/2ef067fc70055fc4d55c75937303414ddcf07e0e

https://github.com/spring-projects/spring-integration/commit/247232bdde24b81814a82100743f77d881aaf06b#diff-e69bfd584978efc415e3ea5cca8bf35c943372e7968d73fe1c4eea27a02d53d4R366

https://github.com/facebook/buck/commit/f26d234e8d3458f34454583c22e3bd5f4b2a5da8#diff-8b1672ed0167e6b7a425fbf4a33be8fc18c01a3a79d830495e4835a41797de14R246

https://github.com/apache/cassandra/commit/35668435090eb47cf8c5e704243510b6cee35a7b#diff-a5de948460b9aa759b9c5af1da662661484df0820d82615af7028089a7e87331R87

https://github.com/addthis/hydra/commit/7fea4c9d5ee97d4a61ad985cadc9c5c0ab2db780#diff-6e31c93704ae2e71e5bcda132ae0f9cb9d6cca9a0169f14cf32bac7697fc7868R75-R80

https://github.com/kiegroup/drools/commit/1bf2875e9d73e2d1cd3b58200d5300485f890ff5#diff-59225e3f98b0396f7a4b33b3de9c5c8aeb2369d213e0ee3575c737179e7f7e60R57-R58

https://github.com/spring-projects/spring-framework/commit/7dd8dc62a5fa08e3cc99d2388ff62f5825151fb9?diff=split#diff-ea43e736983102ff93143d5a8e5a0e63837233bafa3a5f8bae78256211ed9113R230

https://github.com/liferay/liferay-plugins/commit/7c7ecf4cffda166938efd0ae34830e2979c25c7#diff-685c23de6ec190cf9008b52295e9fe3714c9efa7fcd94f7747abb8d56909b154R45-R50

https://github.com/flozender/jgit/commit/45e79a526c7ffebaf8e4758a6cb6b7af05716707?diff=split#diff-61139ff71d8675ad33d046412d1fca65a59c31c8325cc757238d3283eb2219f6R128

tsantalis commented 2 years ago

I added two more Split Conditional cases While Split to If + While https://github.com/apache/drill/commit/711992f22ae6d6dfc43bdb4c01bf8f921d175b38#diff-6c459fac9e29d1448e6a4a08041df7c7250f6aed611eaa036a24a529196b490dR148-R151

https://github.com/JetBrains/intellij-community/commit/9f7de200c9aef900596b09327a52d33241a68d9c#diff-ed6bc52ae4591f4de13f2398154358599d6380ef4f524b4442c3176d82fb037cR105-R107

pouryafard75 commented 1 year ago

Iterator-based while replaced with enhanced-for: The current diff output for the https://github.com/checkstyle/checkstyle/commit/f1afaf83f39b83cc3bd07a2388448b262652a76b#diff-b48cc2ff38026f94180847550cd260a0ebefb4a9cb9635e39f5fa2046311d72bR474 is as follows: image @tsantalis What do we expect to be the proper mappings?

pouryafard75 commented 1 year ago

The current diff output for the StringBuilder declaration in chain decomposed to individual statement https://github.com/jfinal/jfinal/commit/881baed894540031bd55e402933bcad28b74ca88#diff-e19efa6dd99d3caacc529cb4b7d1038422f5f791ce618b4c6c48cbf9d2ef68e3R112 is as follows image Must be checked carefully later

tsantalis commented 1 year ago

@pouryafard75 We could also have an expression mapping between the variable names mListeners and listener I guess you would need a LeafExpression mapping in that case?

tsantalis commented 1 year ago

@pouryafard75 Some of the append calls have not been mapped properly. In general, if the argument is mapped, then the corresponding append calls containing the same argument should be mapped.