org.eclipse.xtext.util.IResourceScopeCache Java Examples

The following examples show how to use org.eclipse.xtext.util.IResourceScopeCache. 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: N4JSResource.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Overridden to make sure that we add the root AST element sneakily to the resource list to make sure that no
 * accidental proxy resolution happens and that we do not increment the modification counter of the contents list.
 */
@Override
protected void updateInternalState(IParseResult newParseResult) {
	setParseResult(newParseResult);
	EObject newRootAstElement = newParseResult.getRootASTElement();
	if (newRootAstElement != null && !getContents().contains(newRootAstElement)) {
		// do not increment the modification counter here
		sneakyAddToContent(newRootAstElement);
	}
	reattachModificationTracker(newRootAstElement);
	clearErrorsAndWarnings();
	addSyntaxErrors();
	doLinking();

	// make sure that the cache adapter is installed on this resource
	IResourceScopeCache cache = getCache();
	if (cache instanceof OnChangeEvictingCache) {
		((OnChangeEvictingCache) cache).getOrCreate(this);
	}
}
 
Example #2
Source File: ResourceSetBasedResourceDescriptionsTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
	resourceSet = new ResourceSetImpl();
	IQualifiedNameProvider qualifiedNameProvider = new IQualifiedNameProvider.AbstractImpl() {
		
		@Override
		public QualifiedName getFullyQualifiedName(EObject obj) {
			return QualifiedName.create(((ENamedElement) obj).getName());
		}

		@Override
		public QualifiedName apply(EObject from) {
			return QualifiedName.create(((ENamedElement) from).getName());
		}
		
	};
	resourceDescriptionManager = new DefaultResourceDescriptionManager();
	resourceDescriptionManager.setCache(IResourceScopeCache.NullImpl.INSTANCE);
	DefaultResourceDescriptionStrategy strategy = new DefaultResourceDescriptionStrategy();
	strategy.setQualifiedNameProvider(qualifiedNameProvider);
	resourceDescriptionManager.setStrategy(strategy);
	resDescs = new ResourceSetBasedResourceDescriptions();
	resDescs.setContext(resourceSet);
	resDescs.setRegistry(this);
	container = new ResourceDescriptionsBasedContainer(resDescs);
}
 
Example #3
Source File: ProcResourceDescription.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ProcResourceDescription(final Resource resource,
        final DefaultResourceDescriptionStrategy strategy,
        final IResourceScopeCache cache) {
    super(resource, strategy, cache);
    this.strategy = strategy;
    this.strategy.setQualifiedNameProvider(new ProcQualifiedNameProvider());
}
 
Example #4
Source File: N4JSResourceDescription.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new description for the given resource.
 */
public N4JSResourceDescription(N4JSCrossReferenceComputer crossReferenceComputer,
		TypeHelper typeHelper,
		IQualifiedNameProvider qualifiedNameProvider,
		Resource resource,
		N4JSResourceDescriptionStrategy strategy,
		IResourceScopeCache cache) {
	super(resource, strategy, cache);
	this.crossReferenceComputer = crossReferenceComputer;
	this.qualifiedNameProvider = qualifiedNameProvider;
	this.typeHelper = typeHelper;
	this.strategy = strategy;
}
 
Example #5
Source File: GamlResourceDescription.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Inject
public GamlResourceDescription(final Resource resource, final IDefaultResourceDescriptionStrategy strategy,
		final IResourceScopeCache cache, final BuiltinGlobalScopeProvider provider) {
	super(resource, strategy, cache);
	this.provider = provider;

}
 
