Java 类org.eclipse.xtext.linking.impl.ImportedNamesAdapter 实例源码

项目:n4js    文件:N4JSLinker.java   
/**
 * Removes the imported names before linking and cleans other caches attached to the AST.
 */
@Override
protected void beforeModelLinked(EObject model, IDiagnosticConsumer diagnosticsConsumer) {
    ImportedNamesAdapter adapter = ImportedNamesAdapter.find(model.eResource());
    if (adapter != null)
        adapter.clear();

    ComposedMemberScope.clearCachedComposedMembers(model);
}
项目:n4js    文件:ImportedNamesRecordingScopeAccess.java   
/**
 * Obtain a global scope to lookup polyfills. Any request by name on the returned scope will record the name in the
 * list of imported names of the given context resource.
 */
public IScope getRecordingPolyfillScope(Resource context) {
    ImportedNamesAdapter importedNamesAdapter = getImportedNamesAdapter(context);
    IScope scope = globalScopeProvider.getScope(context,
            TypeRefsPackage.Literals.PARAMETERIZED_TYPE_REF__DECLARED_TYPE, null);
    return importedNamesAdapter.wrap(scope);
}
项目:n4js    文件:ImportedNamesRecordingScopeAccess.java   
/**
 * Obtain the previously registered adapter for the imported names or register a new one.
 *
 * @param context
 *            the resource that is supposed to hold the adapter
 */
private ImportedNamesAdapter getImportedNamesAdapter(Resource context) {
    ImportedNamesAdapter adapter = ImportedNamesAdapter.find(context);
    if (adapter != null)
        return adapter;
    ImportedNamesAdapter importedNamesAdapter = importedNamesAdapterProvider.get();
    context.eAdapters().add(importedNamesAdapter);
    return importedNamesAdapter;
}
项目:n4js    文件:N4JSRuntimeModule.java   
/**
 * Provides new instances of the ImportedNamesAdapter, e.g. concrete instances of N4JSImportedNamesAdapter.
 *
 * @see ImportedNamesAdapter
 */
public Provider<ImportedNamesAdapter> provideImportedNamesAdapter() {
    return new Provider<ImportedNamesAdapter>() {
        @Override
        public ImportedNamesAdapter get() {
            return new N4JSImportedNamesAdapter();
        }
    };
}
项目:xtext-core    文件:DefaultResourceDescription.java   
@Override
public Iterable<QualifiedName> getImportedNames() {
    EcoreUtil2.resolveLazyCrossReferences(resource, CancelIndicator.NullImpl);
    ImportedNamesAdapter adapter = ImportedNamesAdapter.find(getResource());
    if (adapter != null) {
        ImmutableSet<QualifiedName> result = ImmutableSet.copyOf(adapter.getImportedNames());
        return result;
    }
    return Collections.emptySet();
}
项目:dsl-devkit    文件:ResourceDescription2.java   
/**
 * {@inheritDoc}
 */
@Override
public Map<QualifiedName, Set<EClass>> getImportedNamesTypes() {
  ImportedNamesAdapter adapter = ImportedNamesAdapter.find(getResource());
  if (adapter instanceof ImportedNamesTypesAdapter) {
    return ImmutableMap.copyOf(((ImportedNamesTypesAdapter) adapter).getImportedNamesTypes());
  }
  return Maps.newHashMap();
}
项目:dsl-devkit    文件:ImportedNamesTypesAdapter.java   
/**
 * Returns registered ImportedNameAdapter for given resource.
 *
 * @param resource
 *          Resource for which adapter should be returned.
 * @return registered importedNamesTypesAdapter.
 */
public static ImportedNamesTypesAdapter find(final Resource resource) {
  for (Adapter adapter : resource.eAdapters()) {
    if (adapter instanceof ImportedNamesAdapter) {
      return (ImportedNamesTypesAdapter) adapter;
    }
  }
  return null;
}
项目:dsl-devkit    文件:LinkingService.java   
/**
 * {@inheritDoc}
 */
@Override
protected ImportedNamesTypesAdapter getImportedNamesAdapter(final EObject context) {
  ImportedNamesAdapter adapter = ImportedNamesAdapter.find(context.eResource());
  if (adapter instanceof ImportedNamesTypesAdapter) {
    return (ImportedNamesTypesAdapter) adapter;
  }
  ImportedNamesTypesAdapter importedNamesTypeAdapter = importedNamesAdapterProvider.get();
  context.eResource().eAdapters().add(importedNamesTypeAdapter);
  return importedNamesTypeAdapter;
}