mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-18 23:42:49 +00:00
feat: improve code completion git diff context
This commit is contained in:
parent
b08186f7c5
commit
16cc6d8ea6
3 changed files with 8 additions and 49 deletions
|
|
@ -36,9 +36,13 @@ import org.treesitter.TreeSitterYaml;
|
|||
|
||||
public class CodeCompletionParserFactory {
|
||||
|
||||
public static CodeCompletionParser getParserForFileExtension(String extension)
|
||||
throws IllegalArgumentException {
|
||||
return new CodeCompletionParser(getLanguageForExtension(extension));
|
||||
public static CodeCompletionParser getParserForFileExtension(String extension) {
|
||||
var language = getLanguageForExtension(extension);
|
||||
if (language == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new CodeCompletionParser(language);
|
||||
}
|
||||
|
||||
private static TSLanguage getLanguageForExtension(String extension) {
|
||||
|
|
@ -75,7 +79,7 @@ public class CodeCompletionParserFactory {
|
|||
case "svelte" -> new TreeSitterSvelte();
|
||||
case "swift" -> new TreeSitterSwift();
|
||||
case "yml", "yaml" -> new TreeSitterYaml();
|
||||
default -> throw new IllegalArgumentException("Unsupported file extension: " + extension);
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,51 +17,6 @@ object GitUtil {
|
|||
|
||||
private val logger = thisLogger()
|
||||
|
||||
@Throws(VcsException::class)
|
||||
@JvmStatic
|
||||
fun getStagedDiff(
|
||||
project: Project,
|
||||
gitRepository: GitRepository,
|
||||
includedVersionedFilePaths: List<String> = emptyList()
|
||||
): List<String> {
|
||||
return getGitDiff(project, gitRepository, includedVersionedFilePaths, true)
|
||||
}
|
||||
|
||||
@Throws(VcsException::class)
|
||||
@JvmStatic
|
||||
fun getUnstagedDiff(
|
||||
project: Project,
|
||||
gitRepository: GitRepository,
|
||||
includedUnversionedFilePaths: List<String> = emptyList()
|
||||
): List<String> {
|
||||
return getGitDiff(project, gitRepository, includedUnversionedFilePaths, false)
|
||||
}
|
||||
|
||||
private fun getGitDiff(
|
||||
project: Project,
|
||||
gitRepository: GitRepository,
|
||||
filePaths: List<String>,
|
||||
staged: Boolean
|
||||
): List<String> {
|
||||
val handler = GitLineHandler(project, gitRepository.root, GitCommand.DIFF)
|
||||
if (staged) {
|
||||
handler.addParameters("--cached")
|
||||
}
|
||||
handler.addParameters(
|
||||
"--unified=2",
|
||||
"--diff-filter=AM",
|
||||
"--no-prefix",
|
||||
"--no-color",
|
||||
)
|
||||
|
||||
filePaths.forEach { path ->
|
||||
handler.addParameters(path)
|
||||
}
|
||||
|
||||
val commandResult = Git.getInstance().runCommand(handler)
|
||||
return filterDiffOutput(commandResult.output)
|
||||
}
|
||||
|
||||
@Throws(VcsException::class)
|
||||
@JvmStatic
|
||||
fun getProjectRepository(project: Project): GitRepository? {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue