mirror of
https://github.com/1C-Company/v8-code-style.git
synced 2024-11-28 09:33:06 +02:00
Фикс экспортных методов в форме и команде
This commit is contained in:
parent
2e4dcb0011
commit
71fd0f8e2f
@ -59,6 +59,7 @@
|
||||
|
||||
- Удаление аннотации строгой типизации из модуля
|
||||
- Открытие панели документирующего комментария
|
||||
- Удаление ключевого слова Экспорт для процедур или функций в модуле команды и в модуле формы
|
||||
|
||||
### Исправленные ошибки
|
||||
|
||||
|
@ -256,5 +256,11 @@
|
||||
class="com.e1c.v8codestyle.internal.bsl.ExecutableExtensionFactory:com.e1c.v8codestyle.internal.bsl.StrictTypesProjectOptionProvider">
|
||||
</provider>
|
||||
</extension>
|
||||
<extension
|
||||
point="com.e1c.g5.v8.dt.check.fixes">
|
||||
<fix
|
||||
class="com.e1c.v8codestyle.bsl.qfix.RemoveExportFix">
|
||||
</fix>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
@ -0,0 +1,37 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2022, 1C-Soft LLC and others.
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* 1C-Soft LLC - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.e1c.v8codestyle.bsl.qfix;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
/**
|
||||
* @author Artem Iliukhin
|
||||
*
|
||||
*/
|
||||
final class Messages
|
||||
extends NLS
|
||||
{
|
||||
private static final String BUNDLE_NAME = "com.e1c.v8codestyle.bsl.qfix.messages"; //$NON-NLS-1$
|
||||
public static String RemoveExportFix_Remove_export_keyword_des;
|
||||
public static String RemoveExportFix_Remove_export_keyword_det;
|
||||
static
|
||||
{
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||
}
|
||||
|
||||
private Messages()
|
||||
{
|
||||
// N/A
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2022, 1C-Soft LLC and others.
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* 1C-Soft LLC - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.e1c.v8codestyle.bsl.qfix;
|
||||
|
||||
import static com._1c.g5.v8.dt.bsl.model.BslPackage.Literals.METHOD__EXPORT;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.emf.ecore.util.EcoreUtil;
|
||||
import org.eclipse.jface.text.BadLocationException;
|
||||
import org.eclipse.text.edits.DeleteEdit;
|
||||
import org.eclipse.text.edits.TextEdit;
|
||||
import org.eclipse.xtext.nodemodel.INode;
|
||||
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
|
||||
import com._1c.g5.v8.dt.bsl.model.Method;
|
||||
import com.e1c.g5.v8.dt.check.qfix.components.QuickFix;
|
||||
import com.e1c.v8codestyle.bsl.qfix.external.IXtextBslModuleFixModel;
|
||||
import com.e1c.v8codestyle.bsl.qfix.external.SingleVariantXtextBslModuleFix;
|
||||
import com.e1c.v8codestyle.internal.bsl.BslPlugin;
|
||||
|
||||
/**
|
||||
* The fix to remove export keyword.
|
||||
*
|
||||
* @author Dmitriy Marmyshev
|
||||
*/
|
||||
@QuickFix(checkId = "export-method-in-command-form-module", supplierId = BslPlugin.PLUGIN_ID)
|
||||
public class RemoveExportFix
|
||||
extends SingleVariantXtextBslModuleFix
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void configureFix(FixConfigurer configurer)
|
||||
{
|
||||
configurer.description(Messages.RemoveExportFix_Remove_export_keyword_des)
|
||||
.details(Messages.RemoveExportFix_Remove_export_keyword_det);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextEdit fixIssue(XtextResource state, IXtextBslModuleFixModel model) throws BadLocationException
|
||||
{
|
||||
if (model.getElement() instanceof Method && ((Method)model.getElement()).isExport())
|
||||
{
|
||||
List<INode> nodes = NodeModelUtils.findNodesForFeature(model.getElement(), METHOD__EXPORT);
|
||||
if (nodes.isEmpty())
|
||||
{
|
||||
IStatus status =
|
||||
BslPlugin.createErrorStatus("RemoveExportFix: cannot get node for method export keyword: " //$NON-NLS-1$
|
||||
+ EcoreUtil.getURI(model.getElement()), null);
|
||||
BslPlugin.log(status);
|
||||
return null;
|
||||
}
|
||||
INode node = nodes.get(0);
|
||||
return new DeleteEdit(node.getTotalOffset(), node.getTotalLength());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
###############################################################################
|
||||
# Copyright (C) 2021-2022, 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
|
||||
###############################################################################
|
||||
RemoveExportFix_Remove_export_keyword_des=Remove Export keyword
|
||||
RemoveExportFix_Remove_export_keyword_det=Remove Export keyword
|
@ -0,0 +1,14 @@
|
||||
###############################################################################
|
||||
# Copyright (C) 2021-2022, 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
|
||||
###############################################################################
|
||||
RemoveExportFix_Remove_export_keyword_des=Удалить ключевое слово Экспорт
|
||||
RemoveExportFix_Remove_export_keyword_det=Удалить ключевое слово Экспорт
|
Loading…
Reference in New Issue
Block a user