ソースを参照

Fix Javascript resource editor syntax coloring

Josh Engebretson 10 年 前
コミット
83dd4436b0

ファイルの差分が大きいため隠しています
+ 541 - 0
Resources/EditorData/AtomicEditor/Script/acorn.js


ファイルの差分が大きいため隠しています
+ 109 - 0
Resources/EditorData/AtomicEditor/Script/beautify.js


+ 67 - 0
Resources/EditorData/AtomicEditor/Script/jsutils.js

@@ -0,0 +1,67 @@
+__atomic_acorn = require('./acorn');
+__atomic_beautify = require('./beautify');
+
+exports.parseToJSON = function (source) {
+
+	var start = new Date().getTime();
+
+	var comments = [];
+
+	var ast = __atomic_acorn.parse( source, {
+    	// collect ranges for each node
+    	ranges: true,
+    	locations: true,
+    	onComment: comments,
+	});
+
+	var end = new Date().getTime();
+	var time = end - start;
+
+	// print('Acorn parse time: ' + time);
+
+	ast["comments"] = comments;
+
+	start = new Date().getTime();
+	ast = JSON.stringify(ast);
+	end = new Date().getTime();
+	time = end - start;
+
+	// print('JSON.stringify time: ' + time);
+
+	return ast;
+
+}
+
+
+exports.parseErrorCheck = function(source) {
+
+
+	try {
+
+		__atomic_acorn.parse( source, {
+	    	ranges: true,
+	    	locations: true,
+		});
+
+	} catch(e) {
+
+        //if (!(e instanceof __atomic_acorn.SyntaxError)) throw e;
+
+        if (!(e instanceof SyntaxError))
+        	return false; // rethrow?
+
+        return e;
+
+    }
+
+
+	return false;
+
+}
+
+// TODO: options
+exports.jsBeautify = function (source) {
+
+	return __atomic_beautify.js_beautify(source);
+
+}

+ 1 - 1
Source/AtomicEditorWork/Editors/JSResourceEditor.cpp

@@ -549,7 +549,7 @@ bool JSResourceEditor::ParseJavascriptToJSON(const char* source, String& json, b
     json.Clear();
 
     duk_get_global_string(ctx, "require");
-    duk_push_string(ctx, "AtomicEditor/typescript/modules/jsutils");
+    duk_push_string(ctx, "AtomicEditor/Script/jsutils");
     if (duk_pcall(ctx, 1))
     {
         printf("Error: %s\n", duk_safe_to_string(ctx, -1));

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません