Java 类org.eclipse.xtext.util.IResourceScopeCache 实例源码

项目:n4js    文件:N4JSResource.java   
/**
 * 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);
    }
}
项目:xtext-core    文件:ResourceSetBasedResourceDescriptionsTest.java   
@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);
}
项目:dsl-devkit    文件:NodeModelHandler.java   
/** {@inheritDoc} */
@Override
public void insertProxyModel() {
  // Node model can be accessed by:
  // 1. checking the adapters of an EObject
  ICompositeNode rootNode = null;
  TreeIterator<EObject> iterator = EcoreUtil.getAllProperContents(resource, false);
  while (iterator.hasNext()) {
    EObject eObject = iterator.next();
    LazyLoadingCompositeNode node = new LazyLoadingCompositeNode();
    eObject.eAdapters().add(node);
    if (rootNode == null) {
      rootNode = node;
    }
  }

  // 2. fetching the ParseResult instance of the Resource
  EObject emfRootObject = resource.getContents().isEmpty() ? null : resource.getContents().get(0);
  resource.setParseResult(new ParseResult(emfRootObject, rootNode, false));

  // Add cache now, otherwise it will trigger model inference later.
  IResourceScopeCache cache = resource.getCache();
  if (cache instanceof OnChangeEvictingCache) {
    ((OnChangeEvictingCache) cache).getOrCreate(resource);
  }
}
项目:n4js    文件:N4JSResourceDescription.java   
/**
 * 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;
}
项目:xtext-core    文件:DerivedStateAwareResource.java   
/**
 * 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);
    }
}
项目:xtext-core    文件:DefaultResourceDescription.java   
public DefaultResourceDescription(Resource resource, IDefaultResourceDescriptionStrategy strategy,
            IResourceScopeCache cache) {
    this.resource = resource;
    this.strategy = strategy;
    this.cache = cache;
    this.uri = getNormalizedURI(resource);
}
项目:dsl-devkit    文件:BugAig1084.java   
/**
 * 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();
}
项目:gama    文件:GamlResourceDescription.java   
@Inject
public GamlResourceDescription(final Resource resource, final IDefaultResourceDescriptionStrategy strategy,
        final IResourceScopeCache cache, final BuiltinGlobalScopeProvider provider) {
    super(resource, strategy, cache);
    this.provider = provider;

}
项目:xtext-core    文件:DefaultResourceDescription.java   
/**
 * For testing. Uses a {@link org.eclipse.xtext.util.IResourceScopeCache.NullImpl}.
 */
public DefaultResourceDescription(Resource resource, IDefaultResourceDescriptionStrategy strategy) {
    this(resource, strategy, new IResourceScopeCache.NullImpl());
}
项目:xtext-core    文件:DefaultResourceDescriptionManager.java   
public void setCache(IResourceScopeCache cache) {
    this.cache = cache;
}
项目:xtext-core    文件:DefaultResourceDescriptionManager.java   
public IResourceScopeCache getCache() {
    return cache;
}
项目:xtext-core    文件:XtextResource.java   
public IResourceScopeCache getCache() {
    return cache;
}
项目:xtext-core    文件:XtextResource.java   
public void setCache(IResourceScopeCache cache) {
    this.cache = cache;
}
项目:xtext-core    文件:SimpleLocalScopeProvider.java   
public void setCache(IResourceScopeCache cache) {
    this.cache = cache;
}
项目:xtext-core    文件:ImportUriGlobalScopeProvider.java   
public void setCache(IResourceScopeCache cache) {
    this.cache = cache;
}
项目:xtext-core    文件:PartialLinkingTest.java   
@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");
}
项目:dsl-devkit    文件:ResourceDescription2.java   
public ResourceDescription2(final Resource resource, final IDefaultResourceDescriptionStrategy strategy, final IResourceScopeCache cache) {
  super(resource, strategy, cache);
  this.strategy = strategy;
}
项目:statecharts    文件:STextGlobalScopeProvider.java   
public void setCache(IResourceScopeCache cache) {
    this.cache = cache;
}
项目:dsl-devkit    文件:ILazyLinkingResource2.java   
/**
 * Returns the scope cache for this resource.
 * 
 * @return The IResourceScopeCache object, never {@code null}
 */
IResourceScopeCache getCache();