7
7
import com .intellij .openapi .project .Project ;
8
8
import com .intellij .openapi .vfs .LocalFileSystem ;
9
9
import com .intellij .openapi .vfs .VirtualFile ;
10
- import com .shuzijun .leetcode .plugin .model .CodeTypeEnum ;
11
- import com .shuzijun .leetcode .plugin .model .Config ;
12
- import com .shuzijun .leetcode .plugin .model .Constant ;
13
- import com .shuzijun .leetcode .plugin .model .Question ;
10
+ import com .shuzijun .leetcode .plugin .model .*;
14
11
import com .shuzijun .leetcode .plugin .setting .PersistentConfig ;
12
+ import com .shuzijun .leetcode .plugin .setting .ProjectConfig ;
15
13
import com .shuzijun .leetcode .plugin .utils .*;
16
14
import org .apache .commons .lang .StringUtils ;
17
15
import org .apache .http .client .methods .CloseableHttpResponse ;
@@ -54,6 +52,8 @@ public static void openCode(Question question, Project project) {
54
52
VirtualFile vf = LocalFileSystem .getInstance ().refreshAndFindFileByIoFile (file );
55
53
OpenFileDescriptor descriptor = new OpenFileDescriptor (project , vf );
56
54
FileEditorManager .getInstance (project ).openTextEditor (descriptor , false );
55
+ LeetcodeEditor leetcodeEditor = ProjectConfig .getInstance (project ).getDefEditor (vf .getPath ());
56
+ leetcodeEditor .setQuestionId (question .getQuestionId ());
57
57
} else {
58
58
59
59
if (getQuestion (question , codeTypeEnum )) {
@@ -63,6 +63,8 @@ public static void openCode(Question question, Project project) {
63
63
VirtualFile vf = LocalFileSystem .getInstance ().refreshAndFindFileByIoFile (file );
64
64
OpenFileDescriptor descriptor = new OpenFileDescriptor (project , vf );
65
65
FileEditorManager .getInstance (project ).openTextEditor (descriptor , false );
66
+ LeetcodeEditor leetcodeEditor = ProjectConfig .getInstance (project ).getDefEditor (vf .getPath ());
67
+ leetcodeEditor .setQuestionId (question .getQuestionId ());
66
68
}
67
69
}
68
70
}
@@ -179,7 +181,7 @@ public static void SubmitCode(Question question) {
179
181
JSONObject returnObj = JSONObject .parseObject (body );
180
182
cachedThreadPool .execute (new SubmitCheckTask (returnObj , codeTypeEnum , question ));
181
183
MessageUtils .showInfoMsg ("info" , PropertiesUtils .getInfo ("request.pending" ));
182
- }else if (response != null && response .getStatusLine ().getStatusCode () == 429 ){
184
+ } else if (response != null && response .getStatusLine ().getStatusCode () == 429 ) {
183
185
MessageUtils .showInfoMsg ("info" , PropertiesUtils .getInfo ("request.pending" ));
184
186
} else {
185
187
LogUtils .LOG .error ("提交失败:url:" + post .getURI ().getPath () + ";param:" + arg .toJSONString () + ";body:" + EntityUtils .toString (response .getEntity (), "UTF-8" ));
@@ -386,8 +388,8 @@ public void run() {
386
388
String input = jsonObject .getString ("input" );
387
389
String output = jsonObject .getString ("code_output" );
388
390
String expected = jsonObject .getString ("expected_output" );
389
- String outputs = StringUtils .join (jsonObject .getJSONArray ("code_output" ),"\n \t \t " );
390
- MessageUtils .showInfoMsg ("info" , PropertiesUtils .getInfo ("submit.failed" , input , output , expected ,outputs ));
391
+ String outputs = StringUtils .join (jsonObject .getJSONArray ("code_output" ), "\n \t \t " );
392
+ MessageUtils .showInfoMsg ("info" , PropertiesUtils .getInfo ("submit.failed" , input , output , expected , outputs ));
391
393
392
394
MessageUtils .showInfoMsg ("info" , PropertiesUtils .getInfo ("submit.failed" , input , output , expected ));
393
395
if (!"ac" .equals (question .getStatus ())) {
@@ -396,8 +398,8 @@ public void run() {
396
398
}
397
399
}
398
400
} else {
399
- String outputs = StringUtils .join (jsonObject .getJSONArray ("code_output" ),"\n \t \t " );
400
- MessageUtils .showInfoMsg ("info" , PropertiesUtils .getInfo ("submit.run.failed" , buildErrorMsg (jsonObject ),outputs ));
401
+ String outputs = StringUtils .join (jsonObject .getJSONArray ("code_output" ), "\n \t \t " );
402
+ MessageUtils .showInfoMsg ("info" , PropertiesUtils .getInfo ("submit.run.failed" , buildErrorMsg (jsonObject ), outputs ));
401
403
if (!"ac" .equals (question .getStatus ())) {
402
404
question .setStatus ("notac" );
403
405
ViewManager .updateStatus ();
@@ -446,7 +448,7 @@ public RunCodeCheckTask(JSONObject returnObj) {
446
448
@ Override
447
449
public void run () {
448
450
String key = returnObj .getString ("interpret_expected_id" );
449
- if (StringUtils .isBlank (key )){
451
+ if (StringUtils .isBlank (key )) {
450
452
key = returnObj .getString ("interpret_id" );
451
453
}
452
454
for (int i = 0 ; i < 50 ; i ++) {
@@ -471,11 +473,11 @@ public void run() {
471
473
} else if (jsonObject .getJSONArray ("expected_code_answer" ) != null && !jsonObject .getJSONArray ("expected_code_answer" ).isEmpty ()) {
472
474
expected = jsonObject .getJSONArray ("expected_code_answer" ).getString (0 );
473
475
}
474
- String outputs = StringUtils .join (jsonObject .getJSONArray ("code_output" ),"\n \t \t " );
475
- MessageUtils .showInfoMsg ("info" , PropertiesUtils .getInfo ("test.success" , input , output , expected ,outputs ));
476
+ String outputs = StringUtils .join (jsonObject .getJSONArray ("code_output" ), "\n \t \t " );
477
+ MessageUtils .showInfoMsg ("info" , PropertiesUtils .getInfo ("test.success" , input , output , expected , outputs ));
476
478
} else {
477
- String outputs = StringUtils .join (jsonObject .getJSONArray ("code_output" ),"\n \t \t " );
478
- MessageUtils .showInfoMsg ("info" , PropertiesUtils .getInfo ("submit.run.failed" , buildErrorMsg (jsonObject ),outputs ));
479
+ String outputs = StringUtils .join (jsonObject .getJSONArray ("code_output" ), "\n \t \t " );
480
+ MessageUtils .showInfoMsg ("info" , PropertiesUtils .getInfo ("submit.run.failed" , buildErrorMsg (jsonObject ), outputs ));
479
481
}
480
482
return ;
481
483
}
0 commit comments