Java Code Examples for org.eclipse.emf.common.util.Diagnostic#ERROR
The following examples show how to use
org.eclipse.emf.common.util.Diagnostic#ERROR .
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: ChartEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * Returns a diagnostic describing the errors and warnings listed in the * resource * and the specified exception (if any). * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ public Diagnostic analyzeResourceProblems ( final Resource resource, final Exception exception ) { if ( !resource.getErrors ().isEmpty () || !resource.getWarnings ().isEmpty () ) { final BasicDiagnostic basicDiagnostic = new BasicDiagnostic ( Diagnostic.ERROR, "org.eclipse.scada.ui.chart.model.editor", //$NON-NLS-1$ 0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$ new Object[] { exception == null ? (Object)resource : exception } ); basicDiagnostic.merge ( EcoreUtil.computeDiagnostic ( resource, true ) ); return basicDiagnostic; } else if ( exception != null ) { return new BasicDiagnostic ( Diagnostic.ERROR, "org.eclipse.scada.ui.chart.model.editor", //$NON-NLS-1$ 0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$ new Object[] { exception } ); } else { return Diagnostic.OK_INSTANCE; } }
Example 2
Source File: ItemEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * Returns a diagnostic describing the errors and warnings listed in the resource * and the specified exception (if any). * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Diagnostic analyzeResourceProblems ( Resource resource, Exception exception ) { if ( !resource.getErrors ().isEmpty () || !resource.getWarnings ().isEmpty () ) { BasicDiagnostic basicDiagnostic = new BasicDiagnostic ( Diagnostic.ERROR, "org.eclipse.scada.configuration.item.editor", //$NON-NLS-1$ 0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$ new Object[] { exception == null ? (Object)resource : exception } ); basicDiagnostic.merge ( EcoreUtil.computeDiagnostic ( resource, true ) ); return basicDiagnostic; } else if ( exception != null ) { return new BasicDiagnostic ( Diagnostic.ERROR, "org.eclipse.scada.configuration.item.editor", //$NON-NLS-1$ 0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$ new Object[] { exception } ); } else { return Diagnostic.OK_INSTANCE; } }
Example 3
Source File: ComponentEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * Returns a diagnostic describing the errors and warnings listed in the resource * and the specified exception (if any). * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Diagnostic analyzeResourceProblems ( Resource resource, Exception exception ) { boolean hasErrors = !resource.getErrors ().isEmpty (); if ( hasErrors || !resource.getWarnings ().isEmpty () ) { BasicDiagnostic basicDiagnostic = new BasicDiagnostic ( hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING, "org.eclipse.scada.configuration.component.editor", //$NON-NLS-1$ 0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$ new Object[] { exception == null ? (Object)resource : exception } ); basicDiagnostic.merge ( EcoreUtil.computeDiagnostic ( resource, true ) ); return basicDiagnostic; } else if ( exception != null ) { return new BasicDiagnostic ( Diagnostic.ERROR, "org.eclipse.scada.configuration.component.editor", //$NON-NLS-1$ 0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$ new Object[] { exception } ); } else { return Diagnostic.OK_INSTANCE; } }
Example 4
Source File: InfrastructureEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * Returns a diagnostic describing the errors and warnings listed in the resource * and the specified exception (if any). * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Diagnostic analyzeResourceProblems ( Resource resource, Exception exception ) { boolean hasErrors = !resource.getErrors ().isEmpty (); if ( hasErrors || !resource.getWarnings ().isEmpty () ) { BasicDiagnostic basicDiagnostic = new BasicDiagnostic ( hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING, "org.eclipse.scada.configuration.infrastructure.editor", //$NON-NLS-1$ 0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$ new Object[] { exception == null ? (Object)resource : exception } ); basicDiagnostic.merge ( EcoreUtil.computeDiagnostic ( resource, true ) ); return basicDiagnostic; } else if ( exception != null ) { return new BasicDiagnostic ( Diagnostic.ERROR, "org.eclipse.scada.configuration.infrastructure.editor", //$NON-NLS-1$ 0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$ new Object[] { exception } ); } else { return Diagnostic.OK_INSTANCE; } }
Example 5
Source File: RecipeEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * Returns a diagnostic describing the errors and warnings listed in the resource * and the specified exception (if any). * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Diagnostic analyzeResourceProblems ( Resource resource, Exception exception ) { boolean hasErrors = !resource.getErrors ().isEmpty (); if ( hasErrors || !resource.getWarnings ().isEmpty () ) { BasicDiagnostic basicDiagnostic = new BasicDiagnostic ( hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING, "org.eclipse.scada.configuration.recipe.editor", //$NON-NLS-1$ 0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$ new Object[] { exception == null ? (Object)resource : exception } ); basicDiagnostic.merge ( EcoreUtil.computeDiagnostic ( resource, true ) ); return basicDiagnostic; } else if ( exception != null ) { return new BasicDiagnostic ( Diagnostic.ERROR, "org.eclipse.scada.configuration.recipe.editor", //$NON-NLS-1$ 0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$ new Object[] { exception } ); } else { return Diagnostic.OK_INSTANCE; } }
Example 6
Source File: WorldEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * Returns a diagnostic describing the errors and warnings listed in the resource * and the specified exception (if any). * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Diagnostic analyzeResourceProblems ( Resource resource, Exception exception ) { boolean hasErrors = !resource.getErrors ().isEmpty (); if ( hasErrors || !resource.getWarnings ().isEmpty () ) { BasicDiagnostic basicDiagnostic = new BasicDiagnostic ( hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING, "org.eclipse.scada.configuration.world.editor", //$NON-NLS-1$ 0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$ new Object[] { exception == null ? (Object)resource : exception } ); basicDiagnostic.merge ( EcoreUtil.computeDiagnostic ( resource, true ) ); return basicDiagnostic; } else if ( exception != null ) { return new BasicDiagnostic ( Diagnostic.ERROR, "org.eclipse.scada.configuration.world.editor", //$NON-NLS-1$ 0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$ new Object[] { exception } ); } else { return Diagnostic.OK_INSTANCE; } }
Example 7
Source File: OsgiEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * Returns a diagnostic describing the errors and warnings listed in the resource * and the specified exception (if any). * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Diagnostic analyzeResourceProblems ( Resource resource, Exception exception ) { boolean hasErrors = !resource.getErrors ().isEmpty (); if ( hasErrors || !resource.getWarnings ().isEmpty () ) { BasicDiagnostic basicDiagnostic = new BasicDiagnostic ( hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING, "org.eclipse.scada.configuration.world.editor", //$NON-NLS-1$ 0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$ new Object[] { exception == null ? (Object)resource : exception } ); basicDiagnostic.merge ( EcoreUtil.computeDiagnostic ( resource, true ) ); return basicDiagnostic; } else if ( exception != null ) { return new BasicDiagnostic ( Diagnostic.ERROR, "org.eclipse.scada.configuration.world.editor", //$NON-NLS-1$ 0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$ new Object[] { exception } ); } else { return Diagnostic.OK_INSTANCE; } }
Example 8
Source File: ModbusExporterProcessor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * Validates a ModbusExporterDevice instance using the EMF core validator * API. The * contained ModbusExporterItems are also validated. * * @param device * the ModbusExporterDevice to validate * @throws IllegalStateException * if validation errors are encountered */ private void validateDevice ( final ModbusExporterDevice device ) { // Also validates contained ModbusExporterItems final Diagnostic diag = Diagnostician.INSTANCE.validate ( device ); if ( diag.getSeverity () == Diagnostic.ERROR ) { String msg = "Invalid Modbus Exporter Device"; for ( final Diagnostic child : diag.getChildren () ) { if ( child.getSeverity () == Diagnostic.ERROR ) { msg += "\n" + child.getMessage (); //$NON-NLS-1$ } } throw new IllegalStateException ( msg ); } }
Example 9
Source File: DefaultCheckImpl.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Gets a numeric value mapped to a given {@link Severity}. Severities are mapped to * <ul> * <li>{@link Diagnostic#ERROR} * <li>{@link Diagnostic#WARNING} * <li>{@link Diagnostic#INFO} * </ul> * * @param severity * the issue severity * @return the numeric value representing a severity */ protected int toDiagnosticSeverity(final Severity severity) { int diagnosticSeverity = -1; switch (severity) { case ERROR: diagnosticSeverity = Diagnostic.ERROR; break; case WARNING: diagnosticSeverity = Diagnostic.WARNING; break; case INFO: diagnosticSeverity = Diagnostic.INFO; break; default: throw new IllegalArgumentException("Unknow severity " + severity); //$NON-NLS-1$ } return diagnosticSeverity; }
Example 10
Source File: AbstractDeclarativeValidator.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected int toDiagnosticSeverity(Severity severity) { int diagnosticSeverity = -1; switch (severity) { case ERROR: diagnosticSeverity = Diagnostic.ERROR; break; case WARNING: diagnosticSeverity = Diagnostic.WARNING; break; case INFO: diagnosticSeverity = Diagnostic.INFO; break; default: throw new IllegalArgumentException("Unknow severity " + severity); } return diagnosticSeverity; }
Example 11
Source File: XtextValidator.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
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); }
Example 12
Source File: AbstractBodyParser.java From M2Doc with Eclipse Public License 1.0 | 5 votes |
/** * Gets the {@link List} of {@link TemplateValidationMessage} from the given {@link Diagnostic}. * * @param diagnostic * the {@link Diagnostic} * @param queryText * the query text * @param location * the location of the {@link TemplateValidationMessage} * @return the {@link List} of {@link TemplateValidationMessage} from the given {@link Diagnostic} */ protected List<TemplateValidationMessage> getValidationMessage(Diagnostic diagnostic, String queryText, XWPFRun location) { final List<TemplateValidationMessage> res = new ArrayList<>(); for (Diagnostic child : diagnostic.getChildren()) { final ValidationMessageLevel level; switch (diagnostic.getSeverity()) { case Diagnostic.INFO: level = ValidationMessageLevel.INFO; break; case Diagnostic.WARNING: level = ValidationMessageLevel.WARNING; break; case Diagnostic.ERROR: level = ValidationMessageLevel.ERROR; break; default: level = ValidationMessageLevel.INFO; break; } res.add(new TemplateValidationMessage(level, message(ParsingErrorMessage.INVALIDEXPR, queryText, child.getMessage()), location)); res.addAll(getValidationMessage(child, queryText, location)); } return res; }
Example 13
Source File: M2DocValidator.java From M2Doc with Eclipse Public License 1.0 | 5 votes |
@Override public ValidationMessageLevel caseQuery(Query query) { if (query.getQuery().getDiagnostic().getSeverity() != Diagnostic.ERROR) { final IValidationResult validationResult = aqlValidator.validate(stack.peek(), query.getQuery()); final XWPFRun run = query.getStyleRun(); addValidationMessages(query, run, validationResult); } return getHighestMessageLevel(query); }
Example 14
Source File: ErrorToDiagnoticTranslator.java From gama with GNU General Public License v3.0 | 5 votes |
protected int toDiagnosticSeverity(final GamlCompilationError e) { int diagnosticSeverity = -1; if (e.isError()) { diagnosticSeverity = Diagnostic.ERROR; } else if (e.isWarning()) { diagnosticSeverity = Diagnostic.WARNING; } else if (e.isInfo()) { diagnosticSeverity = Diagnostic.INFO; } return diagnosticSeverity; }
Example 15
Source File: M2DocValidator.java From M2Doc with Eclipse Public License 1.0 | 5 votes |
@Override public ValidationMessageLevel caseLet(Let let) { final IValidationResult validationResult = aqlValidator.validate(stack.peek(), let.getValue()); final Set<IType> types = validationResult.getPossibleTypes(let.getValue().getAst()); final XWPFRun run = let.getRuns().get(1); ValidationMessageLevel variableLevel; if (let.getValue().getDiagnostic().getSeverity() != Diagnostic.ERROR) { addValidationMessages(let, run, validationResult); variableLevel = ValidationMessageLevel.OK; } else { variableLevel = ValidationMessageLevel.ERROR; } if (stack.peek().containsKey(let.getName())) { variableLevel = ValidationMessageLevel.updateLevel(variableLevel, ValidationMessageLevel.WARNING); let.getValidationMessages().add(new TemplateValidationMessage(ValidationMessageLevel.WARNING, String.format("The variable mask an existing variable (%s).", let.getName()), run)); } final Map<String, Set<IType>> iterationVariables = new HashMap<>(stack.peek()); iterationVariables.put(let.getName(), types); stack.push(iterationVariables); final ValidationMessageLevel bodyLevel; try { bodyLevel = doSwitch(let.getBody()); } finally { stack.pop(); } return ValidationMessageLevel.updateLevel(getHighestMessageLevel(let), variableLevel, bodyLevel); }
Example 16
Source File: ValidationMarkerProvider.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private static int diagnosticToStatusSeverity(final int diagnosticSeverity) { if (diagnosticSeverity == Diagnostic.OK) { return IStatus.OK; } else if (diagnosticSeverity == Diagnostic.INFO) { return IStatus.INFO; } else if (diagnosticSeverity == Diagnostic.WARNING) { return IStatus.WARNING; } else if (diagnosticSeverity == Diagnostic.ERROR || diagnosticSeverity == Diagnostic.CANCEL) { return IStatus.ERROR; } return IStatus.INFO; }
Example 17
Source File: ValidateAction.java From scava with Eclipse Public License 2.0 | 5 votes |
/** * @generated */ private static int diagnosticToStatusSeverity(int diagnosticSeverity) { if (diagnosticSeverity == Diagnostic.OK) { return IStatus.OK; } else if (diagnosticSeverity == Diagnostic.INFO) { return IStatus.INFO; } else if (diagnosticSeverity == Diagnostic.WARNING) { return IStatus.WARNING; } else if (diagnosticSeverity == Diagnostic.ERROR || diagnosticSeverity == Diagnostic.CANCEL) { return IStatus.ERROR; } return IStatus.INFO; }
Example 18
Source File: CrossflowEditor.java From scava with Eclipse Public License 2.0 | 5 votes |
/** * Returns a diagnostic describing the errors and warnings listed in the resource * and the specified exception (if any). * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) { boolean hasErrors = !resource.getErrors().isEmpty(); if (hasErrors || !resource.getWarnings().isEmpty()) { BasicDiagnostic basicDiagnostic = new BasicDiagnostic (hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING, "org.eclipse.scava.crossflow.language.editor", 0, getString("_UI_CreateModelError_message", resource.getURI()), new Object [] { exception == null ? (Object)resource : exception }); basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true)); return basicDiagnostic; } else if (exception != null) { return new BasicDiagnostic (Diagnostic.ERROR, "org.eclipse.scava.crossflow.language.editor", 0, getString("_UI_CreateModelError_message", resource.getURI()), new Object[] { exception }); } else { return Diagnostic.OK_INSTANCE; } }
Example 19
Source File: M2DocValidator.java From M2Doc with Eclipse Public License 1.0 | 4 votes |
@Override public ValidationMessageLevel caseConditional(Conditional conditional) { final IValidationResult validationResult = aqlValidator.validate(stack.peek(), conditional.getCondition()); final Set<IType> types = validationResult.getPossibleTypes(conditional.getCondition().getAst()); final ValidationMessageLevel conditionLevel; if (conditional.getCondition().getDiagnostic().getSeverity() != Diagnostic.ERROR) { final XWPFRun run = conditional.getRuns().get(1); addValidationMessages(conditional, run, validationResult); conditionLevel = checkConditionalConditionTypes(conditional, run, types); } else { conditionLevel = ValidationMessageLevel.ERROR; } final Map<String, Set<IType>> thenVariables = new HashMap<>(stack.peek()); thenVariables .putAll(validationResult.getInferredVariableTypes(conditional.getCondition().getAst(), Boolean.TRUE)); stack.push(thenVariables); final ValidationMessageLevel thenLevel; try { thenLevel = doSwitch(conditional.getThen()); } finally { stack.pop(); } final ValidationMessageLevel elseLevel; if (conditional.getElse() != null) { final Map<String, Set<IType>> elseVariables = new HashMap<>(stack.peek()); elseVariables.putAll( validationResult.getInferredVariableTypes(conditional.getCondition().getAst(), Boolean.FALSE)); stack.push(elseVariables); try { elseLevel = doSwitch(conditional.getElse()); } finally { stack.pop(); } } else { elseLevel = ValidationMessageLevel.OK; } return ValidationMessageLevel.updateLevel(getHighestMessageLevel(conditional), conditionLevel, thenLevel, elseLevel); }
Example 20
Source File: M2DocValidator.java From M2Doc with Eclipse Public License 1.0 | 4 votes |
@Override public ValidationMessageLevel caseRepetition(Repetition repetition) { final IValidationResult validationResult = aqlValidator.validate(stack.peek(), repetition.getQuery()); final Set<IType> types = validationResult.getPossibleTypes(repetition.getQuery().getAst()); final XWPFRun run = repetition.getRuns().get(1); ValidationMessageLevel iteratorLevel; if (repetition.getQuery().getDiagnostic().getSeverity() != Diagnostic.ERROR) { addValidationMessages(repetition, run, validationResult); iteratorLevel = validateRepetitionQueryType(repetition, run, types); } else { iteratorLevel = ValidationMessageLevel.ERROR; } if (stack.peek().containsKey(repetition.getIterationVar())) { iteratorLevel = ValidationMessageLevel.updateLevel(iteratorLevel, ValidationMessageLevel.WARNING); repetition.getValidationMessages() .add(new TemplateValidationMessage(ValidationMessageLevel.WARNING, String.format("The iteration variable mask an existing variable (%s).", repetition.getIterationVar()), run)); } final Set<IType> iteratorTypes = new LinkedHashSet<>(); for (IType type : types) { if (type instanceof ICollectionType) { iteratorTypes.add(((ICollectionType) type).getCollectionType()); } } if (iteratorTypes.isEmpty()) { iteratorTypes.add(new NothingType("No collection type for the iterator " + repetition.getIterationVar())); } final Map<String, Set<IType>> iterationVariables = new HashMap<>(stack.peek()); iterationVariables.put(repetition.getIterationVar(), iteratorTypes); stack.push(iterationVariables); final ValidationMessageLevel bodyLevel; try { bodyLevel = doSwitch(repetition.getBody()); } finally { stack.pop(); } return ValidationMessageLevel.updateLevel(getHighestMessageLevel(repetition), iteratorLevel, bodyLevel); }