check javalang

from os import listdir
import os.path
import javalang

mypath1 = ""

# new

mypath2 = ""

files1 = [os.path.join(mypath1, f) for f in listdir(mypath1) if os.path.isfile(os.path.join(mypath1, f))]
files2 = [os.path.join(mypath2, f) for f in listdir(mypath2) if os.path.isfile(os.path.join(mypath2, f))]

files1p = [javalang.parse.parse(open(f).read()) for f in files1]
files2p = [javalang.parse.parse(open(f).read()) for f in files2]


def getfields():
    pathcsv = os.getcwd() + '/codesneedchangeLogs_end.text'
    file = open(pathcsv, 'w+')
    addressofclass = []
    nameold = []
    namenew = []
    nameoldlen = []
    namenewlen = []
    for e1, e2 in zip(files1p, files2p):
        classpath = ['Class:' + str(e1.types[0].name) + '|' + str(e.declarators[0].name) for e in e1.types[0].fields]
        addressofclass += classpath
        name1 = [str(e.declarators[0].name) for e in e1.types[0].fields]
        nameold += name1
        for i in name1:
            if 'field' not in i:
                nameoldlen.append(i)
        name2 = [str(e.declarators[0].name) for e in e2.types[0].fields]
        namenew += name2
        for i in name2:
            if 'field' not in i:
                namenewlen.append(i)
    print('namenewlen', len(namenewlen), 'nameoldlen', len(nameoldlen))
    cname = sorted([name for name in set(nameold) - set(namenew) if 'field' not in name])
    end = [i for i in addressofclass if i.split('|')[1] in cname]
    print(len(end))
    n = 0
    for i in end:
        n += 1
        print(n, i)
        file.write(str(i) + '\n')
    file.close()
    print(pathcsv)


print(getfields())

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值