예제 #1
0
 @Override
 protected void log(final IStatus status) {
   RConsoleCorePlugin.log(status);
 }
예제 #2
0
  @Override
  public void doSubmitFileCommandToConsole(
      final String[] lines,
      final SrcfileData srcfile,
      final ISourceUnit su,
      final IProgressMonitor monitor)
      throws CoreException {
    if (srcfile != null
        && su instanceof IRWorkspaceSourceUnit
        && su.getModelTypeId() == RModel.TYPE_ID) {
      try {
        final IRModelInfo modelInfo =
            (IRModelInfo) su.getModelInfo(RModel.TYPE_ID, IRModelManager.MODEL_FILE, monitor);
        if (modelInfo != null) {
          final IRLangSourceElement fileElement = modelInfo.getSourceElement();
          final RAstNode rootNode = (RAstNode) fileElement.getAdapter(IAstNode.class);
          final List<? extends IRLangSourceElement> elements =
              modelInfo.getSourceElement().getSourceChildren(TAG_ELEMENT_FILTER);

          final List<String> elementIds = new ArrayList<String>(elements.size());
          final List<RObject> elementIndexes = new ArrayList<RObject>(elements.size());

          for (final IRLangSourceElement element : elements) {
            final FDef fdef = (FDef) element.getAdapter(FDef.class);
            if (fdef != null) {
              final String elementId = RDbg.getElementId(element);
              final RAstNode cont = fdef.getContChild();
              final int[] path = RAst.computeRExpressionIndex(cont, rootNode);
              if (elementId != null && path != null) {
                elementIds.add(elementId);
                elementIndexes.add(
                    fRObjectFactory.createVector(fRObjectFactory.createIntData(path)));
              }
            }
          }

          final FunctionCall prepare =
              createFunctionCall("rj:::.statet.prepareSource"); // $NON-NLS-1$
          prepare.add(
              fRObjectFactory.createList(
                  new RObject[] {
                    fRObjectFactory.createVector(
                        fRObjectFactory.createCharData(new String[] {srcfile.getPath()})),
                    fRObjectFactory.createVector(
                        fRObjectFactory.createNumData(new double[] {srcfile.getTimestamp()})),
                    fRObjectFactory.createVector(
                        fRObjectFactory.createIntData(new int[] {rootNode.getChildCount()})),
                    fRObjectFactory.createList(
                        elementIndexes.toArray(new RObject[elementIndexes.size()]),
                        elementIds.toArray(new String[elementIds.size()])),
                  },
                  new String[] {
                    "path", "timestamp", "exprsLength", "elementIds"
                  })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
          prepare.evalVoid(monitor);
        }
      } catch (final CoreException e) {
        RConsoleCorePlugin.log(
            new Status(
                IStatus.ERROR,
                RConsoleCorePlugin.PLUGIN_ID,
                -1,
                NLS.bind(
                    "An error occurred when preparing element tagging for file ''{0}''.",
                    srcfile.getPath()),
                e));
      }
    }
    super.doSubmitFileCommandToConsole(lines, srcfile, su, monitor);
  }