Skip to content

Commit 204552c

Browse files
committed
Change context format
1 parent abc28af commit 204552c

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

json_config_file/json_properties/json_property.gd

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,16 @@ func _get_file_path(file: String) -> String:
332332
return file
333333
else:
334334
return _get_variable("dir_path").plus_file(file)
335+
336+
337+
func _update_context(error_or_warning: Dictionary, context) -> void:
338+
var _index_regex = RegEx.new()
339+
_index_regex.compile("^\\[([0-9]|[1-9]+[0-9]+)\\]$")
340+
341+
if error_or_warning.has("context"):
342+
if _index_regex.search(error_or_warning.context) == null:
343+
error_or_warning.context = context + "." + error_or_warning.context
344+
else:
345+
error_or_warning.context = context + error_or_warning.context
346+
else:
347+
error_or_warning.context = context

json_config_file/json_properties/json_property_array.gd

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,12 @@ func _validate_type(array) -> void:
6363
var index = "[" + String(i) + "]"
6464

6565
for error in _element_property._get_errors():
66-
if error.has("context"):
67-
error.context = index + "/" + error.context
68-
else:
69-
error.context = index
66+
_update_context(error, index)
7067

7168
_errors.append(error)
7269

7370
for warning in _element_property._get_warnings():
74-
if warning.has("context"):
75-
warning.context = index + "/" + warning.context
76-
else:
77-
warning.context = index
71+
_update_context(warning, index)
7872

7973
_warnings.append(warning)
8074

json_config_file/json_properties/json_property_object.gd

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,12 @@ func _validate_type(object) -> void:
8080
_result[property_name] = property._get_result()
8181

8282
for error in property._get_errors():
83-
if error.has("context"):
84-
error.context = property_name + "/" + error.context
85-
else:
86-
error.context = property_name
83+
_update_context(error, property_name)
8784

8885
_errors.append(error)
8986

9087
for warning in property._get_warnings():
91-
if warning.has("context"):
92-
warning.context = property_name + "/" + warning.context
93-
else:
94-
warning.context = property_name
88+
_update_context(warning, property_name)
9589

9690
_warnings.append(warning)
9791

0 commit comments

Comments
 (0)