1
0
mirror of https://github.com/1C-Company/v8-code-style.git synced 2025-12-02 01:11:47 +02:00

#1 Перенос автосортировки метаданных (#8)

This commit is contained in:
Dmitriy Marmyshev
2021-06-19 12:55:51 +03:00
committed by GitHub
parent 6ce35733e7
commit 23509db79f
71 changed files with 3444 additions and 1 deletions

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.e1c.v8codestyle.autosort.itests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@@ -0,0 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=11

View File

@@ -0,0 +1,13 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: com.e1c.v8codestyle.autosort.itests;singleton:=true
Bundle-Version: 0.1.0.qualifier
Bundle-Vendor: %providerName
Fragment-Host: com.e1c.v8codestyle.autosort;bundle-version="[0.1.0,0.2.0)"
Automatic-Module-Name: com.e1c.v8codestyle.autosort.itests
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-Localization: fragment
Import-Package: com._1c.g5.v8.dt.testing;version="[3.1.0,4.0.0)",
org.junit;version="[4.13.0,5.0.0)",
org.junit.runner;version="[4.13.0,5.0.0)"

View File

@@ -0,0 +1,18 @@
###############################################################################
# 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
###############################################################################
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
fragment.properties,\
workspace/

View File

@@ -0,0 +1,15 @@
###############################################################################
# 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
###############################################################################
#Properties file for com.e1c.v8codestyle.autosort.itests
providerName = 1C-Soft LLC
pluginName = 1C:Code style V8 Auto Sort Integration test plugin

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.e1c.v8codestyle</groupId>
<artifactId>tests</artifactId>
<version>0.1.0-SNAPSHOT</version>
</parent>
<artifactId>com.e1c.v8codestyle.autosort.itests</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
</project>

View File

@@ -0,0 +1,44 @@
/*******************************************************************************
* 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.autosort.itests;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IDtProjectManager;
import com._1c.g5.wiring.AbstractServiceAwareModule;
import com.e1c.v8codestyle.autosort.ISortService;
import com.e1c.v8codestyle.internal.autosort.AutoSortPlugin;
/**
* The external dependencies for AutoSort Integration tests plugin
*
* @author Dmitriy Marmyshev
*/
public class ExternalDependenciesModule
extends AbstractServiceAwareModule
{
public ExternalDependenciesModule()
{
super(AutoSortPlugin.getDefault());
}
@Override
protected void doConfigure()
{
// V8 DT
bind(ISortService.class).toService();
bind(IBmModelManager.class).toService();
bind(IDtProjectManager.class).toService();
}
}

View File

