org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider Java Examples

The following examples show how to use org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParallelResourceLoader.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
public ParallelLoadOperation(final ResourceSet parent, final IProject project) {
  this.parent = parent;
  if (queueSize == -1) {
    this.resourceQueue = new LinkedBlockingQueue<Triple<URI, Resource, Throwable>>();
  } else if (queueSize == 0) {
    this.resourceQueue = new SynchronousQueue<Triple<URI, Resource, Throwable>>();
  } else {
    this.resourceQueue = new ArrayBlockingQueue<Triple<URI, Resource, Throwable>>(queueSize);
  }
  this.resourceSetProvider = new ThreadLocal<ResourceSet>() {
    @Override
    protected ResourceSet initialValue() {
      ResourceSet resourceSet = getResourceSetProvider().get(project);
      BuildPhases.setIndexing(resourceSet, BuildPhases.isIndexing(parent));
      DirectLinkingSourceLevelURIsAdapter.setSourceLevelUris(resourceSet, DirectLinkingSourceLevelURIsAdapter.findInstalledAdapter(parent).getSourceLevelURIs());
      resourceSet.getLoadOptions().putAll(parent.getLoadOptions());
      // we are not loading as part of a build
      resourceSet.getLoadOptions().remove(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE);
      resourceSet.setURIConverter(parent.getURIConverter());
      return resourceSet;
    }
  };
  this.executor = Executors.newFixedThreadPool(nThreads, new ThreadFactoryBuilder().setNameFormat("parallel-load-operation-%d").build()); //$NON-NLS-1$
  this.waitTime = getTimeout();
}
 
Example #2
Source File: SharedStateModule.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.8
 */
public void configureResourceDescriptionsProvider(Binder binder) {
	if (Activator.isJavaEnabled()) {
		binder.install(new ResourceDescriptionsProviderModule());
	} else {
		binder.bind(ResourceDescriptionsProvider.class).in(Scopes.SINGLETON);
	}
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.LIVE_SCOPE))
		.to(LiveShadowedResourceDescriptions.class);
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE))
		.to(CurrentDescriptions.ResourceSetAware.class);
	binder.bind(org.eclipse.xtext.resource.IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(IBuilderState.class);
}
 
Example #3
Source File: N4JSRefactoringResourceSetProvider.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public ResourceSet get(IProject project) {
	ResourceSet rs = super.get(project);
	// TODO IDE-3236: @szarnekow: LIVE_SCOPE does not work. PERSISTED_DESCRIPTIONS works. Why?
	rs.getLoadOptions().remove(ResourceDescriptionsProvider.LIVE_SCOPE);
	rs.getLoadOptions().put(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS, Boolean.TRUE);
	return rs;
}
 
Example #4
Source File: ResourceRelocationProcessor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.18
 */
protected void initializeResourceSet(boolean persistedIndexUsageRequested, ResourceRelocationContext context) {
	if (persistedIndexUsageRequested) {
		context.getResourceSet().getLoadOptions().put(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS, Boolean.TRUE);
	} else {
		liveScopeResourceSetInitializer.initialize(context.getResourceSet());
	}
}
 
Example #5
Source File: ProjectOpenedOrClosedListener.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private ResourceSet createResourceSet() {
	ResourceSet resourceSet = getResourceSetProvider().get(null);
	resourceSet.getLoadOptions().put(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE, Boolean.TRUE);
	if (resourceSet instanceof ResourceSetImpl) {
		((ResourceSetImpl) resourceSet).setURIResourceMap(Maps.<URI, Resource> newHashMap());
	}
	return resourceSet;
}
 
Example #6
Source File: XtextBuilder.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @param toBeBuilt
 *            the URIs that will be processed in this build run.
 * @param removedProjects
 *            the projects that are no longer considered by XtextBuilders but are yet to be removed from the index.
 * @param monitor
 *            the progress monitor for the build.
 * @param type
 *            indicates the kind of build that is running.
 * 
 * @since 2.18
 */
