=UTF-8
3 |
--------------------------------------------------------------------------------
/bundles/org.example.ui/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
4 | org.eclipse.jdt.core.compiler.compliance=17
5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7 | org.eclipse.jdt.core.compiler.source=17
8 |
--------------------------------------------------------------------------------
/bundles/org.example.ui/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: %pluginName
4 | Bundle-Vendor: %providerName
5 | Bundle-Version: 1.0.0.qualifier
6 | Bundle-SymbolicName: org.example.ui;singleton:=true
7 | Bundle-Activator: org.example.ui.Activator
8 | Bundle-ActivationPolicy: lazy
9 | Bundle-Localization: plugin
10 | Require-Bundle: org.eclipse.ui;bundle-version="[3.201.0,4.0.0)",
11 | org.eclipse.ui.ide;bundle-version="[3.18.500,4.0.0)",
12 | org.eclipse.xtext.ui;bundle-version="[2.26.0,3.0.0)",
13 | org.apache.log4j;bundle-version="[1.2.15,2.0.0)"
14 | Import-Package: com._1c.g5.v8.dt.bsl.model;version="[5.0.0,6.0.0)",
15 | com._1c.g5.v8.dt.mcore;version="[7.0.0,8.0.0)",
16 | com._1c.g5.v8.dt.mcore.impl;version="[7.0.0,8.0.0)",
17 | com._1c.g5.v8.dt.metadata.mdclass;version="[9.0.0,10.0.0)",
18 | org.antlr.stringtemplate;version="[3.2.0,4.0.0)",
19 | org.eclipse.core.runtime;version="[3.4.0,4.0.0)",
20 | org.osgi.framework;version="[1.8.0,2.0.0)"
21 | Bundle-RequiredExecutionEnvironment: JavaSE-17
22 | Automatic-Module-Name: org.example.ui
23 |
--------------------------------------------------------------------------------
/bundles/org.example.ui/build.properties:
--------------------------------------------------------------------------------
1 | javacCustomEncodings.. = src/[UTF-8]
2 | source.. = src/,\
3 | resources/
4 | bin.includes = META-INF/,\
5 | .,\
6 | plugin.xml,\
7 | plugin.properties,\
8 | resources/
9 |
--------------------------------------------------------------------------------
/bundles/org.example.ui/plugin.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/bundles/org.example.ui/plugin.properties:
--------------------------------------------------------------------------------
1 | pluginName = \u041F\u0440\u0438\u043C\u0435\u0440 \u043F\u043B\u0430\u0433\u0438\u043D\u0430 \u0434\u043B\u044F "1C: Enterprise Development Tools"
2 | providerName = 1C LLC
3 | command.name = \u0421\u043E\u0437\u0434\u0430\u0442\u044C \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432
4 | command.tooltip = \u0412\u044B\u0437\u044B\u0432\u0430\u0435\u0442 \u043A\u043E\u043D\u0441\u0442\u0440\u0443\u043A\u0442\u043E\u0440 \u043E\u0431\u0440\u0430\u0431\u043E\u0442\u0447\u0438\u043A\u0430 \u043F\u0440\u043E\u0432\u0435\u0434\u0435\u043D\u0438\u044F
--------------------------------------------------------------------------------
/bundles/org.example.ui/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
10 |
11 |
12 |
13 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/bundles/org.example.ui/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | org.example
8 | bundles
9 | 1.0.0-SNAPSHOT
10 |
11 | org.example.ui
12 | 1.0.0-SNAPSHOT
13 | eclipse-plugin
14 |
--------------------------------------------------------------------------------
/bundles/org.example.ui/resources/template.txt:
--------------------------------------------------------------------------------
1 |
2 | Процедура ОбработкаПроведения(Отказ, РежимПроведения)
3 | Запись = Движения.$RegisterName$.Добавить();
4 | $body$
5 | Движения.$RegisterName$.Записать();
6 | КонецПроцедуры
--------------------------------------------------------------------------------
/bundles/org.example.ui/src/org/example/ui/Activator.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2020, 1C-Soft LLC
3 | */
4 | package org.example.ui;
5 |
6 | import org.eclipse.core.runtime.IStatus;
7 | import org.eclipse.core.runtime.Plugin;
8 | import org.eclipse.core.runtime.Status;
9 | import org.osgi.framework.BundleContext;
10 |
11 | /**
12 | * Данный класс представляет собой начальную точку в работе плагина.
13 | * В нем следует реализовывать логику создания плагина,
14 | * а так же необходимые действия при завершении работы плагина.
15 | *
16 | * Так же данный класс содержит в себе ряд методов для удобного логирования ошибок
17 | */
18 | public class Activator
19 | extends Plugin
20 | {
21 | public static final String PLUGIN_ID = "com.example.dt.plugin.ui"; //$NON-NLS-1$
22 | private static Activator plugin;
23 |
24 | private BundleContext bundleContext;
25 |
26 | /**
27 | * Получить экземпляр плагина. Через экземпляр плагина можно получать доступ к разнообразным механизмам Eclipse,
28 | * таким как:
29 | *
30 | * - Журнал логирования ошибок плагина
31 | * - Механизм настройки свойств плагина
32 | * - Механизм дескрипторов
33 | *
34 | *
35 | * @return экземпляр плагина, никогда не должен возвращать null
36 | */
37 | public static Activator getDefault()
38 | {
39 | return plugin;
40 | }
41 |
42 | /**
43 | * Запись статуса события в лог журнал плагина.
44 | *
45 | * @param status статус события для логирования, не может быть null
.
46 | * Данный статус содержит в себе информацию о произошедшем событии (ошибка выполнения,
47 | * разнообразные предупреждения), которые были зафиксированы в логике работы плагина.
48 | */
49 | public static void log(IStatus status)
50 | {
51 | plugin.getLog().log(status);
52 | }
53 |
54 | /**
55 | * Запись исключения в лог журнал плагина
56 | *
57 | * @param throwable выкинутое исключение, не может быть null
58 | */
59 | public static void logError(Throwable throwable)
60 | {
61 | log(createErrorStatus(throwable.getMessage(), throwable));
62 | }
63 |
64 | /**
65 | * Создание записи с описанием ошибки в лог журнале плагина по выкинотому исключению и сообщению, его описывающим
66 | *
67 | * @param message описание выкинутого исключения, не может быть null
68 | * @param throwable выкинутое исключение, может быть null
69 | * @return созданное статус событие, не может быть null
70 | */
71 | public static IStatus createErrorStatus(String message, Throwable throwable)
72 | {
73 | return new Status(IStatus.ERROR, PLUGIN_ID, 0, message, throwable);
74 | }
75 |
76 | /**
77 | * Создание записи с описанием предупреждения в лог журнале плагина
78 | *
79 | * @param message описание предупреждения, не может быть null
80 | * @return созданное статус событие, не может быть null
81 | */
82 | public static IStatus createWarningStatus(String message)
83 | {
84 | return new Status(IStatus.WARNING, PLUGIN_ID, 0, message, null);
85 | }
86 |
87 | /**
88 | * Создание записи с описанием предупреждения в лог журнале плагина по выкинотому исключению и сообщению,
89 | * его описывающим
90 | *
91 | * @param message описание выкинутого исключения, не может быть null
92 | * @param throwable выкинутое исключение, может быть null
93 | * @return созданное статус событие, не может быть null
94 | */
95 | public static IStatus createWarningStatus(final String message,
96 | Exception throwable)
97 | {
98 | return new Status(IStatus.WARNING, PLUGIN_ID, 0, message, throwable);
99 | }
100 |
101 | /**
102 | * Данный метод является начальной точкой работы плагина
103 | *
104 | * @param bundleContext объект, создаваемый OSGi Framework, для доступа к разнообразным сервисам, например,
105 | * по работе с файловыми ресурсами внутри проекта
106 | */
107 | @Override
108 | public void start(BundleContext bundleContext) throws Exception
109 | {
110 | super.start(bundleContext);
111 |
112 | this.bundleContext = bundleContext;
113 | plugin = this;
114 | }
115 |
116 | /**
117 | * Данный метод вызывается при завершении работы плагина
118 | *
119 | * @param bundleContext объект, создаваемый OSGi Framework, для доступа к разнообразным сервисам, например,
120 | * по работе с файловыми ресурсами внутри проекта
121 | */
122 | @Override
123 | public void stop(BundleContext bundleContext) throws Exception
124 | {
125 | plugin = null;
126 | super.stop(bundleContext);
127 | }
128 |
129 | /**
130 | * Получить объект, создаваемый OSGi Framework, для доступа к разнообразным сервисам, например, по работе с
131 | * файловыми ресурсами внутри проекта
132 | *
133 | * @return объект, создаваемый OSGi Framework, для доступа к разнообразным сервисам, например, по работе с
134 | * файловыми ресурсами внутри проекта
135 | */
136 | protected BundleContext getContext()
137 | {
138 | return bundleContext;
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/bundles/org.example.ui/src/org/example/ui/DataProcessingHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2020, 1C-Soft LLC
3 | */
4 | package org.example.ui;
5 |
6 | import java.io.IOException;
7 | import java.io.Reader;
8 | import java.nio.charset.StandardCharsets;
9 | import java.util.List;
10 |
11 | import org.antlr.stringtemplate.StringTemplate;
12 | import org.eclipse.core.commands.AbstractHandler;
13 | import org.eclipse.core.commands.ExecutionEvent;
14 | import org.eclipse.core.commands.ExecutionException;
15 | import org.eclipse.core.resources.IFile;
16 | import org.eclipse.core.resources.IProject;
17 | import org.eclipse.emf.ecore.EObject;
18 | import org.eclipse.emf.ecore.util.EcoreUtil;
19 | import org.eclipse.jface.text.BadLocationException;
20 | import org.eclipse.jface.window.Window;
21 | import org.eclipse.swt.SWT;
22 | import org.eclipse.swt.widgets.Display;
23 | import org.eclipse.swt.widgets.MessageBox;
24 | import org.eclipse.ui.IFileEditorInput;
25 | import org.eclipse.ui.IWorkbenchPart;
26 | import org.eclipse.ui.handlers.HandlerUtil;
27 | import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
28 | import org.eclipse.xtext.resource.XtextResource;
29 | import org.eclipse.xtext.ui.editor.XtextEditor;
30 | import org.eclipse.xtext.ui.editor.model.IXtextDocument;
31 | import org.eclipse.xtext.util.Pair;
32 | import org.eclipse.xtext.util.concurrent.IUnitOfWork;
33 |
34 | import com._1c.g5.v8.dt.bsl.model.DeclareStatement;
35 | import com._1c.g5.v8.dt.bsl.model.Module;
36 | import com._1c.g5.v8.dt.bsl.model.ModuleType;
37 | import com._1c.g5.v8.dt.metadata.mdclass.AccumulationRegister;
38 | import com._1c.g5.v8.dt.metadata.mdclass.BasicRegister;
39 | import com._1c.g5.v8.dt.metadata.mdclass.Document;
40 | import com.google.common.base.Function;
41 | import com.google.common.base.Joiner;
42 | import com.google.common.collect.Collections2;
43 | import com.google.common.collect.Lists;
44 | import com.google.common.io.CharSource;
45 | import com.google.common.io.CharStreams;
46 | import com.google.common.io.Resources;
47 |
48 | /**
49 | * Команда создания обработчика проведения в объектном модуле документа, с
50 | * которым связан регистр накопления. Данная команда регистрируется при помощи
51 | * точки разширения с именем "org.eclipse.ui.commands", которая присваивает
52 | * данной команде уникальный идентификатор, по которому можно производит вызов
53 | * данной команды из различных мест, например, из контекстного меню текстового
54 | * редактора.
55 | *
56 | * Данная команда предназначена для работы только с текстовым редактором Xtext
57 | * {@link XtextEditor} и содержит в себе логику для проверки корректности
58 | * добавления обработчика проведения в данный модуль, а так же для определения
59 | * позиции вставки обработчика
60 | */
61 | public class DataProcessingHandler
62 | extends AbstractHandler
63 | {
64 | private static final String TEMPLATE_NAME = "template.txt"; //$NON-NLS-1$
65 | private static String templateContent;
66 |
67 | static
68 | {
69 | //TODO: сделать поддержку генерации английского варианта обработчика
70 | templateContent = readContents(getFileInputSupplier(TEMPLATE_NAME), TEMPLATE_NAME);
71 | }
72 |
73 | @Override
74 | public Object execute(ExecutionEvent event) throws ExecutionException
75 | {
76 | // получим активный Xtext редактор
77 | IWorkbenchPart part = HandlerUtil.getActivePart(event);
78 | XtextEditor target = part.getAdapter(XtextEditor.class);
79 |
80 | if (target != null)
81 | {
82 | // для полученного редактора убедимся, что под ним лежит файл в
83 | // проекте с конфигурацией, иначе это точно не модель объекта
84 | // документа
85 | if (!(target.getEditorInput() instanceof IFileEditorInput))
86 | return null;
87 | IFileEditorInput input = (IFileEditorInput)target.getEditorInput();
88 | IFile file = input.getFile();
89 | if (file == null)
90 | return null;
91 | IProject project = file.getProject();
92 | if (project == null)
93 | return null;
94 | IXtextDocument doc = target.getDocument();
95 |
96 | // получим объект метаданных, к которому принадлежит модуль, из
97 | // которого была вызвана команда
98 | EObject moduleOwner = getModuleOwner(doc);
99 | // проверим, что команда была вызвана из правильного модуля и у
100 | // документа есть хотя бы 1 регистр
101 | if (!(moduleOwner instanceof Document))
102 | {
103 | // Данный модуль не является объектным модулем документа,
104 | // выдадим сообщение об этом и завершим работу
105 | MessageBox dialog = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ERROR);
106 | dialog.setText(Messages.DataProcessingHandler_Error);
107 | dialog.setMessage(Messages.DataProcessingHandler_Error_not_document_object_module);
108 | dialog.open();
109 | return null;
110 | }
111 |
112 | Document mdDocument = (Document)moduleOwner;
113 | List registers = findAccumulationRegister(mdDocument.getRegisterRecords());
114 | if (registers.isEmpty())
115 | {
116 | // У документа нет ниодного регистра накопления, выдадим
117 | // сообщение об этом и завершим работу
118 | MessageBox dialog = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ERROR);
119 | dialog.setText(Messages.DataProcessingHandler_Error);
120 | dialog.setMessage(Messages.DataProcessingHandler_Error_no_accumulation_registers);
121 | dialog.open();
122 | return null;
123 | }
124 |
125 | // создадим диалог конструктора движения регистра
126 | DataProcessingHandlerDialog dialog =
127 | new DataProcessingHandlerDialog(Display.getCurrent().getActiveShell(), mdDocument, registers);
128 | // обработаем завершение работы пользователя с диалогом
129 | if (dialog.open() == Window.OK)
130 | {
131 | // создаем текст обработчика на основании того, что было выбрано
132 | // в конструкторе движения регистра
133 | // для этого воспользуемся заранее приготовленным шаблоном
134 | // обработчика (файл с данным шаблоном находится в папке
135 | // ресурсов плагина)
136 | StringTemplate template = new StringTemplate(templateContent); // считали
137 | // шаблон
138 | // текста
139 | // обработчика
140 | // подставим в шаблон имя регистра,
141 | // для которого делается
142 | // обработка проведения
143 | template.setAttribute("RegisterName", dialog.getRegisterName()); //$NON-NLS-1$
144 | // формируем тело обработчика проведения на основе данных из
145 | // диалога
146 | String body = Joiner.on(System.lineSeparator()).join(
147 | Collections2.transform(dialog.getExpressions(), new Function, String>()
148 | {
149 | @Override
150 | public String apply(Pair item)
151 | {
152 | return "Запись." + item.getFirst() + " = " //$NON-NLS-1$ //$NON-NLS-2$
153 | + item.getSecond() + ';';
154 | }
155 | }));
156 | template.setAttribute("body", body); // дозаполнили шаблон //$NON-NLS-1$
157 | // обработчика
158 | try
159 | {
160 | // определим позицию в модуле, в которую следует добавить
161 | // обработчик
162 | int insertPosition = getInsertHandlerPosition(doc);
163 | // добавляем текст обработчика в модуль
164 | doc.replace(insertPosition, insertPosition, template.toString());
165 | }
166 | catch (BadLocationException e)
167 | {
168 | Activator.createErrorStatus(e.getMessage(), e);
169 | }
170 | }
171 | }
172 | return null;
173 | }
174 |
175 | /*
176 | * Метод выбирает всех регистраторов типа Регистр накопления
177 | */
178 | private List findAccumulationRegister(List registerRecords)
179 | {
180 | List registers = Lists.newArrayList();
181 | for (BasicRegister register : registerRecords)
182 | {
183 | if (register instanceof AccumulationRegister)
184 | registers.add(register);
185 | }
186 | return registers;
187 | }
188 |
189 | private int getInsertHandlerPosition(IXtextDocument doc)
190 | {
191 | //работа с семантической моделью встроенного языка через документ возможна только через специальный метод
192 | //использование других способов приведет к ошибкам
193 | int insertPosition = doc.readOnly(new IUnitOfWork()
194 | {
195 | @Override
196 | public Integer exec(XtextResource res) throws Exception
197 | {
198 | //сперва проверяем, доступность семантической модели встроенного языка
199 | if (res.getContents() != null && !res.getContents().isEmpty())
200 | {
201 | EObject obj = res.getContents().get(0);
202 | if (obj instanceof Module) // проверили, что работаем с правильным объектом семантической модели
203 | {
204 | Module module = (Module)obj;
205 | if (!module.allDeclareStatements().isEmpty())
206 | {
207 | // обработчик вставляется в начало модуля,
208 | // сразу после объявления переменных, если
209 | // они были
210 | DeclareStatement lastDeclStatement =
211 | module.allDeclareStatements().get(module.allDeclareStatements().size() - 1);
212 | return NodeModelUtils.findActualNodeFor(lastDeclStatement).getTotalEndOffset();
213 | }
214 | }
215 | }
216 | return 0;
217 | }
218 | });
219 | return insertPosition;
220 | }
221 |
222 | private EObject getModuleOwner(IXtextDocument doc)
223 | {
224 | //работа с семантической моделью встроенного языка через документ возможна только через специальный метод
225 | //использование других способов приведет к ошибкам
226 | return doc.readOnly(new IUnitOfWork()
227 | {
228 | @Override
229 | public EObject exec(XtextResource res) throws Exception
230 | {
231 | //сперва проверяем, доступность семантической модели встроенного языка
232 | if (res.getContents() != null && !res.getContents().isEmpty())
233 | {
234 | EObject obj = res.getContents().get(0);
235 | if (obj instanceof Module) // проверили, что работаем с правильным объектом семантической модели
236 | {
237 | // интересуют только объектные модули
238 | if (((Module)obj).getModuleType() != ModuleType.OBJECT_MODULE)
239 | return null;
240 | Module module = (Module)obj;
241 | return EcoreUtil.resolve(module.getOwner(), module);
242 | }
243 | }
244 | return null;
245 | }
246 | });
247 | }
248 |
249 | private static String readContents(CharSource source, String path)
250 | {
251 | try (Reader reader = source.openBufferedStream())
252 | {
253 | return CharStreams.toString(reader);
254 | }
255 | catch (IOException | NullPointerException e)
256 | {
257 | return ""; //$NON-NLS-1$
258 | }
259 | }
260 |
261 | private static CharSource getFileInputSupplier(String partName)
262 | {
263 | return Resources.asCharSource(DataProcessingHandler.class.getResource("/resources/" + partName), //$NON-NLS-1$
264 | StandardCharsets.UTF_8);
265 | }
266 | }
267 |
--------------------------------------------------------------------------------
/bundles/org.example.ui/src/org/example/ui/DataProcessingHandlerDialog.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2020, 1C-Soft LLC
3 | */
4 | package org.example.ui;
5 |
6 | import java.util.List;
7 |
8 | import org.eclipse.jface.dialogs.TitleAreaDialog;
9 | import org.eclipse.jface.layout.GridDataFactory;
10 | import org.eclipse.jface.layout.TableColumnLayout;
11 | import org.eclipse.jface.viewers.ArrayContentProvider;
12 | import org.eclipse.jface.viewers.CellEditor;
13 | import org.eclipse.jface.viewers.ColumnViewer;
14 | import org.eclipse.jface.viewers.ColumnWeightData;
15 | import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
16 | import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
17 | import org.eclipse.jface.viewers.DoubleClickEvent;
18 | import org.eclipse.jface.viewers.EditingSupport;
19 | import org.eclipse.jface.viewers.IDoubleClickListener;
20 | import org.eclipse.jface.viewers.ISelectionChangedListener;
21 | import org.eclipse.jface.viewers.IStructuredSelection;
22 | import org.eclipse.jface.viewers.LabelProvider;
23 | import org.eclipse.jface.viewers.SelectionChangedEvent;
24 | import org.eclipse.jface.viewers.StyledString;
25 | import org.eclipse.jface.viewers.TableViewer;
26 | import org.eclipse.jface.viewers.TableViewerColumn;
27 | import org.eclipse.jface.viewers.TextCellEditor;
28 | import org.eclipse.jface.viewers.ViewerCell;
29 | import org.eclipse.swt.SWT;
30 | import org.eclipse.swt.graphics.Image;
31 | import org.eclipse.swt.layout.GridLayout;
32 | import org.eclipse.swt.widgets.Composite;
33 | import org.eclipse.swt.widgets.Control;
34 | import org.eclipse.swt.widgets.Shell;
35 | import org.eclipse.xtext.util.Pair;
36 | import org.eclipse.xtext.util.Tuples;
37 |
38 | import com._1c.g5.v8.dt.mcore.Field;
39 | import com._1c.g5.v8.dt.metadata.mdclass.AccumulationRegister;
40 | import com._1c.g5.v8.dt.metadata.mdclass.AccumulationRegisterDimension;
41 | import com._1c.g5.v8.dt.metadata.mdclass.AccumulationRegisterResource;
42 | import com._1c.g5.v8.dt.metadata.mdclass.BasicRegister;
43 | import com._1c.g5.v8.dt.metadata.mdclass.Document;
44 | import com._1c.g5.v8.dt.metadata.mdclass.DocumentAttribute;
45 | import com.google.common.base.Strings;
46 | import com.google.common.collect.Lists;
47 |
48 | /**
49 | * Диалог конструктора движения регистра.
50 | * В данном диалоге пользователь может выбрать регистр накопления, для которого он хочет сделать обработку проведения.
51 | * А так же указать, состав полей, которые будут учавствовать в логике работы обработчика
52 | * Данный конструктор не поддерживает работу с табличными частями документов
53 | */
54 | public class DataProcessingHandlerDialog
55 | extends TitleAreaDialog
56 | {
57 | private final Document document;
58 | private TableViewer expressionTable;
59 | private TableViewer registerTable;
60 | private String registerName;
61 | private List> expressions;
62 | private List registers;
63 |
64 | /**
65 | * Конструктор
66 | * @param parentShell родительское окно диалога, не может быть null
67 | * @param document документ конфигурации, для модуля которого был вызван диалог, не может быть null
68 | * @param registers все регистраторы документа, типа Регистр накопления, не может быть null
69 | */
70 | public DataProcessingHandlerDialog(Shell parentShell, Document document, List registers)
71 | {
72 | super(parentShell);
73 | this.document = document;
74 | this.registers = registers;
75 | registerName = registers.get(0).getName();
76 | }
77 |
78 | /**
79 | * Получение выражений, заполненных пользователем, которые должны учавствовать в логике работы обработчки проведения
80 | * @return набор выражения обработчика проведения. Данный набор содержит пары значений.
81 | * Где первый элемент пары - это левая часть выражения, которое
82 | * нужно добавить в тело обработчика, а второй элемент пары - это правая часть выражения.
83 | * Не может быть null
84 | */
85 | public List> getExpressions()
86 | {
87 | return expressions;
88 | }
89 |
90 | /**
91 | * Получение имени регистра накопления, для которого пользователь хочет создать обработчик проведения
92 | * @return имя регистра накопления, для которого создается обработчик проведения, не может быть null
93 | */
94 | public String getRegisterName()
95 | {
96 | return registerName;
97 | }
98 |
99 | /**
100 | * Данный метод будет вызван, когда пользователь нажмет кнопку "Ок" диалога.
101 | * В нем происходит наполнение набора выражений обработчика проведения, в соответствии с теми данными,
102 | * которые указал пользователь при работе с диалогом
103 | */
104 | @Override
105 | @SuppressWarnings("unchecked")
106 | protected void okPressed()
107 | {
108 | expressions = Lists.newArrayList();
109 | for (Expression expr : (List)expressionTable.getInput())
110 | {
111 | expressions.add(Tuples.create(expr.field, expr.expression));
112 | }
113 | super.okPressed();
114 | }
115 |
116 | /**
117 | * Данный метод создает и размещает все необходимые элементы в диалоге
118 | * {@inheritDoc}
119 | */
120 | @Override
121 | protected Control createDialogArea(Composite parent)
122 | {
123 | setTitle(Messages.DataProcessingHandlerDialog_dialog_title);
124 | setMessage(Messages.DataProcessingHandlerDialog_dialog_message);
125 | getShell().setText(Messages.DataProcessingHandlerDialog_dialog_text);
126 | Composite control = (Composite)super.createDialogArea(parent);
127 | createTableViewer(control);
128 |
129 | return control;
130 | }
131 |
132 | private void createTableViewer(Composite control)
133 | {
134 | Composite composite = new Composite(control, SWT.NONE);
135 | composite.setLayout(new GridLayout(2, true));
136 | GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
137 | registerTable = createDataTable(composite, Messages.DataProcessingHandlerDialog_Registers, getRegisters());
138 | registerTable.addSelectionChangedListener(new ISelectionChangedListener()
139 | {
140 | @Override
141 | public void selectionChanged(SelectionChangedEvent event)
142 | {
143 | //данный метод соответствует событию выбора регистра накопления из списка
144 | //при данном событии мы должны пересчитать выражения для обработчика проведения
145 | if (!registerName.equals(((IStructuredSelection)event.getSelection()).getFirstElement()))
146 | {
147 | int index = registerTable.getTable().getSelectionIndex();
148 | registerName = registers.get(index).getName();
149 | expressionTable.setInput(createExpressionContent(index));
150 | expressionTable.refresh();
151 | }
152 | }
153 | });
154 | final TableViewer documentTable = createDataTable(composite,
155 | Messages.DataProcessingHandlerDialog_Document_attributes, getDocumentAttributes());
156 | documentTable.addDoubleClickListener(new IDoubleClickListener()
157 | {
158 | @Override
159 | @SuppressWarnings("unchecked")
160 | public void doubleClick(DoubleClickEvent event)
161 | {
162 | //данный метод соответствует событию двойного клика на атрибуте документа
163 | //при данном событии мы заполняем правую часть активного выражения обработчика
164 | //проведения именем данного атрибута
165 | int index = documentTable.getTable().getSelectionIndex();
166 | String documentAttr = ((List)documentTable.getInput()).get(index);
167 | int expressionIndex = expressionTable.getTable().getSelectionIndex();
168 | List listOfExpressions = (List)expressionTable.getInput();
169 | if (expressionIndex < 0 || expressionIndex >= listOfExpressions.size())
170 | {
171 | expressionIndex = 0;
172 | }
173 | listOfExpressions.get(expressionIndex).expression = documentAttr;
174 | expressionTable.refresh();
175 | }
176 | });
177 | composite = new Composite(control, SWT.NONE);
178 | TableColumnLayout columnLayout = new TableColumnLayout();
179 | GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
180 | composite.setLayout(columnLayout);
181 | expressionTable = createExpressionTable(composite, columnLayout);
182 | }
183 |
184 | private TableViewer createExpressionTable(Composite composite, TableColumnLayout columnLayout)
185 | {
186 | final TableViewer tableViewer = new TableViewer(composite, SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION);
187 | GridDataFactory.fillDefaults().grab(true, true).applyTo(tableViewer.getTable());
188 | int height = tableViewer.getTable().getItemHeight() * 5;
189 | tableViewer.getTable().setHeaderVisible(true);
190 | GridDataFactory.fillDefaults().hint(SWT.DEFAULT, height).grab(true, false).applyTo(tableViewer.getTable());
191 | TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.BORDER);
192 | columnLayout.setColumnData(column.getColumn(), new ColumnWeightData(5, ColumnWeightData.MINIMUM_WIDTH, true));
193 | column.getColumn().setResizable(true);
194 | column.getColumn().setText(Messages.DataProcessingHandlerDialog_Field);
195 | column.setLabelProvider(new DelegatingStyledCellLabelProvider(new ExpressionLabelProvider(true)));
196 | column = new TableViewerColumn(tableViewer, SWT.BORDER);
197 | columnLayout.setColumnData(column.getColumn(), new ColumnWeightData(5, ColumnWeightData.MINIMUM_WIDTH, true));
198 | column.getColumn().setResizable(true);
199 | column.getColumn().setText(Messages.DataProcessingHandlerDialog_Expressions);
200 | column.setLabelProvider(new DelegatingStyledCellLabelProvider(new ExpressionLabelProvider(false)));
201 | column.setEditingSupport(new CustomEditingSupport(column.getViewer()));
202 | tableViewer.setContentProvider(ArrayContentProvider.getInstance());
203 | tableViewer.setInput(createExpressionContent(0));
204 | return tableViewer;
205 | }
206 |
207 | private List createExpressionContent(int index)
208 | {
209 | List documentAttr = getDocumentAttributes();
210 | List registerAttr = getRegisterAttr(registers.get(index));
211 | List expressionList = Lists.newArrayList();
212 | for (String attr : registerAttr)
213 | {
214 | if (documentAttr.contains(attr))
215 | expressionList.add(new Expression(attr, attr));
216 | else
217 | expressionList.add(new Expression(attr, "")); //$NON-NLS-1$
218 | }
219 | return expressionList;
220 | }
221 |
222 | private List getRegisterAttr(BasicRegister registerRecords)
223 | {
224 | List fields = Lists.newArrayList();
225 | if (registerRecords instanceof AccumulationRegister)
226 | {
227 | for (AccumulationRegisterDimension dimension : ((AccumulationRegister)registerRecords).getDimensions())
228 | {
229 | if (!Strings.isNullOrEmpty(dimension.getName()))
230 | fields.add(dimension.getName());
231 | }
232 |
233 | for (AccumulationRegisterResource resource : ((AccumulationRegister)registerRecords).getResources())
234 | {
235 | if (!Strings.isNullOrEmpty(resource.getName()))
236 | fields.add(resource.getName());
237 | }
238 | fields.add("Период"); //TODO: сделать поддержку генерации английского варианта обработчика //$NON-NLS-1$
239 | }
240 | return fields;
241 | }
242 |
243 | private TableViewer createDataTable(Composite composite, String headerName, List content)
244 | {
245 | final TableViewer tableViewer = new TableViewer(composite, SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION);
246 | int height = tableViewer.getTable().getItemHeight() * 5;
247 | tableViewer.getTable().setHeaderVisible(true);
248 | GridDataFactory.fillDefaults().hint(SWT.DEFAULT, height).grab(true, false).applyTo(tableViewer.getTable());
249 | TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.BORDER);
250 | column.getColumn().setText(headerName);
251 | column.setLabelProvider(new DelegatingStyledCellLabelProvider(new CustomLabelProvider()));
252 | tableViewer.setContentProvider(ArrayContentProvider.getInstance());
253 | tableViewer.setInput(content);
254 | column.getColumn().pack();
255 | return tableViewer;
256 | }
257 |
258 | private List getRegisters()
259 | {
260 | List registerNames = Lists.newArrayList();
261 | for (BasicRegister register : this.registers)
262 | {
263 | if (!Strings.isNullOrEmpty(register.getName()))
264 | registerNames.add(register.getName());
265 | }
266 | return registerNames;
267 | }
268 |
269 | private List getDocumentAttributes()
270 | {
271 | List documentAttributes = Lists.newArrayList();
272 | for (DocumentAttribute attr : document.getAttributes())
273 | {
274 | if (!Strings.isNullOrEmpty(attr.getName()))
275 | documentAttributes.add(attr.getName());
276 | }
277 | for (Field field : document.getFields())
278 | {
279 | if (!Strings.isNullOrEmpty(field.getNameRu()))
280 | documentAttributes.add(field.getNameRu());
281 | }
282 | return documentAttributes;
283 | }
284 |
285 | private static class Expression
286 | {
287 | public String field;
288 | public String expression;
289 |
290 | Expression(String field, String expression)
291 | {
292 | this.field = field;
293 | this.expression = expression;
294 | }
295 | }
296 |
297 | private static class CustomLabelProvider
298 | extends LabelProvider
299 | implements IStyledLabelProvider
300 | {
301 | @Override
302 | public String getText(Object element)
303 | {
304 | return super.getText(element);
305 | }
306 |
307 | @Override
308 | public StyledString getStyledText(Object element)
309 | {
310 | return new StyledString(super.getText(element));
311 | }
312 |
313 | @Override
314 | public Image getImage(Object element)
315 | {
316 | return super.getImage(element);
317 | }
318 | }
319 |
320 | private static class ExpressionLabelProvider
321 | extends LabelProvider
322 | implements IStyledLabelProvider
323 | {
324 | private final boolean isFieldProvider;
325 |
326 | ExpressionLabelProvider(boolean isFieldProvider)
327 | {
328 | this.isFieldProvider = isFieldProvider;
329 | }
330 |
331 | @Override
332 | public String getText(Object element)
333 | {
334 | if (isFieldProvider)
335 | return super.getText(((Expression)element).field);
336 | else
337 | return super.getText(((Expression)element).expression);
338 | }
339 |
340 | @Override
341 | public StyledString getStyledText(Object element)
342 | {
343 | if (isFieldProvider)
344 | return new StyledString(super.getText(((Expression)element).field));
345 | else
346 | return new StyledString(super.getText(((Expression)element).expression));
347 | }
348 |
349 | @Override
350 | public Image getImage(Object element)
351 | {
352 | return super.getImage(element);
353 | }
354 | }
355 |
356 | private static class CustomEditingSupport
357 | extends EditingSupport
358 | {
359 | private final CellEditor editor;
360 |
361 | CustomEditingSupport(ColumnViewer viewer)
362 | {
363 | super(viewer);
364 | editor = new TextCellEditor((Composite)viewer.getControl());
365 | }
366 |
367 | @Override
368 | protected boolean canEdit(Object arg0)
369 | {
370 | return true;
371 | }
372 |
373 | @Override
374 | protected CellEditor getCellEditor(Object arg0)
375 | {
376 | return editor;
377 | }
378 |
379 | @Override
380 | protected Object getValue(Object arg0)
381 | {
382 | return ((Expression)arg0).expression;
383 | }
384 |
385 | @Override
386 | protected void setValue(Object arg0, Object arg1)
387 | {
388 | //no op
389 | }
390 |
391 | @Override
392 | protected void saveCellEditorValue(CellEditor cellEditor, ViewerCell cell)
393 | {
394 | String value = (String)cellEditor.getValue();
395 | ((Expression)cell.getElement()).expression = value;
396 | getViewer().refresh();
397 | }
398 | }
399 | }
400 |
--------------------------------------------------------------------------------
/bundles/org.example.ui/src/org/example/ui/Messages.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2020, 1C-Soft LLC
3 | */
4 | package org.example.ui;
5 |
6 | import org.eclipse.osgi.util.NLS;
7 |
8 | /**
9 | * Данный класс - представитель локализации механизма строк в Eclipse.
10 | */
11 | final class Messages
12 | extends NLS
13 | {
14 | private static final String BUNDLE_NAME = "org.example.ui.messages"; //$NON-NLS-1$
15 |
16 | public static String DataProcessingHandler_Error_not_document_object_module;
17 | public static String DataProcessingHandler_Error_no_accumulation_registers;
18 | public static String DataProcessingHandler_Error;
19 |
20 | public static String DataProcessingHandlerDialog_dialog_title;
21 | public static String DataProcessingHandlerDialog_dialog_message;
22 | public static String DataProcessingHandlerDialog_dialog_text;
23 | public static String DataProcessingHandlerDialog_Registers;
24 | public static String DataProcessingHandlerDialog_Document_attributes;
25 | public static String DataProcessingHandlerDialog_Field;
26 | public static String DataProcessingHandlerDialog_Expressions;
27 |
28 | static
29 | {
30 | // initialize resource bundle
31 | NLS.initializeMessages(BUNDLE_NAME, Messages.class);
32 | }
33 |
34 | private Messages()
35 | {
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/bundles/org.example.ui/src/org/example/ui/messages.properties:
--------------------------------------------------------------------------------
1 | DataProcessingHandler_Error_not_document_object_module = \u0414\u0430\u043D\u043D\u0430\u044F \u043A\u043E\u043C\u0430\u043D\u0434\u0430 \u043C\u043E\u0436\u0435\u0442 \u0431\u044B\u0442\u044C \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0430 \u0442\u043E\u043B\u044C\u043A\u043E \u0432 \u043E\u0431\u044A\u0435\u043A\u0442\u043D\u043E\u043C \u043C\u043E\u0434\u0443\u043B\u0435 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430
2 | DataProcessingHandler_Error_no_accumulation_registers = \u041D\u0435 \u043D\u0430\u0437\u043D\u0430\u0447\u0435\u043D \u043D\u0438 \u043E\u0434\u0438\u043D \u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043E\u0432. \u0412\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u0435 \u043A\u043E\u043C\u0430\u043D\u0434\u044B \u043D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E
3 | DataProcessingHandler_Error = \u041E\u0448\u0438\u0431\u043A\u0430!
4 | DataProcessingHandlerDialog_dialog_title = \u041A\u043E\u043D\u0441\u0442\u0440\u0443\u043A\u0442\u043E\u0440 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432
5 | DataProcessingHandlerDialog_dialog_message = \u0417\u0430\u043F\u043E\u043B\u043D\u044F\u0435\u0442 \u043A\u043E\u043D\u0442\u0435\u043D\u0442 \u043E\u0431\u0440\u0430\u0431\u043E\u0442\u0447\u0438\u043A\u0430 \u043F\u0440\u043E\u0432\u0435\u0434\u0435\u043D\u0438\u044F \u043C\u043E\u0434\u0443\u043B\u044F \u043E\u0431\u044A\u0435\u043A\u0442\u0430 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430
6 | DataProcessingHandlerDialog_dialog_text = \u041A\u043E\u043D\u0441\u0442\u0440\u0443\u043A\u0442\u043E\u0440 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432
7 | DataProcessingHandlerDialog_Registers = \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u044B
8 | DataProcessingHandlerDialog_Document_attributes = \u0420\u0435\u043A\u0432\u0438\u0437\u0438\u0442\u044B \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430
9 | DataProcessingHandlerDialog_Field = \u041F\u043E\u043B\u0435
10 | DataProcessingHandlerDialog_Expressions = \u0412\u044B\u0440\u0430\u0436\u0435\u043D\u0438\u0435
11 |
--------------------------------------------------------------------------------
/bundles/org.example/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/bundles/org.example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.pde.ManifestBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.pde.SchemaBuilder
20 |
21 |
22 |
23 |
24 |
25 | org.eclipse.jdt.core.javanature
26 | org.eclipse.pde.PluginNature
27 |
28 |
29 |
--------------------------------------------------------------------------------
/bundles/org.example/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding/=UTF-8
3 |
--------------------------------------------------------------------------------
/bundles/org.example/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
4 | org.eclipse.jdt.core.compiler.compliance=17
5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7 | org.eclipse.jdt.core.compiler.source=17
8 |
--------------------------------------------------------------------------------
/bundles/org.example/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: %pluginName
4 | Bundle-Vendor: %providerName
5 | Bundle-Version: 1.0.0.qualifier
6 | Bundle-SymbolicName: org.example;singleton:=true
7 | Bundle-ActivationPolicy: lazy
8 | Bundle-Localization: plugin
9 | Require-Bundle: com._1c.g5.v8.dt.bsl;bundle-version="[26.0.0,27.0.0)",
10 | com._1c.g5.v8.dt.bsl.model;bundle-version="[11.0.0,12.0.0)",
11 | com._1c.g5.v8.dt.mcore;bundle-version="[8.0.0,9.0.0)",
12 | org.eclipse.emf.ecore;bundle-version="[2.26.0,3.0.0)",
13 | org.eclipse.xtext;bundle-version="[2.26.0,3.0.0)"
14 | Bundle-RequiredExecutionEnvironment: JavaSE-17
15 | Automatic-Module-Name: org.example
16 | Export-Package: org.example;version="1.0.0"
17 |
--------------------------------------------------------------------------------
/bundles/org.example/build.properties:
--------------------------------------------------------------------------------
1 | javacCustomEncodings.. = src/[UTF-8]
2 | source.. = src/
3 | bin.includes = META-INF/,\
4 | .,\
5 | plugin.xml,\
6 | plugin.properties
7 |
--------------------------------------------------------------------------------
/bundles/org.example/plugin.properties:
--------------------------------------------------------------------------------
1 | pluginName = \u041F\u0440\u0438\u043C\u0435\u0440 \u043F\u043B\u0430\u0433\u0438\u043D\u0430 \u0434\u043B\u044F "1C: Enterprise Development Tools"
2 | providerName = 1C LLC
--------------------------------------------------------------------------------
/bundles/org.example/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/bundles/org.example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | org.example
8 | bundles
9 | 1.0.0-SNAPSHOT
10 |
11 | org.example
12 | 1.0.0-SNAPSHOT
13 | eclipse-plugin
14 |
--------------------------------------------------------------------------------
/bundles/org.example/src/org/example/ExampleValidator.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2020, 1C-Soft LLC
3 | */
4 | package org.example;
5 |
6 | import org.eclipse.emf.ecore.EObject;
7 | import org.eclipse.xtext.util.CancelIndicator;
8 | import org.eclipse.xtext.validation.Check;
9 | import org.eclipse.xtext.validation.CheckType;
10 |
11 | import com._1c.g5.v8.dt.bsl.model.Method;
12 | import com._1c.g5.v8.dt.bsl.validation.CustomValidationMessageAcceptor;
13 | import com._1c.g5.v8.dt.bsl.validation.IExternalBslValidator;
14 | import com._1c.g5.v8.dt.mcore.McorePackage;
15 |
16 | /**
17 | * Пример расширения проверки модулей.
18 | * Для подробностей см. https://edt.1c.ru/dev/ru/docs/plugins/dev/lang/
19 | *
20 | */
21 | public class ExampleValidator
22 | implements IExternalBslValidator
23 | {
24 | public static final String ERROR_CODE = "Example_MethodNameStartWithCapitalLetter"; //$NON-NLS-1$
25 |
26 | @Override
27 | @Check(CheckType.FAST)
28 | public void validate(EObject object, CustomValidationMessageAcceptor messageAcceptor, CancelIndicator monitor)
29 | {
30 | Method method = (Method)object;
31 | if (!Character.isUpperCase(method.getName().charAt(0)))
32 | {
33 | messageAcceptor.warning(
34 | Messages.getString("ExampleValidator.MethodNameStartWithCapitalLetter"), //$NON-NLS-1$
35 | method,
36 | McorePackage.Literals.NAMED_ELEMENT__NAME, ERROR_CODE);
37 | }
38 | }
39 |
40 | @Override
41 | public boolean needValidation(EObject object)
42 | {
43 | return object instanceof Method;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/bundles/org.example/src/org/example/Messages.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2020, 1C-Soft LLC
3 | */
4 | package org.example;
5 |
6 | import java.util.MissingResourceException;
7 | import java.util.ResourceBundle;
8 |
9 | /**
10 | * Локализация
11 | */
12 | final class Messages
13 | {
14 | private static final String BUNDLE_NAME = "org.example.messages"; //$NON-NLS-1$
15 |
16 | private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
17 |
18 | private Messages()
19 | {
20 | }
21 |
22 | public static String getString(String key)
23 | {
24 | try
25 | {
26 | return RESOURCE_BUNDLE.getString(key);
27 | }
28 | catch (MissingResourceException e)
29 | {
30 | return '!' + key + '!';
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/bundles/org.example/src/org/example/messages.properties:
--------------------------------------------------------------------------------
1 | ExampleValidator.MethodNameStartWithCapitalLetter=\u0418\u043C\u044F \u043C\u0435\u0442\u043E\u0434\u0430 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0441 \u0437\u0430\u0433\u043B\u0430\u0432\u043D\u043E\u0439 \u0431\u0443\u043A\u0432\u044B
2 |
--------------------------------------------------------------------------------
/bundles/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
13 | 4.0.0
14 |
15 | org.example
16 | parent
17 | 1.0.0-SNAPSHOT
18 |
19 |
20 | org.example
21 | bundles
22 | pom
23 | Bundles
24 |
25 |
26 | org.example
27 | org.example.ui
28 |
29 |
30 |
31 |
32 |
33 | org.eclipse.tycho
34 | tycho-source-plugin
35 |
36 |
37 | org.apache.maven.plugins
38 | maven-checkstyle-plugin
39 |
40 |
41 | run-checkstyle
42 | validate
43 |
44 | check
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/checkstyle.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
--------------------------------------------------------------------------------
/features/org.example.feature/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.example.feature
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.pde.FeatureBuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.pde.FeatureNature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/features/org.example.feature/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding/=UTF-8
3 |
--------------------------------------------------------------------------------
/features/org.example.feature/build.properties:
--------------------------------------------------------------------------------
1 | bin.includes = feature.xml,\
2 | feature.properties
--------------------------------------------------------------------------------
/features/org.example.feature/feature.properties:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Copyright (c) 2020 1C-Soft LLC.
3 | #
4 | # This program and the accompanying materials are made available under
5 | # the terms of the Eclipse Public License 2.0 which is available at
6 | # https://www.eclipse.org/legal/epl-2.0/
7 | #
8 | # SPDX-License-Identifier: EPL-2.0
9 | #
10 | # Contributors:
11 | # 1C-Soft LLC - initial API and implementation
12 | ###############################################################################
13 | # feature.properties
14 | # contains externalized strings for feature.xml
15 | # "%foo" in feature.xml corresponds to the key "foo" in this file
16 | # java.io.Properties file (ISO 8859-1 with "\" escapes)
17 | # This file should be translated.
18 |
19 | # "featureName" property - name of the feature
20 | featureName=Example Feature
21 |
22 | # "providerName" property - name of the company that provides the feature
23 | providerName=1C-Soft LLC
24 |
25 | # "description" property - description of the feature
26 | description=Example tycho build
27 |
28 | # "copyright" property - text of the "Feature Update Copyright"
29 | copyright=\
30 | Copyright (c) 2020 1C-Soft LLC and others.\n\n\
31 | This program and the accompanying materials are made available under\n\
32 | the terms of the Eclipse Public License 2.0 which is available at\n\
33 | https://www.eclipse.org/legal/epl-2.0/\n\n\
34 | SPDX-License-Identifier: EPL-2.0\n
35 | ################ end of copyright property ####################################
--------------------------------------------------------------------------------
/features/org.example.feature/feature.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
18 |
19 |
20 | %description
21 |
22 |
23 |
24 | %copyright
25 |
26 |
27 |
28 | %license
29 |
30 |
31 |
37 |
38 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/features/org.example.feature/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
13 | 4.0.0
14 |
15 |
16 | org.example
17 | features
18 | 1.0.0-SNAPSHOT
19 |
20 |
21 | org.example.feature
22 | eclipse-feature
23 |
24 |
25 |
26 |
27 | org.eclipse.tycho
28 | tycho-source-plugin
29 |
30 |
31 | package
32 |
33 | feature-source
34 |
35 |
36 |
37 |
38 |
39 | org.eclipse.tycho
40 | tycho-p2-plugin
41 |
42 |
43 | package
44 |
45 | p2-metadata
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/features/org.example.feature/sourceTemplateFeature/build.properties:
--------------------------------------------------------------------------------
1 | bin.includes = feature.xml,\
2 | feature.properties
3 |
4 | root = target/root-include
--------------------------------------------------------------------------------
/features/org.example.feature/sourceTemplateFeature/feature.properties:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Copyright (c) 2020 1C-Soft LLC.
3 | #
4 | # This program and the accompanying materials are made available under
5 | # the terms of the Eclipse Public License 2.0 which is available at
6 | # https://www.eclipse.org/legal/epl-2.0/
7 | #
8 | # SPDX-License-Identifier: EPL-2.0
9 | #
10 | # Contributors:
11 | # 1C-Soft LLC - initial API and implementation
12 | ###############################################################################
13 | # feature.properties
14 | # contains externalized strings for feature.xml
15 | # "%foo" in feature.xml corresponds to the key "foo" in this file
16 | # java.io.Properties file (ISO 8859-1 with "\" escapes)
17 | # This file should be translated.
18 |
19 | # "featureName" property - name of the feature
20 | featureName=Example Source Feature
21 |
22 | # "providerName" property - name of the company that provides the feature
23 | providerName=1C-Soft LLC
24 |
25 | # "description" property - description of the feature
26 | description=Example tycho build
27 |
28 | # "copyright" property - text of the "Feature Update Copyright"
29 | copyright=\
30 | Copyright (c) 2020 1C-Soft LLC and others.\n\n\
31 | This program and the accompanying materials are made available under\n\
32 | the terms of the Eclipse Public License 2.0 which is available at\n\
33 | https://www.eclipse.org/legal/epl-2.0/\n\n\
34 | SPDX-License-Identifier: EPL-2.0\n
35 | ################ end of copyright property ####################################
--------------------------------------------------------------------------------
/features/org.example.sdk.feature/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.example.sdk.feature
4 |
5 |
6 |
7 |
8 |
9 |
10 | org.eclipse.pde.FeatureNature
11 |
12 |
13 |
--------------------------------------------------------------------------------
/features/org.example.sdk.feature/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding/=UTF-8
3 |
--------------------------------------------------------------------------------
/features/org.example.sdk.feature/build.properties:
--------------------------------------------------------------------------------
1 | bin.includes = feature.xml,\
2 | feature.properties
3 | individualSourceBundles=true
4 | generate.feature@org.example.source=org.example
5 |
--------------------------------------------------------------------------------
/features/org.example.sdk.feature/feature.properties:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Copyright (c) 2020 1C-Soft LLC.
3 | #
4 | # This program and the accompanying materials are made available under
5 | # the terms of the Eclipse Public License 2.0 which is available at
6 | # https://www.eclipse.org/legal/epl-2.0/
7 | #
8 | # SPDX-License-Identifier: EPL-2.0
9 | #
10 | # Contributors:
11 | # 1C-Soft LLC - initial API and implementation
12 | ###############################################################################
13 | # feature.properties
14 | # contains externalized strings for feature.xml
15 | # "%foo" in feature.xml corresponds to the key "foo" in this file
16 | # java.io.Properties file (ISO 8859-1 with "\" escapes)
17 | # This file should be translated.
18 |
19 | # "featureName" property - name of the feature
20 | featureName=Example SDK Feature
21 |
22 | # "providerName" property - name of the company that provides the feature
23 | providerName=1C-Soft LLC
24 |
25 | # "description" property - description of the feature
26 | description=Example tycho build
27 |
28 | # "copyright" property - text of the "Feature Update Copyright"
29 | copyright=\
30 | Copyright (c) 2020 1C-Soft LLC and others.\n\n\
31 | This program and the accompanying materials are made available under\n\
32 | the terms of the Eclipse Public License 2.0 which is available at\n\
33 | https://www.eclipse.org/legal/epl-2.0/\n\n\
34 | SPDX-License-Identifier: EPL-2.0\n
35 | ################ end of copyright property ####################################
--------------------------------------------------------------------------------
/features/org.example.sdk.feature/feature.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
18 |
19 |
20 | %description
21 |
22 |
23 |
24 | %copyright
25 |
26 |
27 |
28 | %license
29 |
30 |
31 |
35 |
36 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/features/org.example.sdk.feature/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
13 | 4.0.0
14 |
15 |
16 | org.example
17 | features
18 | 1.0.0-SNAPSHOT
19 |
20 |
21 | org.example.sdk
22 | eclipse-feature
23 |
24 |
--------------------------------------------------------------------------------
/features/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
14 | 4.0.0
15 |
16 |
17 | org.example
18 | parent
19 | 1.0.0-SNAPSHOT
20 |
21 |
22 | features
23 | pom
24 |
25 | Features
26 |
27 |
28 | true
29 |
30 |
31 |
32 | org.example.feature
33 |
34 |
35 |
36 |
37 | SDK
38 |
39 |
40 | org.example.sdk.feature
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/java.header:
--------------------------------------------------------------------------------
1 | ^/\**$
2 | ^ \* Copyright \(C\) (\d\d\d\d), 1C-Soft LLC$
3 | ^ \*/$
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
14 | 4.0.0
15 |
16 |
17 | org.example
18 | bom
19 | 1.0.0-SNAPSHOT
20 | ./bom/pom.xml
21 |
22 |
23 | org.example
24 | parent
25 | 1.0.0-SNAPSHOT
26 | pom
27 |
28 | Tycho Build Example
29 |
30 |
31 | scm:git:git@github.com:1C-Company/dt-example-plugins.git
32 |
33 |
34 |
35 | targets
36 | bundles
37 | features
38 | repositories
39 | tests
40 |
41 |
42 |
43 |
44 |
45 |
46 | org.eclipse.tycho
47 | tycho-p2-repository-plugin
48 |
49 | ${project.name} Repository
50 |
51 |
52 |
53 | org.eclipse.tycho
54 | target-platform-configuration
55 |
56 |
57 |
58 |
59 | eclipse-plugin
60 | org.apache.felix.scr
61 | 0.0.0
62 |
63 |
64 | eclipse-plugin
65 | org.apache.aries.spifly.dynamic.bundle
66 | 1.3.7
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/repositories/org.example.repository.sdk/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.example.repository.sdk
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/repositories/org.example.repository.sdk/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding/=UTF-8
3 |
--------------------------------------------------------------------------------
/repositories/org.example.repository.sdk/category.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/repositories/org.example.repository.sdk/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
14 | 4.0.0
15 |
16 |
17 | org.example
18 | repositories
19 | 1.0.0-SNAPSHOT
20 |
21 |
22 | org.example.repository.sdk
23 | eclipse-repository
24 |
25 |
--------------------------------------------------------------------------------
/repositories/org.example.repository/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.example.repository
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/repositories/org.example.repository/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding/=UTF-8
3 |
--------------------------------------------------------------------------------
/repositories/org.example.repository/category.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/repositories/org.example.repository/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
14 | 4.0.0
15 |
16 |
17 | org.example
18 | repositories
19 | 1.0.0-SNAPSHOT
20 |
21 |
22 | org.example.repository
23 | eclipse-repository
24 |
25 |
--------------------------------------------------------------------------------
/repositories/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
14 | 4.0.0
15 |
16 |
17 | org.example
18 | parent
19 | 1.0.0-SNAPSHOT
20 |
21 |
22 | repositories
23 | pom
24 |
25 | Update Sites
26 |
27 |
28 | org.example.repository
29 |
30 |
31 |
32 | ${eclipse.p2.latest}
33 | true
34 |
35 |
36 |
37 |
38 | SDK
39 |
40 |
41 | org.example.repository.sdk
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/targets/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.example.targets
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/targets/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding/=UTF-8
3 |
--------------------------------------------------------------------------------
/targets/default/default.target:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/targets/default/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
14 | 4.0.0
15 |
16 |
17 | org.example
18 | targets
19 | 1.0.0-SNAPSHOT
20 |
21 |
22 | org.example
23 | default
24 | 1.0.0-SNAPSHOT
25 |
26 | eclipse-target-definition
27 |
28 | Target Platform
29 |
30 |
--------------------------------------------------------------------------------
/targets/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
14 | 4.0.0
15 |
16 |
17 | org.example
18 | parent
19 | 1.0.0-SNAPSHOT
20 |
21 |
22 | targets
23 | pom
24 |
25 | Targets Definitions
26 |
27 |
28 | true
29 |
30 |
31 |
32 | default
33 |
34 |
35 |
--------------------------------------------------------------------------------
/tests/org.example.itests/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/tests/org.example.itests/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.example.itests
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.pde.ManifestBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.pde.SchemaBuilder
20 |
21 |
22 |
23 |
24 |
25 | org.eclipse.jdt.core.javanature
26 | org.eclipse.pde.PluginNature
27 |
28 |
29 |
--------------------------------------------------------------------------------
/tests/org.example.itests/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding/=UTF-8
3 |
--------------------------------------------------------------------------------
/tests/org.example.itests/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
4 | org.eclipse.jdt.core.compiler.compliance=17
5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7 | org.eclipse.jdt.core.compiler.source=17
8 |
--------------------------------------------------------------------------------
/tests/org.example.itests/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: %pluginName
4 | Bundle-Vendor: %providerName
5 | Bundle-Version: 1.0.0.qualifier
6 | Bundle-SymbolicName: org.example.itests;singleton:=true
7 | Bundle-ActivationPolicy: lazy
8 | Bundle-Localization: plugin
9 | Require-Bundle: org.example;bundle-version="[1.0.0,2.0.0)",
10 | org.junit;bundle-version="[4.13.0,5.0.0)",
11 | org.eclipse.xtext;bundle-version="[2.26.0,3.0.0)",
12 | org.eclipse.core.resources;bundle-version="[3.16.100,4.0.0)",
13 | org.eclipse.core.runtime;bundle-version="[3.24.100,4.0.0)",
14 | com._1c.g5.v8.dt.bsl;bundle-version="[26.0.0,27.0.0)",
15 | com._1c.g5.v8.dt.bsl.core;bundle-version="[6.0.0,7.0.0)",
16 | com._1c.g5.v8.dt.bsl.model;bundle-version="[11.0.0,12.0.0)",
17 | com._1c.g5.v8.dt.core;bundle-version="[23.0.0,24.0.0)",
18 | com._1c.g5.v8.dt.mcore;bundle-version="[8.0.0,9.0.0)",
19 | com._1c.g5.v8.dt.testing;bundle-version="[3.2.200,4.0.0)",
20 | com._1c.g5.ides.core;bundle-version="[6.0.200,7.0.0)"
21 | Bundle-RequiredExecutionEnvironment: JavaSE-17
22 | Automatic-Module-Name: org.example.itests
23 |
--------------------------------------------------------------------------------
/tests/org.example.itests/build.properties:
--------------------------------------------------------------------------------
1 | javacCustomEncodings.. = src/[UTF-8]
2 | source.. = src/
3 | bin.includes = META-INF/,\
4 | .,\
5 | workspace/,\
6 | plugin.properties
7 |
--------------------------------------------------------------------------------
/tests/org.example.itests/plugin.properties:
--------------------------------------------------------------------------------
1 | pluginName = \u0418\u043D\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043E\u043D\u043D\u044B\u0435 \u0442\u0435\u0441\u0442\u044B \u043F\u043B\u0430\u0433\u0438\u043D\u0430 \u0434\u043B\u044F "1C: Enterprise Development Tools"
2 | providerName = 1C LLC
--------------------------------------------------------------------------------
/tests/org.example.itests/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | org.example
8 | tests
9 | 1.0.0-SNAPSHOT
10 |
11 | org.example.itests
12 | 1.0.0-SNAPSHOT
13 | eclipse-test-plugin
14 |
--------------------------------------------------------------------------------
/tests/org.example.itests/src/org/example/itests/ExampleValidatorTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2020, 1C-Soft LLC
3 | */
4 | package org.example.itests;
5 |
6 | import java.util.Collection;
7 | import java.util.List;
8 |
9 | import org.eclipse.xtext.EcoreUtil2;
10 | import org.eclipse.xtext.diagnostics.Severity;
11 | import org.eclipse.xtext.resource.IResourceServiceProvider;
12 | import org.eclipse.xtext.resource.XtextResource;
13 | import org.eclipse.xtext.util.concurrent.IUnitOfWork;
14 | import org.eclipse.xtext.validation.CheckMode;
15 | import org.eclipse.xtext.validation.IResourceValidator;
16 | import org.eclipse.xtext.validation.Issue;
17 | import org.example.ExampleValidator;
18 | import org.junit.Assert;
19 | import org.junit.Rule;
20 | import org.junit.Test;
21 |
22 | import com._1c.g5.v8.dt.bsl.resource.BslResource;
23 | import com._1c.g5.v8.dt.core.handle.IV8File;
24 | import com._1c.g5.v8.dt.core.handle.impl.V8ModelManager;
25 | import com._1c.g5.v8.dt.core.handle.impl.V8XtextFile;
26 | import com._1c.g5.v8.dt.testing.TestingWorkspace;
27 | import com.google.common.base.Predicate;
28 | import com.google.common.collect.Collections2;
29 |
30 | /**
31 | * Пример теста на валидатор
32 | *
33 | * Больше информации о написании тестов см https://edt.1c.ru/dev/ru/docs/plugins/dev/testing/
34 | */
35 | public class ExampleValidatorTest
36 | {
37 | @Rule
38 | public TestingWorkspace testingWorkspace = new TestingWorkspace();
39 |
40 | @Test
41 | public void testMethodStartsWithCapitalLetterWarning() throws Exception
42 | {
43 | check("test", "src/Configuration/ManagedApplicationModule.bsl", Severity.WARNING, //$NON-NLS-1$//$NON-NLS-2$
44 | ExampleValidator.ERROR_CODE, 1);
45 | }
46 |
47 | private void check(String projectName, String fileName, Severity severity, final String issueCode, int lineNumber)
48 | throws Exception
49 | {
50 | Collection issues = validate(projectName, fileName);
51 |
52 | issues = Collections2.filter(issues, new Predicate()
53 | {
54 | @Override
55 | public boolean apply(Issue input)
56 | {
57 | return issueCode.equals(input.getCode());
58 | }
59 | });
60 | Assert.assertEquals(1, issues.size());
61 | Issue issue = issues.iterator().next();
62 | Assert.assertEquals(severity, issue.getSeverity());
63 | Assert.assertEquals(lineNumber, (int)issue.getLineNumber());
64 | }
65 |
66 | private List validate(String projectName, String fileName) throws Exception
67 | {
68 | testingWorkspace.setUpProject(projectName, getClass());
69 |
70 | IV8File file = V8ModelManager.INSTANCE.getV8Model().getV8Project(projectName).getV8File(fileName);
71 | Assert.assertTrue(file instanceof V8XtextFile);
72 | V8XtextFile xtextFile = (V8XtextFile)file;
73 | List issues = xtextFile.readOnly(new IUnitOfWork, XtextResource>()
74 | {
75 | @Override
76 | public List exec(XtextResource state) throws Exception
77 | {
78 |
79 | Assert.assertTrue(state instanceof BslResource);
80 | BslResource resource = (BslResource)state;
81 | resource.setDeepAnalysis(true);
82 |
83 | IResourceServiceProvider provider = resource.getResourceServiceProvider();
84 | IResourceValidator validator = provider.get(IResourceValidator.class);
85 | Assert.assertTrue(validator != null);
86 |
87 | EcoreUtil2.resolveLazyCrossReferences(resource, null);
88 |
89 | return validator.validate(resource, CheckMode.ALL, null);
90 | }
91 | });
92 |
93 | return issues;
94 | }
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/tests/org.example.itests/workspace/test/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | test
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.xtext.ui.shared.xtextBuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.xtext.ui.shared.xtextNature
16 | com._1c.g5.v8.dt.core.V8ConfigurationNature
17 |
18 |
19 |
--------------------------------------------------------------------------------
/tests/org.example.itests/workspace/test/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding/=UTF-8
3 |
--------------------------------------------------------------------------------
/tests/org.example.itests/workspace/test/DT-INF/PROJECT.PMF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Runtime-Version: 8.3.22
3 |
--------------------------------------------------------------------------------
/tests/org.example.itests/workspace/test/src/Configuration/CommandInterface.cmi:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/tests/org.example.itests/workspace/test/src/Configuration/Configuration.mdo:
--------------------------------------------------------------------------------
1 |
2 |
3 | Конфигурация
4 |
5 | ru
6 | Конфигурация
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | 8.3.16
15 | ManagedApplication
16 | PersonalComputer
17 | Russian
18 |
19 | AllowOSBackup
20 |
21 |
22 | Language.Русский
23 | Managed
24 | NotAutoFree
25 | DontUse
26 | DontUse
27 | 8.3.16
28 |
29 | Русский
30 |
31 | ru
32 | Русский
33 |
34 | ru
35 |
36 |
37 |
--------------------------------------------------------------------------------
/tests/org.example.itests/workspace/test/src/Configuration/MainSectionCommandInterface.cmi:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/tests/org.example.itests/workspace/test/src/Configuration/ManagedApplicationModule.bsl:
--------------------------------------------------------------------------------
1 | процедура процедура1() экспорт
2 | Сообщить("Предупреждение");
3 | конецпроцедуры
4 |
5 | процедура Процедура2() экспорт
6 | Сообщить("Привет");
7 | конецпроцедуры
8 |
--------------------------------------------------------------------------------
/tests/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
14 | 4.0.0
15 |
16 |
17 | org.example
18 | parent
19 | 1.0.0-SNAPSHOT
20 |
21 |
22 | tests
23 | pom
24 | Tests
25 |
26 |
27 | org.example.itests
28 |
29 |
30 |
31 |
32 | macosx
33 |
34 |
35 | mac os x
36 | mac
37 |
38 |
39 |
40 | -XstartOnFirstThread
41 |
42 |
43 |
44 | other-os
45 |
46 |
47 | !mac
48 | !mac
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | debug
57 |
58 | -agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=y
59 |
60 |
61 |
62 |
63 |
64 | -Xms80m -Xmx2g -Dosgi.module.lock.timeout=24 --add-modules=ALL-SYSTEM --add-opens=java.base/jdk.internal.misc=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED --add-opens=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --add-opens=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.ref=ALL-UNNAMED
65 |
66 |
67 |
68 |
69 |
70 |
71 | org.eclipse.tycho
72 | target-platform-configuration
73 |
74 |
75 |
76 | org.example
77 | default
78 | 1.0.0-SNAPSHOT
79 |
80 |
81 |
82 |
83 |
84 | p2-installable-unit
85 | com._1c.g5.v8.dt.rcp
86 | 0.0.0
87 |
88 |
89 | eclipse-feature
90 | com._1c.g5.v8.dt.platform.support_v8.3.22.feature
91 | 0.0.0
92 |
93 |
94 |
95 | p2
96 |
97 |
98 |
99 | org.jacoco
100 | jacoco-maven-plugin
101 |
102 |
103 | prepare-agent
104 |
105 | prepare-agent
106 |
107 |
108 |
109 | report
110 | verify
111 |
112 | report
113 |
114 |
115 |
116 | report-aggregate
117 | verify
118 |
119 | report-aggregate
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 | org.eclipse.tycho
130 | tycho-surefire-plugin
131 |
132 | true
133 | true
134 | ${ui.test.vmargs} ${tycho-surefire-plugin.vmargs} ${debug.vmargs}
135 | ${project.build.directory}/work
136 | p2Installed
137 |
138 |
139 |
140 |
141 |
142 |
143 |
--------------------------------------------------------------------------------