protected void toggleWatchpoint(
     IResource resource,
     int lineNumber,
     String fcn,
     String var,
     boolean access,
     boolean modification)
     throws CoreException {
   // look for existing watchpoint to delete
   IBreakpoint[] breakpoints =
       DebugPlugin.getDefault()
           .getBreakpointManager()
           .getBreakpoints(DebugCorePlugin.ID_PDA_DEBUG_MODEL);
   for (int i = 0; i < breakpoints.length; i++) {
     IBreakpoint breakpoint = breakpoints[i];
     if (breakpoint instanceof PDAWatchpoint
         && resource.equals(breakpoint.getMarker().getResource())) {
       PDAWatchpoint watchpoint = (PDAWatchpoint) breakpoint;
       String otherVar = watchpoint.getVariableName();
       String otherFcn = watchpoint.getFunctionName();
       if (otherVar.equals(var) && otherFcn.equals(fcn)) {
         breakpoint.delete();
         return;
       }
     }
   }
   // create watchpoint
   PDAWatchpoint watchpoint =
       new PDAWatchpoint(resource, lineNumber + 1, fcn, var, access, modification);
   DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(watchpoint);
 }
  @Override
  public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection)
      throws CoreException {
    AbstractTextEditor editor = getEditor(part);

    if (editor != null) {
      IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);

      ITextSelection textSelection = (ITextSelection) selection;

      int lineNumber = textSelection.getStartLine() + 1;

      IBreakpoint[] breakpoints =
          DebugPlugin.getDefault()
              .getBreakpointManager()
              .getBreakpoints(DartDebugCorePlugin.DEBUG_MODEL_ID);

      for (int i = 0; i < breakpoints.length; i++) {
        IBreakpoint breakpoint = breakpoints[i];

        if (resource.equals(breakpoint.getMarker().getResource())) {
          if (((ILineBreakpoint) breakpoint).getLineNumber() == lineNumber) {
            breakpoint.delete();
            return;
          }
        }
      }

      DartBreakpoint breakpoint = new DartBreakpoint(resource, lineNumber);

      DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(breakpoint);
    }
  }
  private static void terminate(final ILaunch previousLaunch) throws DebugException {
    final Object signal = new Object();
    final boolean[] terminated = {false};
    DebugPlugin debugPlugin = DebugPlugin.getDefault();
    debugPlugin.addDebugEventListener(
        new IDebugEventSetListener() {

          public void handleDebugEvents(final DebugEvent[] events) {
            for (int i = 0; i < events.length; i++) {
              DebugEvent event = events[i];
              if (isTerminateEventFor(event, previousLaunch)) {
                DebugPlugin.getDefault().removeDebugEventListener(this);
                synchronized (signal) {
                  terminated[0] = true;
                  signal.notifyAll();
                }
              }
            }
          }
        });
    previousLaunch.terminate();
    try {
      synchronized (signal) {
        if (!terminated[0]) {
          signal.wait();
        }
      }
    } catch (InterruptedException e) {
      // ignore
    }
  }