protected void doBuild(ToBeBuilt toBeBuilt, Set<String> removedProjects, IProgressMonitor monitor, BuildType type) throws CoreException {
	buildLogger.log("Building " + getProject().getName());
	// return early if there's nothing to do.
	// we reuse the isEmpty() impl from BuildData assuming that it doesnT access the ResourceSet which is still null 
	// and would be expensive to create.
	boolean indexingOnly = type == BuildType.RECOVERY;
	if (new BuildData(getProject().getName(), null, toBeBuilt, queuedBuildData, indexingOnly, this::needRebuild, removedProjects).isEmpty())
		return;
	SubMonitor progress = SubMonitor.convert(monitor, 2);
	ResourceSet resourceSet = getResourceSetProvider().get(getProject());
	resourceSet.getLoadOptions().put(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE, Boolean.TRUE);
	BuildData buildData = new BuildData(getProject().getName(), resourceSet, toBeBuilt, queuedBuildData, indexingOnly, this::needRebuild, removedProjects);
	ImmutableList<Delta> deltas = builderState.update(buildData, progress.split(1));
	if (participant != null && !indexingOnly) {
		SourceLevelURICache sourceLevelURIs = buildData.getSourceLevelURICache();
		Set<URI> sources = sourceLevelURIs.getSources();
		participant.build(new BuildContext(this, resourceSet, deltas, sources, type),
				progress.split(1));
		try {
			getProject().getWorkspace().checkpoint(false);
		} catch(NoClassDefFoundError e) { // guard against broken Eclipse installations / bogus project configuration
			log.error(e.getMessage(), e);
		}
	} else {
		progress.worked(1);
	}
	resourceSet.eSetDeliver(false);
	for (Resource resource : resourceSet.getResources()) {
		resource.eSetDeliver(false);
	}
	resourceSet.getResources().clear();
	resourceSet.eAdapters().clear();
}
 
Example #7
Source File: AbstractReferringTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(IBuilderState.class);
}
 
Example #8
Source File: AbstractXtendUiModule.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(IBuilderState.class);
}
 
Example #9
Source File: AbstractRefactoringTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(IBuilderState.class);
}
 
Example #10
Source File: AbstractReferringTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsBuilderScope(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE)).to(CurrentDescriptions.ResourceSetAware.class);
}
 
Example #11
Source File: AbstractBmTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(IBuilderState.class);
}
 
Example #12
Source File: AbstractStatemachineRuntimeModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(ResourceSetBasedResourceDescriptions.class);
}
 
Example #13
Source File: AbstractEcore2XtextTestRuntimeModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(ResourceSetBasedResourceDescriptions.class);
}
 
Example #14
Source File: AbstractDomainmodelUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsBuilderScope(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE)).to(CurrentDescriptions.ResourceSetAware.class);
}
 
Example #15
Source File: AbstractPartialSerializationTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(ResourceSetBasedResourceDescriptions.class);
}
 
Example #16
Source File: AbstractDomainmodelRuntimeModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(ResourceSetBasedResourceDescriptions.class);
}
 
Example #17
Source File: AbstractStatemachineUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(IBuilderState.class);
}
 
Example #18
Source File: AbstractArithmeticsUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(IBuilderState.class);
}
 
Example #19
Source File: AbstractBuilderTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(IBuilderState.class);
}
 
Example #20
Source File: AbstractFoldingTestLanguageRuntimeModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(ResourceSetBasedResourceDescriptions.class);
}
 
Example #21
Source File: AbstractIndexTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(ResourceSetBasedResourceDescriptions.class);
}
 
Example #22
Source File: AbstractOutlineTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(IBuilderState.class);
}
 
Example #23
Source File: AbstractOutlineTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsBuilderScope(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE)).to(CurrentDescriptions.ResourceSetAware.class);
}
 
Example #24
Source File: AbstractOutlineTestLanguageRuntimeModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(ResourceSetBasedResourceDescriptions.class);
}
 
Example #25
Source File: AbstractTestLanguageRuntimeModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(ResourceSetBasedResourceDescriptions.class);
}
 
Example #26
Source File: AbstractFoldingTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(IBuilderState.class);
}
 
Example #27
Source File: AbstractIndentationAwareUiTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(ResourceSetBasedResourceDescriptions.class);
}
 
Example #28
Source File: AbstractTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(IBuilderState.class);
}
 
Example #29
Source File: AbstractXtendRuntimeModule.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(ResourceSetBasedResourceDescriptions.class);
}
 
Example #30
Source File: AbstractXmlUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIResourceDescriptionsBuilderScope(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE)).to(CurrentDescriptions.ResourceSetAware.class);
}