Fix Editor project file generation to use custom code editor arguments
This commit is contained in:
@@ -74,7 +74,7 @@ namespace FlaxEditor.Modules.SourceCodeEditing
|
|||||||
public string Name => "Default";
|
public string Name => "Default";
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string GenerateProjectCustomArgs => null;
|
public string GenerateProjectCustomArgs => _currentEditor?.GenerateProjectCustomArgs;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void OpenSolution()
|
public void OpenSolution()
|
||||||
|
|||||||
@@ -29,19 +29,7 @@ namespace FlaxEditor.Modules.SourceCodeEditing
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string GenerateProjectCustomArgs
|
public string GenerateProjectCustomArgs => CodeEditingManager.GetGenerateProjectCustomArgs(Type);
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
switch (Type)
|
|
||||||
{
|
|
||||||
case CodeEditorTypes.VSCodeInsiders:
|
|
||||||
case CodeEditorTypes.VSCode: return "-vscode -vs2022";
|
|
||||||
case CodeEditorTypes.Rider: return "-vs2022";
|
|
||||||
default: return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void OpenSolution()
|
public void OpenSolution()
|
||||||
|
|||||||
@@ -152,6 +152,21 @@ String CodeEditingManager::GetName(CodeEditorTypes editorType)
|
|||||||
return String::Empty;
|
return String::Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String CodeEditingManager::GetGenerateProjectCustomArgs(CodeEditorTypes editorType)
|
||||||
|
{
|
||||||
|
const auto editor = GetCodeEditor(editorType);
|
||||||
|
if (editor)
|
||||||
|
{
|
||||||
|
return editor->GetGenerateProjectCustomArgs();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG(Warning, "Missing code editor type {0}", (int32)editorType);
|
||||||
|
return String::Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CodeEditingManager::OpenFile(CodeEditorTypes editorType, const String& path, int32 line)
|
void CodeEditingManager::OpenFile(CodeEditorTypes editorType, const String& path, int32 line)
|
||||||
{
|
{
|
||||||
const auto editor = GetCodeEditor(editorType);
|
const auto editor = GetCodeEditor(editorType);
|
||||||
|
|||||||
@@ -112,6 +112,15 @@ public:
|
|||||||
/// <returns>The name.</returns>
|
/// <returns>The name.</returns>
|
||||||
virtual String GetName() const = 0;
|
virtual String GetName() const = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the custom arguments for the Flax.Build tool to add when generating project files for this code editor.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The custom arguments to generate project files.</returns>
|
||||||
|
virtual String GetGenerateProjectCustomArgs() const
|
||||||
|
{
|
||||||
|
return String::Empty;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opens the file.
|
/// Opens the file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -176,6 +185,13 @@ public:
|
|||||||
/// <returns>The name.</returns>
|
/// <returns>The name.</returns>
|
||||||
API_FUNCTION() static String GetName(CodeEditorTypes editorType);
|
API_FUNCTION() static String GetName(CodeEditorTypes editorType);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the custom arguments for the Flax.Build tool to add when generating project files for this code editor.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="editorType">The code editor type.</param>
|
||||||
|
/// <returns>The custom arguments to generate project files.</returns>
|
||||||
|
API_FUNCTION() static String GetGenerateProjectCustomArgs(CodeEditorTypes editorType);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opens the file. Handles async opening.
|
/// Opens the file. Handles async opening.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -257,12 +257,17 @@ String RiderCodeEditor::GetName() const
|
|||||||
return TEXT("Rider");
|
return TEXT("Rider");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String RiderCodeEditor::GetGenerateProjectCustomArgs() const
|
||||||
|
{
|
||||||
|
return TEXT("-vs2022");
|
||||||
|
}
|
||||||
|
|
||||||
void RiderCodeEditor::OpenFile(const String& path, int32 line)
|
void RiderCodeEditor::OpenFile(const String& path, int32 line)
|
||||||
{
|
{
|
||||||
// Generate project files if solution is missing
|
// Generate project files if solution is missing
|
||||||
if (!FileSystem::FileExists(_solutionPath))
|
if (!FileSystem::FileExists(_solutionPath))
|
||||||
{
|
{
|
||||||
ScriptsBuilder::GenerateProject(TEXT("-vs2022"));
|
ScriptsBuilder::GenerateProject(GetGenerateProjectCustomArgs());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open file
|
// Open file
|
||||||
@@ -290,7 +295,7 @@ void RiderCodeEditor::OpenSolution()
|
|||||||
// Generate project files if solution is missing
|
// Generate project files if solution is missing
|
||||||
if (!FileSystem::FileExists(_solutionPath))
|
if (!FileSystem::FileExists(_solutionPath))
|
||||||
{
|
{
|
||||||
ScriptsBuilder::GenerateProject(TEXT("-vs2022"));
|
ScriptsBuilder::GenerateProject(GetGenerateProjectCustomArgs());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open solution
|
// Open solution
|
||||||
@@ -312,5 +317,5 @@ void RiderCodeEditor::OpenSolution()
|
|||||||
|
|
||||||
void RiderCodeEditor::OnFileAdded(const String& path)
|
void RiderCodeEditor::OnFileAdded(const String& path)
|
||||||
{
|
{
|
||||||
ScriptsBuilder::GenerateProject();
|
ScriptsBuilder::GenerateProject(GetGenerateProjectCustomArgs());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ public:
|
|||||||
// [CodeEditor]
|
// [CodeEditor]
|
||||||
CodeEditorTypes GetType() const override;
|
CodeEditorTypes GetType() const override;
|
||||||
String GetName() const override;
|
String GetName() const override;
|
||||||
|
String GetGenerateProjectCustomArgs() const override;
|
||||||
void OpenFile(const String& path, int32 line) override;
|
void OpenFile(const String& path, int32 line) override;
|
||||||
void OpenSolution() override;
|
void OpenSolution() override;
|
||||||
void OnFileAdded(const String& path) override;
|
void OnFileAdded(const String& path) override;
|
||||||
|
|||||||
@@ -148,12 +148,17 @@ String VisualStudioEditor::GetName() const
|
|||||||
return String(ToString(_version));
|
return String(ToString(_version));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String VisualStudioEditor::GetGenerateProjectCustomArgs() const
|
||||||
|
{
|
||||||
|
return String::Format(TEXT("-{0}"), String(ToString(_version)).ToLower());
|
||||||
|
}
|
||||||
|
|
||||||
void VisualStudioEditor::OpenFile(const String& path, int32 line)
|
void VisualStudioEditor::OpenFile(const String& path, int32 line)
|
||||||
{
|
{
|
||||||
// Generate project files if solution is missing
|
// Generate project files if solution is missing
|
||||||
if (!FileSystem::FileExists(_solutionPath))
|
if (!FileSystem::FileExists(_solutionPath))
|
||||||
{
|
{
|
||||||
ScriptsBuilder::GenerateProject();
|
ScriptsBuilder::GenerateProject(GetGenerateProjectCustomArgs());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open file
|
// Open file
|
||||||
@@ -172,7 +177,7 @@ void VisualStudioEditor::OpenSolution()
|
|||||||
// Generate project files if solution is missing
|
// Generate project files if solution is missing
|
||||||
if (!FileSystem::FileExists(_solutionPath))
|
if (!FileSystem::FileExists(_solutionPath))
|
||||||
{
|
{
|
||||||
ScriptsBuilder::GenerateProject();
|
ScriptsBuilder::GenerateProject(GetGenerateProjectCustomArgs());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open solution
|
// Open solution
|
||||||
@@ -187,7 +192,7 @@ void VisualStudioEditor::OpenSolution()
|
|||||||
void VisualStudioEditor::OnFileAdded(const String& path)
|
void VisualStudioEditor::OnFileAdded(const String& path)
|
||||||
{
|
{
|
||||||
// TODO: finish dynamic files adding to the project - for now just regenerate it
|
// TODO: finish dynamic files adding to the project - for now just regenerate it
|
||||||
ScriptsBuilder::GenerateProject();
|
ScriptsBuilder::GenerateProject(GetGenerateProjectCustomArgs());
|
||||||
return;
|
return;
|
||||||
if (!FileSystem::FileExists(_solutionPath))
|
if (!FileSystem::FileExists(_solutionPath))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public:
|
|||||||
// [CodeEditor]
|
// [CodeEditor]
|
||||||
CodeEditorTypes GetType() const override;
|
CodeEditorTypes GetType() const override;
|
||||||
String GetName() const override;
|
String GetName() const override;
|
||||||
|
String GetGenerateProjectCustomArgs() const override;
|
||||||
void OpenFile(const String& path, int32 line) override;
|
void OpenFile(const String& path, int32 line) override;
|
||||||
void OpenSolution() override;
|
void OpenSolution() override;
|
||||||
void OnFileAdded(const String& path) override;
|
void OnFileAdded(const String& path) override;
|
||||||
|
|||||||
@@ -128,6 +128,11 @@ String VisualStudioCodeEditor::GetName() const
|
|||||||
return _isInsiders ? TEXT("Visual Studio Code - Insiders") : TEXT("Visual Studio Code");
|
return _isInsiders ? TEXT("Visual Studio Code - Insiders") : TEXT("Visual Studio Code");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String VisualStudioCodeEditor::GetGenerateProjectCustomArgs() const
|
||||||
|
{
|
||||||
|
return TEXT("-vs2022 -vscode");
|
||||||
|
}
|
||||||
|
|
||||||
void VisualStudioCodeEditor::OpenFile(const String& path, int32 line)
|
void VisualStudioCodeEditor::OpenFile(const String& path, int32 line)
|
||||||
{
|
{
|
||||||
// Generate VS solution files for intellisense
|
// Generate VS solution files for intellisense
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ public:
|
|||||||
// [CodeEditor]
|
// [CodeEditor]
|
||||||
CodeEditorTypes GetType() const override;
|
CodeEditorTypes GetType() const override;
|
||||||
String GetName() const override;
|
String GetName() const override;
|
||||||
|
String GetGenerateProjectCustomArgs() const override;
|
||||||
void OpenFile(const String& path, int32 line) override;
|
void OpenFile(const String& path, int32 line) override;
|
||||||
void OpenSolution() override;
|
void OpenSolution() override;
|
||||||
bool UseAsyncForOpen() const override;
|
bool UseAsyncForOpen() const override;
|
||||||
|
|||||||
Reference in New Issue
Block a user