1
0
mirror of https://github.com/1C-Company/v8-code-style.git synced 2024-11-24 16:53:51 +02:00

Доработаны диагностические сообщения в проверке md-object-attribute-comment-incorrect-type (#1342)

* #1340 Доработаны диагностические сообщения в проверке md-object-attribute-comment-incorrect-type
This commit is contained in:
Vadim Goncharov 2023-12-23 11:08:56 +03:00 committed by GitHub
parent d0ab1746ce
commit 1d3e0b5a6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 25 deletions

View File

@ -21,6 +21,7 @@ import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CATALOG_
import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.DOCUMENT;
import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.DOCUMENT_ATTRIBUTE;
import java.text.MessageFormat;
import java.util.Set;
import java.util.TreeSet;
@ -57,19 +58,17 @@ public class MdObjectAttributeCommentCheck
private static final String CHECK_ID = "md-object-attribute-comment-incorrect-type"; //$NON-NLS-1$
public static final String PARAM_CHECK_DOCUMENTS = "checkDocuments"; //$NON-NLS-1$
public static final String PARAM_CHECK_CATALOGS = "checkCatalogs"; //$NON-NLS-1$
public static final String PARAM_ATTRIBUTES_LIST = "attributesList"; //$NON-NLS-1$
private static final String PARAM_CHECK_DOCUMENTS = "checkDocuments"; //$NON-NLS-1$
private static final String PARAM_CHECK_CATALOGS = "checkCatalogs"; //$NON-NLS-1$
private static final String PARAM_ATTRIBUTES_LIST = "attributesList"; //$NON-NLS-1$
public static final String DEFAULT_CHECK_DOCUMENTS = Boolean.toString(true);
public static final String DEFAULT_CHECK_CATALOGS = Boolean.toString(false);
private static final String DEFAULT_CHECK_DOCUMENTS = Boolean.toString(true);
private static final String DEFAULT_CHECK_CATALOGS = Boolean.toString(false);
private static final Set<String> COMMENT_ATTRIBUTES_LIST = Set.of("Комментарий", //$NON-NLS-1$
"Comment"); //$NON-NLS-1$
private static final String DELIMITER = ","; //$NON-NLS-1$
public static final String DEFAULT_ATTRIBUTES_LIST = String.join(DELIMITER, COMMENT_ATTRIBUTES_LIST);
private static final String DEFAULT_CHECK_MESSAGE = Messages.MdObjectAttributeCommentCheck_Default_check_message;
private static final String DEFAULT_ATTRIBUTES_LIST = String.join(DELIMITER, COMMENT_ATTRIBUTES_LIST);
public MdObjectAttributeCommentCheck()
{
@ -127,15 +126,14 @@ public class MdObjectAttributeCommentCheck
return;
}
if (!monitor.isCanceled() && checkDocuments && isDocumentAttribute(object))
boolean isDocument = checkDocuments && isDocumentAttribute(object);
boolean isCatalog = checkCatalogs && isCatalogAttribute(object);
if (!monitor.isCanceled() && (isDocument || isCatalog))
{
checkAttribute(attribute, resultAceptor);
}
if (!monitor.isCanceled() && checkCatalogs && isCatalogAttribute(object))
{
checkAttribute(attribute, resultAceptor);
}
}
private void checkAttribute(BasicFeature attribute, ResultAcceptor resultAceptor)
@ -149,7 +147,9 @@ public class MdObjectAttributeCommentCheck
TypeDescription typeDesc = attribute.getType();
if (McoreUtil.isCompoundType(typeDesc))
{
resultAceptor.addIssue(DEFAULT_CHECK_MESSAGE, BASIC_FEATURE__TYPE);
String msg = MessageFormat.format(Messages.MdObjectAttributeCommentCheck_message,
Messages.MdObjectAttributeCommentCheck_Is_compound_type);
resultAceptor.addIssue(msg, BASIC_FEATURE__TYPE);
return;
}
@ -170,13 +170,17 @@ public class MdObjectAttributeCommentCheck
StringQualifiers qualifiers = typeDesc.getStringQualifiers();
if (qualifiers == null)
{
resultAceptor.addIssue(DEFAULT_CHECK_MESSAGE, BASIC_FEATURE__TYPE);
String msg = MessageFormat.format(Messages.MdObjectAttributeCommentCheck_message,
Messages.MdObjectAttributeCommentCheck_Not_a_String);
resultAceptor.addIssue(msg, BASIC_FEATURE__TYPE);
return;
}
if (qualifiers.getLength() != 0)
{
resultAceptor.addIssue(DEFAULT_CHECK_MESSAGE, BASIC_FEATURE__TYPE);
String msg = MessageFormat.format(Messages.MdObjectAttributeCommentCheck_message,
Messages.MdObjectAttributeCommentCheck_String_is_not_unlimited);
resultAceptor.addIssue(msg, BASIC_FEATURE__TYPE);
}
}
@ -185,7 +189,9 @@ public class MdObjectAttributeCommentCheck
{
if (!attribute.isMultiLine())
{
resultAceptor.addIssue(DEFAULT_CHECK_MESSAGE, BASIC_FEATURE__MULTI_LINE);
String msg = MessageFormat.format(Messages.MdObjectAttributeCommentCheck_message,
Messages.MdObjectAttributeCommentCheck_Multiline_edit_is_not_enabled);
resultAceptor.addIssue(msg, BASIC_FEATURE__MULTI_LINE);
}
}

