mirror of
https://github.com/1C-Company/v8-code-style.git
synced 2025-02-03 18:02:08 +02:00
#969 Квик-фикс открытия панели документирующего комментария
This commit is contained in:
parent
9b7b2c9fdf
commit
2607d03555
@ -57,6 +57,7 @@
|
||||
### Новые быстрые исправления (Quick-fix)
|
||||
|
||||
- Удаление аннотации строгой типизации из модуля
|
||||
- Открытие панели документирующего комментария
|
||||
|
||||
### Исправленные ошибки
|
||||
|
||||
|
@ -49,6 +49,7 @@ Import-Package: com._1c.g5.ides.ui.texteditor.xtext.embedded;version="[5.0.0,6.0
|
||||
com.e1c.g5.v8.dt.bsl.check.qfix;version="[1.0.0,2.0.0)",
|
||||
com.e1c.g5.v8.dt.check.qfix;version="[1.0.0,2.0.0)",
|
||||
com.e1c.g5.v8.dt.check.qfix.components;version="[1.0.0,2.0.0)",
|
||||
com.e1c.g5.v8.dt.check.settings;version="[2.0.0,3.0.0)",
|
||||
com.e1c.v8codestyle.bsl;version="[0.2.0,0.3.0)",
|
||||
com.e1c.v8codestyle.bsl.qfix.external;version="[0.2.0,0.3.0)",
|
||||
com.e1c.v8codestyle.bsl.strict;version="[0.2.0,0.3.0)"
|
||||
|
@ -24,6 +24,10 @@ final class Messages
|
||||
{
|
||||
private static final String BUNDLE_NAME = "com.e1c.v8codestyle.bsl.ui.qfix.messages"; //$NON-NLS-1$
|
||||
|
||||
public static String OpenBslDocCommentViewFix_Description;
|
||||
|
||||
public static String OpenBslDocCommentViewFix_Details;
|
||||
|
||||
public static String UndefinedMethodFix_func_title;
|
||||
public static String UndefinedMethodFix_func_desc;
|
||||
public static String UndefinedMethodFix_proc_title;
|
||||
|
@ -0,0 +1,115 @@
|
||||
/*******************************************************************************
|
||||
* 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.ui.qfix;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jface.text.BadLocationException;
|
||||
import org.eclipse.jface.text.ITextViewer;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.text.edits.TextEdit;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
|
||||
import com._1c.g5.v8.dt.bsl.ui.quickfix.BslQuickFixUtil;
|
||||
import com.e1c.g5.v8.dt.check.settings.CheckUid;
|
||||
import com.e1c.v8codestyle.bsl.qfix.external.IXtextBslModuleFixModel;
|
||||
import com.e1c.v8codestyle.bsl.qfix.external.IXtextInteractiveBslModuleFixModel;
|
||||
import com.e1c.v8codestyle.bsl.qfix.external.SingleVariantXtextBslModuleFix;
|
||||
import com.e1c.v8codestyle.internal.bsl.ui.UiPlugin;
|
||||
import com.e1c.v8codestyle.internal.bsl.ui.views.BslDocCommentView;
|
||||
|
||||
/**
|
||||
* The fix for all strict types checks that allows to remove annotation.
|
||||
*
|
||||
* @author Dmitriy Marmyshev
|
||||
*/
|
||||
public class OpenBslDocCommentViewFix
|
||||
extends SingleVariantXtextBslModuleFix
|
||||
{
|
||||
|
||||
@SuppressWarnings("nls")
|
||||
public static Collection<String> getCheckIds()
|
||||
{
|
||||
return Set.of("doc-comment-field-type-strict", "doc-comment-collection-item-type",
|
||||
"constructor-function-return-section", "doc-comment-use-minus",
|
||||
"doc-comment-export-function-return-section", "doc-comment-field-name", "doc-comment-field-type",
|
||||
"doc-comment-complex-type-with-link", "doc-comment-return-section-type",
|
||||
"doc-comment-description-ends-on-dot", "doc-comment-field-in-description-suggestion",
|
||||
"doc-comment-parameter-in-description-suggestion", "doc-comment-parameter-section",
|
||||
"doc-comment-procedure-return-section", "doc-comment-ref-link", "doc-comment-type");
|
||||
}
|
||||
|
||||
private final CheckUid checkUid;
|
||||
|
||||
/**
|
||||
* Instantiates a new open BSL doc comment view fix.
|
||||
*
|
||||
* @param checkId the check id, cannot be {@code null}.
|
||||
*/
|
||||
public OpenBslDocCommentViewFix(CheckUid checkId)
|
||||
{
|
||||
this.checkUid = checkId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CheckUid getCheckId()
|
||||
{
|
||||
return checkUid;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureFix(FixConfigurer configurer)
|
||||
{
|
||||
configurer.interactive(true)
|
||||
.description(Messages.OpenBslDocCommentViewFix_Description)
|
||||
.details(Messages.OpenBslDocCommentViewFix_Details);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextEdit fixIssue(XtextResource state, IXtextBslModuleFixModel model) throws BadLocationException
|
||||
{
|
||||
IXtextInteractiveBslModuleFixModel interactiveModel = (IXtextInteractiveBslModuleFixModel)model;
|
||||
|
||||
Integer offset = model.getIssue().getOffset() + 1;
|
||||
Display display = PlatformUI.getWorkbench().getDisplay();
|
||||
if (display.isDisposed())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
display.asyncExec(() -> {
|
||||
try
|
||||
{
|
||||
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(BslDocCommentView.ID);
|
||||
}
|
||||
catch (PartInitException e)
|
||||
{
|
||||
UiPlugin.logError(e);
|
||||
}
|
||||
});
|
||||
|
||||
ITextViewer viewer = BslQuickFixUtil.getTextViewer(interactiveModel.getModificationContext());
|
||||
if (viewer != null && !display.isDisposed())
|
||||
{
|
||||
display.asyncExec(() -> {
|
||||
viewer.revealRange(offset, 1);
|
||||
viewer.getTextWidget().setFocus();
|
||||
viewer.setSelectedRange(offset, 1);
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
OpenBslDocCommentViewFix_Details=Open documentation comment data structure view and show current probleme object.
|
||||
|
||||
#Generated by ResourceBundle Editor (http://essiembre.github.io/eclipse-rbe/)
|
||||
###############################################################################
|
||||
@ -14,6 +15,7 @@
|
||||
# Vadim Geraskin - initial contibution
|
||||
###############################################################################
|
||||
|
||||
OpenBslDocCommentViewFix_Description=Open documentation comment structure view
|
||||
UndefinedMethodFix_func_title=Create function
|
||||
UndefinedMethodFix_func_desc=Create a new function in the module
|
||||
UndefinedMethodFix_proc_title=Create procedure
|
||||
|
@ -13,9 +13,18 @@
|
||||
# Vadim Geraskin - initial contibution
|
||||
###############################################################################
|
||||
|
||||
UndefinedMethodFix_func_title=Создать функцию
|
||||
UndefinedMethodFix_func_desc=Создать новую функцию в модуле
|
||||
UndefinedMethodFix_proc_title=Создать процедуру
|
||||
UndefinedMethodFix_proc_desc=Создать новую процедуру в модуле
|
||||
UndefinedVariableFix_title=Создать переменную
|
||||
UndefinedVariableFix_desc=Создать пропущенную переменную на уровне метода или модуля.\nПосле применения исправления сохраните изменения в редакторе.
|
||||
OpenBslDocCommentViewFix_Description = Открыть панель структуры документирующего комментария
|
||||
|
||||
OpenBslDocCommentViewFix_Details = Открыть панель структуры документирующего комментария и показать текущий проблемный объект.
|
||||
|
||||
UndefinedMethodFix_func_desc = Создать новую функцию в модуле
|
||||
|
||||
UndefinedMethodFix_func_title = Создать функцию
|
||||
|
||||
UndefinedMethodFix_proc_desc = Создать новую процедуру в модуле
|
||||
|
||||
UndefinedMethodFix_proc_title = Создать процедуру
|
||||
|
||||
UndefinedVariableFix_desc = Создать пропущенную переменную на уровне метода или модуля.\nПосле применения исправления сохраните изменения в редакторе.
|
||||
|
||||
UndefinedVariableFix_title = Создать переменную
|
||||
|
@ -0,0 +1,62 @@
|
||||
/*******************************************************************************
|
||||
* 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.internal.bsl.ui;
|
||||
|
||||
import com._1c.g5.wiring.IManagedService;
|
||||
import com.e1c.g5.v8.dt.check.qfix.IFix;
|
||||
import com.e1c.g5.v8.dt.check.qfix.IFixContext;
|
||||
import com.e1c.g5.v8.dt.check.qfix.IFixRepository;
|
||||
import com.e1c.g5.v8.dt.check.settings.CheckUid;
|
||||
import com.e1c.v8codestyle.bsl.ui.qfix.OpenBslDocCommentViewFix;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* The registrar of quick-fix instance that applicable for several checks.
|
||||
* The quick-fix should have public constructor with 1 parameter of {@link CheckUid}.
|
||||
*
|
||||
* @author Dmitriy Marmyshev
|
||||
*/
|
||||
public class MultiCheckFixRegistrator
|
||||
implements IManagedService
|
||||
{
|
||||
private static final String CHECK_BUNDLE = "com.e1c.v8codestyle.bsl"; //$NON-NLS-1$
|
||||
|
||||
@Inject
|
||||
private IFixRepository fixRepository;
|
||||
|
||||
/**
|
||||
* Multi-check fix should be added here
|
||||
*/
|
||||
@Override
|
||||
public void activate()
|
||||
{
|
||||
registerOpenBslDocCommentViewFix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
private void registerOpenBslDocCommentViewFix()
|
||||
{
|
||||
for (String checkId : OpenBslDocCommentViewFix.getCheckIds())
|
||||
{
|
||||
CheckUid id = new CheckUid(checkId, CHECK_BUNDLE);
|
||||
|
||||
IFix<? extends IFixContext> instance = new OpenBslDocCommentViewFix(id);
|
||||
fixRepository.registerFix(instance);
|
||||
}
|
||||
}
|
||||
}
|
@ -22,6 +22,8 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
import com._1c.g5.v8.dt.bsl.model.BslPackage;
|
||||
import com._1c.g5.wiring.InjectorAwareServiceRegistrator;
|
||||
import com._1c.g5.wiring.ServiceInitialization;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
@ -43,6 +45,8 @@ public class UiPlugin
|
||||
|
||||
private volatile Injector injector;
|
||||
|
||||
private InjectorAwareServiceRegistrator registrator;
|
||||
|
||||
private static BundleContext context;
|
||||
|
||||
/**
|
||||
@ -129,6 +133,11 @@ public class UiPlugin
|
||||
plugin = this;
|
||||
|
||||
BslPackage.eINSTANCE.eClass();
|
||||
registrator = new InjectorAwareServiceRegistrator(bundleContext, this::getInjector);
|
||||
ServiceInitialization.schedule(() -> {
|
||||
// register services from injector
|
||||
registrator.managedService(MultiCheckFixRegistrator.class).activateBeforeRegistration().registerInjected();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user