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";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string GenerateProjectCustomArgs => null;
|
||||
public string GenerateProjectCustomArgs => _currentEditor?.GenerateProjectCustomArgs;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OpenSolution()
|
||||
|
||||
@@ -29,19 +29,7 @@ namespace FlaxEditor.Modules.SourceCodeEditing
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string GenerateProjectCustomArgs
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
case CodeEditorTypes.VSCodeInsiders:
|
||||
case CodeEditorTypes.VSCode: return "-vscode -vs2022";
|
||||
case CodeEditorTypes.Rider: return "-vs2022";
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
public string GenerateProjectCustomArgs => CodeEditingManager.GetGenerateProjectCustomArgs(Type);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OpenSolution()
|
||||
|
||||
@@ -152,6 +152,21 @@ String CodeEditingManager::GetName(CodeEditorTypes editorType)
|
||||
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)
|
||||
{
|
||||
const auto editor = GetCodeEditor(editorType);
|
||||
|
||||
@@ -112,6 +112,15 @@ public:
|
||||
/// <returns>The name.</returns>
|
||||
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>
|
||||
/// Opens the file.
|
||||
/// </summary>
|
||||
@@ -176,6 +185,13 @@ public:
|
||||
/// <returns>The name.</returns>
|
||||
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>
|
||||
/// Opens the file. Handles async opening.
|
||||
/// </summary>
|
||||
|
||||
@@ -257,12 +257,17 @@ String RiderCodeEditor::GetName() const
|
||||
return TEXT("Rider");
|
||||
}
|
||||
|
||||
String RiderCodeEditor::GetGenerateProjectCustomArgs() const
|
||||
{
|
||||
return TEXT("-vs2022");
|
||||
}
|
||||
|
||||
void RiderCodeEditor::OpenFile(const String& path, int32 line)
|
||||
{
|
||||
// Generate project files if solution is missing
|
||||
if (!FileSystem::FileExists(_solutionPath))
|
||||
{
|
||||
ScriptsBuilder::GenerateProject(TEXT("-vs2022"));
|
||||
ScriptsBuilder::GenerateProject(GetGenerateProjectCustomArgs());
|
||||
}
|
||||
|
||||
// Open file
|
||||
@@ -290,7 +295,7 @@ void RiderCodeEditor::OpenSolution()
|
||||
// Generate project files if solution is missing
|
||||
if (!FileSystem::FileExists(_solutionPath))
|
||||
{
|
||||
ScriptsBuilder::GenerateProject(TEXT("-vs2022"));
|
||||
ScriptsBuilder::GenerateProject(GetGenerateProjectCustomArgs());
|
||||
}
|
||||
|
||||
// Open solution
|
||||
@@ -312,5 +317,5 @@ void RiderCodeEditor::OpenSolution()
|
||||
|
||||
void RiderCodeEditor::OnFileAdded(const String& path)
|
||||
{
|
||||
ScriptsBuilder::GenerateProject();
|
||||
ScriptsBuilder::GenerateProject(GetGenerateProjectCustomArgs());
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
// [CodeEditor]
|
||||
CodeEditorTypes GetType() const override;
|
||||
String GetName() const override;
|
||||
String GetGenerateProjectCustomArgs() const override;
|
||||
void OpenFile(const String& path, int32 line) override;
|
||||
void OpenSolution() override;
|
||||
void OnFileAdded(const String& path) override;
|
||||
|
||||
@@ -148,12 +148,17 @@ String VisualStudioEditor::GetName() const
|
||||
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)
|
||||
{
|
||||
// Generate project files if solution is missing
|
||||
if (!FileSystem::FileExists(_solutionPath))
|
||||
{
|
||||
ScriptsBuilder::GenerateProject();
|
||||
ScriptsBuilder::GenerateProject(GetGenerateProjectCustomArgs());
|
||||
}
|
||||
|
||||
// Open file
|
||||
@@ -172,7 +177,7 @@ void VisualStudioEditor::OpenSolution()
|
||||
// Generate project files if solution is missing
|
||||
if (!FileSystem::FileExists(_solutionPath))
|
||||
{
|
||||
ScriptsBuilder::GenerateProject();
|
||||
ScriptsBuilder::GenerateProject(GetGenerateProjectCustomArgs());
|
||||
}
|
||||
|
||||
// Open solution
|
||||
@@ -187,7 +192,7 @@ void VisualStudioEditor::OpenSolution()
|
||||
void VisualStudioEditor::OnFileAdded(const String& path)
|
||||
{
|
||||
// TODO: finish dynamic files adding to the project - for now just regenerate it
|
||||
ScriptsBuilder::GenerateProject();
|
||||
ScriptsBuilder::GenerateProject(GetGenerateProjectCustomArgs());
|
||||
return;
|
||||
if (!FileSystem::FileExists(_solutionPath))
|
||||
{
|
||||
|
||||
@@ -56,6 +56,7 @@ public:
|
||||
// [CodeEditor]
|
||||
CodeEditorTypes GetType() const override;
|
||||
String GetName() const override;
|
||||
String GetGenerateProjectCustomArgs() const override;
|
||||
void OpenFile(const String& path, int32 line) override;
|
||||
void OpenSolution() 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");
|
||||
}
|
||||
|
||||
String VisualStudioCodeEditor::GetGenerateProjectCustomArgs() const
|
||||
{
|
||||
return TEXT("-vs2022 -vscode");
|
||||
}
|
||||
|
||||
void VisualStudioCodeEditor::OpenFile(const String& path, int32 line)
|
||||
{
|
||||
// Generate VS solution files for intellisense
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
// [CodeEditor]
|
||||
CodeEditorTypes GetType() const override;
|
||||
String GetName() const override;
|
||||
String GetGenerateProjectCustomArgs() const override;
|
||||
void OpenFile(const String& path, int32 line) override;
|
||||
void OpenSolution() override;
|
||||
bool UseAsyncForOpen() const override;
|
||||
|
||||
Reference in New Issue
Block a user