Skip to content

Commit

Permalink
Remove Query Hints as can be done from chat
Browse files Browse the repository at this point in the history
  • Loading branch information
jShiwaniGupta committed Oct 24, 2024
1 parent f5bb110 commit ff697e1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public JPanel getParentPanel() {
return parentPanel;
}

public String getAllJavaEditorText() {
public String getAllCodeEditorText() {
StringBuilder allText = new StringBuilder();
for (int i = 0; i < parentPanel.getComponentCount(); i++) {
if (parentPanel.getComponent(i) instanceof JEditorPane editorPane) {
Expand Down Expand Up @@ -318,7 +318,7 @@ public String getAllEditorText() {
return allText.toString().trim();
}

public int getAllJavaEditorCount() {
public int getAllCodeEditorCount() {
int count = 0;
for (int i = 0; i < parentPanel.getComponentCount(); i++) {
if (parentPanel.getComponent(i) instanceof JEditorPane) {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/io/github/jeddict/ai/hints/JeddictHint.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ public static ErrorDescription run(HintContext ctx) {
fixes.add(new RestEndpointFix(tpHandle, Action.CREATE, elementHandle).toEditorFix());
}
fixes.add(new LearnFix(tpHandle, Action.LEARN, treePath).toEditorFix());
fixes.add(new LearnFix(tpHandle, Action.QUERY, treePath).toEditorFix());
fixes.add(new LearnFix(tpHandle, Action.TEST, treePath).toEditorFix());
break;
// case IDENTIFIER:
Expand Down Expand Up @@ -157,7 +156,6 @@ public static ErrorDescription run(HintContext ctx) {
}
}
fixes.add(new LearnFix(tpHandle, Action.LEARN, treePath).toEditorFix());
fixes.add(new LearnFix(tpHandle, Action.QUERY, treePath).toEditorFix());
fixes.add(new LearnFix(tpHandle, Action.TEST, treePath).toEditorFix());
}
break;
Expand Down
19 changes: 6 additions & 13 deletions src/main/java/io/github/jeddict/ai/hints/LearnFix.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
import org.openide.filesystems.FileObject;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
import static io.github.jeddict.ai.util.UIUtil.askQuery;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
Expand Down Expand Up @@ -204,13 +203,7 @@ protected void performRewrite(JavaFix.TransformationContext tc) throws Exception
executorService.submit(() -> {
String response;
String fileName = fileObject != null ? fileObject.getName() : null;
if (action == Action.QUERY) {
String query = askQuery();
if (query == null) {
return;
}
response = new JeddictChatModel().generateDescription(null, treePath.getCompilationUnit().toString(), null, null, query);
} else if (action == Action.TEST) {
if (action == Action.TEST) {
if (leaf instanceof MethodTree) {
response = new JeddictChatModel().generateTestCase(null, null, leaf.toString(), null, null);
} else {
Expand Down Expand Up @@ -414,7 +407,7 @@ private JPanel createBottomPanel(String type, String fileName, String title, Con
submitButton.setMaximumSize(buttonSize);
eastButtonPanel.add(submitButton);

int javaEditorCount = topComponent.getAllJavaEditorCount();
int javaEditorCount = topComponent.getAllCodeEditorCount();

// Copy Button with Icon (East)
copyButton = createButton(copyIcon);
Expand Down Expand Up @@ -519,16 +512,16 @@ private JPanel createBottomPanel(String type, String fileName, String title, Con
eastButtonPanel.add(contextButton);

copyButton.addActionListener(e -> {
StringSelection stringSelection = new StringSelection(topComponent.getAllJavaEditorText());
StringSelection stringSelection = new StringSelection(topComponent.getAllCodeEditorText());
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, null);
});
saveButton.addActionListener(e -> {
topComponent.saveAs(null, topComponent.getAllJavaEditorText());
topComponent.saveAs(null, topComponent.getAllCodeEditorText());
});
saveToEditorButton.addActionListener(e -> {
if (action != null) {
action.accept(topComponent.getAllJavaEditorText());
action.accept(topComponent.getAllCodeEditorText());
}
});
newChatButton.addActionListener(e -> {
Expand Down Expand Up @@ -726,7 +719,7 @@ private void updateButtons(JButton prevButton, JButton nextButton) {
prevButton.setEnabled(currentResponseIndex > 0);
nextButton.setEnabled(currentResponseIndex < responseHistory.size() - 1);

int javaEditorCount = topComponent.getAllJavaEditorCount();
int javaEditorCount = topComponent.getAllCodeEditorCount();
copyButton.setEnabled(javaEditorCount > 0);
saveButton.setEnabled(javaEditorCount > 0);

Expand Down

0 comments on commit ff697e1

Please sign in to comment.