Skip to content

Commit

Permalink
Chore: rename old addContext/request to addContext/notify
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Hu <[email protected]>
  • Loading branch information
daniel-hutao committed Nov 15, 2023
1 parent 3863d21 commit affc7e1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 36 deletions.
1 change: 1 addition & 0 deletions src/main/java/ai/devchat/devchat/DevChatActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class DevChatActions {
public static final String SET_OR_UPDATE_KEY_RESPONSE = "setOrUpdateKey/response";
public static final String ADD_CONTEXT_REQUEST = "addContext/request";
public static final String ADD_CONTEXT_RESPONSE = "addContext/response";
public static final String ADD_CONTEXT_NOTIFY = "addContext/notify";
public static final String LIST_COMMANDS_REQUEST = "listCommands/request";
public static final String LIST_COMMANDS_RESPONSE = "listCommands/response";
public static final String LIST_CONVERSATIONS_REQUEST = "listConversations/request";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ai.devchat.devchat.handler;

import ai.devchat.devchat.ActionHandler;
import ai.devchat.devchat.DevChatActionHandler;
import ai.devchat.devchat.DevChatActions;

import com.alibaba.fastjson.JSONObject;

public class AddContextNotifyHandler implements ActionHandler {
private JSONObject metadata;
private JSONObject payload;
private final DevChatActionHandler devChatActionHandler;

public final String RESPONSE_FUNC = "AddContextFromEditor";

public AddContextNotifyHandler(DevChatActionHandler devChatActionHandler) {
this.devChatActionHandler = devChatActionHandler;
}

@Override
public void executeAction() {
devChatActionHandler.sendResponse(DevChatActions.ADD_CONTEXT_NOTIFY, RESPONSE_FUNC, (metadata, payload) -> {
metadata.put("status", "success");
metadata.put("error", "");

payload.put("path", this.payload.getString("path"));
payload.put("content", this.payload.getString("content"));
payload.put("languageId", this.payload.getString("languageId"));
payload.put("startLine", this.payload.getInteger("startLine"));
});
}

public void setMetadata(JSONObject metadata) {
this.metadata = metadata;
}

public void setPayload(JSONObject payload) {
this.payload = payload;
}
}

This file was deleted.

8 changes: 4 additions & 4 deletions src/main/java/ai/devchat/idea/action/AddToDevChatAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ai.devchat.common.Log;
import ai.devchat.devchat.DevChatActionHandler;
import ai.devchat.devchat.handler.AddContextRequestHandler;
import ai.devchat.devchat.handler.AddContextNotifyHandler;
import com.alibaba.fastjson.JSONObject;

public class AddToDevChatAction {
Expand All @@ -24,8 +24,8 @@ public void execute(String filePath, String fileContent, String language, int st
payload.put("languageId", language);
payload.put("startLine", startLine);

AddContextRequestHandler addContextRequestHandler = new AddContextRequestHandler(actionHandler);
addContextRequestHandler.setPayload(payload);
addContextRequestHandler.executeAction();
AddContextNotifyHandler addContextNotifyHandler = new AddContextNotifyHandler(actionHandler);
addContextNotifyHandler.setPayload(payload);
addContextNotifyHandler.executeAction();
}
}

0 comments on commit affc7e1

Please sign in to comment.