Java 类org.eclipse.xtext.parser.antlr.IReferableElementsUnloader 实例源码

项目: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    文件:AbstractPartialParserReplaceTest.java   
protected void replaceAndReparse(String model, int offset, int length, String change, String expectedReparseRegion)
        throws Exception {
    IParseResult parseResult = getParseResult(model);
    PartialParsingPointers parsingPointers = getPartialParser().calculatePartialParsingPointers(parseResult, offset,
            length);
    String reparseRegion = getPartialParser().insertChangeIntoReplaceRegion(parsingPointers
            .getDefaultReplaceRootNode(), new ReplaceRegion(offset, length, change));
    assertEquals(expectedReparseRegion, reparseRegion);
    final Wrapper<Boolean> unloaded = Wrapper.wrap(Boolean.FALSE);
    getPartialParser().setUnloader(new IReferableElementsUnloader() {
        @Override
        public void unloadRoot(EObject root) {
            unloaded.set(Boolean.TRUE);
        }
    });
    IParseResult partiallyReparse = reparse(parseResult, offset, length, change);
    assertTrue("unloaded", unloaded.get());
    assertFalse(partiallyReparse.getRootNode().getText(), partiallyReparse.hasSyntaxErrors());
    String expectedReparseModel = model.substring(0, offset) + change + model.substring(offset + length);
    assertEquals(expectedReparseModel, partiallyReparse.getRootNode().getText());
}
项目:xtext-core    文件:AbstractPartialParserCrossContainmentTest.java   
protected void replaceAndReparse(String model, int offset, int length, String inserted, boolean expectSameRoot) throws Exception {
    final XtextResource resource = getResourceFromString(model);
    resource.setUnloader(new IReferableElementsUnloader() {
        @Override
        public void unloadRoot(EObject root) {
            InternalEObject internalEObject = (InternalEObject) root;
            internalEObject.eSetProxyURI(resource.getURI().appendFragment(resource.getURIFragment(internalEObject)));
            internalEObject.eAdapters().clear();
        }});
    assertEquals(1, resource.getContents().size());
    EObject wasObject = resource.getContents().get(0);
    assertNotNull(wasObject.eContainer());
    assertNotSame(wasObject.eResource(), wasObject.eContainer().eResource());
    resource.update(offset, length, inserted);
    assertEquals(1, resource.getContents().size());
    EObject newRoot = resource.getContents().get(0);
    assertEquals(expectSameRoot, wasObject == newRoot);
    if (!expectSameRoot) {
        assertTrue(((InternalEObject)wasObject).eIsProxy());
        assertNotSame(resource, wasObject.eResource());
    }
    assertSame(resource, newRoot.eResource());
}
项目:xtext-core    文件:Bug419429Test.java   
protected void replaceAndReparse(String model, int offset, int length, String change, String expectedReparseRegion)
        throws Exception {
    IParseResult parseResult = getParseResultAndExpect(model, UNKNOWN_EXPECTATION);
    PartialParsingPointers parsingPointers = getPartialParser().calculatePartialParsingPointers(parseResult, offset,
            length);
    String reparseRegion = getPartialParser().insertChangeIntoReplaceRegion(parsingPointers
            .getDefaultReplaceRootNode(), new ReplaceRegion(offset, length, change));
    assertEquals(expectedReparseRegion, reparseRegion);
    final Wrapper<Boolean> unloaded = Wrapper.wrap(Boolean.FALSE);
    getPartialParser().setUnloader(new IReferableElementsUnloader() {
        @Override
        public void unloadRoot(EObject root) {
            unloaded.set(Boolean.TRUE);
        }
    });
    IParseResult partiallyReparse = reparse(parseResult, offset, length, change);
    assertTrue("unloaded", unloaded.get());
    String expectedReparseModel = model.substring(0, offset) + change + model.substring(offset + length);
    assertEquals(expectedReparseModel, partiallyReparse.getRootNode().getText());

    compareWithFullParse(model, offset, length, change);
}
项目:xtext-core    文件:XtextResourceTest.java   
@Test public void testUnloadReferables() throws Exception {
    resource.reparse(simpleModel);
    final Wrapper<Boolean> unloaded = Wrapper.wrap(Boolean.FALSE);
    resource.setUnloader(new IReferableElementsUnloader() {
        @Override
        public void unloadRoot(EObject root) {
            unloaded.set(Boolean.TRUE);
        }
    });
    resource.reparse(simpleModel);
    assertTrue("unloaded", unloaded.get());
}
项目:statecharts    文件:STextRuntimeModule.java   
@Override
public void configure(Binder binder) {
    super.configure(binder);
    binder.bind(IDefaultResourceDescriptionStrategy.class).to(SCTResourceDescriptionStrategy.class);
    // https://github.com/Yakindu/statecharts/issues/1199
    binder.bind(IReferableElementsUnloader.class).to(IReferableElementsUnloader.NullUnloader.class);
}
项目:xtext-core    文件:XtextLinker.java   
public void setUnloader(IReferableElementsUnloader unloader) {
    this.unloader = unloader;
}
项目:xtext-core    文件:XtextLinker.java   
public IReferableElementsUnloader getUnloader() {
    return unloader;
}
项目:xtext-core    文件:PartialParsingHelper.java   
public void setUnloader(IReferableElementsUnloader unloader) {
    this.unloader = unloader;
}
项目:xtext-core    文件:PartialParsingHelper.java   
public IReferableElementsUnloader getUnloader() {
    return unloader;
}
项目:xtext-core    文件:XtextResource.java   
public void setUnloader(IReferableElementsUnloader unloader) {
    this.unloader = unloader;
}
项目:xtext-core    文件:XtextResource.java   
public IReferableElementsUnloader getUnloader() {
    return unloader;
}
项目:xtext-core    文件:XtextRuntimeModule.java   
public Class<? extends IReferableElementsUnloader> bindIReferableElementsUnloader() {
    return XtextReferableElementsUnloader.class;
}
项目:dsl-devkit    文件:FixedPartialParsingHelper.java   
public void setUnloader(final IReferableElementsUnloader unloader) {
  this.unloader = unloader;
}
项目:dsl-devkit    文件:FixedPartialParsingHelper.java   
public IReferableElementsUnloader getUnloader() {
  return unloader;
}
项目:n4js    文件:N4JSRuntimeModule.java   
/**
 * Unloads type model instances.
 *
 * @return Class<{@link N4JSUnloader}>
 */
public Class<? extends IReferableElementsUnloader> bindIReferableElementsUnloader() {
    return N4JSUnloader.class;
}