示例#4
0
 protected void terminated() {
   DebugPlugin manager = DebugPlugin.getDefault();
   if (manager != null) {
     DebugEvent event = new DebugEvent(this, DebugEvent.TERMINATE);
     manager.fireDebugEventSet(new DebugEvent[] {event});
   }
 }
  private static void execute(String commandLine, String[] expectedArgs, String expectedRendered)
      throws Exception {
    String[] arguments = DebugPlugin.parseArguments(commandLine);
    assertEquals(
        "unexpected parseArguments result;", //$NON-NLS-1$
        Arrays.asList(expectedArgs).toString(),
        Arrays.asList(arguments).toString());

    runCommandLine(commandLine, arguments);

    String rendered = DebugPlugin.renderArguments(arguments, null);
    assertEquals("unexpected renderArguments result;", expectedRendered, rendered); // $NON-NLS-1$

    if (!commandLine.equals(rendered)) {
      String[] arguments2 = DebugPlugin.parseArguments(rendered);
      assertEquals(
          "parsing rendered command line doesn't yield original arguments;", //$NON-NLS-1$
          Arrays.asList(expectedArgs).toString(),
          Arrays.asList(arguments2).toString());
    }

    String[] splitArguments = DebugPlugin.splitArguments(commandLine);
    assertEquals(expectedArgs.length, splitArguments.length);
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < splitArguments.length; i++) {
      if (i > 0) {
        sb.append(" "); // $NON-NLS-1$
      }
      sb.append(splitArguments[i]);
    }
    assertEquals(commandLine, sb.toString());
  }
 /* (non-Javadoc)
  * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
  */
 @Override
 public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection)
     throws CoreException {
   ITextEditor textEditor = getEditor(part);
   if (textEditor != null) {
     IResource resource = textEditor.getEditorInput().getAdapter(IResource.class);
     ITextSelection textSelection = (ITextSelection) selection;
     int lineNumber = textSelection.getStartLine();
     IBreakpoint[] breakpoints =
         DebugPlugin.getDefault()
             .getBreakpointManager()
             .getBreakpoints(DebugCorePlugin.ID_PDA_DEBUG_MODEL);
     for (int i = 0; i < breakpoints.length; i++) {
       IBreakpoint breakpoint = breakpoints[i];
       if (breakpoint instanceof ILineBreakpoint
           && resource.equals(breakpoint.getMarker().getResource())) {
         if (((ILineBreakpoint) breakpoint).getLineNumber() == (lineNumber + 1)) {
           // remove
           breakpoint.delete();
           return;
         }
       }
     }
     // create line breakpoint (doc line numbers start at 0)
     PDALineBreakpoint lineBreakpoint = new PDALineBreakpoint(resource, lineNumber + 1);
     DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(lineBreakpoint);
   }
 }
 public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection)
     throws CoreException {
   if (part instanceof IEditorPart) {
     IEditorPart editor = (IEditorPart) part;
     IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);
     ITextSelection textSelection = (ITextSelection) selection;
     int lineNumber = textSelection.getStartLine();
     IBreakpoint[] breakpoints =
         DebugPlugin.getDefault()
             .getBreakpointManager()
             .getBreakpoints(IDroolsDebugConstants.ID_DROOLS_DEBUG_MODEL);
     for (int i = 0; i < breakpoints.length; i++) {
       IBreakpoint breakpoint = breakpoints[i];
       if (resource.equals(breakpoint.getMarker().getResource())) {
         if (breakpoint.getMarker().getType().equals(IDroolsDebugConstants.DROOLS_MARKER_TYPE)) {
           if (((DroolsLineBreakpoint) breakpoint).getDRLLineNumber() == (lineNumber + 1)) {
             breakpoint.delete();
             return;
           }
         }
       }
     }
     // TODO: drools breakpoints can only be created in functions and consequences
     DroolsLineBreakpoint lineBreakpoint = new DroolsLineBreakpoint(resource, lineNumber + 1);
     DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(lineBreakpoint);
   }
 }
 /** Cleans up the process so that it will display as terminated. */
 protected void finish() {
   DebugPlugin manager = DebugPlugin.getDefault();
   if (manager != null) {
     manager.fireDebugEventSet(new DebugEvent[] {new DebugEvent(this, DebugEvent.TERMINATE)});
   }
   paused = false;
 }
  /**
   * Provide the initialization of the listeners additions. The Window, Part, and Document Listener
   * are added. Note that sensor shell should be instantiated before this method is called because
   * <code>processActivity()</code> method uses sensor shell instance.
   */
  private void registerListeners() {
    IWorkbench workbench = EclipseSensorPlugin.getInstance().getWorkbench();

    // :RESOLVED: JULY 1, 2003
    // Supports the multiple window for sensor collection.
    IWorkbenchWindow[] activeWindows = workbench.getWorkbenchWindows();

    // Check if window listener is not added yet. Otherwise multi instances are notified.
    if (this.windowListener == null) {
      this.windowListener = new WindowListenerAdapter();
      workbench.addWindowListener(new WindowListenerAdapter());
    }

    for (int i = 0; i < activeWindows.length; i++) {
      IWorkbenchPage activePage = activeWindows[i].getActivePage();
      activePage.addPartListener(new PartListenerAdapter());
      IEditorPart activeEditorPart = activePage.getActiveEditor();

      // Adds this EclipseSensorPlugin instance to IDocumentListener
      // only when activeEditorPart is the instance of ITextEditor
      // so that null case is also ignored.
      if (activeEditorPart instanceof ITextEditor) {
        // Sets activeTextEditor. Otherwise a first activated file would not be recorded.
        this.activeTextEditor = (ITextEditor) activeEditorPart;
        // Gets opened file since the initial opened file is not notified from IPartListener.
        URI fileResource = EclipseSensor.this.getFileResource(this.activeTextEditor);

        Map<String, String> keyValueMap = new HashMap<String, String>();
        keyValueMap.put(EclipseSensorConstants.SUBTYPE, "Open");
        keyValueMap.put(EclipseSensorConstants.UNIT_TYPE, EclipseSensorConstants.FILE);
        keyValueMap.put(
            EclipseSensorConstants.UNIT_NAME, EclipseSensor.this.extractFileName(fileResource));
        this.addDevEvent(
            EclipseSensorConstants.DEVEVENT_EDIT,
            fileResource,
            keyValueMap,
            "Opened " + fileResource.toString());

        IDocumentProvider provider = this.activeTextEditor.getDocumentProvider();
        IDocument document = provider.getDocument(activeEditorPart.getEditorInput());

        // Initially sets active buffer and threshold buffer.
        // Otherwise a first activated buffer would not be recorded.
        this.activeBufferSize = document.getLength();
        this.thresholdBufferSize = document.getLength();
        document.addDocumentListener(new DocumentListenerAdapter());
      }
    }

    // Handles breakpoint set/unset event.
    IBreakpointManager bpManager = DebugPlugin.getDefault().getBreakpointManager();
    bpManager.addBreakpointListener(new BreakPointerSensor(this));

    // Listens to debug event.
    DebugPlugin.getDefault().addDebugEventListener(new DebugSensor(this));

    // Creates instance to handle build error.
    this.buildErrorSensor = new BuildErrorSensor(this);
  }
  @Override
  protected void dispose() {
    super.dispose();

    if (DebugPlugin.getDefault() != null) {
      DebugPlugin.getDefault().removeDebugEventListener(this);
    }
  }
