本文整理汇总了Java中org.eclipse.xtext.diagnostics.Severity.ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java Severity.ERROR属性的具体用法?Java Severity.ERROR怎么用?Java Severity.ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.xtext.diagnostics.Severity
的用法示例。
在下文中一共展示了Severity.ERROR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: quickFixList
/**
* Example: {@code // XPECT quickFixList at 'a.<|>method' --> 'import A','do other things' }
*
* @param expectation
* comma separated strings, which are proposed as quick fix
* @param resource
* injected xtext-file
* @param offset
* cursor position at '<|>'
* @param checkType
* 'display': verify list of provided proposals comparing their user-displayed strings.
* @param selected
* which proposal to pick
* @param mode
* modus of operation
* @param offset2issue
* mapping of offset(!) to issues.
* @throws Exception
* if failing
*/
@Xpect
@ParameterParser(syntax = "('at' (arg2=STRING (arg3=ID (arg4=STRING)? (arg5=ID)? )? )? )?")
@ConsumedIssues({ Severity.INFO, Severity.ERROR, Severity.WARNING })
public void quickFixList(
@CommaSeparatedValuesExpectation(quoted = true, ordered = true) ICommaSeparatedValuesExpectation expectation, // arg0
@ThisResource XtextResource resource, // arg1
RegionWithCursor offset, // arg2
String checkType, // arg3
String selected, // arg4
String mode, // arg5
@IssuesByLine Multimap<Integer, Issue> offset2issue) throws Exception {
List<IssueResolution> resolutions = collectAllResolutions(resource, offset, offset2issue);
List<String> resolutionNames = Lists.newArrayList();
for (IssueResolution resolution : resolutions) {
resolutionNames.add(resolution.getLabel());
}
expectation.assertEquals(resolutionNames);
}
示例2: registerErrors
private boolean registerErrors(Resource dep, StringBuilder errorResult) {
boolean hasErrors = false;
List<Issue> issues = resourceValidator.validate(dep, CheckMode.ALL, CancelIndicator.NullImpl);
List<Issue> errorIssues = new ArrayList<>();
for (Issue issue : issues) {
if (Severity.ERROR == issue.getSeverity()) {
errorIssues.add(issue);
}
}
hasErrors = !errorIssues.isEmpty();
if (hasErrors) {
errorResult.append("Couldn't compile resource " + dep.getURI() + " because it contains errors: ");
for (Issue errorIssue : errorIssues) {
errorResult
.append(nl + errorIssue.getMessage() + " at line " + errorIssue.getLineNumber());
}
}
return hasErrors;
}
示例3: calculateSeverity
private Severity calculateSeverity(String severety) {
switch (severety) {
case "warning" :
return Severity.WARNING;
case "error" :
return Severity.ERROR;
default :
return Severity.INFO;
}
}
示例4: validate
@Override
public boolean validate(IAcceptor<? super AbstractDiagnostic> result) {
JvmDeclaredType declaringType = getConstructor().getDeclaringType();
if (declaringType.isAbstract()) {
String message = "Cannot instantiate the abstract type " + declaringType.getSimpleName();
AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(
Severity.ERROR,
IssueCodes.ABSTRACT_CLASS_INSTANTIATION,
message,
getExpression(),
getDefaultValidationFeature(), -1, null);
result.accept(diagnostic);
return false;
}
return super.validate(result);
}
示例5: validate
@Override
public boolean validate(IAcceptor<? super AbstractDiagnostic> result) {
if (!getState().isInstanceContext()) {
JvmIdentifiableElement implicitFeature = getFeature();
if (implicitFeature instanceof JvmType) {
JvmIdentifiableElement feature = getState().getResolvedTypes().getLinkedFeature(getOwner());
if (feature == null || feature.eIsProxy() || !(feature instanceof JvmFeature))
return true;
String message = "Cannot make an implicit reference to this from a static context";
AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(Severity.ERROR,
IssueCodes.STATIC_ACCESS_TO_INSTANCE_MEMBER, message, getOwner(),
XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, -1, null);
result.accept(diagnostic);
return false;
}
}
return super.validate(result);
}
示例6: createTypeDiagnostic
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);
}
}
示例7: validateVisibility
protected boolean validateVisibility(IAcceptor<? super AbstractDiagnostic> result) {
if (!isVisible()) {
String message = String.format("The %1$s %2$s%3$s is not visible",
getFeatureTypeName(),
getSimpleFeatureName(),
getFeatureParameterTypesAsString());
AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(
Severity.ERROR,
IssueCodes.FEATURE_NOT_VISIBLE,
message,
getExpression(),
getDefaultValidationFeature(), -1, null);
result.accept(diagnostic);
return false;
}
return true;
}
示例8: validateArity
protected boolean validateArity(IAcceptor<? super AbstractDiagnostic> result) {
if (getArityMismatch() != 0) {
String message;
if (getArguments().isEmpty()) {
message = String.format("Invalid number of arguments. The %1$s %2$s%3$s is not applicable without arguments" ,
getFeatureTypeName(),
getSimpleFeatureName(),
getFeatureParameterTypesAsString());
} else {
message = String.format("Invalid number of arguments. The %1$s %2$s%3$s is not applicable for the arguments %4$s" ,
getFeatureTypeName(),
getSimpleFeatureName(),
getFeatureParameterTypesAsString(),
getArgumentTypesAsString());
}
AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(
Severity.ERROR,
IssueCodes.INVALID_NUMBER_OF_ARGUMENTS,
message,
getExpression(),
getInvalidArgumentsValidationFeature(), -1, null);
result.accept(diagnostic);
return false;
}
return true;
}
示例9: validateTypeArity
protected boolean validateTypeArity(IAcceptor<? super AbstractDiagnostic> result) {
if (getTypeArityMismatch() != 0) {
String message = String.format("Invalid number of type arguments. The %1$s %2$s%3$s is not applicable for the type arguments %4$s",
getFeatureTypeName(),
getSimpleFeatureName(),
getFeatureTypeParametersAsString(true),
getTypeArgumentsAsString(getSyntacticTypeArguments()));
AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(
Severity.ERROR,
IssueCodes.INVALID_NUMBER_OF_TYPE_ARGUMENTS,
message,
getExpression(),
getDefaultValidationFeature(), -1, null);
result.accept(diagnostic);
return false;
}
return true;
}
示例10: validate
@Override
public boolean validate(IAcceptor<? super AbstractDiagnostic> result) {
JvmType type = (JvmType) description.getElementOrProxy();
String typeKind = "";
if (type instanceof JvmPrimitiveType || type instanceof JvmVoid) {
typeKind = "primitive type";
} else if (type instanceof JvmAnnotationType) {
typeKind = "annotation type";
} else if (type instanceof JvmEnumerationType) {
typeKind = "enum type";
} else if (type instanceof JvmGenericType && ((JvmGenericType) type).isInterface()) {
typeKind = "interface type";
} else if (type instanceof JvmTypeParameter) {
typeKind = "type parameter";
}
String message = String.format("Cannot instantiate the %s %s", typeKind, type.getSimpleName());
AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(Severity.ERROR,
IssueCodes.ILLEGAL_CLASS_INSTANTIATION, message, getExpression(),
XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR, -1, null);
result.accept(diagnostic);
return false;
}
示例11: handleCyclicResolution
@Override
protected EObject handleCyclicResolution(Triple<EObject, EReference, INode> triple) throws AssertionError {
if (!isValidationDisabled()) {
EObject context = triple.getFirst();
if (context.eClass() == TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE) {
// here we may end up with cyclic resolution requests in rare situations, e.g. for input types
// like :
/*
* package p;
* class C extends p.C.Bogus {}
*/
return null;
}
DiagnosticMessage message = new DiagnosticMessage("Cyclic linking detected : " + getReferences(triple, resolving), Severity.ERROR, "cyclic-resolution");
List<Diagnostic> list = getDiagnosticList(message);
Diagnostic diagnostic = createDiagnostic(triple, message);
if (!list.contains(diagnostic))
list.add(diagnostic);
}
return null;
}
示例12: stringToSeverity
public Severity stringToSeverity(String severityAsString) {
if (severityAsString == null)
throw new IllegalArgumentException("Severity as string was null");
if (severityAsString.equals(SEVERITY_ERROR)) {
return Severity.ERROR;
}
if (severityAsString.equals(SEVERITY_WARNING)) {
return Severity.WARNING;
}
if (severityAsString.equals(SEVERITY_INFO)) {
return Severity.INFO;
}
if (severityAsString.equals(SEVERITY_IGNORE)) {
return Severity.IGNORE;
}
throw new IllegalArgumentException("Unknown severity '"+severityAsString+"'.");
}
示例13: validateProject
/**
* Validates all non-external Xtext resources of the given project. Prints issues and adds them to the given issue
* acceptor.
*
* @param markedProject
* the project to validate
* @param recorder
* the progress recorder
* @param issueAcceptor
* the issue acceptor
* @throws N4JSCompileErrorException
* if an error occurs during validation
*/
private void validateProject(MarkedProject markedProject, N4ProgressStateRecorder recorder,
IssueAcceptor issueAcceptor) throws N4JSCompileErrorException {
if (logger.isVerbose())
logger.info(" Validating project " + markedProject);
IssueCollector issueCollector = new IssueCollector();
IssueFilter issueFilter = new IssueFilter(issueCollector, issue -> issue.getSeverity() == Severity.ERROR);
issueAcceptor = new IssueAcceptorTee(issueAcceptor, issueFilter);
// validation TODO see IDE-1426 redesign validation calls with generators
for (Resource resource : markedProject.resources) {
if (resource instanceof XtextResource && // is Xtext resource
(!n4jsCore.isNoValidate(resource.getURI())) && // is validating
(!markedProject.externalResources.contains(resource)) // not in external folder
) {
if (logger.isCreateDebugOutput())
logger.debug(" Validating resource " + resource.getURI());
XtextResource xtextResource = (XtextResource) resource;
IResourceValidator validator = xtextResource.getResourceServiceProvider().getResourceValidator();
List<Issue> issues = validator.validate(xtextResource, CheckMode.ALL, CancelIndicator.NullImpl);
if (!issues.isEmpty()) {
recorder.markResourceIssues(resource, issues);
issueAcceptor.acceptAll(issues);
issues.stream().forEach(logger::issue);
}
}
}
// Projects should not compile if there are severe errors:
if (!isKeepOnCompiling()) {
failOnErrors(issueCollector.getCollectedIssues(), markedProject.project.getProjectId());
}
}
示例14: addDiagnostics
public void addDiagnostics(final Resource resource) {
if (resource instanceof XtextResource) {
if (((XtextResource) resource).isValidationDisabled())
return;
}
class DiagnosticAcceptor implements IAcceptor<AbstractDiagnostic> {
@Override
public void accept(/* @Nullable */ AbstractDiagnostic diagnostic) {
if (diagnostic instanceof EObjectDiagnosticImpl) {
Severity severity = ((EObjectDiagnosticImpl) diagnostic).getSeverity();
if (severity == Severity.ERROR) {
resource.getErrors().add(diagnostic);
} else if (severity == Severity.WARNING) {
resource.getWarnings().add(diagnostic);
}
} else {
resource.getErrors().add(diagnostic);
}
}
}
DiagnosticAcceptor acceptor = new DiagnosticAcceptor();
addQueuedDiagnostics(acceptor);
addLinkingDiagnostics(acceptor);
addTypeDiagnostics(acceptor);
}
示例15: getUnhandledExceptionSeverity
@Override
protected Severity getUnhandledExceptionSeverity(JvmExecutable executable) {
if (getFeature() instanceof JvmConstructor) {
return Severity.ERROR;
}
return super.getUnhandledExceptionSeverity(executable);
}