From 6a68ebca6f69905188cccc0093f8fa482d6b304d Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Tue, 22 Jun 2021 14:19:35 +0300 Subject: [PATCH] =?UTF-8?q?#1=20=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BE=D0=BA=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../markdown/ql-temp-table-index.md | 10 ++ .../markdown/ru/ql-temp-table-index.md | 10 ++ bundles/com.e1c.v8codestyle.ql/plugin.xml | 10 +- .../e1c/v8codestyle/ql/check/Messages.java | 3 + .../ql/check/TempTableHasIndex.java | 74 ++++++++++ .../v8codestyle/ql/check/messages.properties | 3 + .../ql/check/messages_ru.properties | 19 +++ .../META-INF/MANIFEST.MF | 7 +- .../build.properties | 3 +- .../resources/temp-table-has-index.ql | 13 ++ .../resources/temp-table-has-no-index.ql | 10 ++ .../ql/itests/CastToMaxNumberTest.java | 5 +- .../ql/itests/JoinToSubQueryTest.java | 5 +- .../ql/itests/TempTableHasIndexTest.java | 131 ++++++++++++++++++ .../ql/itests/TestingCheckResultAcceptor.java | 48 +++++++ .../ql/itests/TestingQlResultAcceptor.java | 71 ++++++++++ .../workspace/QlEmptyProject/.project | 18 +++ .../org.eclipse.core.resources.prefs | 2 + .../QlEmptyProject/DT-INF/PROJECT.PMF | 2 + .../src/Configuration/CommandInterface.cmi | 2 + .../src/Configuration/Configuration.mdo | 41 ++++++ .../MainSectionCommandInterface.cmi | 2 + 22 files changed, 477 insertions(+), 12 deletions(-) create mode 100644 bundles/com.e1c.v8codestyle.ql/markdown/ql-temp-table-index.md create mode 100644 bundles/com.e1c.v8codestyle.ql/markdown/ru/ql-temp-table-index.md create mode 100644 bundles/com.e1c.v8codestyle.ql/src/com/e1c/v8codestyle/ql/check/TempTableHasIndex.java create mode 100644 tests/com.e1c.v8codestyle.ql.itests/resources/temp-table-has-index.ql create mode 100644 tests/com.e1c.v8codestyle.ql.itests/resources/temp-table-has-no-index.ql create mode 100644 tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/TempTableHasIndexTest.java create mode 100644 tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/TestingCheckResultAcceptor.java create mode 100644 tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/TestingQlResultAcceptor.java create mode 100644 tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/.project create mode 100644 tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/.settings/org.eclipse.core.resources.prefs create mode 100644 tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/DT-INF/PROJECT.PMF create mode 100644 tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/src/Configuration/CommandInterface.cmi create mode 100644 tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/src/Configuration/Configuration.mdo create mode 100644 tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/src/Configuration/MainSectionCommandInterface.cmi diff --git a/bundles/com.e1c.v8codestyle.ql/markdown/ql-temp-table-index.md b/bundles/com.e1c.v8codestyle.ql/markdown/ql-temp-table-index.md new file mode 100644 index 00000000..a44667c0 --- /dev/null +++ b/bundles/com.e1c.v8codestyle.ql/markdown/ql-temp-table-index.md @@ -0,0 +1,10 @@ +# ql-temp-table-index + + + +## Noncompliant Code Example + +## Compliant Solution + +## See + diff --git a/bundles/com.e1c.v8codestyle.ql/markdown/ru/ql-temp-table-index.md b/bundles/com.e1c.v8codestyle.ql/markdown/ru/ql-temp-table-index.md new file mode 100644 index 00000000..17d37529 --- /dev/null +++ b/bundles/com.e1c.v8codestyle.ql/markdown/ru/ql-temp-table-index.md @@ -0,0 +1,10 @@ +# ql-temp-table-index + + + +## Неправильно + +## Правильно + +## См. + diff --git a/bundles/com.e1c.v8codestyle.ql/plugin.xml b/bundles/com.e1c.v8codestyle.ql/plugin.xml index 678e53d9..566dfc25 100644 --- a/bundles/com.e1c.v8codestyle.ql/plugin.xml +++ b/bundles/com.e1c.v8codestyle.ql/plugin.xml @@ -24,15 +24,19 @@ + class="com.e1c.v8codestyle.internal.ql.ExecutableExtensionFactory:com.e1c.v8codestyle.ql.check.CamelCaseStringLiteral"> + class="com.e1c.v8codestyle.internal.ql.ExecutableExtensionFactory:com.e1c.v8codestyle.ql.check.JoinToSubQuery"> + class="com.e1c.v8codestyle.internal.ql.ExecutableExtensionFactory:com.e1c.v8codestyle.ql.check.CastToMaxNumber"> + + diff --git a/bundles/com.e1c.v8codestyle.ql/src/com/e1c/v8codestyle/ql/check/Messages.java b/bundles/com.e1c.v8codestyle.ql/src/com/e1c/v8codestyle/ql/check/Messages.java index 3ff6591c..3848c411 100644 --- a/bundles/com.e1c.v8codestyle.ql/src/com/e1c/v8codestyle/ql/check/Messages.java +++ b/bundles/com.e1c.v8codestyle.ql/src/com/e1c/v8codestyle/ql/check/Messages.java @@ -38,6 +38,9 @@ final class Messages public static String JoinToSubQuery_description; public static String JoinToSubQuery_Query_join_to_sub_query_not_allowed; public static String JoinToSubQuery_title; + public static String TempTableHasIndex_description; + public static String TempTableHasIndex_New_temporary_table_should_have_indexes; + public static String TempTableHasIndex_title; static { // initialize resource bundle diff --git a/bundles/com.e1c.v8codestyle.ql/src/com/e1c/v8codestyle/ql/check/TempTableHasIndex.java b/bundles/com.e1c.v8codestyle.ql/src/com/e1c/v8codestyle/ql/check/TempTableHasIndex.java new file mode 100644 index 00000000..17fe9676 --- /dev/null +++ b/bundles/com.e1c.v8codestyle.ql/src/com/e1c/v8codestyle/ql/check/TempTableHasIndex.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (C) 2021, 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.ql.check; + +import static com._1c.g5.v8.dt.ql.model.QlPackage.Literals.ABSTRACT_QUERY_SCHEMA_TABLE__TABLE_NAME; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.EObject; + +import com._1c.g5.v8.dt.ql.model.AbstractQuerySchemaTable; +import com._1c.g5.v8.dt.ql.model.QuerySchemaSelectQuery; +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.g5.v8.dt.ql.check.QlBasicDelegateCheck; + +/** + * The check of QL query that selection put into new temporary table should have some indexes. + * Usually it needs to index join fields with some other table, order fields, filter fields, grouping by fields. + * This check may be enhanced in the future. + * + * @author Dmitriy Marmyshev + */ +public class TempTableHasIndex + extends QlBasicDelegateCheck +{ + + private static final String CHECK_ID = "ql-temp-table-index"; //$NON-NLS-1$ + + @Override + public String getCheckId() + { + return CHECK_ID; + } + + @Override + protected void configureCheck(CheckConfigurer builder) + { + builder.title(Messages.TempTableHasIndex_title) + .description(Messages.TempTableHasIndex_description) + .complexity(CheckComplexity.NORMAL) + .severity(IssueSeverity.MAJOR) + .issueType(IssueType.PERFORMANCE) + .delegate(QuerySchemaSelectQuery.class); + } + + @Override + protected void checkQlObject(EObject object, QueryOwner owner, IQlResultAcceptor resultAceptor, + ICheckParameters parameters, IProgressMonitor monitor) + { + QuerySchemaSelectQuery selectQuery = (QuerySchemaSelectQuery)object; + if (selectQuery.getPlacementTable() == null) + return; + + if (selectQuery.getIndexes() == null || selectQuery.getIndexes().isEmpty()) + { + AbstractQuerySchemaTable table = selectQuery.getPlacementTable(); + resultAceptor.addIssue(Messages.TempTableHasIndex_New_temporary_table_should_have_indexes, table, + ABSTRACT_QUERY_SCHEMA_TABLE__TABLE_NAME); + } + } + +} diff --git a/bundles/com.e1c.v8codestyle.ql/src/com/e1c/v8codestyle/ql/check/messages.properties b/bundles/com.e1c.v8codestyle.ql/src/com/e1c/v8codestyle/ql/check/messages.properties index 0295e610..58d748e6 100644 --- a/bundles/com.e1c.v8codestyle.ql/src/com/e1c/v8codestyle/ql/check/messages.properties +++ b/bundles/com.e1c.v8codestyle.ql/src/com/e1c/v8codestyle/ql/check/messages.properties @@ -23,3 +23,6 @@ CastToMaxNumber_title=Query cast to max number JoinToSubQuery_description=Query join with sub query JoinToSubQuery_Query_join_to_sub_query_not_allowed=Query join to sub query not allowed JoinToSubQuery_title=Query join with sub query +TempTableHasIndex_description=Temporary table should have indexes +TempTableHasIndex_New_temporary_table_should_have_indexes=New temporary table should have indexes +TempTableHasIndex_title=Temporary table should have indexes diff --git a/bundles/com.e1c.v8codestyle.ql/src/com/e1c/v8codestyle/ql/check/messages_ru.properties b/bundles/com.e1c.v8codestyle.ql/src/com/e1c/v8codestyle/ql/check/messages_ru.properties index aa85818b..c5b9aa37 100644 --- a/bundles/com.e1c.v8codestyle.ql/src/com/e1c/v8codestyle/ql/check/messages_ru.properties +++ b/bundles/com.e1c.v8codestyle.ql/src/com/e1c/v8codestyle/ql/check/messages_ru.properties @@ -1,4 +1,17 @@ #Generated by ResourceBundle Editor (http://essiembre.github.io/eclipse-rbe/) +############################################################################### +# Copyright (C) 2021, 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 +############################################################################### +#Generated by ResourceBundle Editor (http://essiembre.github.io/eclipse-rbe/) CamelCaseStringLiteral_Regular_expression_to_skip_literal_content = Регулярное выражение для исключения содержимого литерела @@ -25,3 +38,9 @@ JoinToSubQuery_Query_join_to_sub_query_not_allowed = Соединение в з JoinToSubQuery_description = Соединение запроса с подзапросом JoinToSubQuery_title = Соединение запроса с подзапросом + +TempTableHasIndex_New_temporary_table_should_have_indexes = Новая временная таблица должна содержать индексы + +TempTableHasIndex_description = Временная таблица должна содержать индексы + +TempTableHasIndex_title = Временная таблица должна содержать индексы diff --git a/tests/com.e1c.v8codestyle.ql.itests/META-INF/MANIFEST.MF b/tests/com.e1c.v8codestyle.ql.itests/META-INF/MANIFEST.MF index bab1d78c..4a91fa7d 100644 --- a/tests/com.e1c.v8codestyle.ql.itests/META-INF/MANIFEST.MF +++ b/tests/com.e1c.v8codestyle.ql.itests/META-INF/MANIFEST.MF @@ -10,9 +10,12 @@ Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-Localization: fragment Import-Package: com._1c.g5.v8.bm.integration;version="[9.1.0,10.0.0)", com._1c.g5.v8.dt.core.platform;version="[10.3.0,11.0.0)", + com._1c.g5.v8.dt.dcs.util;version="[13.0.0,14.0.0)", com._1c.g5.v8.dt.form.model;version="[9.0.0,10.0.0)", com._1c.g5.v8.dt.mcore;version="[6.0.0,7.0.0)", - com.e1c.g5.v8.dt.testing.check;version="[1.0.0,2.0.0)", + com._1c.g5.v8.dt.testing;version="[3.0.0,4.0.0)", com._1c.g5.v8.dt.validation.marker;version="[4.0.0,5.0.0)", + com.e1c.g5.v8.dt.testing.check;version="[1.0.0,2.0.0)", org.junit;version="[4.13.0,5.0.0)" -Require-Bundle: org.eclipse.core.resources;bundle-version="[3.13.900,4.0.0)" +Require-Bundle: org.eclipse.core.resources;bundle-version="[3.13.900,4.0.0)", + org.eclipse.xtext;bundle-version="[2.24.0,3.0.0)" diff --git a/tests/com.e1c.v8codestyle.ql.itests/build.properties b/tests/com.e1c.v8codestyle.ql.itests/build.properties index fdd9759e..dced9977 100644 --- a/tests/com.e1c.v8codestyle.ql.itests/build.properties +++ b/tests/com.e1c.v8codestyle.ql.itests/build.properties @@ -15,4 +15,5 @@ output.. = bin/ bin.includes = META-INF/,\ .,\ fragment.properties,\ - workspace/ + workspace/,\ + resources/ diff --git a/tests/com.e1c.v8codestyle.ql.itests/resources/temp-table-has-index.ql b/tests/com.e1c.v8codestyle.ql.itests/resources/temp-table-has-index.ql new file mode 100644 index 00000000..ec7f63d8 --- /dev/null +++ b/tests/com.e1c.v8codestyle.ql.itests/resources/temp-table-has-index.ql @@ -0,0 +1,13 @@ +SELECT + 1 AS Field +INTO T + +INDEX BY + Field +; + +//////////////////////////////////////////////////////////////////////////////// + SELECT + T.Field +FROM + T AS T \ No newline at end of file diff --git a/tests/com.e1c.v8codestyle.ql.itests/resources/temp-table-has-no-index.ql b/tests/com.e1c.v8codestyle.ql.itests/resources/temp-table-has-no-index.ql new file mode 100644 index 00000000..ce715e83 --- /dev/null +++ b/tests/com.e1c.v8codestyle.ql.itests/resources/temp-table-has-no-index.ql @@ -0,0 +1,10 @@ +SELECT + 1 AS Field +INTO T +; + +//////////////////////////////////////////////////////////////////////////////// +SELECT + T.Field +FROM + T AS T \ No newline at end of file diff --git a/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/CastToMaxNumberTest.java b/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/CastToMaxNumberTest.java index d66ed521..121f14da 100644 --- a/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/CastToMaxNumberTest.java +++ b/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/CastToMaxNumberTest.java @@ -29,11 +29,10 @@ import com._1c.g5.v8.dt.form.model.Form; import com._1c.g5.v8.dt.form.model.FormAttribute; import com._1c.g5.v8.dt.validation.marker.Marker; import com.e1c.g5.v8.dt.testing.check.CheckTestBase; -import com.e1c.v8codestyle.ql.check.CamelCaseStringLiteral; +import com.e1c.v8codestyle.ql.check.CastToMaxNumber; /** - * Test {@link CamelCaseStringLiteral} class that checks string literal contains only camel-case words - * or non-word symbols. + * Test {@link CastToMaxNumber} class that checks CAST(10, NUMBER(31,2)) expression to max allowed number. * * @author Dmitriy Marmyshev */ diff --git a/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/JoinToSubQueryTest.java b/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/JoinToSubQueryTest.java index 4b6d55d4..077ee90d 100644 --- a/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/JoinToSubQueryTest.java +++ b/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/JoinToSubQueryTest.java @@ -20,11 +20,10 @@ import com._1c.g5.v8.bm.core.IBmObject; import com._1c.g5.v8.dt.core.platform.IDtProject; import com._1c.g5.v8.dt.validation.marker.Marker; import com.e1c.g5.v8.dt.testing.check.CheckTestBase; -import com.e1c.v8codestyle.ql.check.CamelCaseStringLiteral; +import com.e1c.v8codestyle.ql.check.JoinToSubQuery; /** - * Test {@link CamelCaseStringLiteral} class that checks string literal contains only camel-case words - * or non-word symbols. + * Test {@link JoinToSubQuery} class that checks that selection query has join with some sub query. * * @author Dmitriy Marmyshev */ diff --git a/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/TempTableHasIndexTest.java b/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/TempTableHasIndexTest.java new file mode 100644 index 00000000..bac57d30 --- /dev/null +++ b/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/TempTableHasIndexTest.java @@ -0,0 +1,131 @@ +/******************************************************************************* + * Copyright (C) 2021, 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.ql.itests; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.nio.charset.StandardCharsets; + +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.emf.ecore.EObject; +import org.junit.Before; +import org.junit.Test; + +import com._1c.g5.v8.dt.core.platform.IDtProject; +import com._1c.g5.v8.dt.dcs.util.DcsUtil; +import com._1c.g5.v8.dt.ql.model.QuerySchema; +import com._1c.g5.v8.dt.ql.model.QuerySchemaSelectQuery; +import com.e1c.g5.v8.dt.ql.check.QlBasicDelegateCheck; +import com.e1c.g5.v8.dt.ql.check.QlBasicDelegateCheck.QueryOwner; +import com.e1c.g5.v8.dt.testing.check.SingleProjectReadOnlyCheckTestBase; +import com.e1c.v8codestyle.ql.check.TempTableHasIndex; + +/** + * Test {@link TempTableHasIndex} class that checks selection query that put to new temporary table and has indexes. + * + * @author Dmitriy Marmyshev + */ +public class TempTableHasIndexTest + extends SingleProjectReadOnlyCheckTestBase +{ + + private static final String PROJECT_NAME = "QlEmptyProject"; + + private static final String FOLDER = "/resources/"; + + private TestingCheckResultAcceptor resultAcceptor; + + private TestingQlResultAcceptor qlResultAcceptor; + + private TempTableHasIndex check; + + @Override + protected String getTestConfigurationName() + { + return PROJECT_NAME; + } + + @Before + public void setupCheck() throws Exception + { + resultAcceptor = new TestingCheckResultAcceptor(); + qlResultAcceptor = new TestingQlResultAcceptor(); + QlBasicDelegateCheck.setResultAcceptor((o, f) -> qlResultAcceptor); + check = new TempTableHasIndex(); + } + + @Test + public void testTempTableWithoutIndex() throws Exception + { + IDtProject project = dtProjectManager.getDtProject(PROJECT_NAME); + + String queryText = + new String(getClass().getResourceAsStream(FOLDER + "temp-table-has-no-index.ql").readAllBytes(), + StandardCharsets.UTF_8); + + QuerySchema querySchema = DcsUtil.getQuerySchema(queryText, project); + assertNotNull(querySchema); + assertEquals(2, querySchema.getQueries().size()); + + QlBasicDelegateCheck.setOwner(new QueryOwner(querySchema, null)); + EObject selectQuery = querySchema.getQueries().get(1); + assertTrue(selectQuery instanceof QuerySchemaSelectQuery); + + check.check(selectQuery, resultAcceptor, null, new NullProgressMonitor()); + + assertTrue(qlResultAcceptor.messages.isEmpty()); + assertTrue(qlResultAcceptor.featuredMessages.isEmpty()); + + selectQuery = querySchema.getQueries().get(0); + assertTrue(selectQuery instanceof QuerySchemaSelectQuery); + check.check(selectQuery, resultAcceptor, null, new NullProgressMonitor()); + + assertTrue(qlResultAcceptor.messages.isEmpty()); + assertFalse(qlResultAcceptor.featuredMessages.isEmpty()); + + } + + @Test + public void testTempTableWithIndex() throws Exception + { + IDtProject project = dtProjectManager.getDtProject(PROJECT_NAME); + + String queryText = + new String(getClass().getResourceAsStream(FOLDER + "temp-table-has-index.ql").readAllBytes(), + StandardCharsets.UTF_8); + + QuerySchema querySchema = DcsUtil.getQuerySchema(queryText, project); + assertNotNull(querySchema); + assertEquals(2, querySchema.getQueries().size()); + + QlBasicDelegateCheck.setOwner(new QueryOwner(querySchema, null)); + EObject selectQuery = querySchema.getQueries().get(1); + assertTrue(selectQuery instanceof QuerySchemaSelectQuery); + + check.check(selectQuery, resultAcceptor, null, new NullProgressMonitor()); + + assertTrue(qlResultAcceptor.messages.isEmpty()); + assertTrue(qlResultAcceptor.featuredMessages.isEmpty()); + + selectQuery = querySchema.getQueries().get(0); + assertTrue(selectQuery instanceof QuerySchemaSelectQuery); + check.check(selectQuery, resultAcceptor, null, new NullProgressMonitor()); + + assertTrue(qlResultAcceptor.messages.isEmpty()); + assertTrue(qlResultAcceptor.featuredMessages.isEmpty()); + } + +} diff --git a/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/TestingCheckResultAcceptor.java b/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/TestingCheckResultAcceptor.java new file mode 100644 index 00000000..28b52b92 --- /dev/null +++ b/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/TestingCheckResultAcceptor.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (C) 2021, 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.ql.itests; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import com.e1c.g5.v8.dt.check.ICheckResultAcceptor; +import com.e1c.g5.v8.dt.check.Issue; + +/** + * @author Dmitriy Marmyshev + * + */ +class TestingCheckResultAcceptor + implements ICheckResultAcceptor +{ + final Map> issues = new HashMap<>(); + Iterable iterable; + + @Override + public void addIssue(Object object, Issue issue) + { + issues.computeIfAbsent(object, k -> new ArrayList<>()).add(issue); + } + + @Override + public void delegateChecks(Iterable paramIterable) + { + this.iterable = paramIterable; + } + +} diff --git a/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/TestingQlResultAcceptor.java b/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/TestingQlResultAcceptor.java new file mode 100644 index 00000000..c2baf35b --- /dev/null +++ b/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/itests/TestingQlResultAcceptor.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (C) 2021, 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.ql.itests; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.xtext.util.Triple; +import org.eclipse.xtext.util.Tuples; + +import com.e1c.g5.v8.dt.ql.check.QlBasicDelegateCheck.IQlResultAcceptor; + +/** + * @author Dmitriy Marmyshev + * + */ +class TestingQlResultAcceptor + implements IQlResultAcceptor +{ + + final List messages = new ArrayList<>(); + + final List> featuredMessages = new ArrayList<>(); + + + @Override + public void addIssue(String message) + { + messages.add(message); + } + + @Override + public void addIssue(String message, EObject target, EStructuralFeature feature) + { + featuredMessages.add(Tuples.create(message, target, feature)); + } + + @Override + public void addIssue(String message, EObject target, EStructuralFeature manyFeature, int index) + { + featuredMessages.add(Tuples.create(message, target, manyFeature)); + } + + @Override + public void addIssue(String message, int length) + { + messages.add(message); + } + + @Override + public void addIssue(String message, int lineNumber, int offset, int length) + { + messages.add(message); + } + +} diff --git a/tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/.project b/tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/.project new file mode 100644 index 00000000..0ef34b03 --- /dev/null +++ b/tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/.project @@ -0,0 +1,18 @@ + + + QlEmptyProject + + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + + org.eclipse.xtext.ui.shared.xtextNature + com._1c.g5.v8.dt.core.V8ConfigurationNature + + diff --git a/tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/.settings/org.eclipse.core.resources.prefs b/tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..99f26c02 --- /dev/null +++ b/tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/DT-INF/PROJECT.PMF b/tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/DT-INF/PROJECT.PMF new file mode 100644 index 00000000..6835f1cd --- /dev/null +++ b/tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/DT-INF/PROJECT.PMF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 +Runtime-Version: 8.3.19 diff --git a/tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/src/Configuration/CommandInterface.cmi b/tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/src/Configuration/CommandInterface.cmi new file mode 100644 index 00000000..0cf6de8a --- /dev/null +++ b/tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/src/Configuration/CommandInterface.cmi @@ -0,0 +1,2 @@ + + diff --git a/tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/src/Configuration/Configuration.mdo b/tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/src/Configuration/Configuration.mdo new file mode 100644 index 00000000..9c0158d5 --- /dev/null +++ b/tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/src/Configuration/Configuration.mdo @@ -0,0 +1,41 @@ + + + StringLiteralCameCase + + en + String literal came case + + + + + + + + + 8.3.19 + ManagedApplication + PersonalComputer + + + true + + + OSBackup + true + + + Language.English + Managed + NotAutoFree + DontUse + DontUse + 8.3.19 + + English + + en + English + + en + + diff --git a/tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/src/Configuration/MainSectionCommandInterface.cmi b/tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/src/Configuration/MainSectionCommandInterface.cmi new file mode 100644 index 00000000..0cf6de8a --- /dev/null +++ b/tests/com.e1c.v8codestyle.ql.itests/workspace/QlEmptyProject/src/Configuration/MainSectionCommandInterface.cmi @@ -0,0 +1,2 @@ + +