@Override
 public DefDescriptor<ComponentDef> provide() {
   BaseComponent<?, ?> component =
       Aura.getContextService().getCurrentContext().getCurrentComponent();
   String num = (String) component.getAttributes().getExpression("implNumber");
   // Warning: test:test_Provider_providerImpl no longer exist
   return DefDescriptorImpl.getInstance(
       "test:test_Provider_providerImpl" + num, ComponentDef.class);
 }
示例#2
0
  public DefOverviewModel() throws QuickFixException {

    AuraContext context = Aura.getContextService().getCurrentContext();
    BaseComponent<?, ?> component = context.getCurrentComponent();

    String desc = (String) component.getAttributes().getValue("descriptor");

    DefType defType =
        DefType.valueOf(((String) component.getAttributes().getValue("defType")).toUpperCase());
    DefinitionService definitionService = Aura.getDefinitionService();
    DefDescriptor<?> descriptor =
        definitionService.getDefDescriptor(desc, defType.getPrimaryInterface());

    Definition def = descriptor.getDef();
    ReferenceTreeModel.assertAccess(def);

    Map<DefType, List<DefModel>> depsMap = Maps.newEnumMap(DefType.class);

    Set<DefDescriptor<?>> deps = Sets.newHashSet();

    def.appendDependencies(deps);

    for (DefDescriptor<?> dep : deps) {
      DefType type = dep.getDefType();

      List<DefModel> depsList = depsMap.get(type);
      if (depsList == null) {
        depsList = Lists.newArrayList();
        depsMap.put(type, depsList);
      }
      depsList.add(new DefModel(dep));
    }

    for (Entry<DefType, List<DefModel>> entry : depsMap.entrySet()) {
      List<DefModel> list = entry.getValue();
      Collections.sort(list);

      Map<String, Object> group = Maps.newHashMap();
      group.put("type", AuraTextUtil.initCap(entry.getKey().toString().toLowerCase()));
      group.put("list", list);
      dependencies.add(group);
    }
  }
示例#3
0
  public ComponentDefModel() throws QuickFixException {
    AuraContext context = Aura.getContextService().getCurrentContext();
    BaseComponent<?, ?> component = context.getCurrentComponent();

    String desc = (String) component.getAttributes().getValue("descriptor");

    DefType defType =
        DefType.valueOf(((String) component.getAttributes().getValue("defType")).toUpperCase());
    DefinitionService definitionService = Aura.getDefinitionService();
    descriptor = definitionService.getDefDescriptor(desc, defType.getPrimaryInterface());
    definition = descriptor.getDef();

    ReferenceTreeModel.assertAccess(definition);

    String type = null;
    if (definition instanceof RootDefinition) {
      RootDefinition rootDef = (RootDefinition) definition;
      for (AttributeDef attribute : rootDef.getAttributeDefs().values()) {
        if (ReferenceTreeModel.hasAccess(attribute)) {
          attributes.add(new AttributeModel(attribute));
        }
      }

      DocumentationDef docDef = rootDef.getDocumentationDef();
      doc = docDef != null ? new DocumentationDefModel(docDef) : null;

      if (definition instanceof BaseComponentDef) {
        BaseComponentDef cmpDef = (BaseComponentDef) definition;
        for (RegisterEventDef reg : cmpDef.getRegisterEventDefs().values()) {
          if (ReferenceTreeModel.hasAccess(reg)) {
            events.add(new AttributeModel(reg));
          }
        }

        for (EventHandlerDef handler : cmpDef.getHandlerDefs()) {
          handledEvents.add(new AttributeModel(handler));
        }

        for (DefDescriptor<InterfaceDef> intf : cmpDef.getInterfaces()) {
          if (ReferenceTreeModel.hasAccess(intf.getDef())) {
            interfaces.add(intf.getNamespace() + ":" + intf.getName());
          }
        }

        DefDescriptor<?> superDesc = cmpDef.getExtendsDescriptor();
        if (superDesc != null) {
          theSuper = superDesc.getNamespace() + ":" + superDesc.getName();
        } else {
          theSuper = null;
        }

        isAbstract = cmpDef.isAbstract();
        isExtensible = cmpDef.isExtensible();

      } else if (definition instanceof EventDef) {
        EventDef eventDef = (EventDef) definition;
        DefDescriptor<?> superDesc = eventDef.getExtendsDescriptor();
        if (superDesc != null) {
          theSuper = superDesc.getNamespace() + ":" + superDesc.getName();
        } else {
          theSuper = null;
        }

        type = eventDef.getEventType().name();
        isExtensible = true;
        isAbstract = false;
      } else {
        theSuper = null;
        isExtensible = true;
        isAbstract = false;
      }

      support = rootDef.getSupport().name();

      if (definition instanceof RootDefinition) {
        List<DefDescriptor<?>> deps = ((RootDefinition) definition).getBundle();

        for (DefDescriptor<?> dep : deps) {
          // we already surface the documentation--users don't need to see the source for it.
          if (dep.getDefType() != DefType.DOCUMENTATION) {
            Definition def = dep.getDef();
            if (ReferenceTreeModel.hasAccess(def)) {
              defs.add(new DefModel(dep));
            }
          }
        }
      }
    } else {
      support = null;
      theSuper = null;
      isExtensible = false;
      isAbstract = false;
      doc = null;
    }
    this.type = type;
  }
示例#4
0
 private BaseComponent<?, ?> getComponentWithPath(final String path) {
   BaseComponent<?, ?> comp = Mockito.mock(BaseComponent.class);
   Mockito.when(comp.getPath()).thenReturn(path);
   Mockito.when(comp.hasLocalDependencies()).thenReturn(true);
   return comp;
 }