当前位置: 首页>>代码示例>>Java>>正文


Java Issue.getSeverity方法代码示例

本文整理汇总了Java中org.eclipse.xtext.validation.Issue.getSeverity方法的典型用法代码示例。如果您正苦于以下问题:Java Issue.getSeverity方法的具体用法?Java Issue.getSeverity怎么用?Java Issue.getSeverity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.xtext.validation.Issue的用法示例。


在下文中一共展示了Issue.getSeverity方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerErrors

import org.eclipse.xtext.validation.Issue; //导入方法依赖的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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:XpectN4JSES5TranspilerHelper.java

示例2: handleIssue

import org.eclipse.xtext.validation.Issue; //导入方法依赖的package包/类
/**
 * @param issues
 *            Validation issues to handle
 * @return <code>true</code> if an {@link Issue} with
 *         {@link Severity#ERROR} was found, <code>false</code>
 *         otherwise
 */
@Override
public boolean handleIssue(Iterable<Issue> issues) {
	boolean errorFree = true;
	for (Issue issue : issues) {
		switch (issue.getSeverity()) {
		case ERROR:
			LOG.error(issue.toString());
			errorFree = false;
			break;
		case WARNING:
			LOG.warn(issue.toString());
			break;
		case INFO:
			LOG.info(issue.toString());
			break;
		default:
			break;
		}
	}
	return errorFree;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:29,代码来源:IIssueHandler.java

示例3: logIssue

import org.eclipse.xtext.validation.Issue; //导入方法依赖的package包/类
/**
 * Log issue.
 *
 * @param resource
 *          the resource
 * @param issue
 *          the issue
 * @param logger
 *          the logger
 */
private void logIssue(final Resource resource, final Issue issue, final Logger logger) {
  final String message = NLS.bind(MESSAGE_TEMPLATE, new Object[] {resource.getURI().lastSegment(), issue.getLineNumber(), issue.getMessage()});
  final Severity severity = issue.getSeverity();
  switch (severity) {
  case ERROR:
    logger.error(message);
    break;
  case WARNING:
    logger.warn(message);
    break;
  case INFO:
    if (logger.isInfoEnabled()) {
      logger.info(message);
    }
    break;

  default:
    break;
  }
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:31,代码来源:ModelValidator.java

示例4: getErrors

import org.eclipse.xtext.validation.Issue; //导入方法依赖的package包/类
public Iterable<Issue> getErrors(final EObject element) {
  Iterable<Issue> _xblockexpression = null;
  {
    final IElementIssueProvider issueProvider = this.issueProviderFactory.get(element.eResource());
    final Function1<Issue, Boolean> _function = (Issue it) -> {
      Severity _severity = it.getSeverity();
      return Boolean.valueOf(Objects.equal(_severity, Severity.ERROR));
    };
    _xblockexpression = IterableExtensions.<Issue>filter(issueProvider.getIssues(element), _function);
  }
  return _xblockexpression;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:13,代码来源:ErrorSafeExtensions.java

示例5: hasErrors

import org.eclipse.xtext.validation.Issue; //导入方法依赖的package包/类
public boolean hasErrors(final EObject element) {
  boolean _xblockexpression = false;
  {
    final IElementIssueProvider issueProvider = this.issueProviderFactory.get(element.eResource());
    final Function1<Issue, Boolean> _function = (Issue it) -> {
      Severity _severity = it.getSeverity();
      return Boolean.valueOf(Objects.equal(_severity, Severity.ERROR));
    };
    _xblockexpression = IterableExtensions.<Issue>exists(issueProvider.getIssues(element), _function);
  }
  return _xblockexpression;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:13,代码来源:ErrorSafeExtensions.java

示例6: validate

import org.eclipse.xtext.validation.Issue; //导入方法依赖的package包/类
public void validate(ResourceSet resourceSet, IResourceServiceProvider.Registry registry, Issues issues) {
	List<Resource> resources = Lists.newArrayList(resourceSet.getResources());
	for (Resource resource : resources) {
		try {
			resource.load(null);
			IResourceServiceProvider provider = registry.getResourceServiceProvider(resource.getURI());
			if (provider != null) {
				List<Issue> result = provider.getResourceValidator().validate(resource, CheckMode.ALL, null);
				for (Issue issue : result) {
					switch (issue.getSeverity()) {
						case ERROR:
							issues.addError(issue.getMessage(), issue);
							break;
						case WARNING:
							issues.addWarning(issue.getMessage(), issue);
							break;
						case INFO:
							issues.addInfo(issue.getMessage(), issue);
							break;
						case IGNORE:
							break;
					}
				}
			}
		} catch (IOException e) {
			throw new WorkflowInterruptedException("Couldn't load resource (" + resource.getURI() + ")", e);
		}
	}
	if (isStopOnError() && issues.hasErrors()) {
		String errorMessage = toString(issues);
		throw new WorkflowInterruptedException("Validation problems: \n" + errorMessage);
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:34,代码来源:Validator.java

示例7: shouldGenerate

import org.eclipse.xtext.validation.Issue; //导入方法依赖的package包/类
@Override
public boolean shouldGenerate(final Resource resource, final CancelIndicator cancelIndicator) {
  boolean _isEmpty = resource.getErrors().isEmpty();
  boolean _not = (!_isEmpty);
  if (_not) {
    return false;
  }
  final List<Issue> issues = this.resourceValidator.validate(resource, CheckMode.NORMAL_AND_FAST, cancelIndicator);
  final Function1<Issue, Boolean> _function = (Issue it) -> {
    Severity _severity = it.getSeverity();
    return Boolean.valueOf(Objects.equal(_severity, Severity.ERROR));
  };
  boolean _exists = IterableExtensions.<Issue>exists(issues, _function);
  return (!_exists);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:16,代码来源:IShouldGenerate.java

示例8: afterValidate

import org.eclipse.xtext.validation.Issue; //导入方法依赖的package包/类
@Override
public boolean afterValidate(final URI validated, final Iterable<Issue> issues) {
  boolean errorFree = true;
  for (final Issue issue : issues) {
    Severity _severity = issue.getSeverity();
    if (_severity != null) {
      switch (_severity) {
        case ERROR:
          BuildRequest.DefaultValidationCallback.LOG.error(issue.toString());
          errorFree = false;
          break;
        case WARNING:
          BuildRequest.DefaultValidationCallback.LOG.warn(issue.toString());
          break;
        case INFO:
          BuildRequest.DefaultValidationCallback.LOG.info(issue.toString());
          break;
        case IGNORE:
          BuildRequest.DefaultValidationCallback.LOG.debug(issue.toString());
          break;
        default:
          break;
      }
    }
  }
  return errorFree;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:28,代码来源:BuildRequest.java

示例9: getFormatModel

import org.eclipse.xtext.validation.Issue; //导入方法依赖的package包/类
/**
 * Retrieve the format model associated with a given grammar.
 * <p>
 * <em>Note</em>: Expected to either be in same folder with the same name (except for the extension) or in the SRC outlet.
 * </p>
 *
 * @param grammar
 *          the grammar, must not be {@code null}
 * @param context
 *          xpand execution context, must not be {@code null}
 * @return the format model, or {@code null} if the resource could not be loaded
 * @throws FileNotFoundException
 *           thrown if the format file could not be found
 */
@SuppressWarnings("PMD.NPathComplexity")
public static FormatConfiguration getFormatModel(final Grammar grammar, final XpandExecutionContext context) throws FileNotFoundException {
  Variable resourceUriVariable = context.getVariable("resourceUri");
  if (resourceUriVariable == null) {
    return null;
  }
  URI uri = (URI) resourceUriVariable.getValue();
  final Resource grammarResource = grammar.eResource();
  final ResourceSet resourceSet = grammarResource.getResourceSet();
  Resource formatResource = null;
  try {
    formatResource = resourceSet.getResource(uri, true);
  } catch (final ClasspathUriResolutionException e) {
    // make another attempt
    uri = getDefaultFormatLocation(grammar, context);
    try {
      formatResource = resourceSet.getResource(uri, true);
    } catch (WrappedException e1) {
      formatResource = resourceSet.getResource(uri, false);
      if (formatResource != null) {
        resourceSet.getResources().remove(formatResource);
      }
      throw new FileNotFoundException(uri.toString()); // NOPMD
    }
  }
  if (formatResource == null) {
    throw new FileNotFoundException(uri.toString());
  }

  final List<Issue> issues = getModelValidator().validate(formatResource, LOG);

  for (final Issue issue : issues) {
    if (issue.isSyntaxError() || issue.getSeverity() == Severity.ERROR) {
      throw new WorkflowInterruptedException("Errors found in " + uri.toString() + ": " + issue.getMessage());
    }
  }

  return formatResource.getContents().size() == 0 ? null : (FormatConfiguration) formatResource.getContents().get(0);
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:54,代码来源:FormatFragmentUtil.java

示例10: getValidModel

import org.eclipse.xtext.validation.Issue; //导入方法依赖的package包/类
/**
 * Gets the valid model.
 *
 * @param grammar
 *          the grammar
 * @return the valid model
 */
private ValidModel getValidModel(final Grammar grammar) {
  if (model != null) {
    return model;
  }

  Resource resource = null;
  final String name = GrammarUtil.getName(grammar) + '.' + XTEXT_EXTENSION;
  URI uri;
  for (final Resource res : grammar.eResource().getResourceSet().getResources()) {
    if (res.getURI() != null && name.equals(EmfResourceUtil.getFileName(res.getURI()))) {
      resource = res;
      break;
    }
  }
  if (getValidURI() == null) {
    Assert.isNotNull(resource, NLS.bind(Messages.RESOURCE_NOT_FOUND, name));
    uri = resource.getURI().trimFileExtension().appendFileExtension(VALID_EXTENSION);
  } else {
    uri = URI.createURI(getValidURI());
  }

  resource = resource.getResourceSet().getResource(uri, true);

  final List<Issue> issues = VALIDATOR.validate(resource, LOGGER);
  for (final Issue issue : issues) {
    if (issue.isSyntaxError() || issue.getSeverity() == Severity.ERROR) {
      throw new WorkflowInterruptedException(NLS.bind(Messages.ERROR_FOUND, uri.toString()));
    }
  }
  model = (ValidModel) resource.getContents().get(0);
  return model;
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:40,代码来源:ValidValidatorFragment.java

示例11: toDiagnostic

import org.eclipse.xtext.validation.Issue; //导入方法依赖的package包/类
private Diagnostic toDiagnostic(final Issue issue) {
  Diagnostic _diagnostic = new Diagnostic();
  final Procedure1<Diagnostic> _function = (Diagnostic it) -> {
    it.setCode(issue.getCode());
    DiagnosticSeverity _switchResult = null;
    Severity _severity = issue.getSeverity();
    if (_severity != null) {
      switch (_severity) {
        case ERROR:
          _switchResult = DiagnosticSeverity.Error;
          break;
        case WARNING:
          _switchResult = DiagnosticSeverity.Warning;
          break;
        case INFO:
          _switchResult = DiagnosticSeverity.Information;
          break;
        default:
          _switchResult = DiagnosticSeverity.Hint;
          break;
      }
    } else {
      _switchResult = DiagnosticSeverity.Hint;
    }
    it.setSeverity(_switchResult);
    it.setMessage(issue.getMessage());
    Integer _elvis = null;
    Integer _lineNumber = issue.getLineNumber();
    if (_lineNumber != null) {
      _elvis = _lineNumber;
    } else {
      _elvis = Integer.valueOf(1);
    }
    final int lineNumber = ((_elvis).intValue() - 1);
    Integer _elvis_1 = null;
    Integer _column = issue.getColumn();
    if (_column != null) {
      _elvis_1 = _column;
    } else {
      _elvis_1 = Integer.valueOf(1);
    }
    final int column = ((_elvis_1).intValue() - 1);
    Integer _elvis_2 = null;
    Integer _length = issue.getLength();
    if (_length != null) {
      _elvis_2 = _length;
    } else {
      _elvis_2 = Integer.valueOf(0);
    }
    final Integer length = _elvis_2;
    Position _position = new Position(lineNumber, column);
    Position _position_1 = new Position(lineNumber, (column + (length).intValue()));
    Range _range = new Range(_position, _position_1);
    it.setRange(_range);
  };
  return ObjectExtensions.<Diagnostic>operator_doubleArrow(_diagnostic, _function);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:58,代码来源:LanguageServerImpl.java

示例12: getModel

import org.eclipse.xtext.validation.Issue; //导入方法依赖的package包/类
/**
 * Get the export model that we have to process.
 *
 * @param grammar
 *          The grammar
 * @return The model
 */
private synchronized ExportModel getModel(final Grammar grammar) { // NOPMD NPathComplexity by wth on 24.11.10 08:22
  if (modelLoaded) {
    return model;
  }
  modelLoaded = true;
  Resource resource = grammar.eResource();
  if (resource == null) {
    return null;
  }

  final ResourceSet resourceSet = resource.getResourceSet();
  URI uri = null;
  if (getExportFileURI() != null) {
    uri = URI.createURI(getExportFileURI());
  } else {
    uri = grammar.eResource().getURI().trimFileExtension().appendFileExtension(EXPORT_FILE_EXTENSION);
  }
  try {
    resource = resourceSet.getResource(uri, true);
    final List<Issue> issues = VALIDATOR.validate(resource, LOGGER);

    for (final Issue issue : issues) {
      if (issue.isSyntaxError() || issue.getSeverity() == Severity.ERROR) {
        throw new WorkflowInterruptedException(NLS.bind(Messages.ExportFragment_EXPORT_ERRORS, uri));
      }
    }
    if (resource.getContents().size() == 0) {
      return null;
    }
    model = (ExportModel) resource.getContents().get(0);
    return model;
  } catch (final ClasspathUriResolutionException e) {
    // Resource does not exist.
    if (getExportFileURI() != null) {
      // Explicit file specified, but not found: stop the workflow.
      throw new WorkflowInterruptedException(NLS.bind(Messages.ExportFragment_NO_EXPORT_FILE, uri)); // NOPMD PreserveStackTrace by wth on 24.11.10 08:27
    }
    // No file found at implicit location: work with a null model, generating code that implements the default behavior.
    return null;
  }
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:49,代码来源:ExportFragment.java


注:本文中的org.eclipse.xtext.validation.Issue.getSeverity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。