Example #6
Source File: BugAig1084.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Test that recursive calls to {@link ResourceDescription2#getLookUp()} by {@link ResourceDescription2#computeExportedObjects()} do not cause
 * stack-overflow.
 */
@Test
public void recursiveLookUp() {
  Resource resource = org.mockito.Mockito.mock(Resource.class);
  BasicEList<Adapter> emptyEList = new BasicEList<Adapter>();
  org.mockito.Mockito.when(resource.eAdapters()).thenReturn(emptyEList);
  IResourceScopeCache cache = new OnChangeEvictingCache();
  new ResourceDescription2(resource, null, cache) {
    @Override
    protected List<IEObjectDescription> computeExportedObjects() {
      return Lists.newArrayList(getLookUp().getExportedObjects());
    }
  }.getExportedObjects();
}
 
Example #7
Source File: DefaultResourceDescription.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public DefaultResourceDescription(Resource resource, IDefaultResourceDescriptionStrategy strategy,
			IResourceScopeCache cache) {
	this.resource = resource;
	this.strategy = strategy;
	this.cache = cache;
	this.uri = getNormalizedURI(resource);
}
 
Example #8
Source File: DerivedStateAwareResource.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Overridden to make sure that the cache is initialized during {@link #isLoading() loading}.
 */
@Override
protected void updateInternalState(IParseResult newParseResult) {
	super.updateInternalState(newParseResult);
	// make sure that the cache adapter is installed on this resource
	IResourceScopeCache cache = getCache();
	if (cache instanceof OnChangeEvictingCache) {
		((OnChangeEvictingCache) cache).getOrCreate(this);
	}
}
 
Example #9
Source File: XtendResourceDescription.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public XtendResourceDescription(final Resource resource, final IDefaultResourceDescriptionStrategy strategy, final IResourceScopeCache cache, final IBatchTypeResolver typeResolver, final IQualifiedNameConverter nameConverter) {
  super(resource, strategy, cache);
  this.typeResolver = typeResolver;
  this.nameConverter = nameConverter;
}
 
Example #10
Source File: InEditoProcResourceDescription.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public InEditoProcResourceDescription(Resource resource, DefaultResourceDescriptionStrategy strategy,
        IResourceScopeCache cache) {
    super(resource, strategy, cache);
}
 
Example #11
Source File: XtendResourceDescriptionManager.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public IResourceDescription createResourceDescription(final Resource resource, final IDefaultResourceDescriptionStrategy strategy) {
  IResourceScopeCache _cache = this.getCache();
  return new XtendResourceDescription(resource, strategy, _cache, this.typeResolver, this.nameConverter);
}
 
Example #12
Source File: STextGlobalScopeProvider.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void setCache(IResourceScopeCache cache) {
	this.cache = cache;
}
 
Example #13
Source File: ResourceDescription2.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
public ResourceDescription2(final Resource resource, final IDefaultResourceDescriptionStrategy strategy, final IResourceScopeCache cache) {
  super(resource, strategy, cache);
  this.strategy = strategy;
}
 
Example #14
Source File: KeywordInspector.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public KeywordInspector(ValidationMessageAcceptor messageAcceptor, IResourceScopeCache cache) {
	this.acceptor = messageAcceptor;
	this.cache = cache;
}
 
Example #15
Source File: PartialLinkingTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	with(ReferenceGrammarTestLanguageStandaloneSetup.class);
	IQualifiedNameConverter nameConverter = new IQualifiedNameConverter.DefaultImpl();
	IQualifiedNameProvider nameProvider = new DefaultDeclarativeQualifiedNameProvider();
	ImportUriGlobalScopeProvider globalScopeProvider = new ImportUriGlobalScopeProvider();
	globalScopeProvider.setImportResolver(new ImportUriResolver());
	globalScopeProvider.setCache(IResourceScopeCache.NullImpl.INSTANCE);
	final ResourceDescriptionsProvider provider = new ResourceDescriptionsProvider();
	provider.setResourceDescriptions(new Provider<IResourceDescriptions>() {
		@Override
		public IResourceDescriptions get() {
			return new IResourceDescriptions.NullImpl();
		}
	});
	globalScopeProvider.setResourceDescriptionsProvider(provider);
	globalScopeProvider.setLoadOnDemandDescriptions(new Provider<LoadOnDemandResourceDescriptions>() {
		@Override
		public LoadOnDemandResourceDescriptions get() {
			return PartialLinkingTest.this.get(LoadOnDemandResourceDescriptions.class);
		}
	});
	CaseInsensitivityHelper caseInsensitivityHelper = new CaseInsensitivityHelper();
	globalScopeProvider.setCaseInsensitivityHelper(caseInsensitivityHelper);
	scopeProvider = new ImportedNamespaceAwareLocalScopeProvider(globalScopeProvider, nameProvider, nameConverter, caseInsensitivityHelper);
	modelAsText =
		"spielplatz 1 {\n" +
		"  kind( Bommel1 1)\n" +
		"  kind( Bommel2 2)\n" +
		"  kind( Bommel3 3)\n" +
		"  erwachsener( Bob 4)\n" +
		"  erwachsener( Joe 5)\n" +
		"  familie( Familienname Bob Joe Bommel2 )\n" +
		"}";
	resource = getResourceFromString(modelAsText);
	assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
	model = resource.getParseResult().getRootASTElement();
	final Iterator<EObject> iter = model.eAllContents();
	while (iter.hasNext() && context == null) {
		final EObject candidate = iter.next();
		final String className = candidate.eClass().getName();
		if (className.endsWith("Familie"))
			context = candidate;
	}
	reference = (EReference) context.eClass().getEStructuralFeature("kinder");
}
 
Example #16
Source File: ImportUriGlobalScopeProvider.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void setCache(IResourceScopeCache cache) {
	this.cache = cache;
}
 
Example #17
Source File: SimpleLocalScopeProvider.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void setCache(IResourceScopeCache cache) {
	this.cache = cache;
}
 
Example #18
Source File: XtextResource.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void setCache(IResourceScopeCache cache) {
	this.cache = cache;
}
 
Example #19
Source File: XtextResource.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public IResourceScopeCache getCache() {
	return cache;
}
 
Example #20
Source File: DefaultResourceDescriptionManager.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public IResourceScopeCache getCache() {
	return cache;
}
 
Example #21
Source File: DefaultResourceDescriptionManager.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void setCache(IResourceScopeCache cache) {
	this.cache = cache;
}
 
Example #22
Source File: DefaultResourceDescription.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * For testing. Uses a {@link org.eclipse.xtext.util.IResourceScopeCache.NullImpl}.
 */
public DefaultResourceDescription(Resource resource, IDefaultResourceDescriptionStrategy strategy) {
	this(resource, strategy, new IResourceScopeCache.NullImpl());
}
 
Example #23
Source File: ILazyLinkingResource2.java    From dsl-devkit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Returns the scope cache for this resource.
 *
 * @return The IResourceScopeCache object, never {@code null}
 */
IResourceScopeCache getCache();