소스 검색

allow group differentiation for script check

ncannasse 6 년 전
부모
커밋
a063cab04f
2개의 변경된 파일18개의 추가작업 그리고 2개의 파일을 삭제
  1. 17 1
      hide/comp/cdb/Cell.hx
  2. 1 1
      hide/comp/cdb/ScriptTable.hx

+ 17 - 1
hide/comp/cdb/Cell.hx

@@ -184,7 +184,7 @@ class Cell extends Component {
 		code = code.split("\n").join("<br/>");
 		code = code.split("\t").join("&nbsp;&nbsp;&nbsp;&nbsp;");
 		// typecheck
-		var error = new ScriptEditor.ScriptChecker(editor.config, "cdb."+table.sheet.name+"."+column.name, ["cdb."+table.sheet.name => line.obj]).check(ecode);
+		var error = new ScriptEditor.ScriptChecker(editor.config, "cdb."+getDocumentName(), ["cdb."+table.sheet.name => line.obj]).check(ecode);
 		if( error != null )
 			return '<span class="error">'+code+'</span>';
 		// strings
@@ -195,6 +195,22 @@ class Cell extends Component {
 		return code;
 	}
 
+	public function getGroup() : String {
+		var gid : Null<Int> = Reflect.field(line.obj, "group");
+		if( gid == null ) return null;
+		return table.sheet.props.separatorTitles[gid-1];
+	}
+
+	public function getDocumentName() {
+		var name = table.sheet.name;
+		if( table.sheet.props.hasGroup ) {
+			var g = getGroup();
+			if( g != null ) name += "[group="+g+"]";
+		}
+		name += "."+column.name;
+		return name;
+	}
+
 	function tileHtml( v : cdb.Types.TilePos, ?isInline ) {
 		var path = ide.getPath(v.file);
 		if( !editor.quickExists(path) ) {

+ 1 - 1
hide/comp/cdb/ScriptTable.hx

@@ -22,7 +22,7 @@ class ScriptTable extends SubTable {
 	override function refresh() {
 		var first = script == null;
 		element.html("<div class='cdb-script'></div>");
-		var checker = new ScriptEditor.ScriptChecker(editor.config,"cdb."+cell.table.sheet.name+"."+cell.column.name,[ "cdb."+cell.table.sheet.name => cell.line.obj ]);
+		var checker = new ScriptEditor.ScriptChecker(editor.config,"cdb."+cell.getDocumentName(),[ "cdb."+cell.table.sheet.name => cell.line.obj ]);
 		script = new ScriptEditor(cell.value, checker, element.find("div"));
 		script.onSave = function() @:privateAccess cell.setValue(script.script);
 		script.onClose = function() { close(); cell.select(); }