/** * Semantic quickfix setting the override flag for a rule. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(FormatJavaValidator.OVERRIDE_MISSING_CODE) public void setOverride(final Issue issue, final IssueResolutionAcceptor acceptor) { acceptor.accept(issue, "Set override", "Set override flag.", null, new IModification() { @Override public void apply(final IModificationContext context) throws BadLocationException { context.getXtextDocument().modify(new IUnitOfWork<Void, XtextResource>() { @Override public java.lang.Void exec(final XtextResource state) { Rule rule = (Rule) state.getEObject(issue.getUriToProblem().fragment()); rule.setOverride(true); return null; } }); } }); }
@Override public final void apply(IModificationContext context) throws Exception { context.getXtextDocument().modify(new IUnitOfWork.Void<XtextResource>() { @Override public void process(XtextResource resource) throws Exception { final IMarker marker = issue instanceof N4JSIssue ? ((N4JSIssue) issue).getMarker() : null; final EObject element = resource.getEObject(issue.getUriToProblem().fragment()); final Collection<? extends IChange> changes = modification.computeChanges( context, marker, issue.getOffset(), issue.getLength(), element); modification.computeFinalChanges(); changeManager.applyAll(changes); } }); }
/** * Semantic quickfix removing the override flag for a rule. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(FormatJavaValidator.OVERRIDE_ILLEGAL_CODE) public void removeOverride(final Issue issue, final IssueResolutionAcceptor acceptor) { acceptor.accept(issue, "Remove override", "Remove override.", null, new IModification() { @Override public void apply(final IModificationContext context) throws BadLocationException { context.getXtextDocument().modify(new IUnitOfWork<Void, XtextResource>() { @Override public java.lang.Void exec(final XtextResource state) { Rule rule = (Rule) state.getEObject(issue.getUriToProblem().fragment()); rule.setOverride(false); return null; } }); } }); }
/** * Fix catalog name. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(IssueCodes.WRONG_FILE) public void fixCatalogName(final Issue issue, final IssueResolutionAcceptor acceptor) { acceptor.accept(issue, Messages.CheckQuickfixProvider_CORRECT_CATALOG_NAME_LABEL, Messages.CheckQuickfixProvider_CORRECT_CATALOG_NAME_DESCN, NO_IMAGE, new IModification() { @Override public void apply(final IModificationContext context) throws BadLocationException { IXtextDocument xtextDocument = context.getXtextDocument(); IFile file = xtextDocument.getAdapter(IFile.class); if (file != null) { final String fileName = file.getName(); final String name = fileName.indexOf('.') > 0 ? fileName.substring(0, fileName.lastIndexOf('.')) : fileName; xtextDocument.replace(issue.getOffset(), issue.getLength(), name); } } }); }
/** {@inheritDoc} */ @Override public void apply(final IModificationContext context) throws BadLocationException { final IXtextDocument xtextDocument = context.getXtextDocument(); xtextDocument.readOnly(new IUnitOfWork.Void<XtextResource>() { @Override public void process(final XtextResource state) throws Exception { // NOPMD final EObject target = EcoreUtil2.getContainerOfType(state.getEObject(issue.getUriToProblem().fragment()), type); if (type.isInstance(target)) { int offset = NodeModelUtils.findActualNodeFor(target).getOffset(); int lineOfOffset = xtextDocument.getLineOfOffset(offset); int lineOffset = xtextDocument.getLineOffset(lineOfOffset); StringBuffer buffer = new StringBuffer(); for (int i = 0; i < (offset - lineOffset); i++) { buffer.append(' '); } xtextDocument.replace(offset, 0, NLS.bind(autodocumentation, buffer.toString())); } } }); }
/** * Removes the guard statement occurring at offending position. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(IssueCodes.GUARDS_COME_FIRST) @SuppressWarnings("unchecked") public void removeGuardStatement(final Issue issue, final IssueResolutionAcceptor acceptor) { acceptor.accept(issue, Messages.CheckQuickfixProvider_REMOVE_GUARD_LABEL, Messages.CheckQuickfixProvider_REMOVE_GUARD_DESCN, NO_IMAGE, new ISemanticModification() { @Override public void apply(final EObject element, final IModificationContext context) { final XGuardExpression guard = EcoreUtil2.getContainerOfType(element, XGuardExpression.class); if (guard != null && guard.eContainingFeature().isMany()) { EList<? extends EObject> holder = (EList<? extends EObject>) guard.eContainer().eGet(guard.eContainingFeature()); if (holder != null && holder.contains(guard)) { holder.remove(guard); } } } }); }
/** * Fixes the severity range order by setting the lower severity level kind first and the severity of higher severity level last. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(IssueCodes.ILLEGAL_SEVERITY_RANGE_ORDER) public void fixSeverityRangeOrder(final Issue issue, final IssueResolutionAcceptor acceptor) { acceptor.accept(issue, Messages.CheckQuickfixProvider_FIX_SEVERITY_RANGE_ORDER_LABEL, Messages.CheckQuickfixProvider_FIX_SEVERITY_RANGE_ORDER_DESCN, NO_IMAGE, new ISemanticModification() { @Override public void apply(final EObject element, final IModificationContext context) { final Check check = EcoreUtil2.getContainerOfType(element, Check.class); if (check != null && check.getSeverityRange() != null) { final SeverityRange range = check.getSeverityRange(); SeverityKind oldMinSeverity = range.getMinSeverity(); range.setMinSeverity(range.getMaxSeverity()); range.setMaxSeverity(oldMinSeverity); } } }); }
/** * Fixes an illegally set default severity. The default severity must be within given severity range. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(IssueCodes.DEFAULT_SEVERITY_NOT_IN_RANGE) public void fixIllegalDefaultSeverity(final Issue issue, final IssueResolutionAcceptor acceptor) { if (issue.getData() != null) { for (final String severityProposal : issue.getData()) { final String label = NLS.bind(Messages.CheckQuickfixProvider_DEFAULT_SEVERITY_FIX_LABEL, severityProposal); final String descn = NLS.bind(Messages.CheckQuickfixProvider_DEFAULT_SEVERITY_FIX_DESCN, severityProposal); acceptor.accept(issue, label, descn, NO_IMAGE, new IModification() { @Override public void apply(final IModificationContext context) throws BadLocationException { IXtextDocument xtextDocument = context.getXtextDocument(); xtextDocument.replace(issue.getOffset(), issue.getLength(), severityProposal); } }); } } }
/** * Fix severity by setting it to a legal value as is defined by severity range of referenced check. Legal * severities are passed as issue data (org.eclipse.xtext.validation.Issue#getData()). * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(IssueCodes.SEVERITY_NOT_ALLOWED) public void fixSeverityToMaxSeverity(final Issue issue, final IssueResolutionAcceptor acceptor) { if (issue.getData() != null) { for (final String severityProposal : issue.getData()) { final String label = NLS.bind(Messages.CheckCfgQuickfixProvider_CORRECT_SEVERITY_LABEL, severityProposal); final String descn = NLS.bind(Messages.CheckCfgQuickfixProvider_CORRECT_SEVERITY_DESCN, severityProposal); acceptor.accept(issue, label, descn, NO_IMAGE, new IModification() { public void apply(final IModificationContext context) throws BadLocationException { IXtextDocument xtextDocument = context.getXtextDocument(); xtextDocument.replace(issue.getOffset(), issue.getLength(), severityProposal); } }); } } }
@Fix(IssueCodes.ARRAY_NOT_DECLARED) public void fixArrayNotDeclared(final Issue issue, IssueResolutionAcceptor acceptor) { acceptor.accept(issue, "Remove vector slices", "Removes vector slices from object", null, new ISemanticModification() { @Override public void apply(EObject element, IModificationContext context) throws Exception { if (element instanceof PinAssign) { ((PinAssign) element).setSlices(null); } else if (element instanceof PortAssign) { ((PortAssign) element).setSlices(null); } else if (element instanceof ConnectionAssign) { ((ConnectionAssign) element).setSlices(null); } else if (element instanceof ConnectionRef) { ((ConnectionRef) element).setSlices(null); } } }); }
@Fix(IssueCodes.REQUIRED_ATTRIBUTE_MISSING) public void fixMissingRequiredAttribute(final Issue issue, IssueResolutionAcceptor acceptor) { acceptor.accept(issue, "Add missing required attribute", "Add missing '" + issue.getData()[0] + "' required attribute.", "Attr.gif", new ISemanticModification() { @Override public void apply(EObject element, IModificationContext context) throws Exception { Device device = (Device) element; Attr attr = PhdlFactory.eINSTANCE.createAttr(); attr.setName(issue.getData()[0].toUpperCase()); if (!issue.getData()[0].equals("REFPREFIX")) attr.setValue("my" + issue.getData()[0]); else attr.setValue("R"); device.getElements().add(attr); } }); }
@Fix(SadlJavaValidator.MISSING_ALIAS) public void addImportAlias(final Issue issue, IssueResolutionAcceptor acceptor) { acceptor.accept(issue, "Add import model alias", "Add an alias for the imported model", null, new ISemanticModification() { public void apply(EObject element, IModificationContext context) throws Exception { String alias = null; if (element instanceof com.ge.research.sadl.sadl.Import) { String uri = ((com.ge.research.sadl.sadl.Import)element).getImportURI().trim(); if (uri.endsWith("/")) { uri = uri.substring(0, uri.length() - 1); } int ls = uri.lastIndexOf('/'); if (ls > 0) { alias = uri.substring(ls + 1); } } if (alias == null) { alias = "aliasName"; } ((com.ge.research.sadl.sadl.Import)element).setAlias(alias); } }); }
@Fix(SadlJavaValidator.AMBIGUOUS_NAME) public void addNSQualifier(final Issue issue, final IssueResolutionAcceptor acceptor) { String[] fixes = issue.getData(); Iterator<String> itr = Splitter.on(",").split(fixes[0]).iterator(); while (itr.hasNext()) { // loop over prefixes final String prefix = itr.next(); acceptor.accept(issue, prefix, "Add the namespace prefix '" + prefix + "' to disambiguate name", null, new ISemanticModification() { public void apply(EObject element, IModificationContext context) throws Exception { if (element instanceof ResourceByName) { IXtextDocument xtextDocument = context.getXtextDocument(); if (xtextDocument instanceof XtextDocument) { int insertAt = issue.getOffset(); xtextDocument.replace(insertAt, issue.getLength(), prefix); } } } }); } }
public void addImportTemplateFix(final Issue issue, final IssueResolutionAcceptor acceptor, final String linkText) { boolean _notEquals = (!Objects.equal(linkText, null)); if (_notEquals) { final ISemanticModification _function = new ISemanticModification() { public void apply(final EObject element, final IModificationContext context) throws Exception { if ((element instanceof de.unidue.ecg.characterScript.characterScript.Character)) { final Characters root = EcoreUtil2.<Characters>getContainerOfType(element, Characters.class); final Import import_ = CharacterScriptFactory.eINSTANCE.createImport(); import_.setImportedNamespace(linkText); EList<Import> _imports = root.getImports(); _imports.add(import_); } } }; acceptor.accept(issue, (("Add import for \'" + linkText) + "\'"), (("Add import for \'" + linkText) + "\'"), null, _function); } }
@Fix(EntitiesValidator.HIERARCHY_CYCLE) public void removeSuperType(final Issue issue, final IssueResolutionAcceptor acceptor) { StringConcatenation _builder = new StringConcatenation(); _builder.append("Remove supertype \'"); String[] _data = issue.getData(); String _get = _data[0]; _builder.append(_get, ""); _builder.append("\' "); final ISemanticModification _function = new ISemanticModification() { @Override public void apply(final EObject element, final IModificationContext context) throws Exception { ((Entity) element).setSuperType(null); } }; acceptor.accept(issue, "Remove supertype", _builder.toString(), "delete_obj.gif", _function); }
@Fix(Diagnostic.LINKING_DIAGNOSTIC) public void createMissingEntity(final Issue issue, final IssueResolutionAcceptor acceptor) { final ISemanticModification _function = new ISemanticModification() { @Override public void apply(final EObject element, final IModificationContext context) throws Exception { Entity _containerOfType = EcoreUtil2.<Entity>getContainerOfType(element, Entity.class); IXtextDocument _xtextDocument = context.getXtextDocument(); Integer _offset = issue.getOffset(); Integer _length = issue.getLength(); String _get = _xtextDocument.get((_offset).intValue(), (_length).intValue()); EntitiesModelUtil.addEntityAfter(_containerOfType, _get); } }; acceptor.accept(issue, "Create missing entity", "Create missing entity", "Entity.gif", _function); }
@Fix(EntitiesValidator.INVALID_ENTITY_NAME) public void capitalizeEntityNameFirstLetter(final Issue issue, final IssueResolutionAcceptor acceptor) { String[] _data = issue.getData(); String _get = _data[0]; String _plus = ("Capitalize first letter of \'" + _get); String _plus_1 = (_plus + "\'"); final IModification _function = new IModification() { @Override public void apply(final IModificationContext context) throws Exception { final IXtextDocument xtextDocument = context.getXtextDocument(); Integer _offset = issue.getOffset(); final String firstLetter = xtextDocument.get((_offset).intValue(), 1); Integer _offset_1 = issue.getOffset(); String _firstUpper = StringExtensions.toFirstUpper(firstLetter); xtextDocument.replace((_offset_1).intValue(), 1, _firstUpper); } }; acceptor.accept(issue, "Capitalize first letter", _plus_1, "Entity.gif", _function); }
@Fix(Diagnostic.LINKING_DIAGNOSTIC) public void createMissingEntity(final Issue issue, IssueResolutionAcceptor acceptor) { acceptor.accept(issue, "Create missing entity", // label "Create missing entity", // description "Entity.gif", // icon new ISemanticModification() { public void apply(EObject element, IModificationContext context) throws BadLocationException { IXtextDocument xtextDocument = context.getXtextDocument(); String missingEntityName = xtextDocument.get(issue.getOffset(), issue.getLength()); Entity newEntity = EntitiesFactory.eINSTANCE.createEntity(); newEntity.setName(missingEntityName); Entity currentEntity = EcoreUtil2.getContainerOfType(element, Entity.class); Model model = (Model) currentEntity.eContainer(); model.getEntities().add(model.getEntities().indexOf(currentEntity)+1, newEntity); } } ); }
/** * Returns the semantic element for the given marker or <code>null</code> if not available. * <p> * This method assumes that problems during lookup are not unlikely (marker regions without semantic elements, * invalid regions, out-dated markers, etc.) and that <code>null</code> is an accepted return value in these cases, * so this method is strictly fail-safe an will suppress all errors. */ private EObject getElementForMarker(IModificationContext context, IMarker marker) { try { return context.getXtextDocument().readOnly((XtextResource resource) -> { return resource.getEObject(issueUtil.getUriToProblem(marker).fragment()); }); } catch (Throwable t) { return null; } }
/** * Called if the N4Modification is applied at multiple markers. As default, this method delegates to * {@link #computeChanges(IModificationContext, IMarker, int, int, EObject)}. * * @see #computeChanges(IModificationContext, IMarker, int, int, EObject) */ public Collection<? extends IChange> computeOneOfMultipleChanges( IModificationContext context, IMarker marker, int offset, int length, EObject element) throws Exception { return computeChanges(context, marker, offset, length, element); }
@Fix(IOIJavaValidator.SALARY_TOO_LOW) public void raiseSalary(final Issue issue, IssueResolutionAcceptor acceptor) { acceptor.accept(issue, "Raise Salary", "Raise Salary.", "", new IModification() { public void apply(IModificationContext context) throws BadLocationException { IXtextDocument xtextDocument = context.getXtextDocument(); //String firstLetter = xtextDocument.get(issue.getOffset(), 1); xtextDocument.replace(issue.getOffset(), issue.getLength(), issue.getData()[0]); } }); }
@Fix(IOIJavaValidator.SALARY_TOO_HIGH) public void cutSalary(final Issue issue, IssueResolutionAcceptor acceptor) { acceptor.accept(issue, "Cut Salary", "Cut Salary.", "", new IModification() { public void apply(IModificationContext context) throws BadLocationException { IXtextDocument xtextDocument = context.getXtextDocument(); //String firstLetter = xtextDocument.get(issue.getOffset(), 1); xtextDocument.replace(issue.getOffset(), issue.getLength(), issue.getData()[0]); } }); }
@Fix(RestauranteValidator.NOMBRE_MUY_LARGO) public void arreglarNombre(final Issue issue, final IssueResolutionAcceptor acceptor) { final IModification _function = (IModificationContext context) -> { final IXtextDocument xtextDocument = context.getXtextDocument(); final String nombreActual = xtextDocument.get((issue.getOffset()).intValue(), (issue.getLength()).intValue()); Integer _offset = issue.getOffset(); Integer _length = issue.getLength(); String _substring = nombreActual.substring(0, 18); String _plus = (_substring + "\'"); xtextDocument.replace((_offset).intValue(), (_length).intValue(), _plus); }; acceptor.accept(issue, "Reducir nombre", "Se limitar� el tama�o de nombre al m�ximo sugerido", "ingrediente.ico", _function); }
@Fix(RestauranteValidator.FECHA_INVALIDA) public void arreglarFecha(final Issue issue, final IssueResolutionAcceptor acceptor) { SimpleDateFormat formateadorFecha = new SimpleDateFormat("dd-MM-yyyy"); Calendar calendario = Calendar.getInstance(); final String fecha = formateadorFecha.format(calendario.getTime()); final IModification _function = (IModificationContext context) -> { final IXtextDocument xtextDocument = context.getXtextDocument(); xtextDocument.replace((issue.getOffset()).intValue(), (issue.getLength()).intValue(), fecha); }; acceptor.accept(issue, "Actualizar fecha", "Se pondr� la fecha de hoy para corregir el problema", "fecha.png", _function); }
/** * Syntactic quickfix creating a rule. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(FormatJavaValidator.GRAMMAR_RULE_MISSING_CODE) public void addGrammarRule(final Issue issue, final IssueResolutionAcceptor acceptor) { acceptor.accept(issue, "Create rule", "Create rule " + issue.getData()[0], null, new IModification() { @Override public void apply(final IModificationContext context) throws BadLocationException { final IXtextDocument xtextDocument = context.getXtextDocument(); xtextDocument.replace(xtextDocument.getLength(), 0, "\n" + issue.getData()[0] + " {\n\t\n}"); } }); }
/** * Replaces a guard by an if-expression. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(IssueCodes.GUARDS_DEPRECATED) public void fixGuardStatement(final Issue issue, final IssueResolutionAcceptor acceptor) { acceptor.accept(issue, Messages.CheckQuickfixProvider_GUARD_DEPRECATED_LABEL, Messages.CheckQuickfixProvider_GUARD_DEPRECATED_DESCN, NO_IMAGE, new IModification() { @Override public void apply(final IModificationContext context) throws BadLocationException { IXtextDocument xtextDocument = context.getXtextDocument(); String expr = xtextDocument.get(issue.getOffset(), issue.getLength()); expr = expr.replaceFirst("^guard(\\s*)", "if (!(") + ")) {return}"; xtextDocument.replace(issue.getOffset(), issue.getLength(), expr); } }); }
/** * Fixes the wrong package name. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(IssueCodes.WRONG_PACKAGE) public void fixPackageName(final Issue issue, final IssueResolutionAcceptor acceptor) { acceptor.accept(issue, Messages.CheckQuickfixProvider_CORRECT_PKG_NAME_LABEL, Messages.CheckQuickfixProvider_CORRECT_PKG_NAME_DESCN, NO_IMAGE, new IModification() { @Override public void apply(final IModificationContext context) throws BadLocationException { IXtextDocument xtextDocument = context.getXtextDocument(); final String packageName = resourceUtil.getNameOfContainingPackage(xtextDocument); if (packageName != null) { xtextDocument.replace(issue.getOffset(), issue.getLength(), packageName); } } }); }
/** * Adds an {@code issue} statement to a constraint. If the constraint already contains other expressions, {@code issue} is appended to the end. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(IssueCodes.MISSING_ISSUE_EXPRESSION) public void addIssueExpression(final Issue issue, final IssueResolutionAcceptor acceptor) { acceptor.accept(issue, Messages.CheckQuickfixProvider_ADD_ISSUE_EXPR_LABEL, Messages.CheckQuickfixProvider_ADD_ISSUE_EXPR_DESCN, NO_IMAGE, new IModification() { @Override public void apply(final IModificationContext context) throws BadLocationException { IXtextDocument xtextDocument = context.getXtextDocument(); xtextDocument.replace(issue.getOffset() + issue.getLength() - 1, 0, ' ' + "issue" + ' '); } }); }
/** * Add explicit ID to a check, autogenerated from its label. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(IssueCodes.MISSING_ID_ON_CHECK) public void addIdToCheck(final Issue issue, final IssueResolutionAcceptor acceptor) { acceptor.accept(issue, Messages.CheckQuickfixProvider_ADD_ID_LABEL, NLS.bind(Messages.CheckQuickfixProvider_ADD_ID_DESCN, CHECK), NO_IMAGE, (final EObject element, final IModificationContext context) -> { final Check check = EcoreUtil2.getContainerOfType(element, Check.class); if (check != null) { final String label = check.getLabel(); final String id = CheckUtil.toIdentifier(label); check.setId(id); } }); }
/** * Fixes the circular dependency problem by removing the {@code with} clause. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(IssueCodes.INCLUDED_CATALOGS_WITH_CIRCULAR_DEPENDENCIES) public void removeWithClause(final Issue issue, final IssueResolutionAcceptor acceptor) { acceptor.accept(issue, Messages.CheckQuickfixProvider_REMOVE_WITH_LABEL, Messages.CheckQuickfixProvider_REMOVE_WITH_DESCN, NO_IMAGE, new ISemanticModification() { @Override public void apply(final EObject element, final IModificationContext context) { final CheckCatalog catalog = EcoreUtil2.getContainerOfType(element, CheckCatalog.class); if (catalog != null) { catalog.eUnset(CheckPackage.Literals.CHECK_CATALOG__INCLUDED_CATALOGS); } } }); }
/** * Removes the severity range declaration from the check. Final conflicts with severity range. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(IssueCodes.SEVERITY_RANGES_FOR_FINAL_CHECK) public void removeSeverityRange(final Issue issue, final IssueResolutionAcceptor acceptor) { acceptor.accept(issue, Messages.CheckQuickfixProvider_REMOVE_SEVERITY_RANGE_LABEL, Messages.CheckQuickfixProvider_REMOVE_SEVERITY_RANGE_DESCN, NO_IMAGE, new ISemanticModification() { @Override public void apply(final EObject element, final IModificationContext context) { final Check check = EcoreUtil2.getContainerOfType(element, Check.class); if (check != null) { check.setSeverityRange(null); } } }); }
/** * Removes a duplicate parameter definition. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(IssueCodes.DUPLICATE_PARAMETER_DEFINITION) public void removeDuplicateParameterDefinition(final Issue issue, final IssueResolutionAcceptor acceptor) { acceptor.accept(issue, Messages.CheckQuickfixProvider_REMOVE_PARAM_DEF_LABEL, Messages.CheckQuickfixProvider_REMOVE_PARAM_DEF_DESCN, null, new ISemanticModification() { @Override public void apply(final EObject element, final IModificationContext context) { Check check = EcoreUtil2.getContainerOfType(element, Check.class); check.getFormalParameters().remove(element); } }); }
/** * Removes a duplicate catalog configuration. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(IssueCodes.DUPLICATE_CATALOG_CONFIGURATION) public void removeDuplicateCatalogConfiguration(final Issue issue, final IssueResolutionAcceptor acceptor) { acceptor.accept(issue, Messages.CheckCfgQuickfixProvider_REMOVE_DUPLICATE_CATALOG_LABEL, Messages.CheckCfgQuickfixProvider_REMOVE_DUPLICATE_CATALOG_DESCN, null, new ISemanticModification() { public void apply(final EObject element, final IModificationContext context) { CheckConfiguration configuration = EcoreUtil2.getContainerOfType(element, CheckConfiguration.class); configuration.getLegacyCatalogConfigurations().remove(element); } }); }
/** * Removes a duplicate check configuration. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(IssueCodes.DUPLICATE_CHECK_CONFIGURATION) public void removeDuplicateCheckConfiguration(final Issue issue, final IssueResolutionAcceptor acceptor) { acceptor.accept(issue, Messages.CheckCfgQuickfixProvider_REMOVE_DUPLICATE_CHECK_LABEL, Messages.CheckCfgQuickfixProvider_REMOVE_DUPLICATE_CHECK_DESCN, null, new ISemanticModification() { public void apply(final EObject element, final IModificationContext context) { ConfiguredCatalog catalog = EcoreUtil2.getContainerOfType(element, ConfiguredCatalog.class); catalog.getCheckConfigurations().remove(element); } }); }
/** * Removes a duplicate parameter configuration. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(IssueCodes.DUPLICATE_PARAMETER_CONFIGURATION) public void removeDuplicateParameterConfiguration(final Issue issue, final IssueResolutionAcceptor acceptor) { acceptor.accept(issue, Messages.CheckCfgQuickfixProvider_REMOVE_DUPLICATE_PARAM_LABEL, Messages.CheckCfgQuickfixProvider_REMOVE_DUPLICATE_PARAM_DESCN, null, new ISemanticModification() { public void apply(final EObject element, final IModificationContext context) { ConfiguredCheck check = EcoreUtil2.getContainerOfType(element, ConfiguredCheck.class); check.getParameterConfigurations().remove(element); } }); }
/** * Removes the configured values of a disabled check. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(IssueCodes.DISABLED_CHECK_NOT_CONFIGURED) public void removeConfiguredParamsOfDisabledCheck(final Issue issue, final IssueResolutionAcceptor acceptor) { acceptor.accept(issue, Messages.CheckCfgQuickfixProvider_REMOVE_CONFIGURED_PARAM_LABEL, Messages.CheckCfgQuickfixProvider_REMOVE_CONFIGURED_PARAM_DESCN, null, new ISemanticModification() { public void apply(final EObject element, final IModificationContext context) { ConfiguredCheck check = EcoreUtil2.getContainerOfType(element, ConfiguredCheck.class); check.getParameterConfigurations().removeAll(check.getParameterConfigurations()); } }); }
/** * Reset the severity of a configured check which is final to {@code default}. * * @param issue * the issue * @param acceptor * the acceptor */ @Fix(IssueCodes.FINAL_CHECK_NOT_CONFIGURABLE) public void resetSeverityOfFinalCheck(final Issue issue, final IssueResolutionAcceptor acceptor) { acceptor.accept(issue, Messages.CheckCfgQuickfixProvider_CORRECT_SEVERITY_OF_FINAL_CHECK_LABEL, Messages.CheckCfgQuickfixProvider_CORRECT_SEVERITY_OF_FINAL_CHECK_DESCN, null, new ISemanticModification() { public void apply(final EObject element, final IModificationContext context) { ConfiguredCheck check = EcoreUtil2.getContainerOfType(element, ConfiguredCheck.class); check.setSeverity(SeverityKind.DEFAULT); } }); }
/** * @since 2.4 */ public IssueResolution(String label, String description, String image, IModificationContext modificationContext, IModification modification, int relevance) { this.description = description; this.label = label; this.image = image; this.modificationContext = modificationContext; this.modification = modification; this.relevance = relevance; }
@Fix(SGenJavaValidator.CODE_REQUIRED_FEATURE) public void AddRequiredFeature(final Issue issue, IssueResolutionAcceptor acceptor) { acceptor.accept(issue, "Add feature " + issue.getData()[0], "Adds the feature " + issue.getData()[0], null, new ISemanticModification() { public void apply(EObject element, IModificationContext context) throws Exception { FeatureConfiguration config = getDefaultFeatureConfiguration(issue, element); if (config != null) { GeneratorEntry entry = (GeneratorEntry) element; entry.getFeatures().add(config); } } }); }
@Fix(IssueCodes.NOT_UPPERCASE) public void fixCase(final Issue issue, IssueResolutionAcceptor acceptor) { acceptor.accept(issue, "Convert to UPPERCASE", "Convert '" + issue.getData()[0] + "' to '" + issue.getData()[0].toUpperCase() + "'", "Upcase.gif", new IModification() { @Override public void apply(IModificationContext context) throws BadLocationException { IXtextDocument document = context.getXtextDocument(); String name = document.get(issue.getOffset(), issue.getLength()); document.replace(issue.getOffset(), issue.getLength(), name.toUpperCase()); } }); }