示例#11
0
 /**
  * Cleans up the internal state of this debug target as a result of a session ending with a VM (as
  * a result of a disconnect or termination of the VM).
  *
  * <p>All threads are removed from this target. This target is removed as a breakpoint listener,
  * and all breakpoints are removed from this target.
  */
 protected void cleanup() {
   removeAllThreads();
   DebugPlugin plugin = DebugPlugin.getDefault();
   plugin.getBreakpointManager().removeBreakpointListener(this);
   // plugin.getLaunchManager().removeLaunchListener(this);
   // plugin.getBreakpointManager().removeBreakpointManagerListener(this);
   // plugin.removeDebugEventListener(this);
   removeAllBreakpoints();
 }
 public void disconnected() {
   if (!disconnectAspect.isDisconnected()) {
     setDisconnected(true);
     DebugPlugin.getDefault()
         .getBreakpointManager()
         .removeBreakpointManagerListener(workspaceRelations.getBreakpointHandler());
     DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(debugTargetImpl);
     fireTerminateEvent();
   }
 }
  @Override
  public boolean finalLaunchCheck(
      ILaunchConfiguration configuration, String mode, IProgressMonitor monitor)
      throws CoreException {
    // Check for existing launches of same resource
    BndPreferences prefs = new BndPreferences();
    if (prefs.getWarnExistingLaunches()) {
      IResource launchResource = LaunchUtils.getTargetResource(configuration);
      if (launchResource == null)
        throw new CoreException(
            new Status(
                IStatus.ERROR,
                Plugin.PLUGIN_ID,
                0,
                "Bnd launch target was not specified or does not exist.",
                null));

      int processCount = 0;
      for (ILaunch l : DebugPlugin.getDefault().getLaunchManager().getLaunches()) {
        // ... is it the same launch resource?
        ILaunchConfiguration launchConfig = l.getLaunchConfiguration();
        if (launchConfig == null) {
          continue;
        }
        if (launchResource.equals(LaunchUtils.getTargetResource(launchConfig))) {
          // Iterate existing processes
          for (IProcess process : l.getProcesses()) {
            if (!process.isTerminated()) processCount++;
          }
        }
      }

      // Warn if existing processes running
      if (processCount > 0) {
        Status status =
            new Status(
                IStatus.WARNING,
                Plugin.PLUGIN_ID,
                0,
                "One or more OSGi Frameworks have already been launched for this configuration. Additional framework instances may interfere with each other due to the shared storage directory.",
                null);
        IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(status);
        if (prompter != null) {
          boolean okay = (Boolean) prompter.handleStatus(status, launchResource);
          if (!okay) return okay;
        }
      }
    }

    IStatus launchStatus = getLauncherStatus();

    IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(launchStatus);
    if (prompter != null) return (Boolean) prompter.handleStatus(launchStatus, model);
    return true;
  }
  private void cleanup() {

    ILaunch[] allLaunches = DebugPlugin.getDefault().getLaunchManager().getLaunches();
    if (allLaunches != null) {
      for (int i = 0; i < allLaunches.length; i++) {
        if (launch != allLaunches[i]) {
          DebugPlugin.getDefault().getLaunchManager().removeLaunch(allLaunches[i]);
        }
      }
    }
  }
 /* (non-Javadoc)
  * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
  */
 @Override
 public int compare(Object arg0, Object arg1) {
   IBreakpoint bp0 = (IBreakpoint) DebugPlugin.getAdapter(arg0, IBreakpoint.class);
   IBreakpoint bp1 = (IBreakpoint) DebugPlugin.getAdapter(arg1, IBreakpoint.class);
   if (bp0 != null && bp1 != null) {
     return doCompare(bp0, bp1);
   } else if (arg0 instanceof IBreakpointContainer && arg1 instanceof IBreakpointContainer) {
     return doCompare((IBreakpointContainer) arg0, (IBreakpointContainer) arg1);
   } else {
     return -1; // just return -1 if the two objects are not IBreakpoint type
   }
 }
  private static ILaunchConfiguration createLaunchConfigurationForProject(IJavaProject javaProject)
      throws CoreException {

    DebugPlugin plugin = DebugPlugin.getDefault();
    ILaunchManager manager = plugin.getLaunchManager();

    ILaunchConfigurationType javaAppType =
        manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
    ILaunchConfigurationWorkingCopy wc = javaAppType.newInstance(null, "temp-config");

    wc.setAttribute(
        IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, javaProject.getElementName());
    return wc;
  }
