/** * Creates a diagnostic using the given parameters and the {@link #annotationSource}. * @param severity * @param code * @param message * @param data * @return a diagnostic. */ protected BasicDiagnostic createDiagnostic(int severity, int code, String message, Object... data) { return new BasicDiagnostic(severity, diagnosticSource, code, message, data); }
/** * Validates the MemberTypes constraint of '<em>Time Duration Type</em>'. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public boolean validateTimeDurationType_MemberTypes(Object timeDurationType, DiagnosticChain diagnostics, Map context) { if (diagnostics != null) { BasicDiagnostic tempDiagnostics = new BasicDiagnostic(); if (XMLTypePackage.Literals.DURATION.isInstance(timeDurationType)) { if (xmlTypeValidator.validateDuration((Duration)timeDurationType, tempDiagnostics, context)) return true; } if (XMLTypePackage.Literals.DECIMAL.isInstance(timeDurationType)) { if (xmlTypeValidator.validateDecimal((BigDecimal)timeDurationType, tempDiagnostics, context)) return true; } List children = tempDiagnostics.getChildren(); for (int i = 0; i < children.size(); i++) { diagnostics.add((Diagnostic)children.get(i)); } } else { if (XMLTypePackage.Literals.DURATION.isInstance(timeDurationType)) { if (xmlTypeValidator.validateDuration((Duration)timeDurationType, null, context)) return true; } if (XMLTypePackage.Literals.DECIMAL.isInstance(timeDurationType)) { if (xmlTypeValidator.validateDecimal((BigDecimal)timeDurationType, null, context)) return true; } } return false; }
/** * Parses an instance type name and returns a diagnostic representing the result of the analysis. * The {@link Diagnostic#getData() data} of the diagnostic will contain as the first object, the resulting {@link EGenericType generic type}. * @param instanceTypeName an instance type name. * @return the diagnostic result of the analysis. */ public Diagnostic parseInstanceTypeName(final String instanceTypeName) { BasicDiagnostic placeholder = new BasicDiagnostic(); char [] instanceTypeNameCharacterArray = instanceTypeName == null ? NO_CHARS: instanceTypeName.toCharArray(); EGenericType eGenericType = handleInstanceTypeName(instanceTypeNameCharacterArray, 0, instanceTypeNameCharacterArray.length, placeholder); BasicDiagnostic result = createDiagnostic (placeholder.getSeverity(), DIAGNOSTIC_SOURCE, WELL_FORMED_INSTANCE_TYPE_NAME, "_UI_EClassifierInstanceTypeNameAnalysisResult_diagnostic", new Object [] { instanceTypeName }, new Object [] { eGenericType, instanceTypeName }); result.addAll(placeholder); return result; }
public static Diagnostic createErrorDiagnostic(Throwable throwable, boolean showErrorDialog) Diagnostic diagnostic = BasicDiagnostic.toDiagnostic(throwable); if (showErrorDialog) new BasicDiagnostic( Diagnostic.ERROR, ConverterPlugin.ID, new Object[]{throwable}); basicDiagnostic.add(diagnostic); diagnostic = basicDiagnostic; new BasicDiagnostic( Diagnostic.ERROR, ConverterPlugin.ID, new Object[]{throwable}); basicDiagnostic.addAll(diagnostic); diagnostic = basicDiagnostic;
/** * 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); } }
/** * Converts the given exception to a <code>Diagnostic</code>. The <code>currentMessage</code>, if non-null, should * describe what was being done when the exception occurred, and will be used in forming the diagnostic's message. */ protected Diagnostic toDiagnostic(Exception exception, String currentMessage) { CodeGenEcorePlugin.INSTANCE.log(exception); currentMessage = currentMessage != null ? CodeGenEcorePlugin.INSTANCE.getString("_UI_GenerateException_diagnostic", new Object[] { currentMessage }) : CodeGenEcorePlugin.INSTANCE.getString("_UI_GenericGenerateException_diagnostic"); BasicDiagnostic diagnostic = new BasicDiagnostic(CodeGenEcorePlugin.ID, 0, currentMessage, null); //DMS this doesn't really produce nice output. // diagnostic.add(BasicDiagnostic.toDiagnostic(exception)); return diagnostic; }
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; } } }
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; }
/** * Creates a JETException with the embedded exception. */ public JETException(Throwable exception) { super (BasicDiagnostic.toDiagnostic(exception)); }
public BasicDiagnostic(String source, int code, List<? extends Diagnostic> children, String message, Object[] data) { this(source, code, message, data); if (children != null) { for (Diagnostic diagnostic : children) { add(diagnostic); } } }
/** * Parses a list of type parameters and returns a diagnostic representing the result of the analysis. * The {@link Diagnostic#getData() data} of the diagnostic will contain as the first object, the resulting list of {@link ETypeParameter type parameters}. * @param typeParameterList a comma separated list of type parameters delimited by '<' and '>'. * @return the diagnostic result of the analysis. */ public Diagnostic parseTypeParameterList(final String typeParameterList) { BasicDiagnostic placeholder = new BasicDiagnostic(); char [] instanceTypeNameCharacterArray = typeParameterList == null ? NO_CHARS : typeParameterList.toCharArray(); List<ETypeParameter> eTypeParameters = handleTypeParameters(instanceTypeNameCharacterArray, 0, instanceTypeNameCharacterArray.length, placeholder); BasicDiagnostic result = createDiagnostic (placeholder.getSeverity(), DIAGNOSTIC_SOURCE, WELL_FORMED_INSTANCE_TYPE_NAME, "_UI_EClassifierInstanceTypeNameAnalysisResult_diagnostic", new Object [] { typeParameterList }, new Object [] { eTypeParameters, typeParameterList }); result.addAll(placeholder); return result; }
/** * 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); } }
/** * Converts the given exception to a <code>Diagnostic</code>. The <code>currentMessage</code>, if non-null, should * describe what was being done when the exception occurred, and will be used in forming the diagnostic's message. */ protected Diagnostic toDiagnostic(Exception exception, String currentMessage) { if (!(exception instanceof OperationCanceledException)) { CodeGenEcorePlugin.INSTANCE.log(exception); } currentMessage = currentMessage != null ? CodeGenEcorePlugin.INSTANCE.getString("_UI_GenerateException_diagnostic", new Object[] { currentMessage }) : CodeGenEcorePlugin.INSTANCE.getString("_UI_GenericGenerateException_diagnostic"); BasicDiagnostic diagnostic = new BasicDiagnostic(CodeGenEcorePlugin.ID, 0, currentMessage, null); diagnostic.add(BasicDiagnostic.toDiagnostic(exception)); return diagnostic; }
/** * Creates a JETException with the embedded exception. */ public JETException(Throwable exception) { super (BasicDiagnostic.toDiagnostic(exception)); }
public void addAll(Diagnostic diagnostic) { for (Diagnostic child : diagnostic.getChildren()) { add(child); } }
protected BasicDiagnostic createDiagnostic(int severity, int code, String message, Object... data) { return new BasicDiagnostic(severity, DIAGNOSTIC_SOURCE, code, message, data); }
/** * Validates the MemberTypes constraint of '<em>Time Duration Type</em>'. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public boolean validateTimeDurationType_MemberTypes(Object timeDurationType, DiagnosticChain diagnostics, Map context) { if (diagnostics != null) { BasicDiagnostic tempDiagnostics = new BasicDiagnostic(); if (XMLTypePackage.Literals.DURATION.isInstance(timeDurationType)) { if (xmlTypeValidator.validateDuration(timeDurationType, tempDiagnostics, context)) return true; } if (XMLTypePackage.Literals.DECIMAL.isInstance(timeDurationType)) { if (xmlTypeValidator.validateDecimal((BigDecimal)timeDurationType, tempDiagnostics, context)) return true; } List children = tempDiagnostics.getChildren(); for (int i = 0; i < children.size(); i++) { diagnostics.add((Diagnostic)children.get(i)); } } else { if (XMLTypePackage.Literals.DURATION.isInstance(timeDurationType)) { if (xmlTypeValidator.validateDuration(timeDurationType, null, context)) return true; } if (XMLTypePackage.Literals.DECIMAL.isInstance(timeDurationType)) { if (xmlTypeValidator.validateDecimal((BigDecimal)timeDurationType, null, context)) return true; } } return false; }
/** * Parses a list of type arguments and returns a diagnostic representing the result of the analysis. * The {@link Diagnostic#getData() data} of the diagnostic will contain as the first object, the resulting list of {@link EGenericType type arguments}. * @param typeArgumentList a comma separated list of type arguments. * @return the diagnostic result of the analysis. * @since 2.4 */ public Diagnostic parseTypeArgumentList(final String typeArgumentList) { BasicDiagnostic placeholder = new BasicDiagnostic(); char [] instanceTypeNameCharacterArray = typeArgumentList == null ? NO_CHARS : typeArgumentList.toCharArray(); List<EGenericType> eTypeArguments = handleTypeArguments(instanceTypeNameCharacterArray, 0, instanceTypeNameCharacterArray.length, placeholder); BasicDiagnostic result = createDiagnostic (placeholder.getSeverity(), DIAGNOSTIC_SOURCE, WELL_FORMED_INSTANCE_TYPE_NAME, "_UI_EClassifierInstanceTypeNameAnalysisResult_diagnostic", new Object [] { typeArgumentList }, new Object [] { eTypeArguments, typeArgumentList }); result.addAll(placeholder); return result; }
BasicDiagnostic diagnostic = new BasicDiagnostic( CodeGenPlugin.ID, 0, CodeGenPlugin.INSTANCE.getString("_UI_LineNumber_message", new Object[] {problem.getSourceLineNumber()}); BasicDiagnostic childDiagnostic = new BasicDiagnostic( problem.isWarning() ? Diagnostic.WARNING : problem.isError() ? Diagnostic.ERROR : Diagnostic.INFO, CodeGenPlugin.ID, contents == null ? new Object[]{problem} : new Object[]{problem, new StringBuilder(contents)} ); diagnostic.add(childDiagnostic);