-
Notifications
You must be signed in to change notification settings - Fork 57
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
18
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.
+892
−0
Open
Changes from all commits
Commits
Show all changes
18 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 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
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
79 changes: 79 additions & 0 deletions
79
...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,79 @@ | ||
| /******************************************************************************* | ||
| * 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.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.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 EmptyStatement)) | ||
| { | ||
| return null; | ||
| } | ||
|
|
||
| INode node = NodeModelUtils.findActualNodeFor(eobject); | ||
|
|
||
| if (node == null) | ||
| { | ||
| return null; | ||
| } | ||
| INode checkNode = node.getNextSibling(); | ||
| if (checkNode == null) | ||
| { | ||
| return null; | ||
| } | ||
| 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(";") && !(checkNextNode == null)) //$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.InsertEdit; | ||
| 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 InsertEdit(node.getEndOffset(), ";"); //$NON-NLS-1$ | ||
| } | ||
| } | ||
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
116 changes: 116 additions & 0 deletions
116
.../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,116 @@ | ||
| /******************************************************************************* | ||
| * 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 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.BslDirectLocationIssue; | ||
| import com.e1c.g5.v8.dt.check.CheckComplexity; | ||
| import com.e1c.g5.v8.dt.check.DirectLocation; | ||
| import com.e1c.g5.v8.dt.check.ICheckParameters; | ||
| import com.e1c.g5.v8.dt.check.Issue; | ||
| 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); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| if (allItems.isEmpty()) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| if (allItems.get(0) instanceof EmptyStatement) | ||
| { | ||
| INode node = NodeModelUtils.findActualNodeFor(allItems.get(0)); | ||
|
|
||
| if (node == null) | ||
| { | ||
| return; | ||
| } | ||
| INode checkNode = node.getNextSibling(); | ||
|
|
||
| if (checkNode == null) | ||
| { | ||
| return; | ||
| } | ||
| String checkText = checkNode.getText(); | ||
| INode checkNodeNext = checkNode.getNextSibling(); | ||
| if (checkText.contains(";")) //$NON-NLS-1$ | ||
| { | ||
|
|
||
| DirectLocation directLocation = new DirectLocation(checkNode.getOffset(), checkNode.getLength(), | ||
| checkNode.getStartLine(), allItems.get(0)); | ||
|
|
||
| Issue issue = new BslDirectLocationIssue(Messages.MethodSemicolonExtraCheck_Issue, directLocation); | ||
|
|
||
| resultAceptor.addIssue(issue); | ||
| } | ||
| else if (checkNodeNext.getText().contains(";") && !(checkNodeNext == null)) //$NON-NLS-1$ | ||
| { | ||
| DirectLocation directLocation = new DirectLocation(checkNodeNext.getOffset(), checkNodeNext.getLength(), | ||
| checkNodeNext.getStartLine(), allItems.get(0)); | ||
|
|
||
| Issue issue = new BslDirectLocationIssue(Messages.MethodSemicolonExtraCheck_Issue, directLocation); | ||
|
|
||
| resultAceptor.addIssue(issue); | ||
| } | ||
| } | ||
| } | ||
| } | ||
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.