View File

@ -28,8 +28,12 @@ final class Messages
public static String MdObjectAttributeCommentCheck_Attribute_list;
public static String MdObjectAttributeCommentCheck_Check_catalogs_param;
public static String MdObjectAttributeCommentCheck_Check_documents_param;
public static String MdObjectAttributeCommentCheck_Default_check_message;
public static String MdObjectAttributeCommentCheck_Is_compound_type;
public static String MdObjectAttributeCommentCheck_Multiline_edit_is_not_enabled;
public static String MdObjectAttributeCommentCheck_Not_a_String;
public static String MdObjectAttributeCommentCheck_String_is_not_unlimited;
public static String MdObjectAttributeCommentCheck_description;
public static String MdObjectAttributeCommentCheck_message;
public static String MdObjectAttributeCommentCheck_title;
public static String MdObjectAttributeCommentNotExist_description;
public static String MdObjectAttributeCommentNotExist_Md_Object_attribute_Comment_does_not_exist;

View File

@ -31,17 +31,25 @@ MdListObjectPresentationCheck_decription = Neither Object presentation nor List
MdListObjectPresentationCheck_title = Neither Object presentation nor List presentation is not filled
MdObjectAttributeCommentCheck_Attribute_list=Attributes list
MdObjectAttributeCommentCheck_Attribute_list = Attributes list
MdObjectAttributeCommentCheck_Check_catalogs_param=Check Catalogs
MdObjectAttributeCommentCheck_Check_catalogs_param = Check Catalogs
MdObjectAttributeCommentCheck_Check_documents_param=Check Documents
MdObjectAttributeCommentCheck_Check_documents_param = Check Documents
MdObjectAttributeCommentCheck_Default_check_message=The attribute "Comment" has an invalid type
MdObjectAttributeCommentCheck_Is_compound_type = attribute type is compound
MdObjectAttributeCommentCheck_description=The attribute "Comment" has an invalid type
MdObjectAttributeCommentCheck_Multiline_edit_is_not_enabled = multiline edit is not enabled
MdObjectAttributeCommentCheck_title=The attribute "Comment" has an invalid type
MdObjectAttributeCommentCheck_Not_a_String = type is not a String
MdObjectAttributeCommentCheck_String_is_not_unlimited = String must be of unlimited length
MdObjectAttributeCommentCheck_description = The attribute "Comment" has an invalid type
MdObjectAttributeCommentCheck_message = The attribute "Comment" has an invalid type: {0}
MdObjectAttributeCommentCheck_title = The attribute "Comment" has an invalid type
MdObjectAttributeCommentNotExist_Md_Object_attribute_Comment_does_not_exist = Md Object attribute "Comment" does not exist

View File

@ -38,10 +38,18 @@ MdObjectAttributeCommentCheck_Check_catalogs_param = Проверять спра
MdObjectAttributeCommentCheck_Check_documents_param = Проверять документы
MdObjectAttributeCommentCheck_Default_check_message = Реквизит "Комментарий" имеет недопустимый тип
MdObjectAttributeCommentCheck_Is_compound_type = реквизит имеет составной тип данных
MdObjectAttributeCommentCheck_Multiline_edit_is_not_enabled = не включен многострочный режим
MdObjectAttributeCommentCheck_Not_a_String = тип не Строка
MdObjectAttributeCommentCheck_String_is_not_unlimited = Строка должна быть неограниченной длины
MdObjectAttributeCommentCheck_description = Реквизит "Комментарий" имеет недопустимый тип
MdObjectAttributeCommentCheck_message = Реквизит "Комментарий" имеет недопустимый тип: {0}
MdObjectAttributeCommentCheck_title = Реквизит "Комментарий" имеет недопустимый тип
MdObjectAttributeCommentNotExist_Md_Object_attribute_Comment_does_not_exist = Объект метаданных не имеет реквизит "Комментарий"