示例#17
0
 /**
  * Returns any logical value for the raw value. This method will recurse over the returned value
  * until the same structure is encountered again (to avoid infinite recursion).
  *
  * @param value raw value to possibly be replaced by a logical value
  * @param previousStructureIds the list of logical structures that have already been applied to
  *     the returned value during the recursion of this method. Callers should always pass in a
  *     new, empty list.
  * @return logical value if one is calculated, otherwise the raw value is returned
  */
 protected IValue getLogicalValue(
     IValue value, List previousStructureIds, IPresentationContext context) throws CoreException {
   if (isShowLogicalStructure(context)) {
     ILogicalStructureType[] types = DebugPlugin.getLogicalStructureTypes(value);
     if (types.length > 0) {
       ILogicalStructureType type = DebugPlugin.getDefaultStructureType(types);
       if (type != null && !previousStructureIds.contains(type.getId())) {
         IValue logicalValue = getLogicalStructureCache().getLogicalStructure(type, value);
         previousStructureIds.add(type.getId());
         return getLogicalValue(logicalValue, previousStructureIds, context);
       }
     }
   }
   return value;
 }
  protected ILaunch doLaunch(ILaunchConfiguration config, String testName)
      throws URISyntaxException, IOException, CoreException {
    ILaunch launch;
    IPath pathToFiles = getPathToFiles(testName);

    if (!ValgrindTestsPlugin.RUN_VALGRIND) {
      bindLocation(pathToFiles);
    }

    ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
    wc.setAttribute(
        LaunchConfigurationConstants.ATTR_INTERNAL_OUTPUT_DIR, pathToFiles.toOSString());
    wc.doSave();

    ValgrindTestLaunchDelegate delegate = new ValgrindTestLaunchDelegate();
    launch = new Launch(config, ILaunchManager.PROFILE_MODE, null);

    DebugPlugin.getDefault().getLaunchManager().addLaunch(launch);
    launches.add(launch);
    delegate.launch(config, ILaunchManager.PROFILE_MODE, launch, null);

    if (ValgrindTestsPlugin.RUN_VALGRIND) {
      unbindLocation(pathToFiles);
    }
    return launch;
  }
