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())
check javalang
最新推荐文章于 2024-07-04 16:38:08 发布