Skip to content

Commit

Permalink
Доработаны диагностические сообщения в проверке md-object-attribute-c…
Browse files Browse the repository at this point in the history
…omment-incorrect-type (#1342)

* #1340 Доработаны диагностические сообщения в проверке md-object-attribute-comment-incorrect-type
  • Loading branch information
VAGoncharov authored Dec 23, 2023
1 parent d0ab174 commit 1d3e0b5
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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;

Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -127,15 +126,14 @@ protected void check(Object object, ResultAcceptor resultAceptor, ICheckParamete
return;
}

if (!monitor.isCanceled() && checkDocuments && isDocumentAttribute(object))
{
checkAttribute(attribute, resultAceptor);
}
boolean isDocument = checkDocuments && isDocumentAttribute(object);
boolean isCatalog = checkCatalogs && isCatalogAttribute(object);

if (!monitor.isCanceled() && checkCatalogs && isCatalogAttribute(object))
if (!monitor.isCanceled() && (isDocument || isCatalog))
{
checkAttribute(attribute, resultAceptor);
}

}

private void checkAttribute(BasicFeature attribute, ResultAcceptor resultAceptor)
Expand All @@ -149,7 +147,9 @@ private void checkAttritubeType(BasicFeature attribute, ResultAcceptor resultAce
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;
}

Expand All @@ -170,13 +170,17 @@ private void checkAttritubeType(BasicFeature attribute, ResultAcceptor resultAce
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);
}

}
Expand All @@ -185,7 +189,9 @@ private void checkAttributeIsMultiline(BasicFeature attribute, ResultAcceptor re
{
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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = Объект метаданных не имеет реквизит "Комментарий"
Expand Down

0 comments on commit 1d3e0b5

Please sign in to comment.