示例#19
0
 /**
  * Returns the logical structure cache to use to store calculated structures. If the cache does
  * not exist yet, one is created and a debug event listener is added to clear the cache on RESUME
  * and TERMINATE events.
  *
  * @return the logical structure cache to use
  */
 protected synchronized LogicalStructureCache getLogicalStructureCache() {
   if (fgLogicalCache == null) {
     fgLogicalCache = new LogicalStructureCache();
     // Add a listener to clear the cache when resuming, terminating, or suspending
     DebugPlugin.getDefault()
         .addDebugEventListener(
             new IDebugEventSetListener() {
               public void handleDebugEvents(DebugEvent[] events) {
                 for (int i = 0; i < events.length; i++) {
                   if (events[i].getKind() == DebugEvent.TERMINATE) {
                     fgLogicalCache.clear();
                     break;
                   } else if (events[i].getKind() == DebugEvent.RESUME
                       && events[i].getDetail() != DebugEvent.EVALUATION_IMPLICIT) {
                     fgLogicalCache.clear();
                     break;
                   } else if (events[i].getKind() == DebugEvent.SUSPEND
                       && events[i].getDetail() != DebugEvent.EVALUATION_IMPLICIT) {
                     fgLogicalCache.clear();
                     break;
                   } else if (events[i].getKind() == DebugEvent.CHANGE
                       && events[i].getDetail() == DebugEvent.CONTENT) {
                     fgLogicalCache.clear();
                     break;
                   }
                 }
               }
             });
   }
   return fgLogicalCache;
 }
 public static ILaunchConfiguration[] getVerifierLaunchConfigs() throws CoreException {
   ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
   ILaunchConfigurationType veriferLaunchType =
       manager.getLaunchConfigurationType(VerifierLaunchConfiguration.LAUNCH_ID);
   ILaunchConfiguration[] cfgs = manager.getLaunchConfigurations(veriferLaunchType);
   return cfgs;
 }
  /**
   * Validates if the drop is valid by validating the local selection transfer to ensure that a
   * watch expression can be created for each contained IVariable.
   *
   * @param target target of the drop
   * @return whether the drop is valid
   */
  private boolean validateVariableDrop(Object target) {
    // Target must be null or an IExpression, you cannot add a new watch expression inside another
    if (target != null && getTargetExpression(target) == null) {
      return false;
    }

    IStructuredSelection selection =
        (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
    int enabled = 0;
    int size = -1;
    if (selection != null) {
      size = selection.size();
      IExpressionManager manager = DebugPlugin.getDefault().getExpressionManager();
      Iterator iterator = selection.iterator();
      while (iterator.hasNext()) {
        Object element = iterator.next();
        if (element instanceof IVariable) {
          IVariable variable = (IVariable) element;
          if (variable instanceof IndexedVariablePartition) {
            break;
          } else if (manager.hasWatchExpressionDelegate(variable.getModelIdentifier())
              && isFactoryEnabled(variable)) {
            enabled++;
          } else {
            break;
          }
        }
      }
    }
    return enabled == size;
  }
  protected ILaunch buildAndLaunch(
      ILaunchConfiguration configuration, String mode, IProgressMonitor monitor)
      throws CoreException {
    monitor.beginTask("", 1); // $NON-NLS-1$
    try {
      MavenLaunchDelegate mvld = new TalendMavenLaunchDelegate();
      ILaunch launch = new Launch(configuration, mode, null);
      ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
      launch.setAttribute(
          DebugPlugin.ATTR_LAUNCH_TIMESTAMP, Long.toString(System.currentTimeMillis()));
      launch.setAttribute(
          DebugPlugin.ATTR_CONSOLE_ENCODING, launchManager.getEncoding(configuration));
      if (isCaptureOutputInConsoleView()) {
        launchManager.addLaunch(launch);
      }

      String type = "org.eclipse.m2e.launching.MavenSourceLocator"; // $NON-NLS-1$
      IPersistableSourceLocator locator = launchManager.newSourceLocator(type);
      locator.initializeDefaults(configuration);
      launch.setSourceLocator(locator);
      mvld.launch(configuration, mode, launch, monitor);
      return launch;
    } finally {
      monitor.done();
    }
  }
示例#23
0
 public SimulationView() {
   DebugUITools.getDebugContextManager().addDebugContextListener(this);
   DebugPlugin.getDefault().addDebugEventListener(this);
   kit = new FormToolkit(Display.getDefault());
   font = new Font(Display.getDefault(), new FontData("Courier", 10, SWT.BOLD));
   clockUpdater = new ClockUpdater();
 }
    public void handleDebugEvents(DebugEvent[] events) {
      if (events != null && project != null) {
        int size = events.length;
        for (int i = 0; i < size; i++) {
          for (IProcess process : processes) {
            if (process != null
                && process.equals(events[i].getSource())
                && events[i].getKind() == DebugEvent.TERMINATE) {

              DebugPlugin.getDefault().removeDebugEventListener(this);
              terminateForked();
              Job job =
                  new Job("refresh project") {

                    @Override
                    protected IStatus run(IProgressMonitor monitor) {
                      try {
                        project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
                      } catch (CoreException e) {
                      }
                      GrailsCoreActivator.getDefault().notifyCommandFinish(project);
                      return Status.OK_STATUS;
                    }
                  };
              job.setSystem(true);
              job.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule());
              job.setPriority(Job.INTERACTIVE);
              job.schedule();
            }
          }
        }
      }
    }
 /**
  * Resolves the {@link IBreakpoint} from the given editor and ruler information. Returns <code>
  * null</code> if no breakpoint exists or the operation fails.
  *
  * @param editor the editor
  * @param info the current ruler information
  * @return the {@link IBreakpoint} from the current editor position or <code>null</code>
  */
 protected IBreakpoint getBreakpointFromEditor(ITextEditor editor, IVerticalRulerInfo info) {
   IAnnotationModel annotationModel =
       editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
   IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
   if (annotationModel != null) {
     @SuppressWarnings("unchecked")
     Iterator<Annotation> iterator = annotationModel.getAnnotationIterator();
     while (iterator.hasNext()) {
       Object object = iterator.next();
       if (object instanceof SimpleMarkerAnnotation) {
         SimpleMarkerAnnotation markerAnnotation = (SimpleMarkerAnnotation) object;
         IMarker marker = markerAnnotation.getMarker();
         try {
           if (marker.isSubtypeOf(IBreakpoint.BREAKPOINT_MARKER)) {
             Position position = annotationModel.getPosition(markerAnnotation);
             int line = document.getLineOfOffset(position.getOffset());
             if (line == info.getLineOfLastMouseButtonActivity()) {
               IBreakpoint breakpoint =
                   DebugPlugin.getDefault().getBreakpointManager().getBreakpoint(marker);
               if (breakpoint != null) {
                 return breakpoint;
               }
             }
           }
         } catch (CoreException e) {
         } catch (BadLocationException e) {
         }
       }
     }
   }
   return null;
 }
  @Override
  public void setupLaunchConfiguration(
      ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) throws CoreException {

    super.setupLaunchConfiguration(workingCopy, monitor);

    workingCopy.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, "UTF-8"); // $NON-NLS-1$

    String existingVMArgs =
        workingCopy.getAttribute(
            IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String) null);

    if (null != existingVMArgs) {
      String[] parsedVMArgs = DebugPlugin.parseArguments(existingVMArgs);

      List<String> memoryArgs = new ArrayList<String>();

      if (!CoreUtil.isNullOrEmpty(parsedVMArgs)) {
        for (String pArg : parsedVMArgs) {
          if (pArg.startsWith("-Xm") || pArg.startsWith("-XX:")) // $NON-NLS-1$ //$NON-NLS-2$
          {
            memoryArgs.add(pArg);
          }
        }
      }

      String argsWithoutMem =
          mergeArguments(
              existingVMArgs, getRuntimeVMArguments(), memoryArgs.toArray(new String[0]), false);
      String fixedArgs = mergeArguments(argsWithoutMem, getRuntimeVMArguments(), null, false);

      workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, fixedArgs);
    }
  }
