Java Code Examples for org.eclipse.xtext.diagnostics.Severity#IGNORE
The following examples show how to use
org.eclipse.xtext.diagnostics.Severity#IGNORE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SeverityConverter.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
public Severity stringToSeverity(String severityAsString) { if (severityAsString == null) throw new IllegalArgumentException("Severity as string was null"); if (severityAsString.equals(SEVERITY_ERROR)) { return Severity.ERROR; } if (severityAsString.equals(SEVERITY_WARNING)) { return Severity.WARNING; } if (severityAsString.equals(SEVERITY_INFO)) { return Severity.INFO; } if (severityAsString.equals(SEVERITY_IGNORE)) { return Severity.IGNORE; } throw new IllegalArgumentException("Unknown severity '"+severityAsString+"'."); }
Example 2
Source File: XtextValidator.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Check public void checkOppositeReferenceUsed(Assignment assignment) { Severity severity = getIssueSeverities(getContext(), getCurrentObject()).getSeverity(BIDIRECTIONAL_REFERENCE); if (severity == null || severity == Severity.IGNORE) { // Don't perform any check if the result is ignored return; } EClassifier classifier = GrammarUtil.findCurrentType(assignment); if (classifier instanceof EClass) { EStructuralFeature feature = ((EClass) classifier).getEStructuralFeature(assignment.getFeature()); if (feature instanceof EReference) { EReference reference = (EReference) feature; if (reference.getEOpposite() != null && !(reference.isContainment() || reference.isContainer())) { addIssue("The feature '" + assignment.getFeature() + "' is a bidirectional reference." + " This may cause problems in the linking process.", assignment, XtextPackage.eINSTANCE.getAssignment_Feature(), BIDIRECTIONAL_REFERENCE); } } } }
Example 3
Source File: IssueAcceptor.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Convert the given issues to diagnostics. Does not return issues in files that are neither in the workspace nor * currently opened in the editor. Does not return any issue with severity {@link Severity#IGNORE ignore}. */ protected List<Diagnostic> toDiagnostics(Iterable<? extends LSPIssue> issues) { if (IterableExtensions.isEmpty(issues)) { return Collections.emptyList(); } List<Diagnostic> sortedDiags = new ArrayList<>(); for (LSPIssue issue : issues) { if (issue.getSeverity() != Severity.IGNORE) { sortedDiags.add(diagnosticIssueConverter.toDiagnostic(issue)); } } // Sort issues according to line and position final Comparator<Diagnostic> comparator = new Comparator<>() { @Override public int compare(Diagnostic d1, Diagnostic d2) { Position p1 = d1.getRange().getStart(); Position p2 = d2.getRange().getStart(); int result = ComparisonChain.start() .compare(p1.getLine(), p2.getLine()) .compare(p2.getCharacter(), p2.getCharacter()) .result(); return result; } }; Collections.sort(sortedDiags, comparator); return sortedDiags; }
Example 4
Source File: DiagnosticIssueConverter.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Convert the lsp {@link DiagnosticSeverity} to an Xtext {@link Severity}. * * Defaults to severity {@link Severity#IGNORE}. */ protected Severity toSeverity(DiagnosticSeverity severity) { switch (severity) { case Error: return Severity.ERROR; case Hint: return Severity.IGNORE; case Information: return Severity.INFO; case Warning: return Severity.WARNING; default: return Severity.IGNORE; } }
Example 5
Source File: AbstractPendingLinkingCandidate.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected boolean validateUnhandledExceptions(IAcceptor<? super AbstractDiagnostic> result) { if (getFeature() instanceof JvmExecutable) { JvmExecutable executable = (JvmExecutable) getFeature(); if (getUnhandledExceptionSeverity(executable) != Severity.IGNORE) { if (!executable.getExceptions().isEmpty()) { return validateUnhandledExceptions(executable, result); } } } return true; }
Example 6
Source File: IssueSeverities.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * @return the Severity for the given severity code. Never returns <code>null</code> */ public Severity getSeverity(String code) { if (!configurableIssueCodes.containsKey(code)) { log.error("Configurable issue code '" + code + "' is not registered. Check the binding for " + ConfigurableIssueCodesProvider.class.getName()); return Severity.IGNORE; } final String value = preferenceValues.getPreference(configurableIssueCodes.get(code)); try { return converter.stringToSeverity(value); } catch (IllegalArgumentException e) { log.error(e.getMessage(), e); return Severity.IGNORE; } }
Example 7
Source File: XtextValidator.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Check public void checkJavaPackageNamingConventions(GeneratedMetamodel metamodel){ Severity severity = getIssueSeverities(getContext(), getCurrentObject()).getSeverity(INVALID_JAVAPACKAGE_NAME); if (severity == null || severity == Severity.IGNORE) { // Don't perform any check if the result is ignored return; } final String metamodelName = Strings.emptyIfNull(metamodel.getName()); if (!Strings.equal(metamodelName, metamodelName.toLowerCase())) { addIssue("The generated metamodel name must not contain uppercase characters", metamodel, XtextPackage.eINSTANCE.getGeneratedMetamodel_Name(), INVALID_JAVAPACKAGE_NAME, metamodel.getName()); } }
Example 8
Source File: LanguageServerImpl.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * Convert the given issues to diagnostics. Does not return any issue with severity {@link Severity#IGNORE ignore} * by default. */ protected List<Diagnostic> toDiagnostics(Iterable<? extends Issue> issues) { List<Diagnostic> result = new ArrayList<>(); for (Issue issue : issues) { if (issue.getSeverity() != Severity.IGNORE) { result.add(toDiagnostic(issue)); } } return result; }
Example 9
Source File: DefaultValidationIssueStore.java From statecharts with Eclipse Public License 1.0 | 5 votes |
protected Severity getMinSeverity(Collection<SCTIssue> issues) { Severity minNewSeverity = Severity.IGNORE; for (SCTIssue sctIssue : issues) { minNewSeverity = minNewSeverity.ordinal() > sctIssue.getSeverity().ordinal() ? sctIssue.getSeverity() : minNewSeverity; } return minNewSeverity; }
Example 10
Source File: DefaultProgrammaticWarningSuppressor.java From sarl with Apache License 2.0 | 5 votes |
@SuppressWarnings("synthetic-access") @Override public Severity getSeverity(String code) { if (this.delegate == null || this.ignoredAll) { return Severity.IGNORE; } final String codeId = extractId(code); if (this.ignoredWarnings.contains(codeId)) { return Severity.IGNORE; } return this.delegate.getSeverity(code); }
Example 11
Source File: IssueSeverities.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public boolean isIgnored(String code) { return getSeverity(code) == Severity.IGNORE; }