2
0
Эх сурвалжийг харах

escape keywords in resource names

Nicolas Cannasse 6 жил өмнө
parent
commit
a29d6490a8
1 өөрчлөгдсөн 6 нэмэгдсэн , 1 устгасан
  1. 6 1
      hxd/res/FileTree.hx

+ 6 - 1
hxd/res/FileTree.hx

@@ -75,10 +75,15 @@ class FileTree {
 	}
 
 	static var invalidChars = ~/[^A-Za-z0-9_]/g;
+	static var KEYWORDS = [for( k in ["break","case","cast","catch","class","continue","default","do","dynamic",
+									"else","extends","extern","false","for","function","if","implementes","import",
+									"interface","never","null","override","package","private","public","return",
+									"static","super","switch","this","throw","trace","true","typedef","untyped",
+									"using","var","while"] ) k => true];
 
 	function makeIdent( s : String ) {
 		var ident = invalidChars.replace(s, "_");
-		if( ident == "" || (ident.charCodeAt(0) >= "0".code && ident.charCodeAt(0) <= "9".code) )
+		if( ident == "" || (ident.charCodeAt(0) >= "0".code && ident.charCodeAt(0) <= "9".code) || KEYWORDS.exists(ident) )
 			ident = "_" + ident;
 		return ident;
 	}