示例#27
0
  @Override
  protected GocodeServerInstance doCreateServerInstance(IOperationMonitor om)
      throws CommonException, OperationCancellation {
    Path gocodePath = getServerPath();

    ArrayList2<String> commandLine = new ArrayList2<String>();
    commandLine.add(gocodePath.toString());
    commandLine.add("-s");
    if (GocodeCompletionOperation.USE_TCP) {
      commandLine.add("-sock=tcp");
    }

    LangCore.logInfo(
        "Starting gocode server: "
            + DebugPlugin.renderArguments(commandLine.toArray(String.class), null));

    ProcessBuilder pb = new ProcessBuilder(commandLine);

    IToolOperationMonitor opMonitor =
        toolMgr.startNewOperation(ProcessStartKind.ENGINE_SERVER, true, false);
    String prefixText = "==== Starting gocode server ====\n";

    gocodeSetEnableBuiltins(gocodePath, om, opMonitor, prefixText);

    ExternalProcessNotifyingHelper process =
        toolMgr.new RunToolTask(opMonitor, prefixText, null, pb, om).startProcess();

    return new GocodeServerInstance(gocodePath, process);
  }
示例#28
0
 @Override
 public void stepInto() throws DebugException {
   target.sendRequest(GHCiSyntax.STEP_COMMAND, true);
   DebugPlugin.getDefault()
       .fireDebugEventSet(
           new DebugEvent[] {new DebugEvent(frame, DebugEvent.CHANGE, DebugEvent.CONTENT)});
 }
