org.eclipse.xtext.resource.SynchronizedXtextResourceSet Java Examples

The following examples show how to use org.eclipse.xtext.resource.SynchronizedXtextResourceSet. 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: SynchronizedXtextResourceSetProvider.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public SynchronizedXtextResourceSet get() {
	SynchronizedXtextResourceSet result = new SynchronizedXtextResourceSet();
	result.setClasspathURIContext(classLoader);
	typeProviderFactory.findOrCreateTypeProvider(result);
	return result;
}
 
Example #2
Source File: ModelRepositoryImpl.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
public ModelRepositoryImpl() {
    XtextResourceSet xtextResourceSet = new SynchronizedXtextResourceSet();
    xtextResourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
    this.resourceSet = xtextResourceSet;
    // don't use XMI as a default
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove("*");
}
 
Example #3
Source File: ModelRepositoryImpl.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
@Activate
public ModelRepositoryImpl(final @Reference SafeEMF safeEmf) {
    this.safeEmf = safeEmf;

    XtextResourceSet xtextResourceSet = new SynchronizedXtextResourceSet();
    xtextResourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
    this.resourceSet = xtextResourceSet;
    // don't use XMI as a default
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove("*");
}
 
Example #4
Source File: FormatLinkingService.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<EObject> getLinkedObjects(final EObject context, final EReference ref, final INode node) {
  ResourceSet resourceSet = context.eResource().getResourceSet();
  if (ref == FormatPackage.Literals.FORMAT_CONFIGURATION__TARGET_GRAMMAR) {
    List<EObject> usedGrammars = getUsedGrammar(resourceSet, NodeModelUtils.getTokenText(node));
    if (!usedGrammars.isEmpty()) {
      return usedGrammars;
    } else {
      return super.getLinkedObjects(context, ref, node);
    }
  } else if (ref == FormatPackage.Literals.FORMAT_CONFIGURATION__EXTENDED_FORMAT_CONFIGURATION) {
    List<EObject> extendedFormatConfigurations = getExtendedFormatConfiguration(resourceSet, node);
    if (!extendedFormatConfigurations.isEmpty()) {
      return extendedFormatConfigurations;
    } else {
      return super.getLinkedObjects(context, ref, node);
    }
  } else if ((ref == FormatPackage.Literals.INT_VALUE__REFERENCE || ref == FormatPackage.Literals.STRING_VALUE__REFERENCE)
      && !(resourceSet instanceof SynchronizedXtextResourceSet)) {
    List<EObject> res = super.getLinkedObjects(context, ref, node);
    if (res == null || res.isEmpty()) {
      return getConstant(resourceSet, node);
    } else {
      return res;
    }
  } else if (ref == FormatPackage.Literals.RULE__OVERRIDE) {
    return getExtendedFormatConfiguration(resourceSet, node);
  }

  return super.getLinkedObjects(context, ref, node);
}
 
Example #5
Source File: SynchronizedXtextResourceSetProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public SynchronizedXtextResourceSet get() {
	SynchronizedXtextResourceSet result = new SynchronizedXtextResourceSet();
	result.setClasspathURIContext(classLoader);
	typeProviderFactory.findOrCreateTypeProvider(result);
	return result;
}
 
Example #6
Source File: JdtTypeProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.9
 */
/* @Nullable */
private JvmType findObjectType(/* @NonNull */ String signature, /* @NonNull */ URI resourceURI, boolean traverseNestedTypes) {
	ResourceSet resourceSet = getResourceSet();
	if (resourceSet instanceof SynchronizedXtextResourceSet) {
		synchronized (((SynchronizedXtextResourceSet) resourceSet).getLock()) {
			return doFindObjectType(signature, resourceURI, traverseNestedTypes);		
		}
	}
	return doFindObjectType(signature, resourceURI, traverseNestedTypes);
}
 
Example #7
Source File: SynchronizedXtextResourceSetProvider.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public SynchronizedXtextResourceSet get() {
	SynchronizedXtextResourceSet result = new SynchronizedXtextResourceSet();
	result.setClasspathURIContext(classLoader);
	typeProviderFactory.findOrCreateTypeProvider(result);
	return result;
}
 
Example #8
Source File: ResourceSetWithBuiltInSchemeProvider.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Standard constructor used by the injector.
 */
