Java 类org.eclipse.xtext.validation.IResourceValidator 实例源码

项目:n4js    文件:OwnResourceValidatorAwareValidatingEditorCallback.java   
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);
        });
    }
项目:xtext-extras    文件:JavaSourceLanguageRuntimeModule.java   
@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);
}
项目:xtext-core    文件:XtextValidationTest.java   
@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());
}
项目:dsl-devkit    文件:ValidMarkerUpdateJob.java   
/**
 * 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);
  }
}
项目:statecharts    文件:SCTXtextIntegrationModule.java   
@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);
}
项目:n4js    文件:AbstractBuilderParticipantTest.java   
/**
 * 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);
        }
    });
}
项目:n4js    文件:N4HeadlessCompiler.java   
/**
 * 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());
    }
}
项目:n4js    文件:IssuesProvider.java   
@SuppressWarnings("javadoc")
public IssuesProvider(IResourceValidator resourceValidator, Resource res,
        OperationCanceledManager operationCanceledManager, CancelIndicator ci) {
    this.rv = resourceValidator;
    this.r = res;
    this.operationCanceledManager = operationCanceledManager;
    this.ci = ci;
}
项目:bromium    文件:DslParser.java   
@Inject
public DslParser(ResourceSet resourceSet,
                 IResourceValidator validator,
                 ASTNodeConverter<Model, ApplicationConfiguration> ASTNodeConverter) {
    this.resourceSet = resourceSet;
    this.validator = validator;
    this.ASTNodeConverter = ASTNodeConverter;
}
项目:bromium    文件:DslParserTest.java   
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);
}
项目:xtext-extras    文件:StandaloneBuilder.java   
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);
}
项目:xtext-core    文件:IncrementalBuilder.java   
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);
}
项目:xtext-core    文件:XtextValidationTest.java   
@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());

}
项目:xtext-core    文件:XtextValidationTest.java   
@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());
}
项目:xtext-core    文件:XtextValidationTest.java   
@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());
}
项目:xtext-core    文件:XtextValidationTest.java   
@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());
}
项目:xtext-core    文件:XtextValidationTest.java   
@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());
}
项目:xtext-core    文件:XtextValidationTest.java   
@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());
}
项目:xtext-core    文件:XtextValidationTest.java   
@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());
}
项目:xtext-core    文件:XtextValidationTest.java   
@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());
}
项目:xtext-core    文件:XtextValidationTest.java   
@Test public void testDuplicateArgument() throws Exception {
    XtextResource resource = getResourceFromString(
            "grammar com.acme.Bar with org.eclipse.xtext.common.Terminals\n" +
            "generate metamodel 'myURI'\n" +
            "Model: rule=Rule<Single=true, Single=false>;\n" + 
            "Rule<Single>: 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("Duplicate value for parameter Single", issues.get(0).getMessage());
}
项目:xtext-core    文件:XtextValidationTest.java   
@Test public void testSupressedWarning_01() throws Exception {
    XtextResource resource = getResourceFromString(
            "grammar org.acme.Bar with org.eclipse.xtext.common.Terminals\n" +
            "generate metamodel 'myURI'\n" +

            "Model: child=Child;\n" + 
            "/* SuppressWarnings[noInstantiation] */\n" +
            "Child: name=ID?;");
    assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
    assertTrue(resource.getWarnings().toString(), resource.getWarnings().isEmpty());

    IResourceValidator validator = get(IResourceValidator.class);
    List<Issue> issues = validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
    assertTrue(issues.toString(), issues.isEmpty());
}
项目:xtext-core    文件:XtextValidationTest.java   
@Test public void testSupressedWarning_02() throws Exception {
    XtextResource resource = getResourceFromString(
            "grammar org.acme.Bar with org.eclipse.xtext.common.Terminals\n" +
            "generate metamodel 'myURI'\n" +

            "/* SuppressWarnings[potentialOverride] */\n" + 
            "Parens: \n" + 
            "  ('(' Parens ')'|name=ID) em='!'?;");
    assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
    assertTrue(resource.getWarnings().toString(), resource.getWarnings().isEmpty());

    IResourceValidator validator = get(IResourceValidator.class);
    List<Issue> issues = validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
    assertTrue(issues.toString(), issues.isEmpty());
}
项目:dsl-devkit    文件:CheckMarkerUpdateJob.java   
/**
 * 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 markerCreator
 *          the marker creator
 * @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 MarkerCreator markerCreator, 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);
      file.deleteMarkers(MarkerTypes.EXPENSIVE_VALIDATION, true, IResource.DEPTH_ZERO);

      if (markerCreator != null) {
        for (final Issue issue : list) {
          markerCreator.createMarker(issue, file, MarkerTypes.forCheckType(issue.getType()));
        }
      } else {
        if (LOGGER.isDebugEnabled()) {
          LOGGER.error("Could not create markers. The marker creator is null."); //$NON-NLS-1$
        }
      }
    }
  } catch (final CoreException e) {
    LOGGER.error(e.getMessage(), e);
  } finally {
    monitor.worked(1);
  }
}
项目:bts    文件:ValidationJob.java   
public ValidationJob(IResourceValidator xtextResourceChecker, IReadAccess<XtextResource> xtextDocument,
        IValidationIssueProcessor validationIssueProcessor,CheckMode checkMode) {
    super(Messages.ValidationJob_0);
    this.xtextDocument = xtextDocument;
    this.resourceValidator = xtextResourceChecker;
    this.validationIssueProcessor = validationIssueProcessor;
    this.checkMode = checkMode;
}
项目:statecharts    文件:DefaultValidationJob.java   
public TransactionalValidationRunner(IResourceValidator validator, Resource resource, CheckMode checkMode,
        CancelIndicator indicator) {
    this.validator = validator;
    this.resource = resource;
    this.checkMode = checkMode;
    this.indicator = indicator;

}
项目:statecharts    文件:GenericEditorModule.java   
public void configure(Binder binder) {
    super.configure(binder);
    Multibinder<IEditProposalProvider> proposalProviderBinder = Multibinder.newSetBinder(binder,
            IEditProposalProvider.class);
    proposalProviderBinder.addBinding().to(SmartEditProposalProvider.class);
    proposalProviderBinder.addBinding().to(RefactoringProposalProvider.class);
    binder.bind(IResourceValidator.class).to(SCTResourceValidatorImpl.class);
    binder.bind(IValidationIssueProcessor.class).to(DefaultValidationIssueStore.class);
}
项目:gama    文件:GamlRuntimeModule.java   
@Override
public void configure(final Binder binder) {
    super.configure(binder);
    staticInitialize();
    // binder.bind(ExpressionDescriptionBuilder.class);
    // binder.bind(IDocManager.class).to(GamlResourceDocumenter.class);
    // binder.bind(GamlSyntacticConverter.class);
    binder.bind(IDefaultResourceDescriptionStrategy.class).to(GamlResourceDescriptionStrategy.class);
    binder.bind(IQualifiedNameConverter.class).to(GamlNameConverter.class);
    binder.bind(IResourceDescription.Manager.class).to(GamlResourceDescriptionManager.class);
    // binder.bind(IOutputConfigurationProvider.class).to(GamlOutputConfigurationProvider.class);
    binder.bind(IResourceValidator.class).to(GamlResourceValidator.class);
    binder.bind(ErrorToDiagnoticTranslator.class);

}
项目:sadlos2    文件:OntModelProvider.java   
private static OntModelAdapter findAdapter(Resource resource) {
    if (resource == null) {
        return null;
    }
    Optional<OntModelAdapter> adapter = FIND_ADAPTER_FUNC.apply(resource);
    if (adapter.isPresent()) {
        return adapter.get();
    }
    if (resource instanceof XtextResource) {
        final IResourceValidator validator = ((XtextResource) resource).getResourceServiceProvider().getResourceValidator();
        validator.validate(resource, FAST_ONLY, NullImpl);
    }
    return FIND_ADAPTER_FUNC.apply(resource).orNull();
}
项目:sadlos2    文件:SadlActionHandler.java   
protected Resource prepareActionHandler(IProject project, IFile trgtFile) throws ExecutionException {   
    XtextResource res = getXtextResource(project, trgtFile);
    if (res != null) {
        if (res instanceof XtextResource) {
            IResourceValidator validator = res.getResourceServiceProvider().getResourceValidator();
            validator.validate(res, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
            processor = processorProvider.getProcessor(res);
        }
        return res;
    }
    else {
        throw new ExecutionException("Unable to obtain a resource for the target file '" + trgtFile.getName() + "'");
    }
}
项目:n4js    文件:ResourceUIValidatorExtension.java   
private IResourceValidator getValidator(Resource resource) {
    return getService(resource, IResourceValidator.class);
}
项目:n4js    文件:N4JSRuntimeModule.java   
/**
 * Binds to special N4JS version of IResourceValidator.
 */
