/*synchronized*/Property::Pointer
  TypeExtensionManager::GetProperty(
      Object::Pointer receiver, const std::string& namespaze,
      const std::string& method, bool forcePluginActivation)
  {
    std::clock_t start= 0;
    if (Expressions::TRACING)
    start = std::clock();

    // if we call a static method than the receiver is the class object
    //Class clazz= receiver instanceof Class ? (Class)receiver : receiver.getClass();

    Property::Pointer result(new Property(receiver, namespaze, method));
    Property::Pointer cached(fPropertyCache->Get(result));
    if (!cached.isNull())
    {
      if (cached->IsValidCacheEntry(forcePluginActivation))
      {
        if (Expressions::TRACING)
        {
          BERRY_INFO << "[Type Extension] - method " <<
          receiver->ToString() << "#" << method <<
          " found in cache: " <<
          (double(std::clock() - start))/(CLOCKS_PER_SEC/1000) << " ms.";
        }
        return cached;
      }
      // The type extender isn't loaded in the cached method but can be loaded
      // now. So remove method from cache and do the normal look up so that the
      // implementation class gets loaded.
      fPropertyCache->Remove(cached);
    }
    TypeExtension::Pointer extension(this->Get(receiver->GetClassName()));
    IPropertyTester::Pointer extender(extension->FindTypeExtender(*this, namespaze, method, false /*receiver instanceof Class*/, forcePluginActivation));
    if (!extender.Cast<TypeExtension::CONTINUE_>().IsNull() || extender.IsNull())
    {
      std::string msg("Unknown method for ");
      msg.append(receiver->GetClassName());
      throw CoreException(msg, method);
    }
    result->SetPropertyTester(extender);
    fPropertyCache->Put(result);
    if (Expressions::TRACING)
    {
      BERRY_INFO << "[Type Extension] - method " <<
      typeid(receiver).name() << "#" << method <<
      " not found in cache: " <<
      (double(std::clock() - start))/(CLOCKS_PER_SEC/1000) << " ms.";
    }
    return result;
  }
Esempio n. 2
0
  IIterable::Pointer
  Expressions::GetAsIIterable(Object::Pointer var, Expression::Pointer expression)
  {
    IIterable::Pointer iterable(var.Cast<IIterable>());
    if (!iterable.IsNull())
    {
      return iterable;
    }
    else
    {
      IAdapterManager::Pointer manager= Platform::GetServiceRegistry().GetServiceById<IAdapterManager>("org.blueberry.service.adaptermanager");
      Object::Pointer result;
      Poco::Any any(manager->GetAdapter(var, IIterable::GetStaticClassName()));
      if (!any.empty() && any.type() == typeid(Object::Pointer))
      {
        result = Poco::AnyCast<Object::Pointer>(any);
      }

      if (result)
      {
        iterable = result.Cast<IIterable>();
        return iterable;
      }

      if (manager->QueryAdapter(var->GetClassName(), IIterable::GetStaticClassName()) == IAdapterManager::NOT_LOADED)
        return IIterable::Pointer();

      throw CoreException("The variable is not iterable", expression->ToString());
    }
  }
Esempio n. 3
0
ISelection::Pointer HandlerUtil::GetShowInSelectionChecked(
    ExecutionEvent::Pointer event)
{
  Object::Pointer o = HandlerUtil::GetVariableChecked(event,
      ISources::SHOW_IN_SELECTION());
  if (o.Cast<ISelection>().IsNull())
  {
    HandlerUtil::IncorrectTypeFound(event, ISources::SHOW_IN_SELECTION(),
        "ISelection", o->GetClassName());
  }
  return o.Cast<ISelection>();
}
Esempio n. 4
0
ISelection::Pointer HandlerUtil::GetActiveMenuSelectionChecked(
    ExecutionEvent::Pointer event)
{
  Object::Pointer o = HandlerUtil::GetVariableChecked(event,
      ISources::ACTIVE_MENU_SELECTION_NAME());
  if (o.Cast<ISelection>().IsNull())
  {
    HandlerUtil::IncorrectTypeFound(event,
        ISources::ACTIVE_MENU_SELECTION_NAME(), "ISelection", o->GetClassName());
  }
  return o.Cast<ISelection>();
}
Esempio n. 5
0
HandlerUtil::StringVectorType::Pointer HandlerUtil::GetActiveMenusChecked(
    ExecutionEvent::Pointer event)
{
  Object::Pointer o = HandlerUtil::GetVariableChecked(event,
      ISources::ACTIVE_MENU_NAME());
  if (o.Cast<StringVectorType>().IsNull())
  {
    HandlerUtil::IncorrectTypeFound(event, ISources::ACTIVE_MENU_NAME(),
        "StringVectorType", o->GetClassName());
  }
  return o.Cast<StringVectorType>();
}
Esempio n. 6
0
IWorkbenchPartSite::Pointer HandlerUtil::GetActiveSiteChecked(
    ExecutionEvent::Pointer event)
{
  Object::Pointer o = HandlerUtil::GetVariableChecked(event,
      ISources::ACTIVE_SITE_NAME());
  if (o.Cast<IWorkbenchPartSite>().IsNull())
  {
    HandlerUtil::IncorrectTypeFound(event, ISources::ACTIVE_SITE_NAME(),
        "IWorkbenchSitePart", o->GetClassName());
  }
  return o.Cast<IWorkbenchPartSite>();
}
Esempio n. 7
0
ObjectString::Pointer HandlerUtil::GetActivePartIdChecked(
    ExecutionEvent::Pointer event)
{
  Object::Pointer o = HandlerUtil::GetVariableChecked(event,
      ISources::ACTIVE_PART_ID_NAME());
  if (o.Cast<ObjectString>().IsNull())
  {
    HandlerUtil::IncorrectTypeFound(event, ISources::ACTIVE_PART_ID_NAME(),
        "std::string", o->GetClassName());
  }
  return o.Cast<ObjectString>();
}
Esempio n. 8
0
IWorkbenchWindow::Pointer HandlerUtil::GetActiveWorkbenchWindowChecked(
    ExecutionEvent::Pointer event)
{
  Object::Pointer o = HandlerUtil::GetVariableChecked(event,
      ISources::ACTIVE_WORKBENCH_WINDOW_NAME());
  if (o.Cast<IWorkbenchWindow>().IsNull())
  {
    HandlerUtil::IncorrectTypeFound(event,
        ISources::ACTIVE_WORKBENCH_WINDOW_NAME(), "IWorkbenchWindow",
        o->GetClassName());
  }
  return o.Cast<IWorkbenchWindow>();
}