@@ -31,19 +31,25 @@ void MainWindow::on_actionloadFiles_triggered()
3131 QString file = " diff-backend.exe" ;
3232 qDebug () << file;
3333 backend_process->start (file,lispFiles);
34- if (!backend_process->waitForFinished ()){
34+ if (!backend_process->waitForFinished ()) {
3535 qDebug () << " something is wrong" ;
3636 }
3737
3838 stats = Stat (" stats.json" );
3939 fillStatsTree ();
40- file1 = getJsonDocument (" res1.json" );
41- file2 = getJsonDocument (" res2.json" );
42- analyzeAST (file1,1 );
43- analyzeAST (file2,2 );
40+ synTreeJson1 = getJsonDocument (" res1.json" );
41+ synTreeJson2 = getJsonDocument (" res2.json" );
42+ if (QFile::exists (" comments1.json" )) {
43+ commentsJsonObj1 = getJsonDocument (" comments1.json" ).object ();
44+ }
45+ if (QFile::exists (" comments2.json" )) {
46+ commentsJsonObj2 = getJsonDocument (" comments2.json" ).object ();
47+ }
48+ analyzeSynTree (synTreeJson1,1 );
49+ analyzeSynTree (synTreeJson2,2 );
4450
45- doc1.setTextDescriptionFromJson (QJsonValue (file1 .array ()));
46- doc2.setTextDescriptionFromJson (QJsonValue (file2 .array ()));
51+ doc1.setTextDescriptionFromJson (QJsonValue (synTreeJson1 .array ()),commentsJsonObj1 );
52+ doc2.setTextDescriptionFromJson (QJsonValue (synTreeJson2 .array ()),commentsJsonObj2 );
4753 ui->plainTextEdit ->appendHtml (doc1.getText ());
4854 ui->plainTextEdit_2 ->appendHtml (doc2.getText ());
4955}
@@ -99,7 +105,7 @@ void MainWindow::fillStatsTree()
99105 defunsStats->addChild (dels);
100106}
101107
102- void MainWindow::analyzeAST (QJsonDocument &doc, int num)
108+ void MainWindow::analyzeSynTree (QJsonDocument &doc, int num)
103109{
104110 const auto & topLevelArray = doc.array ();
105111 for (const auto & obj: topLevelArray){
@@ -117,7 +123,7 @@ QJsonDocument MainWindow::getJsonDocument(QString pathname)
117123{
118124 QFile loadFile (pathname);
119125 if (!loadFile.open (QIODevice::ReadOnly)){
120- qWarning (" Couldn't open save file." );
126+ qWarning (" Couldn't open file." );
121127 return QJsonDocument ();
122128 }
123129
@@ -131,20 +137,20 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column)
131137 qDebug () << item->text (0 );
132138 QString text = item->text (0 );
133139 if (text == " all" ){
134- doc1.setTextDescriptionFromJson (QJsonValue (file1 .array ()));
135- doc2.setTextDescriptionFromJson (QJsonValue (file2 .array ()));
140+ doc1.setTextDescriptionFromJson (QJsonValue (synTreeJson1 .array ()), commentsJsonObj1 );
141+ doc2.setTextDescriptionFromJson (QJsonValue (synTreeJson2 .array ()), commentsJsonObj2 );
136142 ui->plainTextEdit ->clear ();
137143 ui->plainTextEdit_2 ->clear ();
138144 ui->plainTextEdit ->appendHtml (doc1.getText ());
139145 ui->plainTextEdit_2 ->appendHtml (doc2.getText ());
140146 } else {
141147 if (nameToObj1.contains (text)){
142- doc1.setTextDescriptionFromJson (QJsonValue (nameToObj1[text]),false );
148+ doc1.setTextDescriptionFromJson (QJsonValue (nameToObj1[text]), commentsJsonObj1, false );
143149 ui->plainTextEdit ->clear ();
144150 ui->plainTextEdit ->appendHtml (doc1.getText ());
145151 }
146152 if (nameToObj2.contains (text)){
147- doc2.setTextDescriptionFromJson (QJsonValue (nameToObj2[text]),false );
153+ doc2.setTextDescriptionFromJson (QJsonValue (nameToObj2[text]), commentsJsonObj2, false );
148154 ui->plainTextEdit_2 ->clear ();
149155 ui->plainTextEdit_2 ->appendHtml (doc2.getText ());
150156 }
0 commit comments