-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code Actions Support (Ask Cody to Fix) (#1921)
Add the ability for the Agent to provide CodeActions. In practice this means "Ask Cody to Fix" is now supported as a QuickFix on errors shown in JetBrains. https://github.com/user-attachments/assets/f3bad3fd-cd67-427c-baa6-449a4c0dfd48 ## FAQ **Q: What errors are supported?** A: Any errors shown in the JetBrains UI. Cody doesn't do any code analysis, we simply pass the issues that JetBrains is showing along. These Issues (or Inspections as they're known) can come both from JetBrain's language support, external Plugins as well as custom Inspections. **Q: Can Cody explain the error like in VSCode?** A: Not yet, but the foundational support is there now so it will be easy enough to add soon. Fixes CODY-2788, CODY-2830 ## Test plan - Verified that existing unit & integration tests work with Protocol migrated protocol classes - Manually verified that "Ask Cody to Fix" command is correctly shown and invoked. Most of the logic remains on the Agent. - Isolated changes on FixupSession to FixupSessionV2 to not introduce bugs in FixupSessionV1 dependent codepaths which currently have low test coverage.
- Loading branch information
Showing
45 changed files
with
486 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/main/java/com/sourcegraph/cody/agent/protocol/TextDocumentShowOptions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
src/main/kotlin/com/sourcegraph/cody/agent/ExtensionConfiguration.kt
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
src/main/kotlin/com/sourcegraph/cody/agent/intellij_extensions/Document.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.sourcegraph.cody.agent.intellij_extensions | ||
|
||
import com.intellij.openapi.editor.Document | ||
import com.sourcegraph.cody.agent.protocol_extensions.Position | ||
import com.sourcegraph.cody.agent.protocol_generated.Position | ||
import com.sourcegraph.cody.agent.protocol_generated.Range | ||
|
||
fun Document.codyPosition(offset: Int): Position { | ||
val line = this.getLineNumber(offset) | ||
val lineStartOffset = this.getLineStartOffset(line) | ||
val character = offset - lineStartOffset | ||
return Position(line, character) | ||
} | ||
|
||
fun Document.codyRange(startOffset: Int, endOffset: Int): Range { | ||
val startLine = this.getLineNumber(startOffset) | ||
val lineStartOffset1 = this.getLineStartOffset(startLine) | ||
val startCharacter = startOffset - lineStartOffset1 | ||
|
||
val endLine = this.getLineNumber(endOffset) | ||
val lineStartOffset2 = | ||
if (startLine == endLine) { | ||
lineStartOffset1 | ||
} else { | ||
this.getLineStartOffset(endLine) | ||
} | ||
val endCharacter = endOffset - lineStartOffset2 | ||
|
||
return Range(Position(startLine, startCharacter), Position(endLine, endCharacter)) | ||
} |
2 changes: 2 additions & 0 deletions
2
src/main/kotlin/com/sourcegraph/cody/agent/protocol/AutocompleteParams.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.