Java 类org.eclipse.xtext.diagnostics.IDiagnosticConsumer 实例源码

项目:n4js    文件:N4JSLinker.java   
/**
 * Clears the list of encoded URIs in {@link N4JSResource}, installs proxies for all cross references inside the
 * parsed model. If validation is enabled finally the {@link ASTStructureValidator} is triggered, that checks the
 * now linked AST structure.
 */
@Override
protected void doLinkModel(final EObject model, final IDiagnosticConsumer consumer) {
    final LinkingDiagnosticProducer producer = new LinkingDiagnosticProducer(consumer);
    getCache().execWithoutCacheClear((N4JSResource) model.eResource(), new IUnitOfWork.Void<N4JSResource>() {

        @Override
        public void process(N4JSResource resource) throws Exception {
            // actual linking
            resource.clearLazyProxyInformation();
            clearReferences(model);
            installProxies(resource, model, producer);
            TreeIterator<EObject> iterator = model.eAllContents();
            while (iterator.hasNext()) {
                EObject eObject = iterator.next();
                clearReferences(eObject);
                installProxies(resource, eObject, producer);
            }
            // pre-processing of AST
            preProcessor.process(resource.getScript(), resource);
            // AST structure validation
            if (!resource.isValidationDisabled())
                getStructureValidator().validate(model, consumer);
        }
    });
}
项目:xtext-core    文件:XtextLinker.java   
@Override
public void linkModel(EObject model, IDiagnosticConsumer consumer) {
    if (model instanceof Grammar) {
        final Xtext2EcoreTransformer transformer = createTransformer((Grammar) model, consumer);
        //TODO duplicate
        transformer.removeGeneratedPackages();
        super.linkModel(model, consumer);
        updateOverriddenRules((Grammar) model);
        try {
            transformer.transform();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            consumer.consume(new ExceptionDiagnostic(e), Severity.ERROR);
        }
        if (!model.eResource().eAdapters().contains(packageRemover))
            model.eResource().eAdapters().add(packageRemover);
    } else {
        super.linkModel(model, consumer);
    }
}
项目:xtext-core    文件:LazyLinker.java   
@Override
protected void doLinkModel(final EObject model, IDiagnosticConsumer consumer) {
    final Multimap<EStructuralFeature.Setting, INode> settingsToLink = ArrayListMultimap.create();
    final LinkingDiagnosticProducer producer = new LinkingDiagnosticProducer(consumer);
    cache.execWithoutCacheClear(model.eResource(), new IUnitOfWork.Void<Resource>() {
        @Override
        public void process(Resource state) throws Exception {
            TreeIterator<EObject> iterator = getAllLinkableContents(model);
            boolean clearAllReferencesRequired = isClearAllReferencesRequired(state);
            while (iterator.hasNext()) {
                EObject eObject = iterator.next();
                if (clearAllReferencesRequired) {
                    clearReferences(eObject);
                }
                installProxies(eObject, producer, settingsToLink);
            }
        }
    });
    installQueuedLinks(settingsToLink);
}
项目:n4js    文件:N4JSLinker.java   
/**
 * Removes the imported names before linking and cleans other caches attached to the AST.
 */
