예제 #1
0
  /*
   * @see IContentProvider#inputChanged(Viewer, Object, Object)
   */
  @Override
  public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
    final boolean isModule = newInput instanceof IErlModule;

    // ErlLogger.debug("content set input:: " + newInput);
    if (isModule && fListener == null) {
      // TODO fixme
      fListener = new ElementChangedListener(null);

      ErlModelManager.getErlangModel().addElementChangedListener(fListener);
    } else if (!isModule && fListener != null) {
      ErlModelManager.getErlangModel().removeElementChangedListener(fListener);
      fListener = null;
    }
  }
예제 #2
0
 @Override
 public void dispose() {
   if (fListener != null) {
     ErlModelManager.getErlangModel().removeElementChangedListener(fListener);
     fListener = null;
   }
 }
예제 #3
0
    private void findRefs(
        final IErlModule theModule, final ITextSelection aSelection, final boolean hasChanged) {
      final IBackend ideBackend = BackendCore.getBackendManager().getIdeBackend();
      fRefs = null;

      if (fCanceled) {
        return;
      }
      try {
        final int offset = aSelection.getOffset();
        final OpenResult res =
            ErlideOpen.open(
                ideBackend.getRpcSite(),
                theModule,
                offset,
                ModelUtils.getImportsAsList(theModule),
                "",
                ErlModelManager.getErlangModel().getPathVars());
        final ErlangSearchPattern pattern =
            SearchUtil.getSearchPatternFromOpenResultAndLimitTo(
                theModule, offset, res, LimitTo.ALL_OCCURRENCES, false);
        if (fCanceled) {
          return;
        }
        if (pattern != null) {
          final ErlSearchScope scope = new ErlSearchScope();
          scope.addModule(theModule);
          final List<ModuleLineFunctionArityRef> findRefs = Lists.newArrayList();
          // TODO: run in background? for large files, this can take
          // seconds
          final OtpErlangObject refs =
              ErlideSearchServer.findRefs(
                  ideBackend.getRpcSite(), pattern, scope, erlangEditor.getStateDir(), true);
          if (refs != null) {
            SearchUtil.addSearchResult(findRefs, refs);
            fRefs = erlangEditor.markOccurencesHandler.getErlangRefs(theModule, findRefs);
          }
        }
      } catch (final RpcTimeoutException e) {
        if (!ideBackend.isStopped()) {
          ErlLogger.warn(e);
        }
      } catch (final RpcException e) {
        ErlLogger.debug(e);
      } catch (final ErlModelException e) {
        ErlLogger.debug(e);
      } catch (final OtpErlangRangeException e) {
        ErlLogger.debug(e);
      }
      if (fRefs == null) {
        if (!erlangEditor.markOccurencesHandler.fStickyOccurrenceAnnotations) {
          erlangEditor.markOccurencesHandler.removeOccurrenceAnnotations();
        } else if (hasChanged) {
          erlangEditor.markOccurencesHandler.removeOccurrenceAnnotations();
        }
      }
    }
예제 #4
0
  @Override
  public Image getColumnImage(final Object element, final int columnIndex) {
    Image img = null;

    final ICoverageObject statsEl = (ICoverageObject) element;

    switch (columnIndex) {
      case 0:
        final ObjectType type = statsEl.getType();

        switch (type) {
          case FUNCTION:
            img = Activator.getImageDescriptor(Images.FUNCTION).createImage();
            break;
          case MODULE:
            IErlModule m;
            try {
              m = ErlModelManager.getErlangModel().findModule(statsEl.getLabel());
            } catch (final ErlModelException e) {
              e.printStackTrace();
              return null;
            }
            img =
                ErlangElementImageProvider.getErlImageDescriptor(
                        m, ErlangElementImageProvider.SMALL_ICONS)
                    .createImage();
            break;
          case FOLDER:
            img =
                PlatformUI.getWorkbench()
                    .getSharedImages()
                    .getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER)
                    .createImage();
            break;
          case PROJECT:
            img =
                PlatformUI.getWorkbench()
                    .getSharedImages()
                    .getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT)
                    .createImage();
            break;
        }
        break;
      case 3:
        img = drawPercentage(statsEl.getPercentage());
        break;
      default:
    }

    return img;
  }
예제 #5
0
 @Override
 public void launch(final ISelection selection, final String mode) {
   ErlLogger.debug("** Launch:: " + selection.toString());
   if (selection.isEmpty()) {
     return;
   }
   if (!(selection instanceof IStructuredSelection)) {
     return;
   }
   final Set<IErlProject> projects = Sets.newHashSet();
   final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
   for (final Object element : structuredSelection.toArray()) {
     if (!(element instanceof IResource)) {
       return;
     }
     final IErlElement erlElement =
         ErlModelManager.getErlangModel().findElement((IResource) element);
     final IErlProject project = ModelUtils.getProject(erlElement);
     if (project != null) {
       projects.add(project);
     }
   }
   if (projects.isEmpty()) {
     return;
   }
   projects.addAll(getDependentProjects(projects));
   final List<IErlProject> projectList = Lists.newArrayList(projects);
   Collections.sort(
       projectList,
       new Comparator<IErlProject>() {
         @Override
         public int compare(final IErlProject o1, final IErlProject o2) {
           return o1.getName().compareTo(o2.getName());
         }
       });
   try {
     doLaunch(mode, projectList);
   } catch (final CoreException e) {
     final IWorkbench workbench = PlatformUI.getWorkbench();
     final Shell shell = workbench.getActiveWorkbenchWindow().getShell();
     MessageDialog.openError(shell, "Error", e.getStatus().getMessage());
   }
 }