本文整理汇总了Java中org.eclipse.xtext.diagnostics.Severity类的典型用法代码示例。如果您正苦于以下问题:Java Severity类的具体用法?Java Severity怎么用?Java Severity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Severity类属于org.eclipse.xtext.diagnostics包,在下文中一共展示了Severity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: quickFixList
import org.eclipse.xtext.diagnostics.Severity; //导入依赖的package包/类
/**
* 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
import org.eclipse.xtext.diagnostics.Severity; //导入依赖的package包/类
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: createInfoMarkers
import org.eclipse.xtext.diagnostics.Severity; //导入依赖的package包/类
private void createInfoMarkers(CompiledContract contract, IFile file) {
if (contract.getEvm() == null || contract.getEvm().getGasEstimates() == null) {
return;
}
GasEstimates gasEstimates = contract.getEvm().getGasEstimates();
SolcIssue solcIssue = new SolcIssue();
solcIssue.setIFile(file);
solcIssue.setLineNumber(1);
solcIssue.setSeverity(Severity.INFO);
String message = prettyPrint(gasEstimates);
solcIssue.setMessage(message);
solcIssue.setErrorCode(createErrorCodeFromMessage(Severity.INFO, message));
EObject element = getEObject(file, 0);
solcIssue.setUriToProblem(EcoreUtil.getURI(element));
try {
super.createMarker(solcIssue, file, NORMAL_VALIDATION);
} catch (CoreException e) {
e.printStackTrace();
}
}
示例4: createSolcIssue
import org.eclipse.xtext.diagnostics.Severity; //导入依赖的package包/类
private SolcIssue createSolcIssue(CompileError error, Set<IResource> filesToCompile) {
String[] parts = error.getFormattedMessage().split(":");
String fileName = partAtIndex(parts, 0);
IFile errorFile = findFileForName(filesToCompile, fileName);
int lineNumber = extractNumber(partAtIndex(parts, 1));
int columnNumber = extractNumber(partAtIndex(parts, 2));
Map<Integer, String> fileContent = getFileContent(errorFile);
int offset = calculateOffset(fileContent, columnNumber, lineNumber);
int length = calculateIssueLength(fileContent.get(lineNumber), partAtIndex(parts, 4));
Severity severity = calculateSeverity(error.getSeverity());
String message = error.getMessage();
SolcIssue solcIssue = new SolcIssue();
solcIssue.setIFile(errorFile);
solcIssue.setLineNumber(lineNumber);
solcIssue.setColumnNumber(columnNumber);
solcIssue.setSeverity(severity);
solcIssue.setMessage(message);
solcIssue.setOffset(offset);
solcIssue.setLength(length);
solcIssue.setErrorCode(createErrorCodeFromMessage(severity, message));
EObject element = getEObject(errorFile, offset);
solcIssue.setUriToProblem(EcoreUtil.getURI(element));
return solcIssue;
}
示例5: calculateSeverity
import org.eclipse.xtext.diagnostics.Severity; //导入依赖的package包/类
private Severity calculateSeverity(String severety) {
switch (severety) {
case "warning" :
return Severity.WARNING;
case "error" :
return Severity.ERROR;
default :
return Severity.INFO;
}
}
示例6: checkValidReturn
import org.eclipse.xtext.diagnostics.Severity; //导入依赖的package包/类
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[] {
}));
}
}
示例7: checkValidReturnExpression
import org.eclipse.xtext.diagnostics.Severity; //导入依赖的package包/类
protected void checkValidReturnExpression(XExpression returnValue, ITypeComputationState expressionState) {
ITypeComputationResult result = expressionState.computeTypes(returnValue);
LightweightTypeReference actualType = result.getActualExpressionType();
int conformanceFlags = result.getConformanceFlags();
if (actualType.isPrimitiveVoid() && (conformanceFlags & ConformanceFlags.NO_IMPLICIT_RETURN) != 0) {
String message = "Invalid return's expression.";
if (returnValue instanceof XReturnExpression) {
// when the return's expression is directory a return
// we provide a more detailed error
message = "Return cannot be nested.";
}
expressionState.addDiagnostic(new EObjectDiagnosticImpl(
Severity.ERROR,
IssueCodes.INVALID_RETURN,
message,
returnValue,
null,
-1,
new String[] {
}));
}
}
示例8: _computeTypes
import org.eclipse.xtext.diagnostics.Severity; //导入依赖的package包/类
protected void _computeTypes(XSynchronizedExpression expr, ITypeComputationState state) {
ITypeComputationState paramState = state.withExpectation(state.getReferenceOwner().newReferenceToObject());
ITypeComputationResult paramType = paramState.computeTypes(expr.getParam());
LightweightTypeReference actualParamType = paramType.getActualExpressionType();
if (actualParamType != null && (actualParamType.isPrimitive() || actualParamType.isAny())) {
state.addDiagnostic(new EObjectDiagnosticImpl(
Severity.ERROR,
IssueCodes.INCOMPATIBLE_TYPES,
actualParamType.getHumanReadableName() + " is not a valid type's argument for the synchronized expression.",
expr.getParam(),
null,
-1,
new String[] {
}));
}
state.computeTypes(expr.getExpression());
}
示例9: toDiagnosticSeverity
import org.eclipse.xtext.diagnostics.Severity; //导入依赖的package包/类
/**
* 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;
}
示例10: validate
import org.eclipse.xtext.diagnostics.Severity; //导入依赖的package包/类
@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);
}
示例11: validate
import org.eclipse.xtext.diagnostics.Severity; //导入依赖的package包/类
@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);
}
示例12: createTypeDiagnostic
import org.eclipse.xtext.diagnostics.Severity; //导入依赖的package包/类
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);
}
}
示例13: validateVisibility
import org.eclipse.xtext.diagnostics.Severity; //导入依赖的package包/类
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;
}
示例14: validateArity
import org.eclipse.xtext.diagnostics.Severity; //导入依赖的package包/类
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;
}
示例15: validate
import org.eclipse.xtext.diagnostics.Severity; //导入依赖的package包/类
@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;
}