@Override public void handleInfo(Diagnostic diagnostic) { getLogger().info(new StringBuilder("INFO: ").append(diagnostic.getMessage()).toString()); } }
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); }
protected String normalizeInstanceTypeName(String value) { if (value != null) { Diagnostic diagnostic = EcoreValidator.EGenericTypeBuilder.INSTANCE.parseInstanceTypeName(value); if (diagnostic.getSeverity() == Diagnostic.OK) { value = EcoreUtil.toJavaInstanceTypeName(((EGenericType)diagnostic.getData().get(0))); } } return value; }
/** * Determines whether code generation can continue, based on the given <code>Diagnostic</code>. This implementation * returns true unless the {@link org.eclipse.emf.common.util.Diagnostic#getSeverity severity} is * <code>CANCEL</code>. * * @see org.eclipse.emf.common.util.Diagnostic#getSeverity() */ protected boolean canContinue(Diagnostic diagnostic) { return diagnostic.getSeverity() != Diagnostic.CANCEL; }
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; } } }
if (diagnostic.getSeverity() == Diagnostic.ERROR) else if (diagnostic.getSeverity() == Diagnostic.WARNING) for (Diagnostic child : diagnostic.getChildren()) if (!EcoreValidator.DIAGNOSTIC_SOURCE.equals(child.getSource()) || child.getCode() != EcoreValidator.CONSISTENT_ARGUMENTS_NONE)
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); } }
boolean result = instanceTypeName != null ? typeBuilderDiagnostic.getSeverity() == Diagnostic.OK && instanceTypeName.equals(formattedName = EcoreUtil.toJavaInstanceTypeName((EGenericType)typeBuilderDiagnostic.getData().get(0))) : eClassifier instanceof EClass || eClassifier instanceof EEnum; if (!result && diagnostics != null) if (typeBuilderDiagnostic != null) if (!typeBuilderDiagnostic.getChildren().isEmpty())
public static Diagnostic createDiagnostic(Diagnostic baseDiagnostic, String source, int code) { BasicDiagnostic basicDiagnostic = new BasicDiagnostic( baseDiagnostic.getSeverity(), source, code, baseDiagnostic.getMessage(), baseDiagnostic.getData().toArray()); basicDiagnostic.addAll(baseDiagnostic); return basicDiagnostic; }
@Override public void add(final Diagnostic diagnostic) { int _severity = diagnostic.getSeverity(); boolean _equals = (_severity == Diagnostic.ERROR); if (_equals) { String _name = grammar.getName(); String _plus = ("Validation Error in " + _name); final String grammarName = (_plus + ": "); Throwable _exception = diagnostic.getException(); boolean _tripleEquals = (_exception == null); if (_tripleEquals) { String _message = diagnostic.getMessage(); String _plus_1 = (grammarName + _message); throw new IllegalStateException(_plus_1); } else { String _message_1 = diagnostic.getMessage(); String _plus_2 = (grammarName + _message_1); Throwable _exception_1 = diagnostic.getException(); throw new IllegalStateException(_plus_2, _exception_1); } } }
public List<Diagnostic> getChildren() { return diagnostic.getChildren(); }
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; } }
@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 List<?> getData() { return diagnostic.getData(); }
/** * @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; }
public DiagnosticException(Diagnostic diagnostic) { super(diagnostic.getMessage(), diagnostic.getException()); this.diagnostic = diagnostic; }
protected void printDiagnostic(StringBuffer out, String prefix, Diagnostic d) { final String indent = " "; out.append(prefix); out.append(d); if (d.getChildren().size() > 0 || d.getException() != null) { out.append(" {\n"); String prefix2 = prefix + indent; if (d.getException() != null) { out.append(prefix2); ByteArrayOutputStream s = new ByteArrayOutputStream(); PrintWriter pw = new PrintWriter(s); d.getException().printStackTrace(pw); pw.flush(); out.append(s.toString()); out.append("\n"); } for (Diagnostic c : d.getChildren()) printDiagnostic(out, prefix2, c); out.append(prefix); out.append("}\n"); } else out.append("\n"); }
@Override public String getMessage() { StringBuffer msg = new StringBuffer(); msg.append(super.getMessage()); msg.append("\n"); for (Diagnostic d : diagnostics) { msg.append(d.getSource()); msg.append(": "); msg.append(d.getMessage()); msg.append("\n"); } return msg.toString(); }
/** * @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(); } }
public int getCode() { return diagnostic.getCode(); }