@Override public JavaSettings getJavaSettings(IProject project, List<String> classesToSkip) { List<LaunchConfigData> launchConfigs = PluginVdm2JavaUtil.getProjectLaunchConfigs(project); if (!launchConfigs.isEmpty()) { String entryExp = PluginVdm2JavaUtil.dialog(launchConfigs); if (entryExp != null) { JavaSettings javaSettings = super.getJavaSettings(project, classesToSkip); javaSettings.setVdmEntryExp(entryExp); return javaSettings; } else { CodeGenConsole.GetInstance().println("Process cancelled by user."); } } else { CodeGenConsole.GetInstance() .println( PluginVdm2JavaUtil.WARNING + " No launch configuration could be found for this project.\n"); CodeGenConsole.GetInstance() .println("Cancelling launch configuration based code generation...\n"); } return null; }
public static List<LaunchConfigData> getProjectLaunchConfigs(final IProject project) { List<LaunchConfigData> matches = new LinkedList<>(); try { ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(); for (ILaunchConfiguration launchConfig : configs) { String launchConfigProjectName = launchConfig.getAttribute(IDebugConstants.VDM_LAUNCH_CONFIG_PROJECT, ""); if (launchConfigProjectName != null && !launchConfigProjectName.equals("") && launchConfigProjectName.equals(project.getName())) { String exp = launchConfig.getAttribute(IDebugConstants.VDM_LAUNCH_CONFIG_EXPRESSION, ""); matches.add(new LaunchConfigData(launchConfig.getName(), exp)); } } } catch (CoreException e) { CodeGenConsole.GetInstance() .printErrorln( "Problem looking up launch configurations for project " + project.getName() + ": " + e.getMessage()); e.printStackTrace(); } return matches; }