Ejemplo n.º 1
0
    /*
     * @see FilteredList.FilterMatcher#match(Object)
     */
    public boolean match(Object element) {
      if (!(element instanceof ITypeInfo)) return false;

      ITypeInfo info = (ITypeInfo) element;
      IQualifiedTypeName qualifiedName = info.getQualifiedTypeName();

      if (fVisibleTypes != null && !fVisibleTypes.contains(new Integer(info.getCElementType())))
        return false;

      if (!fShowLowLevelTypes && qualifiedName.isLowLevel()) return false;

      if (fSegmentMatchers.length == 1 && !fMatchGlobalNamespace)
        return fNameMatcher.match(qualifiedName.getName());

      return matchQualifiedName(info);
    }
  public void run(IAction action) {
    ElementSelectionDialog dialog = new ElementSelectionDialog(getShell());
    configureDialog(dialog);
    int result = dialog.open();
    if (result != IDialogConstants.OK_ID) return;

    ITypeInfo info = (ITypeInfo) dialog.getFirstResult();
    if (info == null) return;

    ICElement[] elements = null;
    ITypeReference location = info.getResolvedReference();
    if (location != null) {
      elements = location.getCElements();
    }
    if (elements == null || elements.length == 0) {
      String title = Messages.OpenTypeInHierarchyAction_errorTitle;
      String message =
          NLS.bind(
              Messages.OpenTypeInHierarchyAction_errorNoDefinition,
              info.getQualifiedTypeName().toString());
      MessageDialog.openError(getShell(), title, message);
    } else {
      IProject project = elements[0].getCProject().getProject();
      IServiceModelManager smm = ServiceModelManager.getInstance();
      IServiceConfiguration serviceConfig = smm.getActiveConfiguration(project);

      IService indexingService = smm.getService(IRDTServiceConstants.SERVICE_C_INDEX);

      IServiceProvider serviceProvider = serviceConfig.getServiceProvider(indexingService);

      if (serviceProvider instanceof IIndexServiceProvider) {
        ITypeHierarchyService service =
            ((IIndexServiceProvider) serviceProvider).getTypeHierarchyService();
        TypeHierarchyUtil.open(service, elements[0], fWorkbenchWindow);
      }
    }
  }
Ejemplo n.º 3
0
    private boolean matchQualifiedName(ITypeInfo info) {
      IQualifiedTypeName qualifiedName = info.getQualifiedTypeName();
      if (fSegmentMatchers.length != qualifiedName.segmentCount()) return false;

      if (fMatchGlobalNamespace) {
        // must match global namespace (eg ::foo)
        if (qualifiedName.segment(0).length() > 0) return false;
      }

      boolean matchFound = true;
      int max = Math.min(fSegmentMatchers.length, qualifiedName.segmentCount());
      for (int i = 0; i < max; ++i) {
        StringMatcher matcher = fSegmentMatchers[i];
        String name = qualifiedName.segment(i);
        if (name == null || !matcher.match(name)) {
          matchFound = false;
          break;
        }
      }
      return matchFound;
    }