mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-12 22:14:54 +00:00
Rename YAML comment transfer functions (no longer solely about transferring missing comments)
This commit is contained in:
1 parent
a09840156f
commit
a6ec1b0621
2 files changed
+6
-6
No files matched your search
@@ -31,7 +31,7 @@ from serena.constants import (
|
||||
SERENA_MANAGED_DIR_NAME,
|
||||
)
|
||||
from serena.util.inspection import determine_programming_language_composition
|
||||
from serena.util.yaml import YamlCommentNormalisation, load_yaml, normalise_yaml_comments, save_yaml, transfer_missing_yaml_comments
|
||||
from serena.util.yaml import YamlCommentNormalisation, load_yaml, normalise_yaml_comments, save_yaml, transfer_yaml_comments
|
||||
from solidlsp.ls_config import Language
|
||||
|
||||
from ..analytics import RegisteredTokenCountEstimator
|
||||
@@ -581,7 +581,7 @@ class ProjectConfig(SharedConfig):
|
||||
|
||||
# transfer missing comments from the template file
|
||||
template_config, _ = self._load_yaml_dict(PROJECT_TEMPLATE_FILE, self.YAML_COMMENT_NORMALISATION)
|
||||
transfer_missing_yaml_comments(template_config, config_with_comments, self.YAML_COMMENT_NORMALISATION, force_update_all=True)
|
||||
transfer_yaml_comments(template_config, config_with_comments, self.YAML_COMMENT_NORMALISATION, force_update_all=True)
|
||||
|
||||
# save project.yml
|
||||
save_yaml(config_path, config_with_comments)
|
||||
@@ -1063,7 +1063,7 @@ class SerenaConfig(SharedConfig):
|
||||
# For some keys, we force updates, because old comments are problematic/misleading.
|
||||
normalise_yaml_comments(commented_yaml, YamlCommentNormalisation.LEADING_WITH_CONVERSION_FROM_TRAILING)
|
||||
template_yaml = load_yaml(SERENA_CONFIG_TEMPLATE_FILE, comment_normalisation=YamlCommentNormalisation.LEADING)
|
||||
transfer_missing_yaml_comments(template_yaml, commented_yaml, YamlCommentNormalisation.LEADING, force_update_all=True)
|
||||
transfer_yaml_comments(template_yaml, commented_yaml, YamlCommentNormalisation.LEADING, force_update_all=True)
|
||||
|
||||
save_yaml(self.config_file_path, commented_yaml)
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ def yaml_comment_entry_is_empty(comment_entry: Any) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def transfer_missing_yaml_comments_by_index(
|
||||
def transfer_yaml_comments_by_index(
|
||||
source: CommentedMap, target: CommentedMap, indices: list[int], forced_update_keys: Sequence[str] = (), force_update_all: bool = False
|
||||
) -> None:
|
||||
"""
|
||||
@@ -231,7 +231,7 @@ def transfer_missing_yaml_comments_by_index(
|
||||
target_comment[index] = source_comment[index]
|
||||
|
||||
|
||||
def transfer_missing_yaml_comments(
|
||||
def transfer_yaml_comments(
|
||||
source: CommentedMap,
|
||||
target: CommentedMap,
|
||||
comment_normalisation: YamlCommentNormalisation,
|
||||
@@ -251,7 +251,7 @@ def transfer_missing_yaml_comments(
|
||||
case YamlCommentNormalisation.NONE:
|
||||
pass
|
||||
case YamlCommentNormalisation.LEADING | YamlCommentNormalisation.LEADING_WITH_CONVERSION_FROM_TRAILING:
|
||||
transfer_missing_yaml_comments_by_index(
|
||||
transfer_yaml_comments_by_index(
|
||||
source, target, [ITEM_COMMENT_INDEX_BEFORE], forced_update_keys=forced_update_keys, force_update_all=force_update_all
|
||||
)
|
||||
case _:
|
||||
|
||||
Reference in new issue
Block a user