@Inject
public ResourceSetWithBuiltInSchemeProvider(
		BuiltInSchemeRegistrar registrar,
		ClassLoader classLoader,
		UriExtensions uriExtensions) {
	@SuppressWarnings("hiding")
	SynchronizedXtextResourceSet resourceSet = new SynchronizedXtextResourceSet();
	attachXtextResourceLocator(resourceSet);
	resourceSet.setClasspathURIContext(classLoader);
	registrar.registerScheme(resourceSet);
	resourceSet.setURIConverter(new EmptyAuthorityAddingNormalizer(resourceSet.getURIConverter(), uriExtensions));
	this.resourceSet = resourceSet;
}
 
Example #9
Source File: ConfiguredResourceSetProvider.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public SynchronizedXtextResourceSet get() {
	SynchronizedXtextResourceSet result = super.get();
	result.setClasspathURIContext(classLoader);
	initialize(result);
	return result;
}
 
Example #10
Source File: ConfiguredResourceSetProvider.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Initialize the given resource set.
 */
protected void initialize(SynchronizedXtextResourceSet resourceSet) {
	attachXtextResourceLocator(resourceSet);
	attachBuiltInSchemeResourceLocator(resourceSet);
	resourceSet.setURIConverter(new EmptyAuthorityAddingNormalizer(resourceSet.getURIConverter(), uriExtensions));
	builtInSchemeRegistrar.registerScopes(resourceSet, resourceSetWithBuiltIns);
}
 
Example #11
Source File: XbaseInjectorProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends Provider<SynchronizedXtextResourceSet>> provideSynchronizedResourceSet() {
	return SynchronizedXtextResourceSetProvider.class;
}
 
Example #12
Source File: GamlModelBuilder.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
private GamlModelBuilder() {
	buildResourceSet = new SynchronizedXtextResourceSet();
}
 
Example #13
Source File: ResourceSetWithBuiltInSchemeProvider.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
private ResourceLocator attachXtextResourceLocator(
		@SuppressWarnings("hiding") SynchronizedXtextResourceSet resourceSet) {
	return new XtextResourceLocator(resourceSet);
}
 
Example #14
Source File: SynchronizedXtextResourceSetTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected XtextResourceSet createEmptyResourceSet() {
  return new SynchronizedXtextResourceSet();
}
 
Example #15
Source File: DefaultRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends XtextResourceSet> bindXtextResourceSet() {
	return SynchronizedXtextResourceSet.class;
}
 
Example #16
Source File: ConfiguredResourceSetProvider.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
private ResourceLocator attachBuiltInSchemeResourceLocator(SynchronizedXtextResourceSet result) {
	return new BuiltInSchemeResourceLocator(result, resourceSetWithBuiltIns);
}
 
Example #17
Source File: N4JSUiModule.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * De-configure the hard coded built in scheme from the runtime bundle.
 */
public Class<? extends XtextResourceSet> bindXtextResourceSet() {
	return SynchronizedXtextResourceSet.class;
}
 
Example #18
Source File: XbaseWithAnnotationsInjectorProvider.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends Provider<SynchronizedXtextResourceSet>> provideSynchronizedResourceSet() {
	return SynchronizedXtextResourceSetProvider.class;
}
 
Example #19
Source File: XbaseInjectorProvider.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends Provider<SynchronizedXtextResourceSet>> provideSynchronizedResourceSet() {
	return SynchronizedXtextResourceSetProvider.class;
}
 
Example #20
Source File: BasicResourceSetProvider.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public SynchronizedXtextResourceSet get() {
	return new SynchronizedXtextResourceSet();
}
 
Example #21
Source File: ConfiguredResourceSetProvider.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
private ResourceLocator attachXtextResourceLocator(SynchronizedXtextResourceSet resourceSet) {
	return new XtextResourceLocator(resourceSet);
}
 
Example #22
Source File: BuiltInSchemeResourceSetInitializer.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void initialize(ResourceSet resourceSet, IProject project) {
	initialize((SynchronizedXtextResourceSet) resourceSet);
}
 
Example #23
Source File: N4JSRuntimeModule.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Bind a resource set that knows about the builtin scheme.
 */
public Class<? extends Provider<? extends SynchronizedXtextResourceSet>> provideConfiguredXtextResourceSet() {
	return ConfiguredResourceSetProvider.class;
}
 
Example #24
Source File: N4JSUiModule.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Bind a resource set that knows about the builtin scheme.
 */
public Class<? extends Provider<? extends SynchronizedXtextResourceSet>> provideXtextResourceSet() {
	return BasicResourceSetProvider.class;
}