本文整理汇总了Java中org.eclipse.xtext.validation.IResourceValidator类的典型用法代码示例。如果您正苦于以下问题:Java IResourceValidator类的具体用法?Java IResourceValidator怎么用?Java IResourceValidator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IResourceValidator类属于org.eclipse.xtext.validation包,在下文中一共展示了IResourceValidator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: newValidationJob
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
private ValidationJob newValidationJob(final XtextEditor editor) {
final IXtextDocument document = editor.getDocument();
final IAnnotationModel annotationModel = editor.getInternalSourceViewer().getAnnotationModel();
final IssueResolutionProvider issueResolutionProvider = getService(editor, IssueResolutionProvider.class);
final MarkerTypeProvider markerTypeProvider = getService(editor, MarkerTypeProvider.class);
final MarkerCreator markerCreator = getService(editor, MarkerCreator.class);
final IValidationIssueProcessor issueProcessor = new CompositeValidationIssueProcessor(
new AnnotationIssueProcessor(document, annotationModel, issueResolutionProvider),
new MarkerIssueProcessor(editor.getResource(), markerCreator, markerTypeProvider));
return editor.getDocument().modify(resource -> {
final IResourceServiceProvider serviceProvider = resource.getResourceServiceProvider();
final IResourceValidator resourceValidator = serviceProvider.getResourceValidator();
return new ValidationJob(resourceValidator, editor.getDocument(), issueProcessor, ALL);
});
}
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:OwnResourceValidatorAwareValidatingEditorCallback.java
示例2: configure
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
@Override
protected void configure() {
this.<Resource.Factory>bind(Resource.Factory.class).to(JavaResource.Factory.class);
this.<IResourceValidator>bind(IResourceValidator.class).toInstance(IResourceValidator.NULL);
this.<IGenerator>bind(IGenerator.class).to(IGenerator.NullGenerator.class);
this.<IEncodingProvider>bind(IEncodingProvider.class).to(IEncodingProvider.Runtime.class);
this.<IResourceServiceProvider>bind(IResourceServiceProvider.class).to(JavaResourceServiceProvider.class);
this.<IContainer.Manager>bind(IContainer.Manager.class).to(SimpleResourceDescriptionsBasedContainerManager.class);
this.<IResourceDescription.Manager>bind(IResourceDescription.Manager.class).to(JavaResourceDescriptionManager.class);
this.<IQualifiedNameProvider>bind(IQualifiedNameProvider.class).to(JvmIdentifiableQualifiedNameProvider.class);
this.<String>bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).toInstance("java");
this.<String>bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.eclipse.xtext.java.Java");
this.<IJvmTypeProvider.Factory>bind(IJvmTypeProvider.Factory.class).to(ClasspathTypeProviderFactory.class);
this.<ClassLoader>bind(ClassLoader.class).toInstance(JavaSourceLanguageRuntimeModule.class.getClassLoader());
this.<IReferableElementsUnloader>bind(IReferableElementsUnloader.class).to(IReferableElementsUnloader.GenericUnloader.class);
final IResourceDescriptionsProvider _function = (ResourceSet it) -> {
return ChunkedResourceDescriptions.findInEmfObject(it);
};
this.<IResourceDescriptionsProvider>bind(IResourceDescriptionsProvider.class).toInstance(_function);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:21,代码来源:JavaSourceLanguageRuntimeModule.java
示例3: testRuleCalledSuper
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
@Test public void testRuleCalledSuper() throws Exception {
XtextResource resource = getResourceFromString(
"grammar com.acme.Bar with org.eclipse.xtext.common.Terminals\n" +
"generate metamodel 'myURI'\n" +
"Model: super=super;\n" +
"super: name=ID;");
IResourceValidator validator = get(IResourceValidator.class);
List<Issue> issues = validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
assertEquals(issues.toString(), 1, issues.size());
assertEquals("Discouraged rule name 'super'", issues.get(0).getMessage());
Grammar grammar = (Grammar) resource.getContents().get(0);
AbstractRule model = grammar.getRules().get(0);
Assignment assignment = (Assignment) model.getAlternatives();
RuleCall ruleCall = (RuleCall) assignment.getTerminal();
assertSame(grammar.getRules().get(1), ruleCall.getRule());
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:18,代码来源:XtextValidationTest.java
示例4: validate
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
/**
* Validate the given resource and create the corresponding markers. The CheckMode is a constant calculated from the constructor
* parameters.
*
* @param resourceValidator
* the resource validator (not null)
* @param file
* the EFS file (not null)
* @param resource
* the EMF resource (not null)
* @param monitor
* the monitor (not null)
*/
protected void validate(final IResourceValidator resourceValidator, final IFile file, final Resource resource, final IProgressMonitor monitor) {
try {
monitor.subTask("validating " + file.getName()); //$NON-NLS-1$
final List<Issue> list = resourceValidator.validate(resource, checkMode, getCancelIndicator(monitor));
if (list != null) {
// resourceValidator.validate returns null if canceled (and not an empty list)
file.deleteMarkers(MarkerTypes.FAST_VALIDATION, true, IResource.DEPTH_ZERO);
file.deleteMarkers(MarkerTypes.NORMAL_VALIDATION, true, IResource.DEPTH_ZERO);
if (performExpensiveValidation) {
file.deleteMarkers(MarkerTypes.EXPENSIVE_VALIDATION, true, IResource.DEPTH_ZERO);
}
for (final Issue issue : list) {
markerCreator.createMarker(issue, file, MarkerTypes.forCheckType(issue.getType()));
}
}
} catch (final CoreException e) {
LOGGER.error(e.getMessage(), e);
} finally {
monitor.worked(1);
}
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:36,代码来源:ValidMarkerUpdateJob.java
示例5: configure
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
@Override
public void configure(Binder binder) {
binder.bind(IResourceValidator.class).to(SCTResourceValidatorImpl.class);
binder.bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).toInstance("sct");
binder.bind(IEncodingProvider.class).to(IEncodingProvider.Runtime.class);
binder.bind(IQualifiedNameProvider.class).to(StextNameProvider.class);
binder.bind(org.eclipse.jface.viewers.ILabelProvider.class)
.annotatedWith(org.eclipse.xtext.ui.resource.ResourceServiceDescriptionLabelProvider.class)
.to(DefaultDescriptionLabelProvider.class);
binder.bind(IDefaultResourceDescriptionStrategy.class).to(SCTResourceDescriptionStrategy.class);
binder.bind(MarkerCreator.class).to(SCTMarkerCreator.class);
binder.bind(MarkerTypeProvider.class).to(SCTMarkerTypeProvider.class);
binder.bind(IDiagnosticConverter.class).to(SCTDiagnosticConverterImpl.class);
binder.bind(IURIEditorOpener.class).annotatedWith(LanguageSpecific.class).to(SCTFileEditorOpener.class);
binder.bind(IMarkerContributor.class).to(TaskMarkerContributor.class);
binder.bind(ITaskFinder.class).to(DomainSpecificTaskFinder.class);
binder.bind(TaskMarkerCreator.class).to(SCTTaskMarkerCreator.class);
binder.bind(TaskMarkerTypeProvider.class).to(SCTTaskMarkerTypeProvider.class);
}
开发者ID:Yakindu,项目名称:statecharts,代码行数:22,代码来源:SCTXtextIntegrationModule.java
示例6: getEditorValidationErrors
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
/**
* Returns validation errors in given Xtext editor.
*/
protected List<Issue> getEditorValidationErrors(XtextEditor editor) {
return editor.getDocument().readOnly(new IUnitOfWork<List<Issue>, XtextResource>() {
@Override
public List<Issue> exec(XtextResource state) throws Exception {
final IResourceValidator validator = state.getResourceServiceProvider().getResourceValidator();
return validator.validate(state, CheckMode.ALL, CancelIndicator.NullImpl);
}
});
}
开发者ID:eclipse,项目名称:n4js,代码行数:13,代码来源:AbstractBuilderParticipantTest.java
示例7: validateProject
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
/**
* 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());
}
}
开发者ID:eclipse,项目名称:n4js,代码行数:48,代码来源:N4HeadlessCompiler.java
示例8: IssuesProvider
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
@SuppressWarnings("javadoc")
public IssuesProvider(IResourceValidator resourceValidator, Resource res,
OperationCanceledManager operationCanceledManager, CancelIndicator ci) {
this.rv = resourceValidator;
this.r = res;
this.operationCanceledManager = operationCanceledManager;
this.ci = ci;
}
开发者ID:eclipse,项目名称:n4js,代码行数:9,代码来源:IssuesProvider.java
示例9: DslParser
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
@Inject
public DslParser(ResourceSet resourceSet,
IResourceValidator validator,
ASTNodeConverter<Model, ApplicationConfiguration> ASTNodeConverter) {
this.resourceSet = resourceSet;
this.validator = validator;
this.ASTNodeConverter = ASTNodeConverter;
}
开发者ID:hristo-vrigazov,项目名称:bromium,代码行数:9,代码来源:DslParser.java
示例10: initMocks
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
private void initMocks(File file) {
applicationConfiguration = mock(ApplicationConfiguration.class);
model = mock(Model.class);
resource = mock(Resource.class, RETURNS_DEEP_STUBS);
when(resource.getAllContents().next()).thenReturn(model);
resourceSet = mock(ResourceSet.class);
when(resourceSet.getResource(URI.createFileURI(file.getAbsolutePath()), true)).thenReturn(resource);
resourceValidator = mock(IResourceValidator.class);
ASTNodeConverter = mock(ASTNodeConverter.class);
when(ASTNodeConverter.convert(model)).thenReturn(applicationConfiguration);
}
开发者ID:hristo-vrigazov,项目名称:bromium,代码行数:12,代码来源:DslParserTest.java
示例11: validate
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
protected boolean validate(final Resource resource) {
String _lastSegment = resource.getURI().lastSegment();
String _plus = ("Starting validation for input: \'" + _lastSegment);
String _plus_1 = (_plus + "\'");
StandaloneBuilder.LOG.info(_plus_1);
final IResourceValidator resourceValidator = this.languageAccess(resource.getURI()).getResourceValidator();
final List<Issue> validationResult = resourceValidator.validate(resource, CheckMode.ALL, null);
return this.issueHandler.handleIssue(validationResult);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:10,代码来源:StandaloneBuilder.java
示例12: validate
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
protected boolean validate(final Resource resource) {
final IResourceValidator resourceValidator = this.context.getResourceServiceProvider(resource.getURI()).getResourceValidator();
if ((resourceValidator == null)) {
return true;
}
String _lastSegment = resource.getURI().lastSegment();
String _plus = ("Starting validation for input: \'" + _lastSegment);
String _plus_1 = (_plus + "\'");
IncrementalBuilder.InternalStatefulIncrementalBuilder.LOG.info(_plus_1);
final List<Issue> validationResult = resourceValidator.validate(resource, CheckMode.ALL, null);
return this.request.getAfterValidate().afterValidate(resource.getURI(), validationResult);
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:13,代码来源:IncrementalBuilder.java
示例13: testExplicitOverride01
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
@Test public void testExplicitOverride01() throws Exception {
IResourceValidator validator = get(IResourceValidator.class);
XtextResource resource = getResourceFromString(
"grammar org.foo.Bar with org.eclipse.xtext.common.Terminals\n" +
"terminal ID_2: ('a'..'z'|'A'..'Z'|'_');");
List<Issue> issues = validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
assertEquals(issues.toString(), 0, issues.size());
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:11,代码来源:XtextValidationTest.java
示例14: testExplicitOverride04
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
@Test public void testExplicitOverride04() throws Exception {
IResourceValidator validator = get(IResourceValidator.class);
XtextResource resource = getResourceFromString(
"grammar org.foo.Bar with org.eclipse.xtext.common.Terminals\n" +
"@Override\n" +
"terminal ID: ('a'..'z'|'A'..'Z'|'_');");
List<Issue> issues = validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
assertEquals(issues.toString(), 0, issues.size());
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:10,代码来源:XtextValidationTest.java
示例15: testMissingArgument
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
@Test public void testMissingArgument() throws Exception {
XtextResource resource = getResourceFromString(
"grammar com.acme.Bar with org.eclipse.xtext.common.Terminals\n" +
"generate metamodel 'myURI'\n" +
"Model: rule=Rule<First=true, Second=false>;\n" +
"Rule<First, Missing, Second>: name=ID;");
IResourceValidator validator = get(IResourceValidator.class);
List<Issue> issues = validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
assertEquals(issues.toString(), 1, issues.size());
assertEquals("Missing argument for parameter Missing", issues.get(0).getMessage());
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:13,代码来源:XtextValidationTest.java
示例16: testMissingArgument2
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
@Test public void testMissingArgument2() throws Exception {
XtextResource resource = getResourceFromString(
"grammar com.acme.Bar with org.eclipse.xtext.common.Terminals\n" +
"generate metamodel 'myURI'\n" +
"Model: rule=Rule<First=true>;\n" +
"Rule<First, Missing, AlsoMissing>: name=ID;");
IResourceValidator validator = get(IResourceValidator.class);
List<Issue> issues = validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
assertEquals(issues.toString(), 1, issues.size());
assertEquals("2 missing arguments for the following parameters: Missing, AlsoMissing", issues.get(0).getMessage());
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:13,代码来源:XtextValidationTest.java
示例17: testMissingArgument3
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
@Test public void testMissingArgument3() throws Exception {
XtextResource resource = getResourceFromString(
"grammar com.acme.Bar with org.eclipse.xtext.common.Terminals\n" +
"generate metamodel 'myURI'\n" +
"Model: rule=Rule<true>;\n" +
"Rule<First, Missing, AlsoMissing>: name=ID;");
IResourceValidator validator = get(IResourceValidator.class);
List<Issue> issues = validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
assertEquals(issues.toString(), 1, issues.size());
assertEquals("Expected 3 arguments but got 1", issues.get(0).getMessage());
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:13,代码来源:XtextValidationTest.java
示例18: testOutOfSequenceArgument_01
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
@Test public void testOutOfSequenceArgument_01() throws Exception {
XtextResource resource = getResourceFromString(
"grammar com.acme.Bar with org.eclipse.xtext.common.Terminals\n" +
"generate metamodel 'myURI'\n" +
"Model: rule=Rule<true, C=false, B=true>;\n" +
"Rule<A, B, C>: name=ID;");
IResourceValidator validator = get(IResourceValidator.class);
List<Issue> issues = validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
assertEquals(issues.toString(), 2, issues.size());
assertEquals("Out of sequence named argument. Expected value for B", issues.get(0).getMessage());
assertEquals("Out of sequence named argument. Expected value for C", issues.get(1).getMessage());
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:14,代码来源:XtextValidationTest.java
示例19: testOutOfSequenceArgument_02
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
@Test public void testOutOfSequenceArgument_02() throws Exception {
XtextResource resource = getResourceFromString(
"grammar com.acme.Bar with org.eclipse.xtext.common.Terminals\n" +
"generate metamodel 'myURI'\n" +
"Model: rule=Rule<true, B=false, C=true>;\n" +
"Rule<A, B, C>: name=ID;");
IResourceValidator validator = get(IResourceValidator.class);
List<Issue> issues = validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
assertEquals(issues.toString(), 0, issues.size());
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:12,代码来源:XtextValidationTest.java
示例20: testOutOfSequenceArgument_03
import org.eclipse.xtext.validation.IResourceValidator; //导入依赖的package包/类
@Test public void testOutOfSequenceArgument_03() throws Exception {
XtextResource resource = getResourceFromString(
"grammar com.acme.Bar with org.eclipse.xtext.common.Terminals\n" +
"generate metamodel 'myURI'\n" +
"Model: rule=Rule<A=true, C=false, B=true>;\n" +
"Rule<A, B, C>: name=ID;");
IResourceValidator validator = get(IResourceValidator.class);
List<Issue> issues = validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
assertEquals(issues.toString(), 0, issues.size());
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:12,代码来源:XtextValidationTest.java
注:本文中的org.eclipse.xtext.validation.IResourceValidator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论