@Override public void reportError(Resource file, String message, String errorCode, Severity severity, String markerType) { EList<Diagnostic> errors = file.getErrors(); errors.add(new EObjectDiagnosticImpl(Severity.ERROR, markerType, message, null, null, -1, null)); }
@Override public List<? extends Problem> getProblems(final Element element) { this.checkCanceled(); final Pair<Resource, EObject> resAndObj = this.getResourceAndEObject(element); final Resource resource = resAndObj.getKey(); EList<Resource.Diagnostic> _errors = resource.getErrors(); EList<Resource.Diagnostic> _warnings = resource.getWarnings(); final Iterable<EObjectDiagnosticImpl> issues = Iterables.<EObjectDiagnosticImpl>filter(Iterables.<Resource.Diagnostic>concat(_errors, _warnings), EObjectDiagnosticImpl.class); final Function1<EObjectDiagnosticImpl, Boolean> _function = (EObjectDiagnosticImpl diag) -> { EObject _problematicObject = diag.getProblematicObject(); EObject _value = resAndObj.getValue(); return Boolean.valueOf(Objects.equal(_problematicObject, _value)); }; final Function1<EObjectDiagnosticImpl, Problem> _function_1 = (EObjectDiagnosticImpl diag) -> { String _code = diag.getCode(); String _message = diag.getMessage(); Problem.Severity _translateSeverity = this.translateSeverity(diag.getSeverity()); ProblemImpl _problemImpl = new ProblemImpl(_code, _message, _translateSeverity); return ((Problem) _problemImpl); }; final Iterable<Problem> result = IterableExtensions.<EObjectDiagnosticImpl, Problem>map(IterableExtensions.<EObjectDiagnosticImpl>filter(issues, _function), _function_1); return IterableExtensions.<Problem>toList(result); }
@Override protected INode getNode() { return doGetNode(problematicObject, problematicFeature, indexOfProblemanticValueInFeature); }
@Override public void clearMarkers(Resource resource, final String markerType) { if (resource != null) { EList<Diagnostic> errors = resource.getErrors(); errors.removeIf(input -> input instanceof EObjectDiagnosticImpl && markerType.contentEquals(((EObjectDiagnosticImpl)input).getCode())); } }
@Override protected INode getNode() { INode result = super.getNode(); for(ILeafNode leaf: result.getLeafNodes()) { if (!leaf.isHidden()) { return leaf; } } return result; } }
/** * Added error indication to import declaration URI * * @param resource * zen model * @param importDeclaration * import declaration statement * @param message * error message */ private void addError(Resource resource, EObject importDeclaration, String message) { resource.getErrors().add(new EObjectDiagnosticImpl(Severity.ERROR, "", //$NON-NLS-1$ message, importDeclaration, RapidmlPackage.Literals.IMPORT_DECLARATION__IMPORT_URI, -1, null)); } }
protected INode doGetNode(EObject object, EStructuralFeature feature, int idx) { if (object == null) return null; if (feature == null) { INode result = NodeModelUtils.findActualNodeFor(object); if (result != null) { return result; } return doGetNode(object.eContainer(), object.eContainmentFeature(), -1); } List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(object, feature); if (nodesForFeature.isEmpty()) { return doGetNode(object, null, -1); } if (nodesForFeature.size() == 1 && idx == -1) return nodesForFeature.get(0); if (nodesForFeature.size() > idx ) { return nodesForFeature.get(idx); } return null; }
@Override public void reportError(EObject ctx, String message, String errorCode, Severity severity, String markerType) { Resource resource = ctx.eResource(); if (resource != null) { EList<Diagnostic> errors = resource.getErrors(); errors.add(new EObjectDiagnosticImpl(Severity.ERROR, markerType, message, ctx, null, -1, null)); } }
private void checkTypeParameterNotAllowedAsLiteral(EObject ctx, JvmType type, ITypeComputationState state) { if (type instanceof JvmTypeParameter) { state.addDiagnostic(new EObjectDiagnosticImpl( Severity.ERROR, IssueCodes.INVALID_USE_OF_TYPE_PARAMETER, "Illegal class literal for the type parameter " + type.getSimpleName()+".", ctx, null, -1, new String[] { })); } }
@Override public void reportErrorNoLocation(EObject ctx, String message, String errorCode, Severity severity, String markerType) { Resource resource = ctx.eResource(); if (resource != null) { EList<Diagnostic> errors = resource.getErrors(); errors.add(new EObjectDiagnosticImpl(Severity.ERROR, markerType, message, resource.getContents().get(0), null, -1, null)); } }
_xifexpression = IterableExtensions.<XAnnotation>head(annotations); EObjectDiagnosticImpl _eObjectDiagnosticImpl = new EObjectDiagnosticImpl(Severity.ERROR, IssueCodes.PROCESSING_ERROR, msg, _xifexpression, null, (-1), null); errors.add(_eObjectDiagnosticImpl); EObjectDiagnosticImpl _eObjectDiagnosticImpl = new EObjectDiagnosticImpl(Severity.ERROR, IssueCodes.PROCESSING_ERROR, msg, target, null, (-1), null); errors.add(_eObjectDiagnosticImpl);
@Override public boolean validate(IAcceptor<? super AbstractDiagnostic> result) { if (chosenCandidate.validate(result)) { StringBuilder messageBuilder = new StringBuilder("Suspiciously overloaded method.\n"); messageBuilder.append("The ").append(getFeatureTypeName()).append("\n\t"); appendCandidate(chosenCandidate, messageBuilder); messageBuilder.append("\noverloads the ").append(getFeatureTypeName()).append("\n\t"); appendCandidate(rejectedCandidate, messageBuilder); messageBuilder.append("."); AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(chosenCandidate.getSeverity(IssueCodes.SUSPICIOUSLY_OVERLOADED_FEATURE), IssueCodes.SUSPICIOUSLY_OVERLOADED_FEATURE, messageBuilder.toString(), getExpression(), XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, -1, null); result.accept(diagnostic); } return false; }
@Override protected JvmTypeReference handleReentrantInvocation(XComputedTypeReferenceImplCustom context) { resolvedTypes.addDiagnostic(new EObjectDiagnosticImpl( Severity.WARNING, IssueCodes.TOO_LITTLE_TYPE_INFORMATION, "Cannot infer type from recursive usage. Type 'Object' is used.", typeResolver.getSourceElement(operation), null, -1, null)); AnyTypeReference result = resolvedTypes.getReferenceOwner().newAnyTypeReference(); return typeResolver.toJavaCompliantTypeReference(result, session); } }
protected AbstractDiagnostic createTypeDiagnostic(XExpression expression, LightweightTypeReference actualType, LightweightTypeReference expectedType) { if (!expectedType.isAny()) { String actualName = actualType.getSimpleName(); String expectedName = expectedType.getSimpleName(); if (actualName.equals(expectedName)) { if (expectedType.isAssignableFrom(actualType)) { return null; } } if (expression.eContainingFeature() == XbasePackage.Literals.XABSTRACT_FEATURE_CALL__IMPLICIT_FIRST_ARGUMENT) { return new EObjectDiagnosticImpl(Severity.ERROR, IssueCodes.INCOMPATIBLE_TYPES, String.format( "Type mismatch: cannot convert implicit first argument from %s to %s", actualType.getHumanReadableName(), expectedType.getHumanReadableName()), expression, null, -1, null); } else { return new EObjectDiagnosticImpl(Severity.ERROR, IssueCodes.INCOMPATIBLE_TYPES, String.format( "Type mismatch: cannot convert from %s to %s", actualType.getHumanReadableName(), expectedType.getHumanReadableName()), expression, null, -1, null); } } else { return new EObjectDiagnosticImpl(Severity.ERROR, IssueCodes.INCOMPATIBLE_TYPES, String.format( "Type mismatch: type %s is not applicable at this location", actualType.getHumanReadableName()), expression, null, -1, null); } }
messageBuilder.append("\nall match."); AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(Severity.ERROR, IssueCodes.AMBIGUOUS_FEATURE_CALL, messageBuilder.toString(), getExpression(), getFeatureToMark(), -1, getDiagnosticData());
protected void checkValidReturn(XReturnExpression object, ITypeComputationState state) { // if the expectation comes from a method's return type // then it is legal, thus we must check if the return is // contained in a throw expression if (hasThrowableExpectation(state) && EcoreUtil2.getContainerOfType(object, XThrowExpression.class) != null) { state.addDiagnostic(new EObjectDiagnosticImpl( Severity.ERROR, IssueCodes.INVALID_RETURN, "Invalid return inside throw.", object, null, -1, new String[] { })); } }
AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl( Severity.ERROR, IssueCodes.UNREACHABLE_CODE,
@Override public void computeTypes(XExpression expression, ITypeComputationState state) { if (expression instanceof SarlBreakExpression) { _computeTypes((SarlBreakExpression) expression, state); } else if (expression instanceof SarlContinueExpression) { _computeTypes((SarlContinueExpression) expression, state); } else if (expression instanceof SarlAssertExpression) { _computeTypes((SarlAssertExpression) expression, state); } else { try { super.computeTypes(expression, state); } catch (Throwable exception) { final Throwable cause = Throwables.getRootCause(exception); state.addDiagnostic(new EObjectDiagnosticImpl( Severity.ERROR, IssueCodes.INTERNAL_ERROR, cause.getLocalizedMessage(), expression, null, -1, null)); } } }
@Override protected JvmTypeReference handleReentrantInvocation(XComputedTypeReferenceImplCustom context) { EObject sourceElement = getSourceElement(member); EStructuralFeature feature = sourceElement.eClass().getEStructuralFeature("name"); resolvedTypes.addDiagnostic(new EObjectDiagnosticImpl( Severity.WARNING, IssueCodes.TOO_LITTLE_TYPE_INFORMATION, "Cannot infer type from recursive usage. Type 'Object' is used.", sourceElement, feature, -1, null)); AnyTypeReference result = resolvedTypes.getReferenceOwner().newAnyTypeReference(); return toJavaCompliantTypeReference(result, session); }
@Override /* @Nullable */ protected JvmTypeReference doGetTypeReference(XComputedTypeReferenceImplCustom context) { try { resolvedTypes.addDiagnostic(new EObjectDiagnosticImpl( Severity.ERROR, IssueCodes.TOO_LITTLE_TYPE_INFORMATION, "Cannot infer type", typeResolver.getSourceElement(member), null, -1, null)); return TypesFactory.eINSTANCE.createJvmAnyTypeReference(); } finally { context.unsetTypeProviderWithoutNotification(); } } }