@Override
protected void beforeModelLinked(EObject model, IDiagnosticConsumer diagnosticsConsumer) {
    ImportedNamesAdapter adapter = ImportedNamesAdapter.find(model.eResource());
    if (adapter != null)
        adapter.clear();

    ComposedMemberScope.clearCachedComposedMembers(model);
}
项目:xtext-extras    文件:Xtext2EcoreTransformerTest.java   
@Override
public XtextResource doGetResource(final InputStream in, final URI uri) throws Exception {
  XtextResourceSet rs = this.<XtextResourceSet>get(XtextResourceSet.class);
  rs.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext/", false), URI.createURI("classpath:/"));
  rs.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext.xbase/", false), URI.createURI("classpath:/"));
  rs.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext.common.types/", false), URI.createURI("classpath:/"));
  rs.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.emf.ecore/", false), URI.createURI("classpath:/"));
  rs.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.xtext.xbase/", false), URI.createURI("classpath:/"));
  rs.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.emf.ecore/", false), URI.createURI("classpath:/"));
  rs.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.xtext.common.types/", false), URI.createURI("classpath:/"));
  rs.setClasspathURIContext(this.getClass());
  Resource _createResource = this.getResourceFactory().createResource(uri);
  final XtextResource resource = ((XtextResource) _createResource);
  rs.getResources().add(resource);
  XtextLinker linker = new XtextLinker() {
    @Override
    protected Xtext2EcoreTransformer createTransformer(final Grammar grammar, final IDiagnosticConsumer consumer) {
      Xtext2EcoreTransformer result = super.createTransformer(grammar, consumer);
      ErrorAcceptor _errorAcceptor = result.getErrorAcceptor();
      Xtext2EcoreTransformerTest.MyErrorAcceptor _myErrorAcceptor = new Xtext2EcoreTransformerTest.MyErrorAcceptor(_errorAcceptor, Xtext2EcoreTransformerTest.this.errorAcceptorMock);
      result.setErrorAcceptor(_myErrorAcceptor);
      return result;
    }
  };
  ILinker _linker = resource.getLinker();
  linker.setScopeProvider(((XtextLinker) _linker).getScopeProvider());
  ILinker _linker_1 = resource.getLinker();
  linker.setLinkingService(((Linker) _linker_1).getLinkingService());
  ILinker _linker_2 = resource.getLinker();
  linker.setLinkingHelper(((Linker) _linker_2).getLinkingHelper());
  XtextLinker.PackageRemover _packageRemover = new XtextLinker.PackageRemover();
  linker.setPackageRemover(_packageRemover);
  LinkingDiagnosticMessageProvider _linkingDiagnosticMessageProvider = new LinkingDiagnosticMessageProvider();
  linker.setDiagnosticMessageProvider(_linkingDiagnosticMessageProvider);
  OnChangeEvictingCache _onChangeEvictingCache = new OnChangeEvictingCache();
  linker.setCache(_onChangeEvictingCache);
  resource.setLinker(linker);
  resource.load(in, null);
  return resource;
}
项目:xtext-core    文件:XtextLinker.java   
@SuppressWarnings("deprecation")
@Override
protected void beforeModelLinked(EObject model, IDiagnosticConsumer diagnosticsConsumer) {
    discardGeneratedPackages(model);
    clearAllReferences(model);
    super.beforeModelLinked(model, diagnosticsConsumer);
    cache.getOrCreate(model.eResource()).ignoreNotifications();
}
项目:xtext-core    文件:AbstractCleaningLinker.java   
protected void beforeModelLinked(EObject model, IDiagnosticConsumer diagnosticsConsumer) {
    Resource resource = model.eResource();
    if (resource instanceof LazyLinkingResource) {
        ((LazyLinkingResource) resource).clearLazyProxyInformation();
    }
    ImportedNamesAdapter adapter = ImportedNamesAdapter.find(resource);
    if (adapter!=null)
        adapter.clear();
}
项目:xtext-core    文件:Xtext2EcoreTransformerTest.java   
@Override
public XtextResource doGetResource(final InputStream in, final URI uri) throws Exception {
  XtextResourceSet rs = this.<XtextResourceSet>get(XtextResourceSet.class);
  rs.setClasspathURIContext(this.getClass());
  Resource _createResource = this.getResourceFactory().createResource(uri);
  final XtextResource resource = ((XtextResource) _createResource);
  rs.getResources().add(resource);
  XtextLinker linker = new XtextLinker() {
    @Override
    protected Xtext2EcoreTransformer createTransformer(final Grammar grammar, final IDiagnosticConsumer consumer) {
      Xtext2EcoreTransformer result = super.createTransformer(grammar, consumer);
      ErrorAcceptor _errorAcceptor = result.getErrorAcceptor();
      Xtext2EcoreTransformerTest.MyErrorAcceptor _myErrorAcceptor = new Xtext2EcoreTransformerTest.MyErrorAcceptor(_errorAcceptor, Xtext2EcoreTransformerTest.this.errorAcceptorMock);
      result.setErrorAcceptor(_myErrorAcceptor);
      return result;
    }
  };
  ILinker _linker = resource.getLinker();
  linker.setScopeProvider(((XtextLinker) _linker).getScopeProvider());
  ILinker _linker_1 = resource.getLinker();
  linker.setLinkingService(((Linker) _linker_1).getLinkingService());
  ILinker _linker_2 = resource.getLinker();
  linker.setLinkingHelper(((Linker) _linker_2).getLinkingHelper());
  XtextLinker.PackageRemover _packageRemover = new XtextLinker.PackageRemover();
  linker.setPackageRemover(_packageRemover);
  LinkingDiagnosticMessageProvider _linkingDiagnosticMessageProvider = new LinkingDiagnosticMessageProvider();
  linker.setDiagnosticMessageProvider(_linkingDiagnosticMessageProvider);
  OnChangeEvictingCache _onChangeEvictingCache = new OnChangeEvictingCache();
  linker.setCache(_onChangeEvictingCache);
  resource.setLinker(linker);
  resource.load(in, null);
  return resource;
}
项目:n4js    文件:N4JSInjectorProviderWithoutStructureValidation.java   
@Override
public void validate(EObject model, IDiagnosticConsumer consumer) {
    // no-op
}
项目:n4js    文件:ASTStructureDiagnosticProducer.java   
ASTStructureDiagnosticProducer(IDiagnosticConsumer consumer) {
    super(consumer);
}
项目:xtext-core    文件:TransformationDiagnosticsProducer.java   
public TransformationDiagnosticsProducer(IDiagnosticConsumer consumer) {
    super(consumer);
}
项目:xtext-core    文件:XtextLinker.java   
protected Xtext2EcoreTransformer createTransformer(Grammar grammar, IDiagnosticConsumer consumer) {
    final Xtext2EcoreTransformer transformer = new Xtext2EcoreTransformer(grammar);
    transformer.setErrorAcceptor(new TransformationDiagnosticsProducer(consumer));
    transformer.setPostProcessor(postProcessor);
    return transformer;
}
项目:xtext-core    文件:XtextLinker.java   
@Override
protected void afterModelLinked(EObject model, IDiagnosticConsumer diagnosticsConsumer) {
    super.afterModelLinked(model, diagnosticsConsumer);
    cache.getOrCreate(model.eResource()).listenToNotifications();
}
项目:xtext-core    文件:AbstractCleaningLinker.java   
protected void afterModelLinked(EObject model, IDiagnosticConsumer diagnosticsConsumer) {
    // clients may override
}
项目:xtext-core    文件:Linker.java   
protected IDiagnosticProducer createDiagnosticProducer(IDiagnosticConsumer consumer) {
    return new LinkingDiagnosticProducer(consumer);
}
项目:xtext-core    文件:Linker.java   
@Override
protected void doLinkModel(EObject model, IDiagnosticConsumer consumer) {
    final IDiagnosticProducer producer = createDiagnosticProducer(consumer);
    ensureModelLinked(model, producer);
}
项目:xtext-core    文件:LinkingDiagnosticProducer.java   
public LinkingDiagnosticProducer(IDiagnosticConsumer consumer) {
    super(consumer);
}
项目:xtext-core    文件:ILinker.java   
/**
 * Sets cross references in the passed {@link EObject} and its {@link EObject#eAllContents() contents},
 * using the information available (usually using the {@link INode} model associated via {@link NodeModelUtils})
 * 
 * @param model the root model of a resource
 * @param diagnosticsConsumer the consumer of linking diagnostics
 */
void linkModel(EObject model, IDiagnosticConsumer diagnosticsConsumer);
项目:xtext-core    文件:AbstractCleaningLinker.java   
protected abstract void doLinkModel(EObject model, IDiagnosticConsumer diagnosticsConsumer);