From 317a1db5aeb62f4f678c783f2fc6cf03a4e222fc Mon Sep 17 00:00:00 2001 From: IvanSergeev Date: Wed, 3 Dec 2025 14:40:41 +0400 Subject: [PATCH 1/7] add LinkPartSpaceCheck qfix and test --- bundles/com.e1c.v8codestyle.bsl.ui/plugin.xml | 3 + .../bsl/ui/qfix/LinkPartSpaceFix.java | 94 +++++++++++++ .../e1c/v8codestyle/bsl/ui/qfix/Messages.java | 3 + .../bsl/ui/qfix/messages.properties | 2 + .../bsl/ui/qfix/messages_ru.properties | 4 + .../markdown/link-part-comment-space.md | 11 ++ .../markdown/ru/link-part-comment-space.md | 15 +++ bundles/com.e1c.v8codestyle.bsl/plugin.xml | 4 + .../bsl/comment/check/LinkPartSpaceCheck.java | 126 ++++++++++++++++++ .../bsl/comment/check/Messages.java | 4 + .../bsl/comment/check/messages.properties | 8 ++ .../bsl/comment/check/messages_ru.properties | 8 ++ .../space-missing-link-part-after.bsl | 9 ++ .../space-missing-link-part-before.bsl | 9 ++ .../resources/space-missing-link-part.bsl | 8 ++ .../resources/space-non-missing-link-part.bsl | 8 ++ .../check/itests/LinkPartSpaceCheckTest.java | 123 +++++++++++++++++ 17 files changed, 439 insertions(+) create mode 100644 bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java create mode 100644 bundles/com.e1c.v8codestyle.bsl/markdown/link-part-comment-space.md create mode 100644 bundles/com.e1c.v8codestyle.bsl/markdown/ru/link-part-comment-space.md create mode 100644 bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-after.bsl create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-before.bsl create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part.bsl create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/resources/space-non-missing-link-part.bsl create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/comment/check/itests/LinkPartSpaceCheckTest.java diff --git a/bundles/com.e1c.v8codestyle.bsl.ui/plugin.xml b/bundles/com.e1c.v8codestyle.bsl.ui/plugin.xml index 73435860..5489747d 100644 --- a/bundles/com.e1c.v8codestyle.bsl.ui/plugin.xml +++ b/bundles/com.e1c.v8codestyle.bsl.ui/plugin.xml @@ -392,6 +392,9 @@ + + diff --git a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java new file mode 100644 index 00000000..2fe1d96c --- /dev/null +++ b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright (C) 2025, 1C-Soft LLC and others. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * 1C-Soft LLC - initial API and implementation + *******************************************************************************/ +package com.e1c.v8codestyle.bsl.ui.qfix; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.text.edits.DeleteEdit; +import org.eclipse.text.edits.InsertEdit; +import org.eclipse.text.edits.ReplaceEdit; +import org.eclipse.text.edits.TextEdit; +import org.eclipse.xtext.nodemodel.INode; +import org.eclipse.xtext.nodemodel.util.NodeModelUtils; +import org.eclipse.xtext.resource.XtextResource; + +import com._1c.g5.v8.dt.bsl.model.Method; +import com._1c.g5.v8.dt.bsl.model.Module; +import com.e1c.g5.v8.dt.bsl.check.qfix.IXtextBslModuleFixModel; +import com.e1c.g5.v8.dt.bsl.check.qfix.SingleVariantXtextBslModuleFix; +import com.e1c.g5.v8.dt.check.qfix.components.QuickFix; + +/** + * Correct format link part + * + * @author Ivan Sergeev + */ +@QuickFix(checkId = "link-part-comment-space", supplierId = "com.e1c.v8codestyle.bsl") +public class LinkPartSpaceFix + extends SingleVariantXtextBslModuleFix +{ + + @Override + protected void configureFix(FixConfigurer configurer) + { + configurer.interactive(true) + .description(Messages.LinkPartSpaceFix_Description) + .details(Messages.LinkPartSpaceFix_Details); + } + + @Override + protected TextEdit fixIssue(XtextResource state, IXtextBslModuleFixModel model) throws BadLocationException + { + int issueOffset = model.getIssue().getOffset(); + Method method = (Method)model.getElement(); + EObject eObject = getModule(method); + while (!(eObject instanceof Module)) + { + eObject = getModule(eObject); + } + if (eObject instanceof Module) + { + INode node = NodeModelUtils.findActualNodeFor(eObject); + if (node == null) + { + return null; + } + String editText = node.getText(); + char checkChar = editText.charAt(issueOffset + 1); + + if (!Character.isLetter(checkChar)) + { + String nextChar = String.valueOf(editText.charAt(issueOffset + 2)); + if (nextChar.equals(" ")) //$NON-NLS-1$ + { + return new DeleteEdit(issueOffset + 1, 1); + } + else + { + return new ReplaceEdit(issueOffset + 1, 1, " "); //$NON-NLS-1$ + } + } + else + { + return new InsertEdit(issueOffset + 1, " "); //$NON-NLS-1$ + } + } + return null; + } + + private EObject getModule(EObject eObject) + { + EObject nextContainer = eObject.eContainer(); + return nextContainer; + } +} diff --git a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/Messages.java b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/Messages.java index 6108dca3..0f420544 100644 --- a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/Messages.java +++ b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/Messages.java @@ -62,6 +62,9 @@ final class Messages public static String SelfAssignFix_Description; public static String SelfAssignFix_Details; + public static String LinkPartSpaceFix_Description; + public static String LinkPartSpaceFix_Details; + static { // initialize resource bundle diff --git a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages.properties b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages.properties index a4d9cab0..520927ab 100644 --- a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages.properties +++ b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages.properties @@ -29,6 +29,8 @@ SelfAssignFix_Description = Remove self-assign variable SelfAssignFix_Details = Remove self-assign variable ServerExecutionSafeModeFix_description = Enable safe mode ServerExecutionSafeModeFix_details = Insert safe mode enable statement before "Execute" or "Eval" method call +LinkPartSpaceFix_Description = Add missing space +LinkPartSpaceFix_Details = Add missing space UndefinedMethodFix_func_title=Create function UndefinedMethodFix_func_desc=Create a new function in the module UndefinedMethodFix_proc_title=Create procedure diff --git a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages_ru.properties b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages_ru.properties index 0fe5b29d..91641e33 100644 --- a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages_ru.properties +++ b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages_ru.properties @@ -41,6 +41,10 @@ ServerExecutionSafeModeFix_description = Включить безопасный ServerExecutionSafeModeFix_details = Добавить включение безопасного режима перед вызовом метода "Выполнить" или "Вычислить" +LinkPartSpaceFix_Description = Добавить пропущенный пробел + +LinkPartSpaceFix_Details = Добавить пропущенный пробел + UndefinedMethodFix_func_desc = Создать новую функцию в модуле UndefinedMethodFix_func_title = Создать функцию diff --git a/bundles/com.e1c.v8codestyle.bsl/markdown/link-part-comment-space.md b/bundles/com.e1c.v8codestyle.bsl/markdown/link-part-comment-space.md new file mode 100644 index 00000000..6784cef5 --- /dev/null +++ b/bundles/com.e1c.v8codestyle.bsl/markdown/link-part-comment-space.md @@ -0,0 +1,11 @@ +# Space in link part comment + +Missing space before link. + +## Noncompliant Code Example + +//IncorrectLink - SeeCatalogs.Catalog + +## Compliant Solution + +//CorrectLink - See Catalogs.Catalog \ No newline at end of file diff --git a/bundles/com.e1c.v8codestyle.bsl/markdown/ru/link-part-comment-space.md b/bundles/com.e1c.v8codestyle.bsl/markdown/ru/link-part-comment-space.md new file mode 100644 index 00000000..b3992e38 --- /dev/null +++ b/bundles/com.e1c.v8codestyle.bsl/markdown/ru/link-part-comment-space.md @@ -0,0 +1,15 @@ +# Пробел в описании метода перед ссылкой + +Пропущеный пробел перед ссылкой в описании метода коментарием. + +## Неправильно + +Например, неправильно: + +//Неправельная ссылка - См.Справочники.Справочник1 + +## Правильно + +Например, правельно: + +//Правельная ссылка - См. Справочники.Справочник1 \ No newline at end of file diff --git a/bundles/com.e1c.v8codestyle.bsl/plugin.xml b/bundles/com.e1c.v8codestyle.bsl/plugin.xml index 72973bf4..a1309786 100644 --- a/bundles/com.e1c.v8codestyle.bsl/plugin.xml +++ b/bundles/com.e1c.v8codestyle.bsl/plugin.xml @@ -196,6 +196,10 @@ category="com.e1c.v8codestyle.bsl.comment" class="com.e1c.v8codestyle.internal.bsl.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.comment.check.RefLinkPartCheck"> + + diff --git a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java new file mode 100644 index 00000000..2691e4aa --- /dev/null +++ b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java @@ -0,0 +1,126 @@ +/******************************************************************************* + * Copyright (C) 2025, 1C-Soft LLC and others. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * 1C-Soft LLC - initial API and implementation + *******************************************************************************/ +package com.e1c.v8codestyle.bsl.comment.check; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.nodemodel.INode; +import org.eclipse.xtext.nodemodel.util.NodeModelUtils; +import org.eclipse.xtext.scoping.IScopeProvider; + +import com._1c.g5.v8.dt.bsl.documentation.comment.BslDocumentationComment; +import com._1c.g5.v8.dt.bsl.documentation.comment.BslDocumentationComment.Description; +import com._1c.g5.v8.dt.bsl.documentation.comment.IDescriptionPart; +import com._1c.g5.v8.dt.bsl.documentation.comment.LinkPart; +import com._1c.g5.v8.dt.bsl.model.Method; +import com._1c.g5.v8.dt.core.platform.IBmModelManager; +import com._1c.g5.v8.dt.core.platform.IResourceLookup; +import com._1c.g5.v8.dt.core.platform.IV8Project; +import com._1c.g5.v8.dt.core.platform.IV8ProjectManager; +import com.e1c.g5.dt.core.api.naming.INamingService; +import com.e1c.g5.dt.core.api.platform.BmOperationContext; +import com.e1c.g5.v8.dt.check.CheckComplexity; +import com.e1c.g5.v8.dt.check.ICheckParameters; +import com.e1c.g5.v8.dt.check.settings.IssueSeverity; +import com.e1c.g5.v8.dt.check.settings.IssueType; +import com.e1c.v8codestyle.check.CommonSenseCheckExtension; +import com.e1c.v8codestyle.internal.bsl.BslPlugin; +import com.google.inject.Inject; + +/** + * Validates {@link LinkPart} of documentation comment has a space before the link + * + * @author Ivan Sergeev + */ +public class LinkPartSpaceCheck + extends AbstractDocCommentTypeCheck +{ + private static final String CHECK_ID = "link-part-comment-space"; //$NON-NLS-1$ + + /** + * Instantiates a new reference link part check. + * + * @param resourceLookup service for look up workspace resources, see {@link IResourceLookup}, cannot be null + * @param namingService service for getting names of EDT object and resources, cannot be null + * @param bmModelManager service for getting instance of Bm Model by {@link EObject}, cannot be null + * @param v8ProjectManager {@link IV8ProjectManager} for getting {@link IV8Project} by {@link EObject}, cannot be null + * @param scopeProvider the scope provider service, cannot be {@code null}. + */ + @Inject + public LinkPartSpaceCheck(IResourceLookup resourceLookup, INamingService namingService, + IBmModelManager bmModelManager, IV8ProjectManager v8ProjectManager, IScopeProvider scopeProvider) + { + super(resourceLookup, namingService, bmModelManager, v8ProjectManager); + } + + @Override + public String getCheckId() + { + return CHECK_ID; + } + + @Override + protected void configureCheck(CheckConfigurer builder) + { + builder.title(Messages.LinkPartSpaceCheck_title) + .description(Messages.LinkPartSpaceCheck_description) + .complexity(CheckComplexity.NORMAL) + .severity(IssueSeverity.MINOR) + .issueType(IssueType.CODE_STYLE) + .extension(new CommonSenseCheckExtension(getCheckId(), BslPlugin.PLUGIN_ID)) + .delegate(LinkPart.class); + } + + @Override + protected void checkDocumentationCommentObject(IDescriptionPart object, BslDocumentationComment root, + DocumentationCommentResultAcceptor resultAceptor, ICheckParameters parameters, + BmOperationContext typeComputationContext, IProgressMonitor monitor) + { + LinkPart linkPart = (LinkPart)object; + + if (object.getParent() instanceof Description) + { + String checkString = linkPart.getInitialContent(); + String stringLink = linkPart.getLinkText(); + Method method = root.getMethod(); + INode node = NodeModelUtils.findActualNodeFor(method); + if (node == null) + { + return; + } + if (checkString.toLowerCase().indexOf("См.".toLowerCase()) != -1 //$NON-NLS-1$ + || checkString.toLowerCase().indexOf("See".toLowerCase()) != -1) //$NON-NLS-1$ + { + String textMethod = node.getText(); + int indexCheckChar = textMethod.indexOf(checkString); + int indexLinkText = checkString.indexOf(stringLink); + char checkChar = checkString.charAt(indexLinkText - 1); + char checkPrevChar = textMethod.charAt(indexCheckChar - 1); + if (!String.valueOf(checkChar).equals(" ") //$NON-NLS-1$ + && !Character.isLetter(checkPrevChar)) + { + if (stringLink.equals(":") || stringLink.equals("_")) //$NON-NLS-1$ //$NON-NLS-2$ + { + resultAceptor.addIssue(Messages.LinkPartSpaceCheck_issueColon, linkPart.getLineNumber(), + linkPart.getLinkTextOffset() - 1, 2); + } + else + { + resultAceptor.addIssue(Messages.LinkPartSpaceCheck_issue, linkPart.getLineNumber(), + linkPart.getLinkTextOffset() - 1, 2); + } + } + } + } + } +} \ No newline at end of file diff --git a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/Messages.java b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/Messages.java index 69d08199..87711af1 100644 --- a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/Messages.java +++ b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/Messages.java @@ -73,6 +73,10 @@ final class Messages public static String RefLinkPartCheck_description; public static String RefLinkPartCheck_Link_referenced_to_unexisting_object; public static String RefLinkPartCheck_title; + public static String LinkPartSpaceCheck_description; + public static String LinkPartSpaceCheck_issue; + public static String LinkPartSpaceCheck_title; + public static String LinkPartSpaceCheck_issueColon; public static String TypeDefinitionCheck_description; public static String TypeDefinitionCheck_title; public static String TypeDefinitionCheck_Unkown_type_M_specified; diff --git a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages.properties b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages.properties index ff3a4bb1..76b0810b 100644 --- a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages.properties +++ b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages.properties @@ -114,6 +114,14 @@ RefLinkPartCheck_description = Documentation comment link referenced object exis RefLinkPartCheck_title = Documentation comment link referenced object exist +LinkPartSpaceCheck_description = Check for space after 'See' before link + +LinkPartSpaceCheck_title = Check for space after 'See' before link + +LinkPartSpaceCheck_issue = There is a space missing after 'See' before the link + +LinkPartSpaceCheck_issueColon = There is extra colon before the link + TypeDefinitionCheck_Unkown_type_M_specified = Unknown type "{0}" specified in documentation comment TypeDefinitionCheck_description = Documentation comment type definition contains valid type name diff --git a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages_ru.properties b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages_ru.properties index 482f968b..6ae6eeaf 100644 --- a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages_ru.properties +++ b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages_ru.properties @@ -114,6 +114,14 @@ RefLinkPartCheck_description = Ссылка документирующего к RefLinkPartCheck_title = Ссылка документирующего комментария на существующий объект +LinkPartSpaceCheck_description = Проверка наличия пробела после 'См.' перед ссылкой + +LinkPartSpaceCheck_title = Проверка наличия пробела после 'См.' перед ссылкой + +LinkPartSpaceCheck_issue = Отсутствует пробел после 'См.' перед ссылкой + +LinkPartSpaceCheck_issueColon = Лишнее двоеточие перед ссылкой + TypeDefinitionCheck_Unkown_type_M_specified = Неизвестный тип "{0}" указан в документирующем комментарии TypeDefinitionCheck_description = Определение типа документирующего комментария содержит правильное имя типа diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-after.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-after.bsl new file mode 100644 index 00000000..5ec70bb1 --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-after.bsl @@ -0,0 +1,9 @@ +#Region Abcd + +//CorrectLink - See Catalog.Catalog1 +//IncorrectLink - SeeCatalog.Catalog1 +Procedure Test() + +EndProcedure + +#EndRegion diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-before.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-before.bsl new file mode 100644 index 00000000..e06944fd --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-before.bsl @@ -0,0 +1,9 @@ +#Region Abcd + +//IncorrectLink - SeeCatalog.Catalog1 +//CorrectLink - See Catalog.Catalog1 +Procedure Test() + +EndProcedure + +#EndRegion diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part.bsl new file mode 100644 index 00000000..752afba0 --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part.bsl @@ -0,0 +1,8 @@ +#Region Abcd + +//IncorrectLink - SeeCatalog.Catalog1 +Procedure Test() + +EndProcedure + +#EndRegion diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/space-non-missing-link-part.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-non-missing-link-part.bsl new file mode 100644 index 00000000..4e6705c9 --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-non-missing-link-part.bsl @@ -0,0 +1,8 @@ +#Region Abcd + +//CorrectLink - See Catalog.Catalog1 +Procedure Test() + +EndProcedure + +#EndRegion diff --git a/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/comment/check/itests/LinkPartSpaceCheckTest.java b/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/comment/check/itests/LinkPartSpaceCheckTest.java new file mode 100644 index 00000000..743c7cd2 --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/comment/check/itests/LinkPartSpaceCheckTest.java @@ -0,0 +1,123 @@ +/******************************************************************************* + * Copyright (C) 2025, 1C-Soft LLC and others. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * 1C-Soft LLC - initial API and implementation + *******************************************************************************/ +package com.e1c.v8codestyle.bsl.comment.check.itests; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.junit.Test; + +import com._1c.g5.v8.dt.validation.marker.Marker; +import com._1c.g5.v8.dt.validation.marker.StandardExtraInfo; +import com.e1c.v8codestyle.bsl.check.itests.AbstractSingleModuleTestBase; +import com.e1c.v8codestyle.bsl.comment.check.LinkPartSpaceCheck; + +/** + * Tests for {@link LinkPartSpaceCheck} check. + * + * @author Ivan Sergeev + */ +public class LinkPartSpaceCheckTest + extends AbstractSingleModuleTestBase +{ + private static final String PROJECT_NAME = "EventHandlerBooleanParam"; + + private static final String MODULE_FILE_NAME = "/src/Catalogs/Products/ManagerModule.bsl"; + + public LinkPartSpaceCheckTest() + { + super(LinkPartSpaceCheck.class); + } + + @Override + protected boolean enableCleanUp() + { + return true; + } + + @Override + protected String getTestConfigurationName() + { + return PROJECT_NAME; + } + + @Override + protected String getModuleFileName() + { + return MODULE_FILE_NAME; + } + + /** + * Test incorrect link. + * + * @throws Exception the exception + */ + @Test + public void testIncorrectLink() throws Exception + { + updateModule(FOLDER_RESOURCE + "space-missing-link-part.bsl"); + + List markers = getModuleMarkers(); + assertEquals(1, markers.size()); + Marker marker = markers.get(0); + assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); + } + + /** + * Test incorrect link after another link. + * + * @throws Exception the exception + */ + @Test + public void testLinkAfter() throws Exception + { + updateModule(FOLDER_RESOURCE + "space-missing-link-part-after.bsl"); + + List markers = getModuleMarkers(); + assertEquals(1, markers.size()); + Marker marker = markers.get(0); + assertEquals(Integer.valueOf(4), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); + } + + /** + * Test incorrect link before another link + * + * @throws Exception the exception + */ + @Test + public void testLinkBefore() throws Exception + { + updateModule(FOLDER_RESOURCE + "space-missing-link-part-before.bsl"); + + List markers = getModuleMarkers(); + assertEquals(1, markers.size()); + Marker marker = markers.get(0); + assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); + } + + /** + * Test correct link. + * + * @throws Exception the exception + */ + @Test + public void testCorrectLink() throws Exception + { + updateModule(FOLDER_RESOURCE + "space-non-missing-link-part.bsl"); + + List markers = getModuleMarkers(); + assertTrue(markers.isEmpty()); + } +} From a5edc70ad9e87bfee7abd427a0ac8fa30a056fc4 Mon Sep 17 00:00:00 2001 From: Ivan Sergeev <55486074+alonthedark@users.noreply.github.com> Date: Wed, 3 Dec 2025 15:02:19 +0400 Subject: [PATCH 2/7] Update messages.properties --- .../src/com/e1c/v8codestyle/bsl/ui/qfix/messages.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages.properties b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages.properties index 520927ab..1628aa81 100644 --- a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages.properties +++ b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages.properties @@ -29,8 +29,8 @@ SelfAssignFix_Description = Remove self-assign variable SelfAssignFix_Details = Remove self-assign variable ServerExecutionSafeModeFix_description = Enable safe mode ServerExecutionSafeModeFix_details = Insert safe mode enable statement before "Execute" or "Eval" method call -LinkPartSpaceFix_Description = Add missing space -LinkPartSpaceFix_Details = Add missing space +LinkPartSpaceFix_Description = Correct the link format +LinkPartSpaceFix_Details = Correct the link format UndefinedMethodFix_func_title=Create function UndefinedMethodFix_func_desc=Create a new function in the module UndefinedMethodFix_proc_title=Create procedure From 25ef8aae830ea488ffd91d1ee6f78a385424ab56 Mon Sep 17 00:00:00 2001 From: Ivan Sergeev <55486074+alonthedark@users.noreply.github.com> Date: Wed, 3 Dec 2025 15:03:01 +0400 Subject: [PATCH 3/7] Update messages_ru.properties --- .../com/e1c/v8codestyle/bsl/ui/qfix/messages_ru.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages_ru.properties b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages_ru.properties index 91641e33..3a7065db 100644 --- a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages_ru.properties +++ b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages_ru.properties @@ -41,9 +41,9 @@ ServerExecutionSafeModeFix_description = Включить безопасный ServerExecutionSafeModeFix_details = Добавить включение безопасного режима перед вызовом метода "Выполнить" или "Вычислить" -LinkPartSpaceFix_Description = Добавить пропущенный пробел +LinkPartSpaceFix_Description = Привести ссылку к правильному формату -LinkPartSpaceFix_Details = Добавить пропущенный пробел +LinkPartSpaceFix_Details = Привести ссылку к правильному формату UndefinedMethodFix_func_desc = Создать новую функцию в модуле From 50f3cc5b7a20fe86a58d2ab7269f0b68b462b3f0 Mon Sep 17 00:00:00 2001 From: IvanSergeev Date: Mon, 8 Dec 2025 17:40:53 +0400 Subject: [PATCH 4/7] add new test and index check --- .../bsl/ui/qfix/LinkPartSpaceFix.java | 6 +- .../bsl/comment/check/LinkPartSpaceCheck.java | 11 +++- .../extra-colon-before-space-link-part.bsl | 8 +++ ...xtra-colon-before-underscore-link-part.bsl | 8 +++ .../resources/extra-colon-link-part.bsl | 8 +++ .../resources/extra-underscore-link-part.bsl | 8 +++ .../check/itests/LinkPartSpaceCheckTest.java | 64 +++++++++++++++++++ 7 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-before-space-link-part.bsl create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-before-underscore-link-part.bsl create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-link-part.bsl create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/resources/extra-underscore-link-part.bsl diff --git a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java index 2fe1d96c..6c588be6 100644 --- a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java +++ b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java @@ -64,6 +64,10 @@ public class LinkPartSpaceFix return null; } String editText = node.getText(); + if (editText.length() < issueOffset + 1) + { + return null; + } char checkChar = editText.charAt(issueOffset + 1); if (!Character.isLetter(checkChar)) @@ -91,4 +95,4 @@ public class LinkPartSpaceFix EObject nextContainer = eObject.eContainer(); return nextContainer; } -} +} \ No newline at end of file diff --git a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java index 2691e4aa..c087037c 100644 --- a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java +++ b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java @@ -20,6 +20,7 @@ import org.eclipse.xtext.scoping.IScopeProvider; import com._1c.g5.v8.dt.bsl.documentation.comment.BslDocumentationComment; import com._1c.g5.v8.dt.bsl.documentation.comment.BslDocumentationComment.Description; +import com._1c.g5.v8.dt.bsl.documentation.comment.IBslCommentToken; import com._1c.g5.v8.dt.bsl.documentation.comment.IDescriptionPart; import com._1c.g5.v8.dt.bsl.documentation.comment.LinkPart; import com._1c.g5.v8.dt.bsl.model.Method; @@ -98,12 +99,16 @@ public class LinkPartSpaceCheck { return; } - if (checkString.toLowerCase().indexOf("См.".toLowerCase()) != -1 //$NON-NLS-1$ - || checkString.toLowerCase().indexOf("See".toLowerCase()) != -1) //$NON-NLS-1$ + String textMethod = node.getText(); + if (checkString.toLowerCase().indexOf(IBslCommentToken.LINK_RU.toLowerCase()) != -1 + || checkString.toLowerCase().indexOf(IBslCommentToken.LINK.toLowerCase()) != -1) { - String textMethod = node.getText(); int indexCheckChar = textMethod.indexOf(checkString); int indexLinkText = checkString.indexOf(stringLink); + if (indexLinkText == -1 || indexCheckChar == -1 || indexLinkText == 0) + { + return; + } char checkChar = checkString.charAt(indexLinkText - 1); char checkPrevChar = textMethod.charAt(indexCheckChar - 1); if (!String.valueOf(checkChar).equals(" ") //$NON-NLS-1$ diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-before-space-link-part.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-before-space-link-part.bsl new file mode 100644 index 00000000..c73a4cb5 --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-before-space-link-part.bsl @@ -0,0 +1,8 @@ +#Region Abcd + +//IncorrectLink - See: Catalog.Catalog1 +Procedure Test() + +EndProcedure + +#EndRegion diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-before-underscore-link-part.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-before-underscore-link-part.bsl new file mode 100644 index 00000000..1aeaaf65 --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-before-underscore-link-part.bsl @@ -0,0 +1,8 @@ +#Region Abcd + +//IncorrectLink - See:_Catalog.Catalog1 +Procedure Test() + +EndProcedure + +#EndRegion diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-link-part.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-link-part.bsl new file mode 100644 index 00000000..432198e9 --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-link-part.bsl @@ -0,0 +1,8 @@ +#Region Abcd + +//IncorrectLink - See:Catalog.Catalog1 +Procedure Test() + +EndProcedure + +#EndRegion diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-underscore-link-part.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-underscore-link-part.bsl new file mode 100644 index 00000000..381a83fc --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-underscore-link-part.bsl @@ -0,0 +1,8 @@ +#Region Abcd + +//IncorrectLink - See_Catalog.Catalog1 +Procedure Test() + +EndProcedure + +#EndRegion diff --git a/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/comment/check/itests/LinkPartSpaceCheckTest.java b/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/comment/check/itests/LinkPartSpaceCheckTest.java index 743c7cd2..9569f038 100644 --- a/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/comment/check/itests/LinkPartSpaceCheckTest.java +++ b/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/comment/check/itests/LinkPartSpaceCheckTest.java @@ -75,6 +75,70 @@ public class LinkPartSpaceCheckTest assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); } + /** + * Test incorrect link with underscore. + * + * @throws Exception the exception + */ + @Test + public void testIncorrectLinkWithUnderscore() throws Exception + { + updateModule(FOLDER_RESOURCE + "extra-underscore-link-part.bsl"); + + List markers = getModuleMarkers(); + assertEquals(1, markers.size()); + Marker marker = markers.get(0); + assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); + } + + /** + * Test incorrect link with colon before. + * + * @throws Exception the exception + */ + @Test + public void testIncorrectLinkWithColonBeforeUnderscore() throws Exception + { + updateModule(FOLDER_RESOURCE + "extra-colon-before-underscore-link-part.bsl"); + + List markers = getModuleMarkers(); + assertEquals(1, markers.size()); + Marker marker = markers.get(0); + assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); + } + + /** + * Test incorrect link with colon. + * + * @throws Exception the exception + */ + @Test + public void testIncorrectLinkWithColon() throws Exception + { + updateModule(FOLDER_RESOURCE + "extra-colon-link-part.bsl"); + + List markers = getModuleMarkers(); + assertEquals(1, markers.size()); + Marker marker = markers.get(0); + assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); + } + + /** + * Test incorrect link with colon before space. + * + * @throws Exception the exception + */ + @Test + public void testIncorrectLinkWithColonBeforeSpace() throws Exception + { + updateModule(FOLDER_RESOURCE + "extra-colon-link-part.bsl"); + + List markers = getModuleMarkers(); + assertEquals(1, markers.size()); + Marker marker = markers.get(0); + assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); + } + /** * Test incorrect link after another link. * From e71a1cc1205198c7b437f3099f2e019ff105e6f5 Mon Sep 17 00:00:00 2001 From: IvanSergeev Date: Wed, 10 Dec 2025 17:55:18 +0400 Subject: [PATCH 5/7] add check "Tab" and test, fix issue --- .../bsl/ui/qfix/LinkPartSpaceFix.java | 2 +- .../markdown/ru/link-part-comment-space.md | 8 ++--- .../bsl/comment/check/LinkPartSpaceCheck.java | 4 +++ .../space-non-missing-tab-link-part.bsl | 8 +++++ .../check/itests/LinkPartSpaceCheckTest.java | 36 ++++++++----------- 5 files changed, 31 insertions(+), 27 deletions(-) create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/resources/space-non-missing-tab-link-part.bsl diff --git a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java index 6c588be6..8b387695 100644 --- a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java +++ b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java @@ -73,7 +73,7 @@ public class LinkPartSpaceFix if (!Character.isLetter(checkChar)) { String nextChar = String.valueOf(editText.charAt(issueOffset + 2)); - if (nextChar.equals(" ")) //$NON-NLS-1$ + if (nextChar.equals(" ") || nextChar.equals("\t")) //$NON-NLS-1$ //$NON-NLS-2$ { return new DeleteEdit(issueOffset + 1, 1); } diff --git a/bundles/com.e1c.v8codestyle.bsl/markdown/ru/link-part-comment-space.md b/bundles/com.e1c.v8codestyle.bsl/markdown/ru/link-part-comment-space.md index b3992e38..9793e4e0 100644 --- a/bundles/com.e1c.v8codestyle.bsl/markdown/ru/link-part-comment-space.md +++ b/bundles/com.e1c.v8codestyle.bsl/markdown/ru/link-part-comment-space.md @@ -1,15 +1,15 @@ # Пробел в описании метода перед ссылкой -Пропущеный пробел перед ссылкой в описании метода коментарием. +Пропущенный пробел перед ссылкой в описании метода комментарием. ## Неправильно Например, неправильно: -//Неправельная ссылка - См.Справочники.Справочник1 +//Неправильная ссылка - См.Справочники.Справочник1 ## Правильно -Например, правельно: +Например, правильно: -//Правельная ссылка - См. Справочники.Справочник1 \ No newline at end of file +//Правильная ссылка - См. Справочники.Справочник1 \ No newline at end of file diff --git a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java index c087037c..df03609e 100644 --- a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java +++ b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java @@ -114,6 +114,10 @@ public class LinkPartSpaceCheck if (!String.valueOf(checkChar).equals(" ") //$NON-NLS-1$ && !Character.isLetter(checkPrevChar)) { + if (String.valueOf(checkChar).equals("\t")) //$NON-NLS-1$ + { + return; + } if (stringLink.equals(":") || stringLink.equals("_")) //$NON-NLS-1$ //$NON-NLS-2$ { resultAceptor.addIssue(Messages.LinkPartSpaceCheck_issueColon, linkPart.getLineNumber(), diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/space-non-missing-tab-link-part.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-non-missing-tab-link-part.bsl new file mode 100644 index 00000000..4e6705c9 --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-non-missing-tab-link-part.bsl @@ -0,0 +1,8 @@ +#Region Abcd + +//CorrectLink - See Catalog.Catalog1 +Procedure Test() + +EndProcedure + +#EndRegion diff --git a/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/comment/check/itests/LinkPartSpaceCheckTest.java b/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/comment/check/itests/LinkPartSpaceCheckTest.java index 9569f038..baf58ea5 100644 --- a/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/comment/check/itests/LinkPartSpaceCheckTest.java +++ b/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/comment/check/itests/LinkPartSpaceCheckTest.java @@ -32,33 +32,11 @@ import com.e1c.v8codestyle.bsl.comment.check.LinkPartSpaceCheck; public class LinkPartSpaceCheckTest extends AbstractSingleModuleTestBase { - private static final String PROJECT_NAME = "EventHandlerBooleanParam"; - - private static final String MODULE_FILE_NAME = "/src/Catalogs/Products/ManagerModule.bsl"; - public LinkPartSpaceCheckTest() { super(LinkPartSpaceCheck.class); } - @Override - protected boolean enableCleanUp() - { - return true; - } - - @Override - protected String getTestConfigurationName() - { - return PROJECT_NAME; - } - - @Override - protected String getModuleFileName() - { - return MODULE_FILE_NAME; - } - /** * Test incorrect link. * @@ -184,4 +162,18 @@ public class LinkPartSpaceCheckTest List markers = getModuleMarkers(); assertTrue(markers.isEmpty()); } + + /** + * Test correct link with tab. + * + * @throws Exception the exception + */ + @Test + public void testCorrectLinkWithTab() throws Exception + { + updateModule(FOLDER_RESOURCE + "space-non-missing-tab-link-part.bsl"); + + List markers = getModuleMarkers(); + assertTrue(markers.isEmpty()); + } } From 83036f105930e72c9a6dcfcda5028dda24ac9ad5 Mon Sep 17 00:00:00 2001 From: IvanSergeev Date: Tue, 16 Dec 2025 16:53:17 +0400 Subject: [PATCH 6/7] fix and add test ru variant --- .../bsl/ui/qfix/LinkPartSpaceFix.java | 56 +++---- .../bsl/ui/qfix/messages.properties | 4 +- .../bsl/ui/qfix/messages_ru.properties | 4 +- .../bsl/comment/check/LinkPartSpaceCheck.java | 26 ++-- .../bsl/comment/check/Messages.java | 1 - .../bsl/comment/check/messages.properties | 4 +- .../bsl/comment/check/messages_ru.properties | 8 +- .../extra-colon-before-space-link-part-ru.bsl | 8 + ...a-colon-before-underscore-link-part-ru.bsl | 8 + .../resources/extra-colon-link-part-ru.bsl | 8 + .../extra-underscore-link-part-ru.bsl | 8 + .../space-missing-link-part-after-ru.bsl | 9 ++ .../space-missing-link-part-before-ru.bsl | 9 ++ .../resources/space-missing-link-part-ru.bsl | 8 + .../space-non-missing-link-part-ru.bsl | 8 + .../space-non-missing-tab-link-part-ru.bsl | 8 + .../check/itests/LinkPartSpaceCheckTest.java | 140 ++++++++++++++++++ 17 files changed, 251 insertions(+), 66 deletions(-) create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-before-space-link-part-ru.bsl create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-before-underscore-link-part-ru.bsl create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-link-part-ru.bsl create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/resources/extra-underscore-link-part-ru.bsl create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-after-ru.bsl create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-before-ru.bsl create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-ru.bsl create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/resources/space-non-missing-link-part-ru.bsl create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/resources/space-non-missing-tab-link-part-ru.bsl diff --git a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java index 8b387695..9a5cfbf6 100644 --- a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java +++ b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java @@ -12,17 +12,16 @@ *******************************************************************************/ package com.e1c.v8codestyle.bsl.ui.qfix; -import org.eclipse.emf.ecore.EObject; import org.eclipse.jface.text.BadLocationException; import org.eclipse.text.edits.DeleteEdit; import org.eclipse.text.edits.InsertEdit; import org.eclipse.text.edits.ReplaceEdit; import org.eclipse.text.edits.TextEdit; +import org.eclipse.xtext.EcoreUtil2; import org.eclipse.xtext.nodemodel.INode; import org.eclipse.xtext.nodemodel.util.NodeModelUtils; import org.eclipse.xtext.resource.XtextResource; -import com._1c.g5.v8.dt.bsl.model.Method; import com._1c.g5.v8.dt.bsl.model.Module; import com.e1c.g5.v8.dt.bsl.check.qfix.IXtextBslModuleFixModel; import com.e1c.g5.v8.dt.bsl.check.qfix.SingleVariantXtextBslModuleFix; @@ -50,49 +49,34 @@ public class LinkPartSpaceFix protected TextEdit fixIssue(XtextResource state, IXtextBslModuleFixModel model) throws BadLocationException { int issueOffset = model.getIssue().getOffset(); - Method method = (Method)model.getElement(); - EObject eObject = getModule(method); - while (!(eObject instanceof Module)) + Module module = EcoreUtil2.getContainerOfType(model.getElement(), Module.class); + INode moduleNode = NodeModelUtils.findActualNodeFor(module); + if (moduleNode == null) { - eObject = getModule(eObject); + return null; } - if (eObject instanceof Module) + String editText = moduleNode.getText(); + if (editText.length() < issueOffset + 1) { - INode node = NodeModelUtils.findActualNodeFor(eObject); - if (node == null) - { - return null; - } - String editText = node.getText(); - if (editText.length() < issueOffset + 1) - { - return null; - } - char checkChar = editText.charAt(issueOffset + 1); + return null; + } + char checkChar = editText.charAt(issueOffset + 1); - if (!Character.isLetter(checkChar)) + if (!Character.isLetter(checkChar)) + { + String nextChar = String.valueOf(editText.charAt(issueOffset + 2)); + if (nextChar.equals(" ") || nextChar.equals("\t")) //$NON-NLS-1$ //$NON-NLS-2$ { - String nextChar = String.valueOf(editText.charAt(issueOffset + 2)); - if (nextChar.equals(" ") || nextChar.equals("\t")) //$NON-NLS-1$ //$NON-NLS-2$ - { - return new DeleteEdit(issueOffset + 1, 1); - } - else - { - return new ReplaceEdit(issueOffset + 1, 1, " "); //$NON-NLS-1$ - } + return new DeleteEdit(issueOffset + 1, 1); } else { - return new InsertEdit(issueOffset + 1, " "); //$NON-NLS-1$ + return new ReplaceEdit(issueOffset + 1, 1, " "); //$NON-NLS-1$ } } - return null; - } - - private EObject getModule(EObject eObject) - { - EObject nextContainer = eObject.eContainer(); - return nextContainer; + else + { + return new InsertEdit(issueOffset + 1, " "); //$NON-NLS-1$ + } } } \ No newline at end of file diff --git a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages.properties b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages.properties index 520927ab..fbb113ea 100644 --- a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages.properties +++ b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages.properties @@ -29,8 +29,8 @@ SelfAssignFix_Description = Remove self-assign variable SelfAssignFix_Details = Remove self-assign variable ServerExecutionSafeModeFix_description = Enable safe mode ServerExecutionSafeModeFix_details = Insert safe mode enable statement before "Execute" or "Eval" method call -LinkPartSpaceFix_Description = Add missing space -LinkPartSpaceFix_Details = Add missing space +LinkPartSpaceFix_Description = Correct the link format 'See link' +LinkPartSpaceFix_Details = Correct the link format 'See link' UndefinedMethodFix_func_title=Create function UndefinedMethodFix_func_desc=Create a new function in the module UndefinedMethodFix_proc_title=Create procedure diff --git a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages_ru.properties b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages_ru.properties index 91641e33..ad5bbb33 100644 --- a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages_ru.properties +++ b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/messages_ru.properties @@ -41,9 +41,9 @@ ServerExecutionSafeModeFix_description = Включить безопасный ServerExecutionSafeModeFix_details = Добавить включение безопасного режима перед вызовом метода "Выполнить" или "Вычислить" -LinkPartSpaceFix_Description = Добавить пропущенный пробел +LinkPartSpaceFix_Description = Привести ссылку к правильному формату 'См. Ссылка' -LinkPartSpaceFix_Details = Добавить пропущенный пробел +LinkPartSpaceFix_Details = Привести ссылку к правильному формату 'См. Ссылка' UndefinedMethodFix_func_desc = Создать новую функцию в модуле diff --git a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java index df03609e..d5eeda1e 100644 --- a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java +++ b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java @@ -94,15 +94,15 @@ public class LinkPartSpaceCheck String checkString = linkPart.getInitialContent(); String stringLink = linkPart.getLinkText(); Method method = root.getMethod(); - INode node = NodeModelUtils.findActualNodeFor(method); - if (node == null) - { - return; - } - String textMethod = node.getText(); if (checkString.toLowerCase().indexOf(IBslCommentToken.LINK_RU.toLowerCase()) != -1 || checkString.toLowerCase().indexOf(IBslCommentToken.LINK.toLowerCase()) != -1) { + INode node = NodeModelUtils.findActualNodeFor(method); + if (node == null) + { + return; + } + String textMethod = node.getText(); int indexCheckChar = textMethod.indexOf(checkString); int indexLinkText = checkString.indexOf(stringLink); if (indexLinkText == -1 || indexCheckChar == -1 || indexLinkText == 0) @@ -118,18 +118,10 @@ public class LinkPartSpaceCheck { return; } - if (stringLink.equals(":") || stringLink.equals("_")) //$NON-NLS-1$ //$NON-NLS-2$ - { - resultAceptor.addIssue(Messages.LinkPartSpaceCheck_issueColon, linkPart.getLineNumber(), - linkPart.getLinkTextOffset() - 1, 2); - } - else - { - resultAceptor.addIssue(Messages.LinkPartSpaceCheck_issue, linkPart.getLineNumber(), - linkPart.getLinkTextOffset() - 1, 2); - } + resultAceptor.addIssue(Messages.LinkPartSpaceCheck_issue, linkPart.getLineNumber(), + linkPart.getLinkTextOffset() - 1, 2); } } } } -} \ No newline at end of file +} diff --git a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/Messages.java b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/Messages.java index 87711af1..3069b784 100644 --- a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/Messages.java +++ b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/Messages.java @@ -76,7 +76,6 @@ final class Messages public static String LinkPartSpaceCheck_description; public static String LinkPartSpaceCheck_issue; public static String LinkPartSpaceCheck_title; - public static String LinkPartSpaceCheck_issueColon; public static String TypeDefinitionCheck_description; public static String TypeDefinitionCheck_title; public static String TypeDefinitionCheck_Unkown_type_M_specified; diff --git a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages.properties b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages.properties index 76b0810b..81df3ebb 100644 --- a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages.properties +++ b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages.properties @@ -118,9 +118,7 @@ LinkPartSpaceCheck_description = Check for space after 'See' before link LinkPartSpaceCheck_title = Check for space after 'See' before link -LinkPartSpaceCheck_issue = There is a space missing after 'See' before the link - -LinkPartSpaceCheck_issueColon = There is extra colon before the link +LinkPartSpaceCheck_issue = There must be a space after 'See' before the link TypeDefinitionCheck_Unkown_type_M_specified = Unknown type "{0}" specified in documentation comment diff --git a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages_ru.properties b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages_ru.properties index 6ae6eeaf..bce41e8e 100644 --- a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages_ru.properties +++ b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages_ru.properties @@ -114,13 +114,11 @@ RefLinkPartCheck_description = Ссылка документирующего к RefLinkPartCheck_title = Ссылка документирующего комментария на существующий объект -LinkPartSpaceCheck_description = Проверка наличия пробела после 'См.' перед ссылкой +LinkPartSpaceCheck_description = Проверка наличия пробельных символов после 'См.' перед ссылкой -LinkPartSpaceCheck_title = Проверка наличия пробела после 'См.' перед ссылкой +LinkPartSpaceCheck_title = Проверка наличия пробельных символов после 'См.' перед ссылкой -LinkPartSpaceCheck_issue = Отсутствует пробел после 'См.' перед ссылкой - -LinkPartSpaceCheck_issueColon = Лишнее двоеточие перед ссылкой +LinkPartSpaceCheck_issue = Должен быть пробельный символ после 'См.' перед ссылкой TypeDefinitionCheck_Unkown_type_M_specified = Неизвестный тип "{0}" указан в документирующем комментарии diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-before-space-link-part-ru.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-before-space-link-part-ru.bsl new file mode 100644 index 00000000..46ec9ab4 --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-before-space-link-part-ru.bsl @@ -0,0 +1,8 @@ +#Region Abcd + +//IncorrectLink - См.: Catalog.Catalog1 +Procedure Test() + +EndProcedure + +#EndRegion diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-before-underscore-link-part-ru.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-before-underscore-link-part-ru.bsl new file mode 100644 index 00000000..935b167f --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-before-underscore-link-part-ru.bsl @@ -0,0 +1,8 @@ +#Region Abcd + +//IncorrectLink - См.:_Catalog.Catalog1 +Procedure Test() + +EndProcedure + +#EndRegion diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-link-part-ru.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-link-part-ru.bsl new file mode 100644 index 00000000..8becb5b2 --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-colon-link-part-ru.bsl @@ -0,0 +1,8 @@ +#Region Abcd + +//IncorrectLink - См.:Catalog.Catalog1 +Procedure Test() + +EndProcedure + +#EndRegion diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-underscore-link-part-ru.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-underscore-link-part-ru.bsl new file mode 100644 index 00000000..8b27fe20 --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/extra-underscore-link-part-ru.bsl @@ -0,0 +1,8 @@ +#Region Abcd + +//IncorrectLink - См._Catalog.Catalog1 +Procedure Test() + +EndProcedure + +#EndRegion diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-after-ru.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-after-ru.bsl new file mode 100644 index 00000000..5298a67d --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-after-ru.bsl @@ -0,0 +1,9 @@ +#Region Abcd + +//CorrectLink - См. Catalog.Catalog1 +//IncorrectLink - См.Catalog.Catalog1 +Procedure Test() + +EndProcedure + +#EndRegion diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-before-ru.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-before-ru.bsl new file mode 100644 index 00000000..1825618d --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-before-ru.bsl @@ -0,0 +1,9 @@ +#Region Abcd + +//IncorrectLink - См.Catalog.Catalog1 +//CorrectLink - См. Catalog.Catalog1 +Procedure Test() + +EndProcedure + +#EndRegion diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-ru.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-ru.bsl new file mode 100644 index 00000000..d59229ae --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-missing-link-part-ru.bsl @@ -0,0 +1,8 @@ +#Region Abcd + +//IncorrectLink - См.Catalog.Catalog1 +Procedure Test() + +EndProcedure + +#EndRegion diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/space-non-missing-link-part-ru.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-non-missing-link-part-ru.bsl new file mode 100644 index 00000000..c666e10f --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-non-missing-link-part-ru.bsl @@ -0,0 +1,8 @@ +#Region Abcd + +//CorrectLink - См. Catalog.Catalog1 +Procedure Test() + +EndProcedure + +#EndRegion diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/space-non-missing-tab-link-part-ru.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-non-missing-tab-link-part-ru.bsl new file mode 100644 index 00000000..c666e10f --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/space-non-missing-tab-link-part-ru.bsl @@ -0,0 +1,8 @@ +#Region Abcd + +//CorrectLink - См. Catalog.Catalog1 +Procedure Test() + +EndProcedure + +#EndRegion diff --git a/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/comment/check/itests/LinkPartSpaceCheckTest.java b/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/comment/check/itests/LinkPartSpaceCheckTest.java index baf58ea5..ed42d9da 100644 --- a/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/comment/check/itests/LinkPartSpaceCheckTest.java +++ b/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/comment/check/itests/LinkPartSpaceCheckTest.java @@ -53,6 +53,22 @@ public class LinkPartSpaceCheckTest assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); } + /** + * Test incorrect link. + * + * @throws Exception the exception + */ + @Test + public void testIncorrectLinkRu() throws Exception + { + updateModule(FOLDER_RESOURCE + "space-missing-link-part-ru.bsl"); + + List markers = getModuleMarkers(); + assertEquals(1, markers.size()); + Marker marker = markers.get(0); + assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); + } + /** * Test incorrect link with underscore. * @@ -69,6 +85,22 @@ public class LinkPartSpaceCheckTest assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); } + /** + * Test incorrect link with underscore. + * + * @throws Exception the exception + */ + @Test + public void testIncorrectLinkWithUnderscoreRu() throws Exception + { + updateModule(FOLDER_RESOURCE + "extra-underscore-link-part-ru.bsl"); + + List markers = getModuleMarkers(); + assertEquals(1, markers.size()); + Marker marker = markers.get(0); + assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); + } + /** * Test incorrect link with colon before. * @@ -85,6 +117,22 @@ public class LinkPartSpaceCheckTest assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); } + /** + * Test incorrect link with colon before. + * + * @throws Exception the exception + */ + @Test + public void testIncorrectLinkWithColonBeforeUnderscoreRu() throws Exception + { + updateModule(FOLDER_RESOURCE + "extra-colon-before-underscore-link-part-ru.bsl"); + + List markers = getModuleMarkers(); + assertEquals(1, markers.size()); + Marker marker = markers.get(0); + assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); + } + /** * Test incorrect link with colon. * @@ -101,6 +149,22 @@ public class LinkPartSpaceCheckTest assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); } + /** + * Test incorrect link with colon. + * + * @throws Exception the exception + */ + @Test + public void testIncorrectLinkWithColonRu() throws Exception + { + updateModule(FOLDER_RESOURCE + "extra-colon-link-part-ru.bsl"); + + List markers = getModuleMarkers(); + assertEquals(1, markers.size()); + Marker marker = markers.get(0); + assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); + } + /** * Test incorrect link with colon before space. * @@ -117,6 +181,22 @@ public class LinkPartSpaceCheckTest assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); } + /** + * Test incorrect link with colon before space. + * + * @throws Exception the exception + */ + @Test + public void testIncorrectLinkWithColonBeforeSpaceRu() throws Exception + { + updateModule(FOLDER_RESOURCE + "extra-colon-link-part-ru.bsl"); + + List markers = getModuleMarkers(); + assertEquals(1, markers.size()); + Marker marker = markers.get(0); + assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); + } + /** * Test incorrect link after another link. * @@ -133,6 +213,22 @@ public class LinkPartSpaceCheckTest assertEquals(Integer.valueOf(4), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); } + /** + * Test incorrect link after another link. + * + * @throws Exception the exception + */ + @Test + public void testLinkAfterRu() throws Exception + { + updateModule(FOLDER_RESOURCE + "space-missing-link-part-after-ru.bsl"); + + List markers = getModuleMarkers(); + assertEquals(1, markers.size()); + Marker marker = markers.get(0); + assertEquals(Integer.valueOf(4), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); + } + /** * Test incorrect link before another link * @@ -149,6 +245,22 @@ public class LinkPartSpaceCheckTest assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); } + /** + * Test incorrect link before another link + * + * @throws Exception the exception + */ + @Test + public void testLinkBeforeRu() throws Exception + { + updateModule(FOLDER_RESOURCE + "space-missing-link-part-before-ru.bsl"); + + List markers = getModuleMarkers(); + assertEquals(1, markers.size()); + Marker marker = markers.get(0); + assertEquals(Integer.valueOf(3), marker.getExtraInfo().get(StandardExtraInfo.TEXT_LINE)); + } + /** * Test correct link. * @@ -163,6 +275,20 @@ public class LinkPartSpaceCheckTest assertTrue(markers.isEmpty()); } + /** + * Test correct link. + * + * @throws Exception the exception + */ + @Test + public void testCorrectLinkRu() throws Exception + { + updateModule(FOLDER_RESOURCE + "space-non-missing-link-part-ru.bsl"); + + List markers = getModuleMarkers(); + assertTrue(markers.isEmpty()); + } + /** * Test correct link with tab. * @@ -176,4 +302,18 @@ public class LinkPartSpaceCheckTest List markers = getModuleMarkers(); assertTrue(markers.isEmpty()); } + + /** + * Test correct link with tab. + * + * @throws Exception the exception + */ + @Test + public void testCorrectLinkWithTabRu() throws Exception + { + updateModule(FOLDER_RESOURCE + "space-non-missing-tab-link-part-ru.bsl"); + + List markers = getModuleMarkers(); + assertTrue(markers.isEmpty()); + } } From 824abf9b4d1501bd79dc3cffb872c59b0666f8b8 Mon Sep 17 00:00:00 2001 From: IvanSergeev Date: Thu, 18 Dec 2025 14:31:59 +0400 Subject: [PATCH 7/7] fix issue --- .../com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java | 7 ++++++- .../markdown/ru/link-part-comment-space.md | 4 ---- .../v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java | 6 +++--- .../com/e1c/v8codestyle/bsl/comment/check/Messages.java | 6 +++--- .../e1c/v8codestyle/bsl/comment/check/messages.properties | 6 +++--- .../v8codestyle/bsl/comment/check/messages_ru.properties | 6 +++--- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java index 9a5cfbf6..5a8d0de4 100644 --- a/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java +++ b/bundles/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/LinkPartSpaceFix.java @@ -56,7 +56,8 @@ public class LinkPartSpaceFix return null; } String editText = moduleNode.getText(); - if (editText.length() < issueOffset + 1) + int textLenght = editText.length(); + if (textLenght < issueOffset + 1) { return null; } @@ -64,6 +65,10 @@ public class LinkPartSpaceFix if (!Character.isLetter(checkChar)) { + if (textLenght < issueOffset + 2) + { + return null; + } String nextChar = String.valueOf(editText.charAt(issueOffset + 2)); if (nextChar.equals(" ") || nextChar.equals("\t")) //$NON-NLS-1$ //$NON-NLS-2$ { diff --git a/bundles/com.e1c.v8codestyle.bsl/markdown/ru/link-part-comment-space.md b/bundles/com.e1c.v8codestyle.bsl/markdown/ru/link-part-comment-space.md index 9793e4e0..ee26a8ac 100644 --- a/bundles/com.e1c.v8codestyle.bsl/markdown/ru/link-part-comment-space.md +++ b/bundles/com.e1c.v8codestyle.bsl/markdown/ru/link-part-comment-space.md @@ -4,12 +4,8 @@ ## Неправильно -Например, неправильно: - //Неправильная ссылка - См.Справочники.Справочник1 ## Правильно -Например, правильно: - //Правильная ссылка - См. Справочники.Справочник1 \ No newline at end of file diff --git a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java index d5eeda1e..c009a9fe 100644 --- a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java +++ b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/LinkPartSpaceCheck.java @@ -73,8 +73,8 @@ public class LinkPartSpaceCheck @Override protected void configureCheck(CheckConfigurer builder) { - builder.title(Messages.LinkPartSpaceCheck_title) - .description(Messages.LinkPartSpaceCheck_description) + builder.title(Messages.LinkPartSpaceCheck_Title) + .description(Messages.LinkPartSpaceCheck_Description) .complexity(CheckComplexity.NORMAL) .severity(IssueSeverity.MINOR) .issueType(IssueType.CODE_STYLE) @@ -118,7 +118,7 @@ public class LinkPartSpaceCheck { return; } - resultAceptor.addIssue(Messages.LinkPartSpaceCheck_issue, linkPart.getLineNumber(), + resultAceptor.addIssue(Messages.LinkPartSpaceCheck_Issue, linkPart.getLineNumber(), linkPart.getLinkTextOffset() - 1, 2); } } diff --git a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/Messages.java b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/Messages.java index 3069b784..235695d8 100644 --- a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/Messages.java +++ b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/Messages.java @@ -73,9 +73,9 @@ final class Messages public static String RefLinkPartCheck_description; public static String RefLinkPartCheck_Link_referenced_to_unexisting_object; public static String RefLinkPartCheck_title; - public static String LinkPartSpaceCheck_description; - public static String LinkPartSpaceCheck_issue; - public static String LinkPartSpaceCheck_title; + public static String LinkPartSpaceCheck_Description; + public static String LinkPartSpaceCheck_Issue; + public static String LinkPartSpaceCheck_Title; public static String TypeDefinitionCheck_description; public static String TypeDefinitionCheck_title; public static String TypeDefinitionCheck_Unkown_type_M_specified; diff --git a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages.properties b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages.properties index 81df3ebb..51dc0f19 100644 --- a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages.properties +++ b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages.properties @@ -114,11 +114,11 @@ RefLinkPartCheck_description = Documentation comment link referenced object exis RefLinkPartCheck_title = Documentation comment link referenced object exist -LinkPartSpaceCheck_description = Check for space after 'See' before link +LinkPartSpaceCheck_Description = Check for space after 'See' before link -LinkPartSpaceCheck_title = Check for space after 'See' before link +LinkPartSpaceCheck_Title = Check for space after 'See' before link -LinkPartSpaceCheck_issue = There must be a space after 'See' before the link +LinkPartSpaceCheck_Issue = There must be a space after 'See' before the link TypeDefinitionCheck_Unkown_type_M_specified = Unknown type "{0}" specified in documentation comment diff --git a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages_ru.properties b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages_ru.properties index bce41e8e..9c366093 100644 --- a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages_ru.properties +++ b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/comment/check/messages_ru.properties @@ -114,11 +114,11 @@ RefLinkPartCheck_description = Ссылка документирующего к RefLinkPartCheck_title = Ссылка документирующего комментария на существующий объект -LinkPartSpaceCheck_description = Проверка наличия пробельных символов после 'См.' перед ссылкой +LinkPartSpaceCheck_Description = Проверка наличия пробельных символов после 'См.' перед ссылкой -LinkPartSpaceCheck_title = Проверка наличия пробельных символов после 'См.' перед ссылкой +LinkPartSpaceCheck_Title = Проверка наличия пробельных символов после 'См.' перед ссылкой -LinkPartSpaceCheck_issue = Должен быть пробельный символ после 'См.' перед ссылкой +LinkPartSpaceCheck_Issue = Должен быть пробельный символ после 'См.' перед ссылкой TypeDefinitionCheck_Unkown_type_M_specified = Неизвестный тип "{0}" указан в документирующем комментарии