feat: add project context to code completions (#571)

* feat: add context to code completions

* feat: context finder for Python

* feat: improve and refactor context finder for Python

* feat: include method calls in JavaContextFinder

* test: add JavaContextFinder tests

* test: add PythonContextFinder tests

* fix: CompletionContextService thread

* fix: InfillPromptTemplate context files string

* refactor: simplify findRelevantElements for Java and Python

* feat: only add code snippets instead of files for code-completion context

* feat: add default multi-file prompt template

* fix: add Codestral multi-file FIM

* feat: add feature flag for context aware code completions

* feat: truncate project context elements for code completion
This commit is contained in:
Phil 2024-07-03 16:38:03 +02:00 committed by GitHub
parent e6088cc0d8
commit 620226ff1d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 762 additions and 77 deletions

View file

@ -48,6 +48,7 @@ public class ConfigurationComponent {
private final JBCheckBox methodNameGenerationCheckBox;
private final JBCheckBox autoFormattingCheckBox;
private final JBCheckBox autocompletionPostProcessingCheckBox;
private final JBCheckBox autocompletionContextAwareCheckBox;
private final JTextArea systemPromptTextArea;
private final JTextArea commitMessagePromptTextArea;
private final IntegerField maxTokensField;
@ -128,6 +129,10 @@ public class ConfigurationComponent {
CodeGPTBundle.get("configurationConfigurable.autocompletionPostProcessing.label"),
configuration.isAutocompletionPostProcessingEnabled()
);
autocompletionContextAwareCheckBox = new JBCheckBox(
CodeGPTBundle.get("configurationConfigurable.autocompletionContextAwareCheckBox.label"),
configuration.isAutocompletionPostProcessingEnabled()
);
mainPanel = FormBuilder.createFormBuilder()
.addComponent(tablePanel)
@ -138,6 +143,7 @@ public class ConfigurationComponent {
.addComponent(methodNameGenerationCheckBox)
.addComponent(autoFormattingCheckBox)
.addComponent(autocompletionPostProcessingCheckBox)
.addComponent(autocompletionContextAwareCheckBox)
.addVerticalGap(4)
.addComponent(new TitledSeparator(
CodeGPTBundle.get("configurationConfigurable.section.assistant.title")))
@ -166,6 +172,7 @@ public class ConfigurationComponent {
state.setMethodNameGenerationEnabled(methodNameGenerationCheckBox.isSelected());
state.setAutoFormattingEnabled(autoFormattingCheckBox.isSelected());
state.setAutocompletionPostProcessingEnabled(autocompletionPostProcessingCheckBox.isSelected());
state.setAutocompletionContextAwareEnabled(autocompletionContextAwareCheckBox.isSelected());
return state;
}
@ -183,6 +190,8 @@ public class ConfigurationComponent {
autoFormattingCheckBox.setSelected(configuration.isAutoFormattingEnabled());
autocompletionPostProcessingCheckBox.setSelected(
configuration.isAutocompletionPostProcessingEnabled());
autocompletionContextAwareCheckBox.setSelected(
configuration.isAutocompletionContextAwareEnabled());
}
private Map<String, String> getTableData() {