public Class<? extends IResourceValidator> bindIResourceValidator() {
    return N4JSResourceValidator.class;
}
项目:bromium    文件:DefaultModule.java   
@Provides
public IResourceValidator getResourceValidator() {
    return dslInjector.getInstance(IResourceValidator.class);
}
项目:gw4e.project    文件:AbstractDSLPoliciesRuntimeModule.java   
public Class<? extends IResourceValidator> bindIResourceValidator() {
    return DerivedStateAwareResourceValidator.class;
}
项目:xtext-extras    文件:AbstractPureXbaseRuntimeModule.java   
public Class<? extends IResourceValidator> bindIResourceValidator() {
    return DerivedStateAwareResourceValidator.class;
}
项目:xtext-extras    文件:LanguageAccess.java   
public IResourceValidator getResourceValidator() {
    return resourceServiceProvider.getResourceValidator();
}
项目:xtext-extras    文件:JavaResourceServiceProvider.java   
@Override
public IResourceValidator getResourceValidator() {
  return null;
}
项目:xtext-extras    文件:XbaseGeneratorFragment.java   
@Override
public Set<Binding> getGuiceBindingsRt(Grammar grammar) {
    if (!usesXbaseGrammar(grammar))
        return emptySet();
    BindFactory config = new BindFactory()

            // overrides binding from org.eclipse.xtext.generator.exporting.QualifiedNamesFragment
            .addTypeToType(IQualifiedNameProvider.class.getName(),
                            "org.eclipse.xtext.xbase.scoping.XbaseQualifiedNameProvider");

    if (useInferredJvmModel) {
        config = config
                .addTypeToType(ILocationInFileProvider.class.getName(),
                        "org.eclipse.xtext.xbase.jvmmodel.JvmLocationInFileProvider")
                .addTypeToType(IGlobalScopeProvider.class.getName(),
                        "org.eclipse.xtext.common.types.xtext.TypesAwareDefaultGlobalScopeProvider")
                .addTypeToType("org.eclipse.xtext.xbase.validation.FeatureNameValidator",
                        "org.eclipse.xtext.xbase.validation.LogicalContainerAwareFeatureNameValidator")
                .addTypeToType("org.eclipse.xtext.xbase.typesystem.internal.DefaultBatchTypeResolver",
                        "org.eclipse.xtext.xbase.typesystem.internal.LogicalContainerAwareBatchTypeResolver")
                .addTypeToType("org.eclipse.xtext.xbase.typesystem.internal.DefaultReentrantTypeResolver",
                        "org.eclipse.xtext.xbase.typesystem.internal.LogicalContainerAwareReentrantTypeResolver")
                .addTypeToType(IResourceValidator.class.getCanonicalName(), 
                        "org.eclipse.xtext.xbase.annotations.validation.DerivedStateAwareResourceValidator");
        if(generateXtendInferrer) {
            config = config
                .addTypeToType("org.eclipse.xtext.xbase.jvmmodel.IJvmModelInferrer",
                    getJvmModelInferrerName(grammar, getNaming()));
        }
    } else {
        config = config
                .addTypeToType(ILocationInFileProvider.class.getName(),
                            "org.eclipse.xtext.xbase.resource.XbaseLocationInFileProvider");

    }
    if (usesXImportSection(grammar)) {
        config = config.addConfiguredBinding(
                IScopeProvider.class.getName() + "Delegate",
                "binder.bind("
                        + IScopeProvider.class.getName()
                        + ".class).annotatedWith(com.google.inject.name.Names.named("
                        + AbstractDeclarativeScopeProvider.class.getName()
                        + ".NAMED_DELEGATE)).to("+ getImportScopeProvider(grammar)+")");
    }
    return config.getBindings();
}
项目:xtext-extras    文件:XbaseWithLogicalContainerInjectorProvider.java   
public Class<? extends IResourceValidator> bindIResourceValidator() {
    return DerivedStateAwareResourceValidator.class;
}
项目:xtext-extras    文件:AbstractBug462047LangRuntimeModule.java   
public Class<? extends IResourceValidator> bindIResourceValidator() {
    return DerivedStateAwareResourceValidator.class;
}