Skip to content

Commit

Permalink
update files
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhvani Patel committed Aug 9, 2017
1 parent 0e2179a commit b7ba932
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 19 deletions.
68 changes: 51 additions & 17 deletions Scripts/check_javac_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def checkJavaCSyntax(src):
myFile = open("ToCheck.java", "w")
myFile.write(data)
myFile.close()
proc = subprocess.Popen(['javac', 'ToCheck.java'], stderr=subprocess.PIPE)
proc = subprocess.Popen(['javac', 'ToCheck.java', '-nowarn'], stderr=subprocess.PIPE)
streamdata, err = proc.communicate()
rc = proc.returncode
if rc == 0:
Expand All @@ -64,17 +64,21 @@ def checkJavaCSyntax(src):
#print "split"
#print len(err)
lastErrorNum = err[lastLine:]

#print lastErrorNum
lastError = lastErrorNum[:lastErrorNum.index('error')-1]
numError = int(lastError)


lineNums = []
insToks = []
indRepeats = []
indRepeatsB = []
typeErrors = []
origLineNums = []
origLineNums = []
origLineNumsB = []
flag = False
flagB = False
ind = 0
for ind in range(numError):
fileInd = find_nth(err, "ToCheck.java:", ind+1)
temp = err[fileInd:]
Expand All @@ -98,16 +102,26 @@ def checkJavaCSyntax(src):
insTok = firstLine[errorColInd+7:expectInd-1]
if insTok == "class, interface, or enum":
flag = True
flagB = False
insToks.append("class")
insToks.append("interface")
insToks.append("enum")
typeErrors.append('i')
typeErrors.append('i')
elif insTok == "(\' or \'[":
flagB = True
flag = False
insToks.append("(")
insToks.append("[")
typeErrors.append('i')
else:
flag = False
flagB = False
insToks.append(insTok)

else:
flag = False
flagB = False
typeErrors.append('')
insToks.append('')
cutColInd = find_nth(temp, ":", 2)
Expand All @@ -117,16 +131,23 @@ def checkJavaCSyntax(src):
#print int(line)
lineNums.append(int(line))
origLineNums.append(int(line))
indRepeats.append(origLineNums.index(int(line)))
#indRepeats.append(origLineNums.index(int(line)))
indRepeats.append(ind)
lineNums.append(int(line))
if flagB == True:
lineNums.append(int(line))
origLineNumsB.append(int(line))
indRepeatsB.append(ind)
#indRepeatsB.append(origLineNumsB.index(int(line)))
else:
origLineNums.append(int(line))
origLineNums.append(int(line))
origLineNumsB.append(int(line))
lineNums.append(int(line))

ind += 1
#print lineNums
#print origLineNums
#print "RADHA"

#print indRepeatsB
#print "----OUT----"
checkInd = err.find("is public, should be declared in a file named")
#print msgNo
Expand All @@ -143,13 +164,26 @@ def checkJavaCSyntax(src):
if x == rid:
lineNums.remove(rid)
msgNo = []
#print indRepeats
for x in range(len(lineNums) - (len(indRepeats)*2)):
#print indRepeatsB
msgNoInd = 0
#print
for x in range(len(lineNums) - (( (len(indRepeats)*2) + (len(indRepeatsB)) ) )):
#print x
if x in indRepeats:
#print "TRUE"
msgNo.append(x+1)
msgNo.append(x+1)
msgNo.append(x+1)
msgNo.append(msgNoInd+1)
msgNo.append(msgNoInd+2)
msgNo.append(msgNoInd+3)
msgNoInd += 3
elif x in indRepeatsB:
msgNo.append(msgNoInd+1)
msgNo.append(msgNoInd+2)
msgNoInd += 2
else:
msgNo.append(msgNoInd+1)
msgNoInd += 1
#print msgNo


#print msgNo
#print lineNums
Expand All @@ -160,11 +194,11 @@ def checkJavaCSyntax(src):
return None
else:
#errorObj = CompileError(fileName, line, column, None, text, errorname)
#print err
#print msgNo
#print lineNums
#print insToks
#print typeErrors
print err
print msgNo
print lineNums
print insToks
print typeErrors
#print len(msgNo)
#print len(lineNums)
#print len(insToks)
Expand Down
4 changes: 2 additions & 2 deletions Scripts/create_eclipse_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def createEclipseCSV():
#print len(strPaths)
csvfile = open('eclipse_fixes.csv', 'wb')
datWriter = csv.writer(csvfile, delimiter=',',
quotechar='|', quoting=csv.QUOTE_MINIMAL)
quoting=csv.QUOTE_MINIMAL)

print "START"
fileNum = 0
Expand All @@ -42,7 +42,7 @@ def createEclipseCSV():
tool = "eclipse"
sfid = path[find_nth(path, "/", 4)+1:find_nth(path, "/", 5)]
meid = path[find_nth(path, "/", 5)+1:find_nth(path, "/", 6)]
numTotLines, msgNo, lineNums, insToks, typeErrors = checkEclipseSyntax(path)
numTotLines, msgNo, lineNums, insToks, typeErrors = checkEclipseSyntax(path, False)
#print numTotLines, msgNo, lineNums, insToks, typeErrors
for ind in range(len(msgNo)):
toPut = [tool, sfid, meid, numTotLines, msgNo[ind], lineNums[ind], typeErrors[ind], insToks[ind]]
Expand Down

0 comments on commit b7ba932

Please sign in to comment.