Skip to content

Commit 1d3e0b5

Browse files
authored
Доработаны диагностические сообщения в проверке md-object-attribute-comment-incorrect-type (#1342)
* #1340 Доработаны диагностические сообщения в проверке md-object-attribute-comment-incorrect-type
1 parent d0ab174 commit 1d3e0b5

4 files changed

Lines changed: 51 additions & 25 deletions

File tree

bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectAttributeCommentCheck.java

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.DOCUMENT;
2222
import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.DOCUMENT_ATTRIBUTE;
2323

24+
import java.text.MessageFormat;
2425
import java.util.Set;
2526
import java.util.TreeSet;
2627

@@ -57,19 +58,17 @@ public class MdObjectAttributeCommentCheck
5758

5859
private static final String CHECK_ID = "md-object-attribute-comment-incorrect-type"; //$NON-NLS-1$
5960

60-
public static final String PARAM_CHECK_DOCUMENTS = "checkDocuments"; //$NON-NLS-1$
61-
public static final String PARAM_CHECK_CATALOGS = "checkCatalogs"; //$NON-NLS-1$
62-
public static final String PARAM_ATTRIBUTES_LIST = "attributesList"; //$NON-NLS-1$
61+
private static final String PARAM_CHECK_DOCUMENTS = "checkDocuments"; //$NON-NLS-1$
62+
private static final String PARAM_CHECK_CATALOGS = "checkCatalogs"; //$NON-NLS-1$
63+
private static final String PARAM_ATTRIBUTES_LIST = "attributesList"; //$NON-NLS-1$
6364

64-
public static final String DEFAULT_CHECK_DOCUMENTS = Boolean.toString(true);
65-
public static final String DEFAULT_CHECK_CATALOGS = Boolean.toString(false);
65+
private static final String DEFAULT_CHECK_DOCUMENTS = Boolean.toString(true);
66+
private static final String DEFAULT_CHECK_CATALOGS = Boolean.toString(false);
6667

6768
private static final Set<String> COMMENT_ATTRIBUTES_LIST = Set.of("Комментарий", //$NON-NLS-1$
6869
"Comment"); //$NON-NLS-1$
6970
private static final String DELIMITER = ","; //$NON-NLS-1$
70-
public static final String DEFAULT_ATTRIBUTES_LIST = String.join(DELIMITER, COMMENT_ATTRIBUTES_LIST);
71-
72-
private static final String DEFAULT_CHECK_MESSAGE = Messages.MdObjectAttributeCommentCheck_Default_check_message;
71+
private static final String DEFAULT_ATTRIBUTES_LIST = String.join(DELIMITER, COMMENT_ATTRIBUTES_LIST);
7372

7473
public MdObjectAttributeCommentCheck()
7574
{
@@ -127,15 +126,14 @@ protected void check(Object object, ResultAcceptor resultAceptor, ICheckParamete
127126
return;
128127
}
129128

130-
if (!monitor.isCanceled() && checkDocuments && isDocumentAttribute(object))
131-
{
132-
checkAttribute(attribute, resultAceptor);
133-
}
129+
boolean isDocument = checkDocuments && isDocumentAttribute(object);
130+
boolean isCatalog = checkCatalogs && isCatalogAttribute(object);
134131

135-
if (!monitor.isCanceled() && checkCatalogs && isCatalogAttribute(object))
132+
if (!monitor.isCanceled() && (isDocument || isCatalog))
136133
{
137134
checkAttribute(attribute, resultAceptor);
138135
}
136+
139137
}
140138

141139
private void checkAttribute(BasicFeature attribute, ResultAcceptor resultAceptor)
@@ -149,7 +147,9 @@ private void checkAttritubeType(BasicFeature attribute, ResultAcceptor resultAce
149147
TypeDescription typeDesc = attribute.getType();
150148
if (McoreUtil.isCompoundType(typeDesc))
151149
{
152-
resultAceptor.addIssue(DEFAULT_CHECK_MESSAGE, BASIC_FEATURE__TYPE);
150+
String msg = MessageFormat.format(Messages.MdObjectAttributeCommentCheck_message,
151+
Messages.MdObjectAttributeCommentCheck_Is_compound_type);
152+
resultAceptor.addIssue(msg, BASIC_FEATURE__TYPE);
153153
return;
154154
}
155155

@@ -170,13 +170,17 @@ private void checkAttritubeType(BasicFeature attribute, ResultAcceptor resultAce
170170
StringQualifiers qualifiers = typeDesc.getStringQualifiers();
171171
if (qualifiers == null)
172172
{
173-
resultAceptor.addIssue(DEFAULT_CHECK_MESSAGE, BASIC_FEATURE__TYPE);
173+
String msg = MessageFormat.format(Messages.MdObjectAttributeCommentCheck_message,
174+
Messages.MdObjectAttributeCommentCheck_Not_a_String);
175+
resultAceptor.addIssue(msg, BASIC_FEATURE__TYPE);
174176
return;
175177
}
176178

177179
if (qualifiers.getLength() != 0)
178180
{
179-
resultAceptor.addIssue(DEFAULT_CHECK_MESSAGE, BASIC_FEATURE__TYPE);
181+
String msg = MessageFormat.format(Messages.MdObjectAttributeCommentCheck_message,
182+
Messages.MdObjectAttributeCommentCheck_String_is_not_unlimited);
183+
resultAceptor.addIssue(msg, BASIC_FEATURE__TYPE);
180184
}
181185

182186
}
@@ -185,7 +189,9 @@ private void checkAttributeIsMultiline(BasicFeature attribute, ResultAcceptor re
185189
{
186190
if (!attribute.isMultiLine())
187191
{
188-
resultAceptor.addIssue(DEFAULT_CHECK_MESSAGE, BASIC_FEATURE__MULTI_LINE);
192+
String msg = MessageFormat.format(Messages.MdObjectAttributeCommentCheck_message,
193+
Messages.MdObjectAttributeCommentCheck_Multiline_edit_is_not_enabled);
194+
resultAceptor.addIssue(msg, BASIC_FEATURE__MULTI_LINE);
189195
}
190196
}
191197

bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/Messages.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ final class Messages
2828
public static String MdObjectAttributeCommentCheck_Attribute_list;
2929
public static String MdObjectAttributeCommentCheck_Check_catalogs_param;
3030
public static String MdObjectAttributeCommentCheck_Check_documents_param;
31-
public static String MdObjectAttributeCommentCheck_Default_check_message;
31+
public static String MdObjectAttributeCommentCheck_Is_compound_type;
32+
public static String MdObjectAttributeCommentCheck_Multiline_edit_is_not_enabled;
33+
public static String MdObjectAttributeCommentCheck_Not_a_String;
34+
public static String MdObjectAttributeCommentCheck_String_is_not_unlimited;
3235
public static String MdObjectAttributeCommentCheck_description;
36+
public static String MdObjectAttributeCommentCheck_message;
3337
public static String MdObjectAttributeCommentCheck_title;
3438
public static String MdObjectAttributeCommentNotExist_description;
3539
public static String MdObjectAttributeCommentNotExist_Md_Object_attribute_Comment_does_not_exist;

bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/messages.properties

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,25 @@ MdListObjectPresentationCheck_decription = Neither Object presentation nor List
3131

3232
MdListObjectPresentationCheck_title = Neither Object presentation nor List presentation is not filled
3333

34-
MdObjectAttributeCommentCheck_Attribute_list=Attributes list
34+
MdObjectAttributeCommentCheck_Attribute_list = Attributes list
3535

36-
MdObjectAttributeCommentCheck_Check_catalogs_param=Check Catalogs
36+
MdObjectAttributeCommentCheck_Check_catalogs_param = Check Catalogs
3737

38-
MdObjectAttributeCommentCheck_Check_documents_param=Check Documents
38+
MdObjectAttributeCommentCheck_Check_documents_param = Check Documents
3939

40-
MdObjectAttributeCommentCheck_Default_check_message=The attribute "Comment" has an invalid type
40+
MdObjectAttributeCommentCheck_Is_compound_type = attribute type is compound
4141

42-
MdObjectAttributeCommentCheck_description=The attribute "Comment" has an invalid type
42+
MdObjectAttributeCommentCheck_Multiline_edit_is_not_enabled = multiline edit is not enabled
4343

44-
MdObjectAttributeCommentCheck_title=The attribute "Comment" has an invalid type
44+
MdObjectAttributeCommentCheck_Not_a_String = type is not a String
45+
46+
MdObjectAttributeCommentCheck_String_is_not_unlimited = String must be of unlimited length
47+
48+
MdObjectAttributeCommentCheck_description = The attribute "Comment" has an invalid type
49+
50+
MdObjectAttributeCommentCheck_message = The attribute "Comment" has an invalid type: {0}
51+
52+
MdObjectAttributeCommentCheck_title = The attribute "Comment" has an invalid type
4553

4654
MdObjectAttributeCommentNotExist_Md_Object_attribute_Comment_does_not_exist = Md Object attribute "Comment" does not exist
4755

bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/messages_ru.properties

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,18 @@ MdObjectAttributeCommentCheck_Check_catalogs_param = Проверять спра
3838

3939
MdObjectAttributeCommentCheck_Check_documents_param = Проверять документы
4040

41-
MdObjectAttributeCommentCheck_Default_check_message = Реквизит "Комментарий" имеет недопустимый тип
41+
MdObjectAttributeCommentCheck_Is_compound_type = реквизит имеет составной тип данных
42+
43+
MdObjectAttributeCommentCheck_Multiline_edit_is_not_enabled = не включен многострочный режим
44+
45+
MdObjectAttributeCommentCheck_Not_a_String = тип не Строка
46+
47+
MdObjectAttributeCommentCheck_String_is_not_unlimited = Строка должна быть неограниченной длины
4248

4349
MdObjectAttributeCommentCheck_description = Реквизит "Комментарий" имеет недопустимый тип
4450

51+
MdObjectAttributeCommentCheck_message = Реквизит "Комментарий" имеет недопустимый тип: {0}
52+
4553
MdObjectAttributeCommentCheck_title = Реквизит "Комментарий" имеет недопустимый тип
4654

4755
MdObjectAttributeCommentNotExist_Md_Object_attribute_Comment_does_not_exist = Объект метаданных не имеет реквизит "Комментарий"

0 commit comments

Comments
 (0)