Skip to content

Commit

Permalink
Proto migrations, ide name fix (#116)
Browse files Browse the repository at this point in the history
* inital move

* clean

* rename ide

* revert absolute_uri document name

* note

* workign

* backwards comp

* clean

* compatible

* breh

* version

---------

Co-authored-by: Saransh Saini <[email protected]>
  • Loading branch information
saranshsaini and saranshsaini authored Sep 13, 2024
1 parent 52ad53d commit 0de7a6b
Show file tree
Hide file tree
Showing 5 changed files with 314 additions and 22 deletions.
4 changes: 2 additions & 2 deletions CodeiumVS.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B37F2AE5-CDEC-45B3-944D-8EF912810A12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B37F2AE5-CDEC-45B3-944D-8EF912810A12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B37F2AE5-CDEC-45B3-944D-8EF912810A12}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{B37F2AE5-CDEC-45B3-944D-8EF912810A12}.Debug|Any CPU.Build.0 = Release|Any CPU
{B37F2AE5-CDEC-45B3-944D-8EF912810A12}.Debug|arm64.ActiveCfg = Debug|arm64
{B37F2AE5-CDEC-45B3-944D-8EF912810A12}.Debug|arm64.Build.0 = Debug|arm64
{B37F2AE5-CDEC-45B3-944D-8EF912810A12}.Debug|x86.ActiveCfg = Debug|x86
Expand Down
4 changes: 3 additions & 1 deletion CodeiumVS/LanguageServer/LanguageServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public async Task InitializeAsync()
await PrepareAsync();

_metadata.request_id = 0;
_metadata.ide_name = "visual_studio";
// TODO: Change name
_metadata.ide_name = "vscode";
_metadata.ide_version = ideVersion;
_metadata.extension_name = Vsix.Name;
_metadata.extension_version = _languageServerVersion;
Expand Down Expand Up @@ -781,6 +782,7 @@ public async Task<IList<CompletionItem>?>
cursor_offset = (ulong)cursorPosition,
line_ending = lineEnding,
absolute_path = absolutePath,
absolute_path_migrate_me_to_uri = absolutePath,
relative_path = Path.GetFileName(absolutePath) },
editor_options = new() {
tab_size = (ulong)tabSize,
Expand Down
12 changes: 10 additions & 2 deletions CodeiumVS/LanguageServer/LanguageServerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ void OnMessage(object sender, MessageEventArgs msg)

if (request.ShouldSerializeopen_file_pointer())
{

var data = request.open_file_pointer;
OpenSelection(
data.file_path, data.start_line, data.start_col, data.end_line, data.end_col);
data.file_path_migrate_me_to_uri.IsNullOrEmpty() ? data.file_path : data.file_path_migrate_me_to_uri, data.start_line, data.start_col, data.end_line, data.end_col);
}
else if (request.ShouldSerializeinsert_at_cursor())
{
Expand All @@ -64,7 +65,7 @@ void OnMessage(object sender, MessageEventArgs msg)
}
}

ApplyDiff(data.file_path, data.diff.start_line, data.diff.end_line, replacement);
ApplyDiff(data.file_path_migrate_me_to_uri.IsNullOrEmpty() ? data.file_path : data.file_path_migrate_me_to_uri, data.diff.start_line, data.diff.end_line, replacement);
}
}

Expand Down Expand Up @@ -185,6 +186,7 @@ public async Task ExplainCodeBlockAsync(string filePath, Language language,
new() { explain_code_block = new() {
code_block_info = codeBlockInfo,
file_path = filePath,
file_path_migrate_me_to_uri = filePath,
language = language,
} };

Expand All @@ -200,6 +202,7 @@ public async Task ExplainFunctionAsync(string filePath, FunctionInfo functionInf
new() { explain_function = new() {
function_info = functionInfo,
file_path = filePath,
file_path_migrate_me_to_uri = filePath,
language = functionInfo.Language,
} };

Expand All @@ -216,6 +219,7 @@ public async Task GenerateFunctionUnitTestAsync(string instructions, string file
new() { function_unit_tests = new() {
function_info = functionInfo,
file_path = filePath,
file_path_migrate_me_to_uri = filePath,
language = functionInfo.Language,
instructions = instructions,
} };
Expand All @@ -232,6 +236,7 @@ public async Task GenerateFunctionDocstringAsync(string filePath, FunctionInfo f
new() { function_docstring = new() {
function_info = functionInfo,
file_path = filePath,
file_path_migrate_me_to_uri = filePath,
language = functionInfo.Language,
} };

Expand All @@ -247,6 +252,7 @@ public async Task RefactorCodeBlockAsync(string prompt, string filePath, Languag
request.get_chat_message_request.chat_messages[0].intent =
new() { code_block_refactor = new() { code_block_info = codeBlockInfo,
file_path = filePath,
file_path_migrate_me_to_uri = filePath,
language = language,
refactor_description = prompt } };

Expand All @@ -262,6 +268,7 @@ public async Task RefactorFunctionAsync(string prompt, string filePath,
request.get_chat_message_request.chat_messages[0].intent =
new() { function_refactor = new() { function_info = functionInfo,
file_path = filePath,
file_path_migrate_me_to_uri = filePath,
language = functionInfo.Language,
refactor_description = prompt } };

Expand Down Expand Up @@ -299,6 +306,7 @@ public async Task ExplainProblemAsync(string problemMessage, SnapshotSpan span)
surroundingLineStart.Start, surroundingLineEnd.End - surroundingLineStart.Start),
language = Languages.Mapper.GetLanguage(span.Snapshot.TextBuffer.ContentType).Type,
file_path = span.Snapshot.TextBuffer.GetFileName(),
file_path_migrate_me_to_uri = span.Snapshot.TextBuffer.GetFileName(),
line_number = problemLineStart.LineNumber + 1,
} };

Expand Down
Loading

0 comments on commit 0de7a6b

Please sign in to comment.