/** * Creates an {@link ILaunchConfiguration} containing the information of this instance, only available when run * within the Eclipse IDE. If an {@link ILaunchConfiguration} with the same name has been run before, the instance * from the launch manager is used. This is usually done in the {@code ILaunchShortcut}. * * @see #fromLaunchConfiguration(ILaunchConfiguration) */ public ILaunchConfiguration toLaunchConfiguration() throws CoreException { ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurations(configurationType); boolean configurationHasChanged = false; for (ILaunchConfiguration config : configs) { if (configName.equals(config.getName())) { configurationHasChanged = hasConfigurationChanged(config); if (!configurationHasChanged) { return config; } } } IContainer container = null; ILaunchConfigurationWorkingCopy workingCopy = configurationType.newInstance(container, configName); workingCopy.setAttribute(XT_FILE_TO_RUN, xtFileToRun); workingCopy.setAttribute(WORKING_DIRECTORY, workingDirectory.getAbsolutePath()); return workingCopy.doSave(); }
/** * Converts a {@link TestConfiguration} to an {@link ILaunchConfiguration}. Will throw a {@link WrappedException} in * case of error. * * @see TestConfiguration#readPersistentValues() */ public ILaunchConfiguration toLaunchConfiguration(ILaunchConfigurationType type, TestConfiguration testConfig) { try { final ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurations(type); for (ILaunchConfiguration config : configs) { if (equals(testConfig, config)) return config; } final IContainer container = null; final ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(container, testConfig.getName()); workingCopy.setAttributes(testConfig.readPersistentValues()); return workingCopy.doSave(); } catch (Exception e) { throw new WrappedException("could not convert N4JS TestConfiguration to Eclipse ILaunchConfiguration", e); } }
/** * Converts a {@link RunConfiguration} to an {@link ILaunchConfiguration}. Will throw a {@link WrappedException} in * case of error. * * @see RunConfiguration#readPersistentValues() */ public ILaunchConfiguration toLaunchConfiguration(ILaunchConfigurationType type, RunConfiguration runConfig) { try { final ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurations(type); for (ILaunchConfiguration config : configs) { if (equals(runConfig, config)) return config; } final IContainer container = null; final ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(container, runConfig.getName()); workingCopy.setAttributes(runConfig.readPersistentValues()); return workingCopy.doSave(); } catch (Exception e) { throw new WrappedException("could not convert N4JS RunConfiguration to Eclipse ILaunchConfiguration", e); } }
/** * Launch a file, using the file information, which means using default launch configurations. */ protected void launchFile(IFile originalFileToRun, String mode) { final String runnerId = getRunnerId(); final String path = originalFileToRun.getFullPath().toOSString(); final URI moduleToRun = URI.createPlatformResourceURI(path, true); final String implementationId = chooseImplHelper.chooseImplementationIfRequired(runnerId, moduleToRun); if (implementationId == ChooseImplementationHelper.CANCEL) return; RunConfiguration runConfig = runnerFrontEnd.createConfiguration(runnerId, implementationId, moduleToRun); ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(getLaunchConfigTypeID()); DebugUITools.launch(runConfigConverter.toLaunchConfiguration(type, runConfig), mode); // execution dispatched to proper delegate LaunchConfigurationDelegate }
/** * Returns a new executor that will delegate execution to {@link DebugPlugin#exec(String[], File, String[])} for * execution within the Eclipse launch framework. This executor is intended for the UI case. * * @see RunnerFrontEnd#createDefaultExecutor() */ public IExecutor createEclipseExecutor() { return new IExecutor() { @Override public Process exec(String[] cmdLine, File workingDirectory, Map<String, String> envp) throws ExecutionException { String[] envpArray = envp.entrySet().stream() .map(pair -> pair.getKey() + "=" + pair.getValue()) .toArray(String[]::new); try { return DebugPlugin.exec(cmdLine, workingDirectory, envpArray); } catch (CoreException e) { throw new ExecutionException(e); } } }; }
/** * Handles the given {@link TerminatedReply}. * * @param terminatedReply * the {@link TerminatedReply} */ private void handleTerminatedReply(TerminatedReply terminatedReply) { final String threadName = terminatedReply.getThreadName(); if (threadName == null) { // EMF model change factory.getModelUpdater().terminatedReply(getHost()); // unregister as a breakpoint listener DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this); // Eclipse change fireTerminateEvent(); } else { // EMF model change Thread eThread = DebugTargetUtils.getThread(getHost(), threadName); factory.getModelUpdater().terminatedReply(eThread); // Eclipse change DSLThreadAdapter thread = factory.getThread(eThread); thread.fireTerminateEvent(); // notify current instruction listeners StackFrame eFrame = eThread.getTopStackFrame(); while (eFrame != null) { fireCurrentInstructionTerminatedEvent(eFrame); eFrame = eFrame.getParentFrame(); } } }
/** * {@inheritDoc} * * @see org.eclipse.debug.core.model.IThread#getBreakpoints() */ public IBreakpoint[] getBreakpoints() { final List<IBreakpoint> res = new ArrayList<IBreakpoint>(); if (isSuspended()) { final URI instructionUri = EcoreUtil.getURI(getHost().getTopStackFrame().getCurrentInstruction()); for (IBreakpoint breakpoint : DebugPlugin.getDefault().getBreakpointManager().getBreakpoints( getModelIdentifier())) { if (breakpoint instanceof DSLBreakpoint && (((DSLBreakpoint)breakpoint).getURI().equals(instructionUri))) { res.add(breakpoint); } } } return res.toArray(new IBreakpoint[res.size()]); }
/** * {@inheritDoc} * * @see org.eclipse.sirius.tools.api.ui.IExternalJavaAction#execute(java.util.Collection, java.util.Map) */ public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters) { final ILaunchConfigurationType launchConfigType = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurationType(getLaunchConfigurationTypeID()); Set<String> modes = new HashSet<String>(); modes.add("debug"); try { ILaunchDelegate[] delegates = launchConfigType.getDelegates(modes); if (delegates.length != 0 && delegates[0].getDelegate() instanceof AbstractDSLLaunchConfigurationDelegateUI) { AbstractDSLLaunchConfigurationDelegateUI delegate = (AbstractDSLLaunchConfigurationDelegateUI)delegates[0] .getDelegate(); delegate.launch(delegate.getLaunchableResource(PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage().getActiveEditor()), getFirstInstruction(selections), "debug"); } } catch (CoreException e) { DebugSiriusIdeUiPlugin.getPlugin().getLog().log( new Status(IStatus.ERROR, DebugSiriusIdeUiPlugin.ID, e.getLocalizedMessage(), e)); } }
/** * Gets the {@link DSLBreakpoint} for the given {@link EObject instruction}. * * @param instruction * the {@link EObject instruction} * @return the {@link DSLBreakpoint} for the given {@link EObject instruction} if nay, <code>null</code> * otherwise */ protected DSLBreakpoint getBreakpoint(EObject instruction) { DSLBreakpoint res = null; IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager() .getBreakpoints(identifier); final URI instructionURI = EcoreUtil.getURI(instruction); for (IBreakpoint breakpoint : breakpoints) { if (breakpoint instanceof DSLBreakpoint && ((DSLBreakpoint)breakpoint).getURI() != null && ((DSLBreakpoint)breakpoint).getURI().equals(instructionURI)) { res = (DSLBreakpoint)breakpoint; break; } } return res; }
public static void cleanWorkspace() throws CoreException { IProject[] projects = getRoot().getProjects(); deleteProjects(projects); IProject[] otherProjects = getRoot().getProjects(IContainer.INCLUDE_HIDDEN); deleteProjects(otherProjects); ILaunchConfigurationType configType = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurationType(GW4ELaunchShortcut.GW4ELAUNCHCONFIGURATIONTYPE); ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurations(configType); for (int i = 0; i < configs.length; i++) { ILaunchConfiguration config = configs[i]; config.delete(); } }
private ILaunchConfiguration findConfig() { if (cachedGenerated != null) { return cachedGenerated; } try { for (ILaunchConfiguration config : DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(getType())) { if (config.getName().equals(generator.fullName(cfg))) { cachedGenerated = config; break; } } } catch (CoreException e) { LcDslInternalHelper.log(IStatus.WARNING, "cannot lookup launch configuration", e); } return cachedGenerated; }
private void addLaunchCfg() { try { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager .getLaunchConfigurationType("org.eclipse.pde.ui.RuntimeWorkbench"); ILaunchConfiguration[] lcs = manager.getLaunchConfigurations(type); List<ILaunchConfiguration> configList = Arrays.asList(lcs); List<String> configs = configList.stream().map(config -> config.getName()).collect(Collectors.toList()); ComboDialog dialog = new ComboDialog(getShell(), true); dialog.setTitle("Choose launch config"); dialog.setInfoText("Choose Eclipse launch conguration to edit it's configuration settings"); dialog.setAllowedValues(configs); if (dialog.open() == OK) { String selectedName = dialog.getValue(); ILaunchConfiguration selectedConfig = configList.stream().filter(config -> selectedName.equals(config.getName())).findFirst().get(); String configLocation = getConfigLocation(selectedConfig); valueAdded(new File(configLocation, ".settings").getAbsolutePath()); buttonPressed(IDialogConstants.OK_ID); } } catch (CoreException e) { PrefEditorPlugin.log(e); } }
@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(DSPPlugin.ID_DSP_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) DSPLineBreakpoint lineBreakpoint = new DSPLineBreakpoint(resource, lineNumber + 1); DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(lineBreakpoint); } }
private static String[] constructLaunchCommand(Map<String, ? extends Argument> launchingOptions, String address) { final String javaHome = launchingOptions.get(DebugUtility.HOME).value(); final String javaExec = launchingOptions.get(DebugUtility.EXEC).value(); final String slash = System.getProperty("file.separator"); boolean suspend = Boolean.valueOf(launchingOptions.get(DebugUtility.SUSPEND).value()); final String javaOptions = launchingOptions.get(DebugUtility.OPTIONS).value(); final String main = launchingOptions.get(DebugUtility.MAIN).value(); StringBuilder execString = new StringBuilder(); execString.append("\"" + javaHome + slash + "bin" + slash + javaExec + "\""); execString.append(" -Xdebug -Xnoagent -Djava.compiler=NONE"); execString.append(" -Xrunjdwp:transport=dt_socket,address=" + address + ",server=n,suspend=" + (suspend ? "y" : "n")); if (javaOptions != null) { execString.append(" " + javaOptions); } execString.append(" " + main); return DebugPlugin.parseArguments(execString.toString()); }
public void evaluate(String expression, InvocationResult listener) { IExpressionManager expressionManager = DebugPlugin.getDefault().getExpressionManager(); StackFrameModel stackFrame = getTopFrame(); IWatchExpressionDelegate delegate = expressionManager.newWatchExpressionDelegate(stackFrame.getStackFrame().getModelIdentifier()); delegate.evaluateExpression(expression, stackFrame.getStackFrame(), new IWatchExpressionListener() { public void watchEvaluationFinished(IWatchExpressionResult result) { listener.valueReturn(result.getValue()); // setChanged(); // notifyObservers(new Event<IStackFrameModel>(Event.Type.EVALUATION, getTopFrame())); // try { // evaluationNotify(); // } catch (DebugException e) { // e.printStackTrace(); // } } }); }
public void invoke(String methodName, InvocationResult listener, String ... args) { IExpressionManager expressionManager = DebugPlugin.getDefault().getExpressionManager(); StackFrameModel stackFrame = getRuntimeModel().getTopFrame(); IWatchExpressionDelegate delegate = expressionManager.newWatchExpressionDelegate(stackFrame.getStackFrame().getModelIdentifier()); // List<String> refPaths = getRuntimeModel().findReferencePaths(this); // if(refPaths.isEmpty()) // return; ReferencePath refPath = getRuntimeModel().findReferencePaths(this); if(refPath == null) return; // String exp = refPaths.get(0) + "." + methodName + "(" + String.join(", ", args) + ")"; String exp = refPath.referencePath + "." + methodName + "(" + String.join(", ", args) + ")"; // IStackFrame context = getRuntimeModel().getFirstVisibleFrame().getStackFrame(); delegate.evaluateExpression(exp, refPath.context, new ExpressionListener(exp, listener)); }
@Before public void setup() throws Exception { javaProject1 = new JavaProjectKit("project1"); javaProject2 = new JavaProjectKit("project2"); preferences = new TestPreferences(); filter = new DefaultScopeFilter(preferences); configuration = DebugPlugin .getDefault() .getLaunchManager() .getLaunchConfigurationType( "org.eclipse.jdt.launching.localJavaApplication") .newInstance(javaProject1.project, "test.launch"); rootSrc1 = javaProject1.createSourceFolder("src1"); rootSrc2 = javaProject2.createSourceFolder("testsrc"); rootBin1 = javaProject1.createJAR("testdata/bin/signatureresolver.jar", "/sample.jar", new Path("/UnitTestProject/sample.jar"), null); JavaProjectKit.waitForBuild(); }
/** * Determines all current coverage launches which are running. * * @return list of running coverage launches */ public static List<ICoverageLaunch> getRunningCoverageLaunches() { final List<ICoverageLaunch> result = new ArrayList<ICoverageLaunch>(); for (final ILaunch launch : DebugPlugin.getDefault().getLaunchManager() .getLaunches()) { if (launch instanceof ICoverageLaunch && !launch.isTerminated()) { result.add((ICoverageLaunch) launch); } } return result; }
@VisibleForTesting static ILaunchConfiguration createMavenPackagingLaunchConfiguration(IProject project) throws CoreException { ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType launchConfigurationType = launchManager .getLaunchConfigurationType(MavenLaunchConstants.LAUNCH_CONFIGURATION_TYPE_ID); String launchConfigName = "CT4E App Engine flexible Maven deploy artifact packaging " + project.getLocation().toString().replaceAll("[^a-zA-Z0-9]", "_"); ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance( null /*container*/, launchConfigName); workingCopy.setAttribute(ILaunchManager.ATTR_PRIVATE, true); // IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND; workingCopy.setAttribute("org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND", true); workingCopy.setAttribute(MavenLaunchConstants.ATTR_POM_DIR, project.getLocation().toString()); workingCopy.setAttribute(MavenLaunchConstants.ATTR_GOALS, "package"); workingCopy.setAttribute(RefreshUtil.ATTR_REFRESH_SCOPE, "${project}"); workingCopy.setAttribute(RefreshUtil.ATTR_REFRESH_RECURSIVE, true); IPath jreContainerPath = getJreContainerPath(project); workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, jreContainerPath.toString()); return workingCopy; }
@Override @SuppressWarnings("rawtypes") public Map getParameterValues() { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); Map<String, String> modes = new HashMap<>(); for (String modeId : LocalAppEngineServerLaunchConfigurationDelegate.SUPPORTED_LAUNCH_MODES) { ILaunchMode mode = manager.getLaunchMode(modeId); if (mode != null) { // label is intended to be shown in menus and buttons and often has // embedded '&' for mnemonics, which isn't useful here String label = mode.getLabel(); label = label.replace("&", ""); modes.put(label, mode.getIdentifier()); } } return modes; }
private ILaunchConfiguration[] getConfigurations(IFile file) { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType(LAUNCH_CONFIG_TYPE_CODE_ANALYSIS); try { // configurations that match the given resource List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>(); // candidates ILaunchConfiguration[] candidates = manager.getLaunchConfigurations(type); String name = FileUtils.getRelativePath(file); for (ILaunchConfiguration config : candidates) { String fileName = config.getAttribute(CAL_XDF.longName(), ""); if (fileName.equals(name)) { configs.add(config); } } return configs.toArray(new ILaunchConfiguration[] {}); } catch (Exception e) { e.printStackTrace(); return null; } }
private ILaunchConfiguration[] getConfigurations(IFile file) { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType(LAUNCH_CONFIG_TYPE_NUMA_EXECUTION_ANALYSIS); try { // configurations that match the given resource List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>(); // candidates ILaunchConfiguration[] candidates = manager.getLaunchConfigurations(type); String name = FileUtils.getRelativePath(file); for (ILaunchConfiguration config : candidates) { String fileName = config.getAttribute(CAL_XDF.longName(), ""); if (fileName.equals(name)) { configs.add(config); } } return configs.toArray(new ILaunchConfiguration[] {}); } catch (Exception e) { e.printStackTrace(); return null; } }
private ILaunchConfiguration[] getConfigurations(IFile file) { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType(LAUNCH_CONFIG_TYPE_TABU_PERFORMANCE_ESTMATION_ANALYSIS); try { // configurations that match the given resource List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>(); // candidates ILaunchConfiguration[] candidates = manager.getLaunchConfigurations(type); String name = FileUtils.getRelativePath(file); for (ILaunchConfiguration config : candidates) { String fileName = config.getAttribute(CAL_XDF.longName(), ""); if (fileName.equals(name)) { configs.add(config); } } return configs.toArray(new ILaunchConfiguration[] {}); } catch (Exception e) { e.printStackTrace(); return null; } }
private ILaunchConfiguration[] getConfigurations(IFile file) { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager .getLaunchConfigurationType(LAUNCH_CONFIG_TYPE_DYNAMIC_EXECUTION_ANALYSIS); try { // configurations that match the given resource List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>(); // candidates ILaunchConfiguration[] candidates = manager.getLaunchConfigurations(type); String name = FileUtils.getRelativePath(file); for (ILaunchConfiguration config : candidates) { String fileName = config.getAttribute(CAL_XDF.longName(), ""); if (fileName.equals(name)) { configs.add(config); } } return configs.toArray(new ILaunchConfiguration[] {}); } catch (Exception e) { e.printStackTrace(); return null; } }
private ILaunchConfiguration[] getConfigurations(IFile file) { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType(LAUNCH_CONFIG_TYPE_DYNAMIC_INTERPRETER_ANALYSIS); try { // configurations that match the given resource List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>(); // candidates ILaunchConfiguration[] candidates = manager.getLaunchConfigurations(type); String name = FileUtils.getRelativePath(file); for (ILaunchConfiguration config : candidates) { String fileName = config.getAttribute(CAL_XDF.longName(), ""); if (fileName.equals(name)) { configs.add(config); } } return configs.toArray(new ILaunchConfiguration[] {}); } catch (Exception e) { e.printStackTrace(); return null; } }
/** * Creates an ant build configuration {@link ILaunchConfiguration} * * @param configName * name of the configuration to be created * @param targets * ant targets to be called * @param buildPath * path to build.xml file * @param projectName * name of the projects * @return ant build configuration */ private static ILaunchConfiguration createAntBuildConfig(String configName, String targets, String buildPath, String projectName) throws CoreException { ILaunchConfiguration launchCfg; ILaunchConfigurationType type = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurationType("org.eclipse.ant.AntLaunchConfigurationType"); ILaunchConfigurationWorkingCopy config = null; config = type.newInstance(null, configName); config.setAttribute("org.eclipse.ui.externaltools.ATTR_ANT_TARGETS", targets); config.setAttribute("org.eclipse.ui.externaltools.ATTR_CAPTURE_OUTPUT", true); config.setAttribute("org.eclipse.ui.externaltools.ATTR_LOCATION", buildPath); config.setAttribute("org.eclipse.ui.externaltools.ATTR_SHOW_CONSOLE", true); config.setAttribute("org.eclipse.ui.externaltools.ATTR_ANT_PROPERTIES", Collections.<String, String>emptyMap()); config.setAttribute("org.eclipse.ant.ui.DEFAULT_VM_INSTALL", true); config.setAttribute("org.eclipse.jdt.launching.MAIN_TYPE", "org.eclipse.ant.internal.launching.remote.InternalAntRunner"); config.setAttribute("org.eclipse.jdt.launching.PROJECT_ATTR", projectName); config.setAttribute("org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER", "org.eclipse.ant.ui.AntClasspathProvider"); config.setAttribute("process_factory_id", "org.eclipse.ant.ui.remoteAntProcessFactory"); if (configName.equals(PLATFORM_BUILD_CONFIG) || configName.equals(PLATFORM_CLEAN_BUILD_CONFIG)) { config.setAttribute("org.eclipse.debug.core.ATTR_REFRESH_SCOPE", "${workspace}"); } launchCfg = config.doSave(); return launchCfg; }
private static ILaunchConfiguration chooseLaunchConfiguration(String workingDir, String operation) { try { ILaunchConfigurationType ngLaunchConfigurationType = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurationType(AngularCLILaunchConstants.LAUNCH_CONFIGURATION_ID); ILaunchConfiguration[] ngConfigurations = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurations(ngLaunchConfigurationType); for (ILaunchConfiguration conf : ngConfigurations) { if (workingDir.equals(conf.getAttribute(AngularCLILaunchConstants.WORKING_DIR, (String) null)) && operation.equals(conf.getAttribute(AngularCLILaunchConstants.OPERATION, (String) null))) { return conf; } } } catch (CoreException e) { TypeScriptCorePlugin.logError(e, e.getMessage()); } return null; }
private ILaunchConfigurationWorkingCopy getRemoteDebugConfig(IProject activeProj) throws CoreException { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_REMOTE_JAVA_APPLICATION); ILaunchConfigurationWorkingCopy config = type.newInstance(null, "Debug "+activeProj.getName()); config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, activeProj.getName()); config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_ALLOW_TERMINATE, true); config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR); IVMConnector connector = JavaRuntime.getVMConnector(IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR); Map<String, Argument> def = connector.getDefaultArguments(); Map<String, String> argMap = new HashMap<String, String>(def.size()); argMap.put("hostname", getHostname(activeProj)); argMap.put("port", "8348"); WPILibJavaPlugin.logInfo(argMap.toString()); config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, argMap); return config; }
@Override public void launchesTerminated(ILaunch[] launches) { boolean found = false; for (int i = 0; i < launches.length; i++) { if (launches[i].equals(launch)) { found = true; break; } } if (!found || notified) { return; } notified = true; if (success) { succeededCallback.run(); } DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this); }
/** * @see Model#getByName(String) */ public static Model getByName(final String fullQualifiedModelName) { Assert.isNotNull(fullQualifiedModelName); Assert.isLegal(!fullQualifiedModelName.contains(Model.SPEC_MODEL_DELIM), "Not a full-qualified model name."); final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); final ILaunchConfigurationType launchConfigurationType = launchManager .getLaunchConfigurationType(TLCModelLaunchDelegate.LAUNCH_CONFIGURATION_TYPE); try { final ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(launchConfigurationType); for (int i = 0; i < launchConfigurations.length; i++) { // Can do equals here because of full qualified name. final ILaunchConfiguration launchConfiguration = launchConfigurations[i]; if (fullQualifiedModelName.equals(launchConfiguration.getName())) { return launchConfiguration.getAdapter(Model.class); } } } catch (CoreException shouldNeverHappen) { shouldNeverHappen.printStackTrace(); } return null; }
public static Model getBy(final IFile aFile) { Assert.isNotNull(aFile); final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); final ILaunchConfigurationType launchConfigurationType = launchManager .getLaunchConfigurationType(TLCModelLaunchDelegate.LAUNCH_CONFIGURATION_TYPE); try { final ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(launchConfigurationType); for (int i = 0; i < launchConfigurations.length; i++) { // Can do equals here because of full qualified name. final ILaunchConfiguration launchConfiguration = launchConfigurations[i]; if (aFile.equals(launchConfiguration.getFile())) { return launchConfiguration.getAdapter(Model.class); } } } catch (CoreException shouldNeverHappen) { shouldNeverHappen.printStackTrace(); } return null; }
void addBreakpoint(IResource resource, IDocument document, int linenumber) throws CoreException { IBreakpoint bp = lineBreakpointExists(resource, linenumber); if(bp != null) { DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(bp, true); } int charstart = -1, charend = -1; try { IRegion line = document.getLineInformation(linenumber - 1); charstart = line.getOffset(); charend = charstart + line.getLength(); } catch (BadLocationException ble) {} HashMap<String, String> attributes = new HashMap<String, String>(); attributes.put(IJavaScriptBreakpoint.TYPE_NAME, null); attributes.put(IJavaScriptBreakpoint.SCRIPT_PATH, resource.getFullPath().makeAbsolute().toString()); attributes.put(IJavaScriptBreakpoint.ELEMENT_HANDLE, null); JavaScriptDebugModel.createLineBreakpoint(resource, linenumber, charstart, charend, attributes, true); }
IBreakpoint lineBreakpointExists(IResource resource, int linenumber) { IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(JavaScriptDebugModel.MODEL_ID); IJavaScriptLineBreakpoint breakpoint = null; for (int i = 0; i < breakpoints.length; i++) { if(breakpoints[i] instanceof IJavaScriptLineBreakpoint) { breakpoint = (IJavaScriptLineBreakpoint) breakpoints[i]; try { if(IJavaScriptLineBreakpoint.MARKER_ID.equals(breakpoint.getMarker().getType()) && resource.equals(breakpoint.getMarker().getResource()) && linenumber == breakpoint.getLineNumber()) { return breakpoint; } } catch (CoreException e) {} } } return null; }
@Override public void toggleWatchpoints(IWorkbenchPart part, ISelection selection) throws CoreException { if (part instanceof BfEditor) { LocationDialog dialog = new LocationDialog(((BfEditor) part).getEditorSite().getShell()); if (dialog.open() == 0) { int location = dialog.getMemoryLocation(); int value = dialog.getSuspendValue(); if (location == -1 || value == -1) { return; } byte b = (byte) value; BfWatchpoint bw = new BfWatchpoint(location, b, dialog.isAccess(), dialog.isModification()); DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(bw); } } }
@Override public void init() { try { ListBasedValidationIssueAcceptor acceptor = new ListBasedValidationIssueAcceptor(); ExecutionFlow flow = sequencer.transform(statechart, acceptor); if (acceptor.getTraces(Severity.ERROR).size() > 0) { Status errorStatus = new Status(Status.ERROR, SimulationCoreActivator.PLUGIN_ID, ERROR_DURING_SIMULATION, acceptor.getTraces(Severity.ERROR).iterator().next().toString(), null); IStatusHandler statusHandler = DebugPlugin.getDefault().getStatusHandler(errorStatus); try { statusHandler.handleStatus(errorStatus, getDebugTarget()); } catch (CoreException e) { e.printStackTrace(); } } if (!context.isSnapshot()) { contextInitializer.initialize(context, flow); } interpreter.initialize(flow, context, useInternalEventQueue()); } catch (Exception ex) { handleException(ex); throw new InitializationException(ex.getMessage()); } }
private ILaunch createAndLaunchConfiguration(ExecutionMode executionMode, IProgressMonitor monitor, URI launchURI) { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); String launchPathName = launchURI.toPlatformString(true); String tmpProjectName = launchPathName.substring(1, launchPathName.length()); String projectName = tmpProjectName.substring(0, tmpProjectName.indexOf('/')); IProject launchProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); IFile launchFile = launchProject.getFile(launchPathName.replaceFirst("/"+projectName+"/", "")); ILaunchConfiguration launch = manager.getLaunchConfiguration(launchFile); try { ILaunch startedLaunch = launch.launch(ILaunchManager.DEBUG_MODE, monitor); return startedLaunch; } catch (CoreException e) { e.printStackTrace(); } return null; }
public static ILaunch getLaunch(String launchId) { if (launchId == null) { return null; } ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches(); for (ILaunch launch : launches) { ILaunchConfiguration config = launch.getLaunchConfiguration(); try { if (launchId.equals(config.getAttribute(CLOUD_DEBUG_LAUNCH_ID, (String) null))) { return launch; } } catch (CoreException e) { DockerFoundryPlugin.logWarning(e.getMessage()); } } return null; }
protected ILaunchConfiguration findConfiguration(String configname) { String projectName = getProjectName(); ILaunchConfiguration result = null; try { ILaunchConfiguration[] configs = DebugPlugin.getDefault() .getLaunchManager().getLaunchConfigurations(); for (int i = 0; i < configs.length; i++) { ILaunchConfiguration configuration = configs[i]; if (configuration.getName().equals(configname)) { String confProjectName = configuration .getAttribute( IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); if (projectName.equals(confProjectName)) { result = configuration; } } } } catch (CoreException ignore) { } return result; }
public ISourceContainer createSourceContainer(String memento) throws CoreException { MementoFormat.Parser parser = new MementoFormat.Parser(memento); String prefix; String typeId; String subContainerMemento; try { prefix = parser.nextComponent(); typeId = parser.nextComponent(); subContainerMemento = parser.nextComponent(); } catch (MementoFormat.ParserException e) { throw new CoreException(new Status(IStatus.ERROR, ChromiumDebugPlugin.PLUGIN_ID, "Failed to parse memento", e)); //$NON-NLS-1$ } ISourceContainerType subContainerType = DebugPlugin.getDefault().getLaunchManager().getSourceContainerType(typeId); ISourceContainer subContainer = subContainerType.createSourceContainer(subContainerMemento); return new SourceNameMapperContainer(prefix, subContainer); }
private MontoLineBreakpoint findEclipseLineBreakpoint(Breakpoint breakpoint) { if (breakpoint != null) { IBreakpoint[] eclipseBreakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(Activator.PLUGIN_ID); for (IBreakpoint eclipseBreakpoint : eclipseBreakpoints) { if (eclipseBreakpoint instanceof MontoLineBreakpoint) { MontoLineBreakpoint eclipseMontoBreakpoint = (MontoLineBreakpoint) eclipseBreakpoint; try { if (eclipseMontoBreakpoint.getSource().equals(breakpoint.getSource()) && eclipseMontoBreakpoint.getLineNumber() == breakpoint.getLineNumber()) { return eclipseMontoBreakpoint; } } catch (DebugException ignored) { } } } } return null; }