@@ -0,0 +1,128 @@
/*******************************************************************************
* 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.autosort.itests;
import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION;
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 org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import com._1c.g5.v8.bm.core.IBmObject;
import com._1c.g5.v8.bm.core.IBmTransaction;
import com._1c.g5.v8.bm.integration.AbstractBmTask;
import com._1c.g5.v8.bm.integration.IBmModel;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IDtProject;
import com._1c.g5.v8.dt.core.platform.IDtProjectManager;
import com._1c.g5.v8.dt.metadata.mdclass.Configuration;
import com._1c.g5.v8.dt.testing.GuiceModules;
import com._1c.g5.v8.dt.testing.JUnitGuiceRunner;
import com._1c.g5.v8.dt.testing.TestingWorkspace;
import com.e1c.v8codestyle.autosort.AutoSortPreferences;
import com.e1c.v8codestyle.autosort.ISortService;
import com.google.inject.Inject;
/**
* Tests for {@link ISortService}
*/
@RunWith(value = JUnitGuiceRunner.class)
@GuiceModules(modules = { ExternalDependenciesModule.class })
public class SortServiceTest
{
private static final String PROJECT_NAME = "Sort";
@Rule
public TestingWorkspace testingWorkspace = new TestingWorkspace(true, true);
@Inject
private ISortService sortService;
@Inject
public IDtProjectManager dtProjectManager;
@Inject
public IBmModelManager bmModelManager;
@Test
public void testSortOff() throws Exception
{
IProject project = testingWorkspace.setUpProject(PROJECT_NAME, getClass());
assertNotNull(project);
IDtProject dtProject = dtProjectManager.getDtProject(project);
assertNotNull(dtProject);
IStatus status = sortService.sortAllMetadata(dtProject, new NullProgressMonitor());
assertTrue(status.isOK());
IBmObject object = getTopObjectByFqn(CONFIGURATION.getName(), dtProject);
assertTrue(object instanceof Configuration);
Configuration configuration = (Configuration)object;
assertFalse(configuration.getCommonModules().isEmpty());
assertEquals("ГМодуль", configuration.getCommonModules().get(0).getName());
assertEquals("БМодуль", configuration.getCommonModules().get(1).getName());
assertEquals("ОбщийМодуль", configuration.getCommonModules().get(2).getName());
assertEquals("АМодуль", configuration.getCommonModules().get(3).getName());
}
@Test
public void testSortSortTop() throws Exception
{
IProject project = testingWorkspace.setUpProject(PROJECT_NAME, getClass());
assertNotNull(project);
IDtProject dtProject = dtProjectManager.getDtProject(project);
assertNotNull(dtProject);
IEclipsePreferences prefs = AutoSortPreferences.getPreferences(project);
prefs.putBoolean(AutoSortPreferences.KEY_ALL_TOP, true);
prefs.flush();
IStatus status = sortService.sortAllMetadata(dtProject, new NullProgressMonitor());
assertTrue(status.isOK());
IBmObject object = getTopObjectByFqn(CONFIGURATION.getName(), dtProject);
assertTrue(object instanceof Configuration);
Configuration configuration = (Configuration)object;
assertFalse(configuration.getCommonModules().isEmpty());
assertEquals("АМодуль", configuration.getCommonModules().get(0).getName());
assertEquals("БМодуль", configuration.getCommonModules().get(1).getName());
assertEquals("ГМодуль", configuration.getCommonModules().get(2).getName());
assertEquals("ОбщийМодуль", configuration.getCommonModules().get(3).getName());
}
protected IBmObject getTopObjectByFqn(final String fqn, IDtProject dtProject)
{
IBmModel model = this.bmModelManager.getModel(dtProject);
return model.executeReadonlyTask(new AbstractBmTask<IBmObject>("GetObject")
{
@Override
public IBmObject execute(IBmTransaction transaction, IProgressMonitor progressMonitor)
{
return transaction.getTopObjectByFqn(fqn);
}
});
}
}

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Sort</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>com._1c.g5.v8.dt.core.V8ConfigurationNature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@@ -0,0 +1,2 @@
Manifest-Version: 1.0
Runtime-Version: 8.3.19

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:CommonModule xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="bfcde769-ba07-48bd-9026-64d301bb8077">
<name>АМодуль</name>
<synonym>
<key>en</key>
<value>А модуль</value>
</synonym>
<server>true</server>
<externalConnection>true</externalConnection>
<clientOrdinaryApplication>true</clientOrdinaryApplication>
</mdclass:CommonModule>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:CommonModule xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="9e98f1c5-d74b-49b1-b58f-693663cff48f">
<name>БМодуль</name>
<synonym>
<key>en</key>
<value>Б модуль</value>
</synonym>
<server>true</server>
<externalConnection>true</externalConnection>
<clientOrdinaryApplication>true</clientOrdinaryApplication>
</mdclass:CommonModule>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:CommonModule xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="6f1efee7-e03b-4d91-bff1-85eb8165135d">
<name>ГМодуль</name>
<synonym>
<key>en</key>
<value>Г модуль</value>
</synonym>
<server>true</server>
<externalConnection>true</externalConnection>
<clientOrdinaryApplication>true</clientOrdinaryApplication>
</mdclass:CommonModule>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:CommonModule xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="db7e9dab-45c7-4f13-b973-2b8ded05e637">
<name>ОбщийМодуль</name>
<synonym>
<key>en</key>
<value>Общий модуль</value>
</synonym>
<server>true</server>
<externalConnection>true</externalConnection>
<clientOrdinaryApplication>true</clientOrdinaryApplication>
</mdclass:CommonModule>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<cmi:CommandInterface xmlns:cmi="http://g5.1c.ru/v8/dt/cmi"/>

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:Configuration xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="a184d5b1-2676-4279-9856-c55fd29ca9ca">
<name>Sort</name>
<synonym>
<key>en</key>
<value>Sort</value>
</synonym>
<containedObjects classId="9cd510cd-abfc-11d4-9434-004095e12fc7" objectId="df9bdbaa-4937-46b7-b6da-16bf6d75c9d1"/>
<containedObjects classId="9fcd25a0-4822-11d4-9414-008048da11f9" objectId="bc43d33b-00f7-4793-be2f-9e51c85991d3"/>
<containedObjects classId="e3687481-0a87-462c-a166-9f34594f9bba" objectId="78aa4961-ac81-4c60-8c07-3cbdf05aac80"/>
<containedObjects classId="9de14907-ec23-4a07-96f0-85521cb6b53b" objectId="5daae9a6-f62c-497e-8570-73588ef03584"/>
<containedObjects classId="51f2d5d8-ea4d-4064-8892-82951750031e" objectId="0a0e32e7-affa-4380-8a39-8901603ded2d"/>
<containedObjects classId="e68182ea-4237-4383-967f-90c1e3370bc7" objectId="6d58e02d-4f3e-4c18-bce9-ad488925a114"/>
<containedObjects classId="fb282519-d103-4dd3-bc12-cb271d631dfc" objectId="bcebccb3-b730-41ad-bf55-6d2bc4023eca"/>
<configurationExtensionCompatibilityMode>8.3.19</configurationExtensionCompatibilityMode>
<defaultRunMode>ManagedApplication</defaultRunMode>
<usePurposes>PersonalComputer</usePurposes>
<usedMobileApplicationFunctionalities>
<functionality>
<use>true</use>
</functionality>
<functionality>
<functionality>OSBackup</functionality>
<use>true</use>
</functionality>
</usedMobileApplicationFunctionalities>
<defaultLanguage>Language.English</defaultLanguage>
<dataLockControlMode>Managed</dataLockControlMode>
<objectAutonumerationMode>NotAutoFree</objectAutonumerationMode>
<modalityUseMode>DontUse</modalityUseMode>
<synchronousPlatformExtensionAndAddInCallUseMode>DontUse</synchronousPlatformExtensionAndAddInCallUseMode>
<compatibilityMode>8.3.19</compatibilityMode>
<languages uuid="58e06e29-5b1c-4bea-9358-f9cd51169821">
<name>English</name>
<synonym>
<key>en</key>
<value>English</value>
</synonym>
<languageCode>en</languageCode>
</languages>
<commonModules>CommonModule.ГМодуль</commonModules>
<commonModules>CommonModule.БМодуль</commonModules>
<commonModules>CommonModule.ОбщийМодуль</commonModules>
<commonModules>CommonModule.АМодуль</commonModules>
</mdclass:Configuration>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<cmi:CommandInterface xmlns:cmi="http://g5.1c.ru/v8/dt/cmi"/>

View File

@@ -25,6 +25,7 @@
<modules>
<module>com.e1c.v8codestyle.md.itests</module>
<module>com.e1c.v8codestyle.autosort.itests</module>
</modules>
<profiles>