diff options
author | Henrik Rentz-Reichert | 2012-11-21 09:44:46 +0000 |
---|---|---|
committer | Henrik Rentz-Reichert | 2012-11-21 09:44:46 +0000 |
commit | c0e2f108621b51571be3327aa77d32625de7a99a (patch) | |
tree | 51c27535f219fde43a733e9bca425212528a41cb /plugins/org.eclipse.etrice.core.etmap.ui/src | |
parent | dc0682eebdbd0d1d21400a7efbe8ea1dbcb98e88 (diff) | |
download | org.eclipse.etrice-c0e2f108621b51571be3327aa77d32625de7a99a.tar.gz org.eclipse.etrice-c0e2f108621b51571be3327aa77d32625de7a99a.tar.xz org.eclipse.etrice-c0e2f108621b51571be3327aa77d32625de7a99a.zip |
[core.etmap] validation and quick fixes
Diffstat (limited to 'plugins/org.eclipse.etrice.core.etmap.ui/src')
-rw-r--r-- | plugins/org.eclipse.etrice.core.etmap.ui/src/org/eclipse/etrice/core/etmap/ui/quickfix/ETMapQuickfixProvider.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/plugins/org.eclipse.etrice.core.etmap.ui/src/org/eclipse/etrice/core/etmap/ui/quickfix/ETMapQuickfixProvider.java b/plugins/org.eclipse.etrice.core.etmap.ui/src/org/eclipse/etrice/core/etmap/ui/quickfix/ETMapQuickfixProvider.java index 634587455..7f93d11fe 100644 --- a/plugins/org.eclipse.etrice.core.etmap.ui/src/org/eclipse/etrice/core/etmap/ui/quickfix/ETMapQuickfixProvider.java +++ b/plugins/org.eclipse.etrice.core.etmap.ui/src/org/eclipse/etrice/core/etmap/ui/quickfix/ETMapQuickfixProvider.java @@ -12,7 +12,15 @@ package org.eclipse.etrice.core.etmap.ui.quickfix; +import org.eclipse.xtext.ui.editor.model.IXtextDocument; +import org.eclipse.xtext.ui.editor.model.edit.IModification; +import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; import org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider; +import org.eclipse.xtext.ui.editor.quickfix.Fix; +import org.eclipse.xtext.ui.editor.quickfix.IssueResolutionAcceptor; +import org.eclipse.xtext.validation.Issue; +import org.eclipse.etrice.core.etmap.validation.ETMapJavaValidator; +import org.eclipse.jface.text.BadLocationException; public class ETMapQuickfixProvider extends DefaultQuickfixProvider { @@ -27,4 +35,55 @@ public class ETMapQuickfixProvider extends DefaultQuickfixProvider { // }); // } + @Fix(ETMapJavaValidator.DUPLICATE_SUBSYS_MAPPING) + public void removeDuplicateSubSysMapping(final Issue issue, IssueResolutionAcceptor acceptor) { + acceptor.accept(issue, "Remove duplicate", "remove this mapping", "upcase.png", new IModification() { + public void apply(IModificationContext context) throws BadLocationException { + IXtextDocument xtextDocument = context.getXtextDocument(); + xtextDocument.replace(issue.getOffset(), issue.getLength(), ""); + } + }); + } + + @Fix(ETMapJavaValidator.UNMAPPED_SUBSYS_REFS) + public void addMissingSubSysMappings(final Issue issue, IssueResolutionAcceptor acceptor) { + acceptor.accept(issue, "Add mappings", "add missing mappings", "upcase.png", new IModification() { + public void apply(IModificationContext context) throws BadLocationException { + IXtextDocument xtextDocument = context.getXtextDocument(); + int offset = issue.getOffset()+issue.getLength(); + String insertion = "\n"+issue.getData()[0]; + if (issue.getData()[1].equals(ETMapJavaValidator.EMPTY)) { + --offset; + insertion += "\t\t"; + } + xtextDocument.replace(offset, 0, insertion); + } + }); + } + + @Fix(ETMapJavaValidator.DUPLICATE_THREAD_MAPPING) + public void removeDuplicateThreadMapping(final Issue issue, IssueResolutionAcceptor acceptor) { + acceptor.accept(issue, "Remove duplicate", "remove this mapping", "upcase.png", new IModification() { + public void apply(IModificationContext context) throws BadLocationException { + IXtextDocument xtextDocument = context.getXtextDocument(); + xtextDocument.replace(issue.getOffset(), issue.getLength(), ""); + } + }); + } + + @Fix(ETMapJavaValidator.UNMAPPED_THREAD_REFS) + public void addMissingThreadMappings(final Issue issue, IssueResolutionAcceptor acceptor) { + acceptor.accept(issue, "Add mappings", "add missing mappings", "upcase.png", new IModification() { + public void apply(IModificationContext context) throws BadLocationException { + IXtextDocument xtextDocument = context.getXtextDocument(); + int offset = issue.getOffset()+issue.getLength(); + String insertion = "\n"+issue.getData()[0]; + if (issue.getData()[1].equals(ETMapJavaValidator.EMPTY)) { + --offset; + insertion += "\t\t"; + } + xtextDocument.replace(offset, 0, insertion); + } + }); + } } |