public int getCode() { return diagnostic.getCode(); }
public int getCode() { return diagnostic.getCode(); }
public boolean createMessageForSource(Diagnostic diagnostic, EObject object, ValidationMessageAcceptor acceptor) { String code = XtextValidator.class.getName() + ".PackageValidation." + diagnostic.getCode(); int severity = diagnostic.getSeverity(); if (diagnostic.getCode() == EcoreValidator.UNIQUE_CLASSIFIER_NAMES || diagnostic.getCode() == EcoreValidator.UNIQUE_FEATURE_NAMES) severity = Diagnostic.ERROR; String message = diagnostic.getMessage(); return createMessageForSource(message, code, severity, object, acceptor); }
public void doCreateMessage(Diagnostic diagnostic, EObject object, EStructuralFeature feature, ValidationMessageAcceptor acceptor) { String code = XtextValidator.class.getName() + ".PackageValidation." + diagnostic.getCode(); int severity = diagnostic.getSeverity(); if (diagnostic.getCode() == EcoreValidator.UNIQUE_CLASSIFIER_NAMES || diagnostic.getCode() == EcoreValidator.UNIQUE_FEATURE_NAMES) severity = Diagnostic.ERROR; String message = diagnostic.getMessage(); doCreateMessage(message, code, severity, object, feature, acceptor); }
/** * @since 2.4 */ protected String getIssueCode(org.eclipse.emf.common.util.Diagnostic diagnostic) { if (diagnostic instanceof AbstractValidationDiagnostic) { AbstractValidationDiagnostic diagnosticImpl = (AbstractValidationDiagnostic) diagnostic; return diagnosticImpl.getIssueCode(); } else { return diagnostic.getSource() + "." + diagnostic.getCode(); } }
@Override public void convertValidatorDiagnostic(org.eclipse.emf.common.util.Diagnostic diagnostic, IAcceptor<Issue> acceptor) { if (diagnostic instanceof BasicDiagnostic) { List<?> data = diagnostic.getData(); if (!data.isEmpty() && data.get(0) instanceof Throwable) { Throwable t = (Throwable) data.get(0); throwError(t); } if (EObjectValidator.DIAGNOSTIC_SOURCE.equals(diagnostic.getSource()) && diagnostic.getCode() == EObjectValidator.EOBJECT__EVERY_REFERENCE_IS_CONTAINED) { throwError(new RuntimeException("Dangling reference found.")); } } }
public boolean apply(Diagnostic d) { if (severity != null && d.getSeverity() != severity) return false; if (code != null && !code.equals(d.getCode())) return false; if (issueCode != null && d instanceof AbstractValidationDiagnostic && !((AbstractValidationDiagnostic) d).getIssueCode().equals(issueCode)) return false; if (msg != null && d.getMessage() != null && !d.getMessage().contains(msg)) return false; return true; }
public boolean apply(Diagnostic d) { if (severity != null && d.getSeverity() != severity) return false; if (code != null && !code.equals(d.getCode())) return false; if (issueCode != null && d instanceof AbstractValidationDiagnostic && !((AbstractValidationDiagnostic) d).getIssueCode().equals(issueCode)) return false; if (msg != null && d.getMessage() != null && !d.getMessage().contains(msg)) return false; return true; }
@Override public boolean apply(Diagnostic d) { if (severity != null && d.getSeverity() != severity) return false; if (code != null && !code.equals(d.getCode())) return false; if (issueCode != null && d instanceof AbstractValidationDiagnostic && !((AbstractValidationDiagnostic) d).getIssueCode().equals(issueCode)) return false; if (msg != null && d.getMessage() != null && !d.getMessage().contains(msg)) return false; return true; }
private void propageValidationResult(Diagnostic diagnostic, GeneratedMetamodel metamodel, ValidationMessageAcceptor acceptor) { if (diagnostic.getSeverity() != Diagnostic.OK) { if (diagnostic.getCode() != 0) { List<?> data = diagnostic.getData(); if (!data.isEmpty() && data.get(0) instanceof EObject) { doPropagateValidationResult(diagnostic, metamodel, acceptor); } } for(Diagnostic child: diagnostic.getChildren()) propageValidationResult(child, metamodel, acceptor); } }
public static int computeActionCode(Diagnostic diagnostic) { if (ConverterPlugin.ID.equals(diagnostic.getSource())) { int actionCode = diagnostic.getCode(); for (Diagnostic child : diagnostic.getChildren()) { actionCode |= computeActionCode(child); } return actionCode; } else { return ACTION_DEFAULT; } }
/** * @param diagnostic * @param offset * @param length * @param file * @param prefs * @return a configured message */ public static Message createFromDiagnostic(final Diagnostic diagnostic, int offset, int length, IFile file, ELValidationPreferences prefs) { final int severity = prefs.getDiagnosticSeverity(diagnostic.getCode()); final Message message = new MyLocalizedMessage( convertSeverity(severity), diagnostic.getMessage(), file, diagnostic.getCode()); message.setOffset(offset); message.setLength(length); return message; }
/** * Handles problems of single evaluation performed on behalf of batch * evaluate invocation. */ private void handleNextEvaluateProblems() { Diagnostic nextEvalProblems = getProblems(); if (nextEvalProblems != null) { if (batchEvalProblems == null) { BasicDiagnostic rootDiagnostic = new BasicDiagnostic( nextEvalProblems.getSeverity(), OCLPlugin.getPluginId(), nextEvalProblems.getCode(), nextEvalProblems.getMessage(), null); batchEvalProblems = rootDiagnostic; } batchEvalProblems.add(nextEvalProblems); } }
/** * Handles problems of single evaluation performed on behalf of batch * evaluate invocation. */ private void handleNextEvaluateProblems() { Diagnostic nextEvalProblems = getProblems(); if (nextEvalProblems != null) { if (batchEvalProblems == null) { BasicDiagnostic rootDiagnostic = new BasicDiagnostic( nextEvalProblems.getSeverity(), OCLPlugin.getPluginId(), nextEvalProblems.getCode(), nextEvalProblems.getMessage(), null); batchEvalProblems = rootDiagnostic; } batchEvalProblems.add(nextEvalProblems); } }
public static Diagnostic mergeDiagnostic(Diagnostic baseDiagnostic, Diagnostic diagnosticToBeMerged) { if (diagnosticToBeMerged == null) { return baseDiagnostic; } else { if (baseDiagnostic == null) { return diagnosticToBeMerged; } else if (baseDiagnostic instanceof DiagnosticChain) { ((DiagnosticChain)baseDiagnostic).merge(diagnosticToBeMerged); return baseDiagnostic; } else { BasicDiagnostic basicDiagnostic = new BasicDiagnostic( baseDiagnostic.getSeverity(), baseDiagnostic.getSource(), baseDiagnostic.getCode(), baseDiagnostic.getMessage(), baseDiagnostic.getData().toArray()); basicDiagnostic.addAll(baseDiagnostic); basicDiagnostic.add(diagnosticToBeMerged); return basicDiagnostic; } } }
child.getCode() != EcoreValidator.CONSISTENT_ARGUMENTS_NONE)
child.getCode() != EcoreValidator.CONSISTENT_ARGUMENTS_NONE)