示例#29
0
  public IBreakpoint findIBreakpoint(String filename, int lineNumber) {
    IBreakpoint[] breakpoints =
        DebugPlugin.getDefault()
            .getBreakpointManager()
            .getBreakpoints(this.debugServiceFactory.getLIConstants().getDebugModel());
    for (int i = 0; i < breakpoints.length; i++) {
      IBreakpoint breakpoint = breakpoints[i];
      if (supportsBreakpoint(breakpoint)) {

        try {
          if (breakpoint.isEnabled()) {
            // only add the breakpoint to the debugger when the
            // breakpoint is enabled
            int l = breakpoint.getMarker().getAttribute(IMarker.LINE_NUMBER, -1);
            // TODO: get marker language type or get language from
            // the resource
            IResource r = breakpoint.getMarker().getResource();
            String location = r.getProjectRelativePath().toOSString();
            if (l > 0) {
              // only linenumbers greater than 0 are valid as
              // linenumber is 1-based
              if (location.equals(filename) && lineNumber == l) {
                return breakpoint;
              }
            }
          }
        } catch (CoreException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    }
    return null;
  }
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite contents = (Composite) super.createDialogArea(parent);

    setTitle(Messages.ManageLaunchesDialog_manageLaunches);
    setTitleImage(DartDebugUIPlugin.getImage("wiz/run_wiz.png")); // $NON-NLS-1$

    Composite composite = new Composite(contents, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(composite);
    createDialogUI(composite);

    DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(this);

    parent.addDisposeListener(
        new DisposeListener() {
          @Override
          public void widgetDisposed(DisposeEvent e) {
            DebugPlugin.getDefault()
                .getLaunchManager()
                .removeLaunchConfigurationListener(ManageLaunchesDialog.this);
          }
        });

    return contents;
  }