You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support multiple files in the side-by-side diff. In v0.3.0 only one file is supported.
Test:
Use the DevoxxGeniePlugin source code
Add files `AddDirectoryAction' and 'AddFileAction'
Select 'Simple Git Diff' in the settings
Prompt: Add javadoc to both files
Ollama with Llam3.2 is used
Git diff is: both files are present in the 'LLM suggested' side, the 'original code' of AddFileAction is present. So only these changes can be applied easily
LLM response is:
// Filename: AddDirectoryAction.java
package com.devoxx.genie.action;
import com.devoxx.genie.model.LanguageModel;
import com.devoxx.genie.model.ScanContentResult;
import com.devoxx.genie.model.enumarations.ModelProvider;
import com.devoxx.genie.service.DevoxxGenieSettingsService;
import com.devoxx.genie.service.FileListManager;
import com.devoxx.genie.service.LLMModelRegistryService;
import com.devoxx.genie.service.ProjectContentService;
import com.devoxx.genie.ui.settings.DevoxxGenieStateService;
import com.devoxx.genie.ui.util.NotificationUtil;
import com.devoxx.genie.ui.util.WindowContextFormatterUtil;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
/**
* Action to add directory content to clipboard.
*/
public class AddDirectoryAction extends DumbAwareAction {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = e.getProject();
if (project == null) {
return;
}
ensureToolWindowVisible(project);
FileListManager fileListManager = FileListManager.getInstance();
VirtualFile[] children = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
List<VirtualFile> filesToAdd = new ArrayList<>();
for (VirtualFile child : children) {
if (!child.isDirectory() && !fileListManager.contains(child)) {
filesToAdd.add(child);
}
}
if (!filesToAdd.isEmpty()) {
fileListManager.addFiles(filesToAdd);
NotificationUtil.sendNotification(project, "Added " + filesToAdd.size() + " file(s) to prompt context");
} else {
NotificationUtil.sendNotification(project, "No new files to add or only directories selected");
}
}
@Override
public void update(@NotNull AnActionEvent e) {
VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
e.getPresentation().setEnabledAndVisible(files != null && files.length > 0);
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
@Override
public boolean isDumbAware() {
return true;
}
}
// Filename: AddFileAction.java
package com.devoxx.genie.action;
import com.devoxx.genie.service.FileListManager;
import com.devoxx.genie.ui.util.NotificationUtil;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
/**
* Action to add file(s) to prompt context.
*/
public class AddFileAction extends DumbAwareAction {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = e.getProject();
if (project == null) {
return;
}
ensureToolWindowVisible(project);
FileListManager fileListManager = FileListManager.getInstance();
VirtualFile[] selectedFiles = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
if (selectedFiles != null && selectedFiles.length > 0) {
List<VirtualFile> filesToAdd = new ArrayList<>();
for (VirtualFile file : selectedFiles) {
if (!file.isDirectory() && !fileListManager.contains(file)) {
filesToAdd.add(file);
}
}
if (!filesToAdd.isEmpty()) {
fileListManager.addFiles(filesToAdd);
NotificationUtil.sendNotification(project, "Added " + filesToAdd.size() + " file(s) to prompt context");
} else {
NotificationUtil.sendNotification(project, "No new files to add or only directories selected");
}
} else {
NotificationUtil.sendNotification(project, "No files selected");
}
}
@Override
public void update(@NotNull AnActionEvent e) {
VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
e.getPresentation().setEnabledAndVisible(files != null && files.length > 0);
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
@Override
public boolean isDumbAware() {
return true;
}
}
The text was updated successfully, but these errors were encountered:
Follow-up from #339
Support multiple files in the side-by-side diff. In v0.3.0 only one file is supported.
Test:
Git diff is: both files are present in the 'LLM suggested' side, the 'original code' of AddFileAction is present. So only these changes can be applied easily
LLM response is:
The text was updated successfully, but these errors were encountered: