summaryrefslogtreecommitdiff
path: root/DevTools/HackStudio/CodeDocument.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'DevTools/HackStudio/CodeDocument.cpp')
-rw-r--r--DevTools/HackStudio/CodeDocument.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/DevTools/HackStudio/CodeDocument.cpp b/DevTools/HackStudio/CodeDocument.cpp
index dbe8a22dac..cddbcb4ae3 100644
--- a/DevTools/HackStudio/CodeDocument.cpp
+++ b/DevTools/HackStudio/CodeDocument.cpp
@@ -28,11 +28,30 @@
namespace HackStudio {
+NonnullRefPtr<CodeDocument> CodeDocument::create(const LexicalPath& file_path, Client* client)
+{
+ return adopt(*new CodeDocument(file_path, client));
+}
+
NonnullRefPtr<CodeDocument> CodeDocument::create(Client* client)
{
return adopt(*new CodeDocument(client));
}
+CodeDocument::CodeDocument(const LexicalPath& file_path, Client* client)
+ : TextDocument(client)
+ , m_file_path(file_path)
+{
+ if (file_path.basename().ends_with(".cpp") || file_path.basename().ends_with(".h"))
+ m_language = Language::Cpp;
+ else if (file_path.basename().ends_with(".js"))
+ m_language = Language::JavaScript;
+ else if (file_path.basename().ends_with(".ini"))
+ m_language = Language::Ini;
+ else if (file_path.basename().ends_with(".sh"))
+ m_language = Language::Shell;
+}
+
CodeDocument::CodeDocument(Client* client)
: TextDocument(client)
{