Skip to content

Commit

Permalink
feat: add include file in context to editor context menu (#475)
Browse files Browse the repository at this point in the history
* feat: add include file in context to editor context menu

* fix: custom title for IncludeFilesInContextAction in editor context menu
  • Loading branch information
PhilKes authored Apr 18, 2024
1 parent 29b36c5 commit 9666590
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public IncludeFilesInContextAction() {
super(CodeGPTBundle.get("action.includeFilesInContext.title"));
}

public IncludeFilesInContextAction(String customTitleKey) {
super(CodeGPTBundle.get(customTitleKey));
}

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
var project = e.getProject();
Expand Down Expand Up @@ -93,11 +97,6 @@ public void nodeStateChanged(@NotNull CheckedTreeNode node) {
}

private @Nullable FileCheckboxTree getCheckboxTree(DataContext dataContext) {
var psiElement = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
if (psiElement != null) {
return new PsiElementCheckboxTree(psiElement);
}

var selectedVirtualFiles = VIRTUAL_FILE_ARRAY.getData(dataContext);
if (selectedVirtualFiles != null) {
return new VirtualFileCheckboxTree(selectedVirtualFiles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.intellij.openapi.project.Project;
import ee.carlrobert.codegpt.CodeGPTKeys;
import ee.carlrobert.codegpt.ReferencedFile;
import ee.carlrobert.codegpt.actions.IncludeFilesInContextAction;
import ee.carlrobert.codegpt.conversations.message.Message;
import ee.carlrobert.codegpt.settings.configuration.ConfigurationSettings;
import ee.carlrobert.codegpt.toolwindow.chat.ChatToolWindowContentManager;
Expand Down Expand Up @@ -75,6 +76,8 @@ protected void actionPerformed(Project project, Editor editor, String selectedTe
};
group.add(action);
});
group.addSeparator();
group.add(new IncludeFilesInContextAction("action.includeFileInContext.title"));
}
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages/codegpt.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ action.generateCommitMessage.description=Generate commit message
action.generateCommitMessage.serviceWarning=Messages can only be generated with OpenAI or Azure service
action.generateCommitMessage.missingCredentials=Credentials not provided
action.includeFilesInContext.title=Include In Context...
action.includeFileInContext.title=Include File In Context...
action.includeFilesInContext.dialog.title=Include In Context
action.includeFilesInContext.dialog.description=Choose the files that you wish to include in the final prompt
action.includeFilesInContext.dialog.repeatableContext.label=Repeatable context:
Expand Down

0 comments on commit 9666590

Please sign in to comment.