-
Notifications
You must be signed in to change notification settings - Fork 58
Feature/issue 1508 semicolon extra and missing #1509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alonthedark
wants to merge
24
commits into
1C-Company:master
Choose a base branch
from
alonthedark:feature/issue-1508-semicolon-extra-and-mising
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
4180068
Add checks missing and extra semicolon, qfix.
18040f7
Add checks missing and extra semicolon, qfix.
alonthedark c8d888d
Add checks missing and extra semicolon, qfix.
alonthedark 1538aa2
Add checks missing and extra semicolon, qfix.
alonthedark 604dd88
Add checks missing and extra semicolon, qfix.
alonthedark 719d92a
Add checks missing and extra semicolon, qfix.
alonthedark 4b1ee9d
Add checks missing and extra semicolon, qfix.
alonthedark a951483
Add checks missing and extra semicolon, qfix.
alonthedark 71378da
Add checks missing and extra semicolon, qfix.
alonthedark 7712e6c
Add checks missing and extra semicolon, qfix.
alonthedark 1494474
Update MethodSemicolonExtraCheck.java
alonthedark eeaf544
Update MethodSemicolonExtraFix.java
alonthedark c0f14b4
Update messages.properties
alonthedark a0b426d
Update SemicolonMissingFix.java
alonthedark 1d592bd
Update Messages.java
alonthedark 576a4ce
Изменено подчеркивание лишней точки с запятой подчеркивается только она
93ae72b
Update SemicolonMissingFix.java
alonthedark f09963a
Update MethodSemicolonExtraFix.java
alonthedark 1fc52f5
Update SemicolonMissingCheck.java
alonthedark 22487cb
Update SemicolonMissingCheck.java
alonthedark 2be3c82
Update SemicolonMissingCheck.java
alonthedark 3b42a9a
Изменение проверки и добавление новых тестов
023b240
Добавлено описание
cd7d723
Merge branch 'master' into feature/issue-1508-semicolon-extra-and-mising
alonthedark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
...m.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/MethodSemicolonExtraFix.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| /******************************************************************************* | ||
| * Copyright (C) 2025, 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.List; | ||
|
|
||
| import org.eclipse.emf.ecore.EObject; | ||
| 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.EmptyStatement; | ||
| import com._1c.g5.v8.dt.bsl.model.Method; | ||
| import com._1c.g5.v8.dt.bsl.model.Statement; | ||
| import com._1c.g5.v8.dt.bsl.model.util.BslUtil; | ||
| import com.e1c.g5.v8.dt.bsl.check.qfix.IXtextBslModuleFixModel; | ||
| import com.e1c.g5.v8.dt.bsl.check.qfix.SingleVariantXtextBslModuleFix; | ||
| import com.e1c.g5.v8.dt.check.qfix.components.QuickFix; | ||
|
|
||
| /** | ||
| * Removes extra semicolon | ||
| * | ||
| * @author Ivan Sergeev | ||
| */ | ||
| @QuickFix(checkId = "method-semicolon-extra", supplierId = "com.e1c.v8codestyle.bsl") | ||
| public class MethodSemicolonExtraFix | ||
| extends SingleVariantXtextBslModuleFix | ||
| { | ||
|
|
||
| @Override | ||
| protected void configureFix(FixConfigurer configurer) | ||
| { | ||
| configurer.interactive(true) | ||
| .description(Messages.MethodSemicolonExtraFix_Description) | ||
| .details(Messages.MethodSemicolonExtraFix_Description); | ||
| } | ||
|
|
||
| @Override | ||
| protected TextEdit fixIssue(XtextResource state, IXtextBslModuleFixModel model) throws BadLocationException | ||
| { | ||
| EObject eobject = model.getElement(); | ||
| if (!(eobject instanceof Method)) | ||
| { | ||
| return null; | ||
| } | ||
|
|
||
| List<Statement> allItems = BslUtil.allStatements(eobject); | ||
|
|
||
| INode node = NodeModelUtils.findActualNodeFor(allItems.get(0)); | ||
|
|
||
| int size = allItems.size(); | ||
|
|
||
| for (int i = 0; i < size; i++) | ||
| { | ||
| if (allItems.get(i) instanceof EmptyStatement) | ||
| { | ||
| node = NodeModelUtils.findActualNodeFor(allItems.get(i)); | ||
|
|
||
| if (node == null) | ||
| { | ||
| return null; | ||
| } | ||
| INode checkNode = node.getNextSibling(); | ||
alonthedark marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| String checkText = checkNode.getText(); | ||
| INode checkNextNode = checkNode.getNextSibling(); | ||
| if (checkText.contains(";")) //$NON-NLS-1$ | ||
| { | ||
| return new DeleteEdit(checkNode.getTotalOffset(), checkNode.getTotalLength()); | ||
| } | ||
| else if (checkNextNode.getText().contains(";")) //$NON-NLS-1$ | ||
| { | ||
| return new DeleteEdit(checkNextNode.getTotalOffset(), checkNextNode.getTotalLength()); | ||
| } | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
| } | ||
63 changes: 63 additions & 0 deletions
63
...s/com.e1c.v8codestyle.bsl.ui/src/com/e1c/v8codestyle/bsl/ui/qfix/SemicolonMissingFix.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /******************************************************************************* | ||
| * Copyright (C) 2025, 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 org.eclipse.emf.ecore.EObject; | ||
| import org.eclipse.jface.text.BadLocationException; | ||
| import org.eclipse.text.edits.ReplaceEdit; | ||
| 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.Conditional; | ||
| import com._1c.g5.v8.dt.bsl.model.Statement; | ||
| import com.e1c.g5.v8.dt.bsl.check.qfix.IXtextBslModuleFixModel; | ||
| import com.e1c.g5.v8.dt.bsl.check.qfix.SingleVariantXtextBslModuleFix; | ||
| import com.e1c.g5.v8.dt.check.qfix.components.QuickFix; | ||
|
|
||
| /** | ||
| * Add missing semicolon | ||
| * | ||
| * @author Ivan Sergeev | ||
| */ | ||
| @QuickFix(checkId = "semicolon-missing", supplierId = "com.e1c.v8codestyle.bsl") | ||
| public class SemicolonMissingFix | ||
| extends SingleVariantXtextBslModuleFix | ||
| { | ||
|
|
||
| @Override | ||
| protected void configureFix(FixConfigurer configurer) | ||
| { | ||
| configurer.interactive(true) | ||
| .description(Messages.SemicolonMissingFix_Description) | ||
| .details(Messages.SemicolonMissngFix_Details); | ||
| } | ||
|
|
||
| @Override | ||
| protected TextEdit fixIssue(XtextResource state, IXtextBslModuleFixModel model) throws BadLocationException | ||
| { | ||
| EObject eobject = model.getElement(); | ||
| if (!(eobject instanceof Statement) & !(eobject instanceof Conditional)) | ||
| { | ||
| return null; | ||
| } | ||
|
|
||
| INode node = NodeModelUtils.findActualNodeFor(eobject); | ||
| if (node == null) | ||
| { | ||
| return null; | ||
| } | ||
| return new ReplaceEdit(node.getTotalOffset(), node.getTotalLength(), node.getText() + ";"); //$NON-NLS-1$ | ||
alonthedark marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
.../com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/check/MethodSemicolonExtraCheck.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| /******************************************************************************* | ||
| * Copyright (C) 2025, 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.check; | ||
|
|
||
| import static com._1c.g5.v8.dt.bsl.model.BslPackage.Literals.METHOD; | ||
| import static com._1c.g5.v8.dt.mcore.McorePackage.Literals.NAMED_ELEMENT__NAME; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.eclipse.core.runtime.IProgressMonitor; | ||
| import org.eclipse.xtext.nodemodel.INode; | ||
| import org.eclipse.xtext.nodemodel.util.NodeModelUtils; | ||
|
|
||
| import com._1c.g5.v8.dt.bsl.model.EmptyStatement; | ||
| import com._1c.g5.v8.dt.bsl.model.Method; | ||
| import com._1c.g5.v8.dt.bsl.model.Statement; | ||
| import com._1c.g5.v8.dt.bsl.model.util.BslUtil; | ||
| import com.e1c.g5.v8.dt.check.CheckComplexity; | ||
| import com.e1c.g5.v8.dt.check.ICheckParameters; | ||
| import com.e1c.g5.v8.dt.check.components.ModuleTopObjectNameFilterExtension; | ||
| import com.e1c.g5.v8.dt.check.settings.IssueSeverity; | ||
| import com.e1c.g5.v8.dt.check.settings.IssueType; | ||
| import com.e1c.v8codestyle.check.CommonSenseCheckExtension; | ||
| import com.e1c.v8codestyle.internal.bsl.BslPlugin; | ||
|
|
||
| /** | ||
| * Checks method declaration contain extra semicolon | ||
| * | ||
| * @author Ivan Sergeev | ||
| */ | ||
| public class MethodSemicolonExtraCheck | ||
| extends AbstractModuleStructureCheck | ||
| { | ||
| private static final String CHECK_ID = "method-semicolon-extra"; //$NON-NLS-1$ | ||
|
|
||
| @Override | ||
| public String getCheckId() | ||
| { | ||
| return CHECK_ID; | ||
| } | ||
|
|
||
| @Override | ||
| protected void configureCheck(CheckConfigurer builder) | ||
| { | ||
| builder.title(Messages.MethodSemicolonExtraCheck_Title) | ||
| .description(Messages.MethodSemicolonExtraCheck_Description) | ||
| .complexity(CheckComplexity.NORMAL) | ||
| .severity(IssueSeverity.MINOR) | ||
| .issueType(IssueType.CODE_STYLE) | ||
| .extension(new ModuleTopObjectNameFilterExtension()) | ||
| .extension(new CommonSenseCheckExtension(getCheckId(), BslPlugin.PLUGIN_ID)) | ||
| .module() | ||
| .checkedObjectType(METHOD); | ||
| } | ||
|
|
||
| @Override | ||
| protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters, | ||
| IProgressMonitor monitor) | ||
| { | ||
| Method method = (Method)object; | ||
| List<Statement> allItems = BslUtil.allStatements(method); | ||
alonthedark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (allItems.isEmpty()) | ||
| { | ||
| return; | ||
| } | ||
| INode node = NodeModelUtils.findActualNodeFor(allItems.get(0)); | ||
|
|
||
| if (allItems.get(0) instanceof EmptyStatement) | ||
| { | ||
| node = NodeModelUtils.findActualNodeFor(allItems.get(0)); | ||
|
|
||
| if (node == null) | ||
| { | ||
| return; | ||
| } | ||
| INode checkNode = node.getNextSibling(); | ||
|
|
||
| if (checkNode == null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| String checkText = checkNode.getText(); | ||
|
|
||
| if (checkText.contains(";")) //$NON-NLS-1$ | ||
| { | ||
| resultAceptor.addIssue(Messages.MethodSemicolonExtraCheck_Issue, NAMED_ELEMENT__NAME); | ||
alonthedark marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| INode checkNodeNext = checkNode.getNextSibling(); | ||
|
|
||
| if (checkNodeNext == null) | ||
| { | ||
| return; | ||
| } | ||
| String checkNextText = checkNodeNext.getText(); | ||
| if (checkNextText.contains(";")) //$NON-NLS-1$ | ||
| { | ||
| resultAceptor.addIssue(Messages.MethodSemicolonExtraCheck_Issue, NAMED_ELEMENT__NAME); | ||
| } | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.