Skip to content

Commit

Permalink
Added new command: "RECEIVE_LLM_SNIPPET_MSG" functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
yaad96 committed Apr 2, 2024
1 parent 9fd550e commit a9ba9a8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/FollowAndAuthorRulesProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class FollowAndAuthorRulesProcessor {
private tagTable: Tag[];
private currentProjectPath: string;
public readonly wsMessages: string[] = [
WebSocketConstants.RECEIVE_LLM_SNIPPET_MSG,
WebSocketConstants.RECEIVE_SNIPPET_XML_MSG,
WebSocketConstants.RECEIVE_MODIFIED_RULE_MSG,
WebSocketConstants.RECEIVE_MODIFIED_TAG_MSG,
Expand Down Expand Up @@ -92,10 +93,23 @@ export class FollowAndAuthorRulesProcessor {
const command = jsonData.command;

switch (command) {

case WebSocketConstants.RECEIVE_LLM_SNIPPET_MSG:
console.log("CAME HERE");
const code = jsonData.data.code;
// Format the explanation as a multiline comment
const explanationAsComment = `/*\n * ${jsonData.data.explanation.replace(/\n/g, '\n * ')}\n */\n\n`;

// Create a new split window with the explanation comment at the top and the code below
vscode.workspace.openTextDocument({ content: explanationAsComment + code, language: 'java' }) // Adjust the language as necessary
.then(document => {
vscode.window.showTextDocument(document, { preview: false, viewColumn: vscode.ViewColumn.Beside });
});

case WebSocketConstants.RECEIVE_SNIPPET_XML_MSG:
// Handle RECEIVE_SNIPPET_XML_MSG
const xmlString = jsonData.data.xml;


const tempXmlFilePath = path.join(this.currentProjectPath, Constants.TEMP_XML_FILE);
const xmlHeader = Constants.XML_HEADER;
Expand Down
1 change: 1 addition & 0 deletions src/WebSocketConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export class WebSocketConstants {
static readonly MESSAGE_KEY_COMMAND: string = "command";
static readonly MESSAGE_KEY_DATA: string = "data";

static readonly RECEIVE_LLM_SNIPPET_MSG:string= "LLM_SNIPPET";
static readonly RECEIVE_MODIFIED_RULE_MSG: string = "MODIFIED_RULE";
static readonly RECEIVE_MODIFIED_TAG_MSG: string = "MODIFIED_TAG";
static readonly RECEIVE_SNIPPET_XML_MSG: string = "XML_RESULT";
Expand Down

0 comments on commit a9ba9a8

Please sign in to comment.